Skip to main content
 首页 » 编程设计

php之Braintree 付款托管资金

2024年05月10日11xiaohuochai

我正在尝试在 php 中使用 Braintree 来实现托管资金。我已经从here下载了库。我的代码如下:-

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 获得了代码

请您参考如下方法:

终于我从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);