Php Braintree支付托管资金

Php Braintree支付托管资金,php,braintree,Php,Braintree,我试图在php中使用braintree实现托管资金。我已经从下载了图书馆。我的代码如下:- require_once "../braintree/lib/Braintree.php"; Braintree_Configuration::environment("sandbox"); Braintree_Configuration::merchantId("was4zgn5x6vt99h"); Braintree_Configuration::publicKey("ydjrasdwyw9npkv

我试图在php中使用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);

我从

中获得了代码。我认为您需要两件事:

  • 传递商户帐户id-请参阅上的示例

  • 您只能在您的商户帐户使用Marketplace时进行托管


  • 我认为您的代码中犯了一个错误:

    'holdInEscrow' => true
    
    应该是:

    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);
    

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

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

    require_once.“./braintree/lib/braintree.php”;
    Braintree_配置::环境(“沙盒”);
    Braintree_配置::merchantId(“was4zgn5x6vt99h”);
    Braintree_配置::公钥(“ydjrasdwyw9npkvnw4”);
    Braintree_配置::私钥(“f197ac5a66a1fsad37d3950890b2cbda9”);
    $result=Braintree\u交易::销售(
    排列(
    “金额”=>“100.00”,
    'merchantAccountId'=>'test\u user\u instant\u 5vcgn574',
    “信用卡”=>数组(
    “编号”=>“4111111111”,
    “到期日期”=>“2014年12月”,
    ),
    “选项”=>数组(
    “submitForSettlement”=>真,
    “holdInEscrow”=>正确,
    ),
    “serviceFeeAmount”=>“1”
    )
    );
    回声“;
    打印(“\n消息:“.$result->message”);
    
    看来,这不是您的代码错误。他们不能以代管的方式处理这笔交易。我不清楚你在说什么。请给我一些可以帮助我的链接。如果这些是你真正的钥匙,你可能会想要更改它们…谢谢@BradWerth,不,这些不是我真正的钥匙。你能给我推荐一些关于braintree托管的东西吗?@Bik你有没有想过?我也有同样的问题,数组中不相关的尾随逗号不会影响结果
    'holdInEscrow' => true
    
    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);