w3sami/stripe-bundle

一个简单的Symfony 5组件,用于封装Stripe API。

安装: 21

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 1

类型:symfony-bundle

1.0.10 2020-07-09 16:32 UTC

This package is auto-updated.

Last update: 2024-09-29 23:06:11 UTC


README

一个用于与Symfony 5一起使用的Stripe API简单封装器。

此组件封装了stripe-php库,因此您可以轻松地将它注入到自己的Symfony代码中。它还提供了一些快捷方式,用于获取和创建客户端、创建和取消订阅以及执行单次收费。

要查看stripe php库的所有可用方法,请参阅https://github.com/stripe/stripe-php

设置

步骤 1:使用composer安装W3samiStripeBundle

运行以下命令使用composer安装:

$ composer require "w3sami/stripe-bundle:1.*"

步骤 2:添加配置

# config/packages/w3sami.yml
w3sami:
  stripe:
    stripe_private_key: %stripe_private_key%

用法

使用服务

<?php
  use W3sami\StripeBundle\Services\StripeClient;
  public function __construct(StripeClient $stripeClient) {
  }
?>

或者

<?php
  $stripeClient = $this->get('stripe_client');
?>

##示例

###创建客户 & 订阅

<?php 
    $customer = $stripeClient->createCustomer($token, $email, $name, $phone);

    // Store customer information

    $subsciption = $stripeClient->createSubscription($customerId, $planId);

    // Store subscription information

?>

要查看stripe服务所有可用的API调用,请参阅https://stripe.com/docs/api