2014-09-03 107 views
2

我想在php中使用braintree实现托管资金。我从here下载了库。我的代码如下: -Braintree支付托管资金

require_once "../braintree/lib/Braintree.php"; 

Braintree_Configuration::environment("sandbox"); 
Braintree_Configuration::merchantId("was4zgn5x6vt99h"); 
Braintree_Configuration::publicKey("ydjrasdwyw9npkvnw4"); 
Braintree_Configuration::privateKey("f197ac5a66a1fsad37d3950890b2cbda9"); 

$result = Braintree_Transaction::sale(
    array(
'amount' => "100.00", 

'creditCard' => array(
    'number' => "4111111111111111", 
    'expirationDate' => "12/2014", 
), 
'options' => array(
    'submitForSettlement' => true, 
    'holdInEscrow' => true, 
) 

) 
    ); 
echo "<pre>"; 
print_r("\n message: " . $result->message); 

它是直接付款的工作。但它不适用于托管。请检查我的代码。

错误是: -

"message: Transaction could not be held in escrow." 

我已得到here

+0

看来,这不是你的代码错误。他们无法将此交易作为托管处理。 – user4035 2014-09-03 11:54:45

+0

我不清楚你在说什么。请给我一些链接,可以帮助我.. – Bik 2014-09-03 12:06:34

+0

如果这些是你真正的钥匙,你可能会想要改变他们... – 2014-09-04 17:00:28

回答

6

最后我得到了Braintree的实际答案。我不得不再添加两个参数。一个merchantAccountId等是serviceFeeAmount。这里merchantAccountId id实际上是子商户merchantAccountId。您将从Braintree获得merchantAccountId。登录后,请转至设置 - >处理。在页面底部,您将获得查看全部商户帐户。在这里你会得到merchantAccountId。不要使用默认的merchantAccountId,它不会工作。

require_once "../braintree/lib/Braintree.php"; 
Braintree_Configuration::environment("sandbox"); 
Braintree_Configuration::merchantId("was4zgn5x6vt99h"); 
Braintree_Configuration::publicKey("ydjrasdwyw9npkvnw4"); 
Braintree_Configuration::privateKey("f197ac5a66a1fsad37d3950890b2cbda9"); 

$result = Braintree_Transaction::sale(
    array(
'amount' => "100.00", 
'merchantAccountId' => 'test_user_instant_5vcgn574', 
'creditCard' => array(
    'number' => "4111111111111111", 
    'expirationDate' => "12/2014", 
), 
'options' => array(
    'submitForSettlement' => true, 
    'holdInEscrow' => true, 
), 
'serviceFeeAmount' =>'1' 

) 
); 
echo "<pre>"; 
print_r("\n message: " . $result->message); 
2

我觉得你做你的代码中的错误:

'options' => array(
    'submitForSettlement' => true, 
    'holdInEscrow' => true, 
) 

应该是:

'holdInEscrow' => true 

应该没有逗号后'holdInEscrow' => true

+0

这是不相关的,数组中的尾随逗号不影响结果 – shakaran 2017-01-17 19:22:30