sprypradeep/yii2-braintree

yii 2 braintree集成

安装: 41

依赖: 0

建议: 0

安全性: 0

星标: 1

关注者: 2

分支: 2

开放问题: 0

类型:yii2-extension

1.0.1 2016-05-16 10:49 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:09:56 UTC


README

为yii 2提供的braintree

安装

安装此扩展的首选方式是通过 composer.

运行以下命令之一

php composer.phar require --prefer-dist sprypradeep/yii2-braintree "*"

或者

"sprypradeep/yii2-braintree": "*"

将以下内容添加到您的 composer.json 文件的require部分。

使用方法

安装扩展后,您应在应用程序配置中配置它,如下所示

'components' => [
    'braintree' => [
        'class' => 'sprypradeep\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' => 'pradeep',
    ....
]);

$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)