Braintree支付托管资金

时间:2014-09-03 11:48:11

标签: php braintree

我正在尝试使用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

的代码

3 个答案:

答案 0 :(得分:6)

最后我得到了布伦特里的实际答案。我不得不再添加两个参数。一个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);

答案 1 :(得分:4)

我认为你需要两件事:

  1. 传递merchant_account_id - 请参阅https://www.braintreepayments.com/docs/php/transactions/escrow上的示例

  2. 如果您的商家帐户使用的是Marketplace,则只能进行托管。 https://www.braintreepayments.com/docs/php/guide/marketplace

答案 2 :(得分:2)

我认为你在代码中犯了一个错误:

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

应该是:

'holdInEscrow' => true

'holdInEscrow' => true

后应该没有逗号