bryglen/ yii2-braintree
yii 2 braintree集成
1.0.0
2015-09-25 09:28 UTC
Requires
- braintree/braintree_php: 2.30.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-14 16:29:22 UTC
README
yii 2的braintree
安装
安装此扩展的首选方式是通过composer。
运行以下命令:
php composer.phar require --prefer-dist bryglen/yii2-braintree "*"
或者
"bryglen/yii2-braintree": "*"
将以下内容添加到您的composer.json
文件的require部分:
使用方法
扩展安装完成后,您应该在应用程序配置中对其进行配置,如下所示:
'components' => [ 'braintree' => [ 'class' => 'bryglen\braintree\Braintree', 'environment' => 'sandbox', 'merchantId' => 'your_merchant_id', 'publicKey' => 'your_public_key', 'privateKey' => 'your_private_key', ] ]
** 创建客户
$braintree = Yii::$app->braintree; $response = $braintree->call('Customer', 'create', [ 'firstName' => 'bryan', .... ]); $braintree = Yii::$app->braintree; $response = $braintree->call('Transaction', 'sale', [ 'amount' => 25.00, 'customerId' => 1, 'paymentMethodToken' => 'some_token' .... ]);
braintree使用静态方法为其API,为了使用braintree的静态方法,应如下所示:Braintree_Transaction::sale($args)
变为$braintree->call('Transaction', 'sale', $args)