braintree php,fecmall 集成 braintreepayments 信用卡收款方式(php Yii2框架)服务端(server)部分...

fecmall 集成 braintreepayments 信用卡收款方式(php Yii2框架)服务端(server)部分

php要求

>The Braintree PHP SDK requires PHP version 7.2.0 or higher and the PHP cURL extension.

php版本7.2+, 以及需要php curl扩展

Version: 4.5.0

SHA256: db1a7572944a221b2d661aaa1f9276d2a9b44ccb306589456ec8a6ce489f2e99

配置环境初始化

1.沙盒环境

$gateway = new Braintree_Gateway([

'environment' => 'sandbox',

'merchantId' => 'use_your_merchant_id',

'publicKey' => 'use_your_public_key',

'privateKey' => 'use_your_private_key'

]);

2.正式环境

$gateway = new Braintree_Gateway([

'environment' => 'production',

'merchantId' => 'use_your_merchant_id',

'publicKey' => 'use_your_public_key',

'privateKey' => 'use_your_private_key'

]);

生成client token

生成客户令牌

您的服务器负责生成客户端令牌,其中包含客户端初始化客户端SDK与Braintree进行通信所需的所有授权和配置信息。 生成客户令牌时包含customerId可使回头客从以前使用的付款方式选项中进行选择,从而改善了多次结帐时的用户体验。

$clientToken = $gateway->clientToken()->generate([

"customerId" => $aCustomerId

]);

If the customer can't be found, it will return a validation error.

发送client token到客户端

echo($clientToken = $gateway->clientToken()->generate());

从客户端获取 payment method nonce

$nonceFromTheClient = $_POST["payment_method_nonce"]

/* Use payment method nonce here */

创建交易Create a transaction

$result = $gateway->transaction()->sale([

'amount' => '10.00',

'paymentMethodNonce' => $nonceFromTheClient,

'options' => [

'submitForSettlement' => True

]

]);

The sale call returns a Transaction Result Object which contains the transaction and information about the request.

测试您的整合Test your integration

上线

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值