Braintree payments

I am trying to implement escrow funding using braintree in php. I downloaded the library from here . My code is below: -

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

      

It works for direct payment. But it doesn't work for escrow. Check my code.

Mistake: -

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

      

I have code here

+2


source to share


3 answers


I finally got a real answer from Braintree. I had to add two more parameters. One merchantAccountId

and the other serviceFeeAmount

. Here merchantAccountId

id is actually a sub-cooper merchantAccountId

. You will receive merchantAccountId

from Braintree. After logging in, do settings-> Processing . At the bottom of the page, you will get View All Merchant Accounts . You will get the merchantAccountId here. Don't use the default merchantAccountId, it won't work.



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

      

+6


source


I think you need two things:



+4


source


I think you made a mistake in your code:

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

      

Should be:

'holdInEscrow' => true

      

After 'holdInEscrow' => true

there should not be a comma.
+2


source







All Articles