本人以下列方式核实信用卡:
$result = Braintree_PaymentMethod::create([
'paymentMethodNonce' => nonceFromTheClient,
'options' => [
'verifyCard' => true
]
]);
一旦验证成功,我就会得到一个巨大的对象,它包括:
Braintree_Result_Successful[Braintree_Customer[id=123456,merchantId=xyz,firstName=,lastName=,company=,email=,phone=,fax=,website=,createdAt=Friday,11-9月15日22:05:53 UTC,updatedAt=Friday,11-9月15日22:05:53 UTC,customFields=,creditCards=0=Braintree_CreditCard[bin=411111,expirationMonth=03,expirationYear=2017,last4=1111,cardType=Visa,expirationYear=2017,en36 19#,en36 20#,11-9月-15 22:05:53 UTC,,,,#en31,32#,en35,##en36,,#,,en42 37,,11 22:05:52,39,11-9月22日maskedNumber=411111******1111,.]
我想读取上面的响应中看到的信用卡令牌值:"token=384zbr“
我尝试以以下方式访问它,但没有工作。
$result->creditCard->token
$result->creditCards[0]->token
我得到一个异常,上面写着“Braintree_Result_Successful: creditCard上的未定义属性”。
发布于 2015-09-14 17:18:20
Braintree的支持帮助我纠正了它。访问令牌的正确方法是
$result->customer->paymentMethods[0]->token;
发布于 2015-09-14 17:03:56
如果您使用print_r
而不是print
,那么对象的结构将更容易阅读!$result->paymentMethod->token
是从结果对象访问令牌的方式。
发布于 2015-09-14 15:36:38
你能这样做吗?
$ token = result->Braintree_Result_Successful[0]-> Braintree_Customer[0]->token
https://stackoverflow.com/questions/32552978
复制相似问题