scribe / stripe-bundle
此包已被废弃且不再维护。未建议替代包。
处理与 stripe.com 支付 API 交互的 Symfony 扩展包
v1.0.2
2014-11-12 20:37 UTC
Requires
- php: >=5.4
- symfony/framework-bundle: >=2.0
- symfony/monolog-bridge: >=2.0
This package is not auto-updated.
Last update: 2022-02-01 12:31:58 UTC
README
处理与 stripe.com api 进行支付交互的 Symfony 扩展包
要求
- 您必须注册一个账户并从 http://stripe.com/ 获取 API 密钥
- PHP5
- Curl PHP 模块
安装
将以下内容添加到 composer.json 文件中的 require
块
"scribe/stripe-bundle": "dev-master"
执行 composer.phar update
命令下载您的新包(此命令还将更新任何过时的包)。
要将扩展包注册到您的应用程序中,您必须将扩展包添加到位于 AppKernel.php
文件中的 $bundles
数组
new Scribe\StripeBundle\ScribeStripeBundle()
配置
编辑您的 symfony config.yml 文件并至少添加以下行
scribe_stripe:
api_key: your-api-key-goes-here
您还可以选择配置以下项目(显示它们的默认值)
scribe_stripe:
api_key: your-api-key-goes-here
verify_ssl_certificates: true
log_activity: false
用法
最小化用法
$charge = $container->get('scribe.stripe.charge'); try { $charge ->setAmount(10, 00) ->setCardNumber('4242424242424242') ->setCardExperation(01, 16) ->setCardCvc('000') ->charge() ; } catch(\Scribe\StripeBundle\Exception\StripeException $e) { // handle exception } $response = $charge->getResponse();
您还可以使用其他字段集合(https://stripe.com/docs/api/php#create_charge)将附加数据传递给 Stripe。
$charge = $container->get('scribe.stripe.charge'); try { $charge ->setAmount(10, 20) ->setCardNumber('4242424242424242') ->setCardExperation(1, 2016) ->setCardCvc('000') ->setName('First Last') ->setAddressLine01('123 Address Ln.') ->setAddressLine02('Suite 666') ->setCity('City') ->setState('State') ->setZip('12345') ->setCountry('USA') ->setMetadata([ 'my_client_id' => '123456', 'something_else' => 'more info about the customer', ]) ->setDescription('A test Stripe charge!') ->setStatementDescription('TEST CHARGE') ->setReceiptEmail('someone@somwhere.com') ->charge() ; } catch(\Scribe\StripeBundle\Exception\StripeException $e) { // handle exception } $response = $charge->getResponse();
许可证
请参阅此软件附带的相关 LICENSE 文件。