Payment with Braintree retrieving data from vault
我首先借助API创建了一个客户,当一个客户成功创建后,它通过我创建了信用卡的customerId将我的customerId返回给我。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // for creating user gateway->customer()->create([ 'firstName' => $firstName, 'lastName' => $lastName, 'company' => $company, 'email' => $email, 'phone' => $phone, 'fax' => $fax, 'website' => $website ]); //for creating card $result = $this->gateway->creditCard()->create([ 'customerId' => $customerId, 'number' => $number, 'expirationDate' => $expirationDate, 'cvv' => $cvv |
在将卡成功保存在Vault中后,它给了我一个令牌为了检索卡中的数据,我这样做:
1 | $result = $this->gateway->creditCard()->find($token); |
并向我退还了卡的详细信息,现在我想使用该卡的详细信息或令牌进行付款(因为我很困惑)。 以前我通过UI下降成功完成了付款,但是这次我想使用保管库
完全公开:我在Braintree工作。 如有其他疑问,请随时联系
支持。 sub>
现在您已经有了付款方式令牌,您可以将该值作为参数传递给Transaction Sale API调用,以使用保存的付款方式(而不是代表一次性使用付款方式的付款方式随机数)完成交易。
例
1 2 3 4 5 6 | $result = $gateway->transaction()->sale( [ 'paymentMethodToken' => 'the_payment_method_token', 'amount' => '100.00' ] ); |