I'm just trying to do a test with paypal chained payments, and it's really frustrating. My goal for this test is to send the primary receiver $15 and then $1 to a secondary receiver. Here is my code:
$api = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";
$input = array(
"actionType" => "PAY",
"currencyCode" => "USD",
"feesPayer" => "EACHRECEIVER",
"cancelUrl" => "https://www.google.com", //test url
"returnUrl" => "https://www.google.com", //test url
"receiverList" => array(
"receiver" => array( //send primary receiver $15
"amount" => "15.00",
"email" => "[email protected]",
"primary" => true
),
"receiver" => array( //send owner of site $1 commission
"amount" => "1.00",
"email" => "[email protected]",
"primary" => false
)
),
"requestEnvelope" => array(
"errorLanguage" => "en_US"
)
);
$headers = array(
"X-PAYPAL-SECURITY-USERID: ".USER_ID, //predefined
"X-PAYPAL-SECURITY-PASSWORD: ".USER_PASS, //predefined
"X-PAYPAL-SECURITY-SIGNATURE: ".USER_SIG, //predefined
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T"
);
$ch = curl_init($api);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($input));
$response = curl_exec($ch);
var_dump($response);
When I try to do this, it works, but in my payment details it only shows the $1 to the secondary receiver, there is no trace of the primary receiver:
{"paymentInfo":[{"receiver":{"amount":"1.00","email":"[email protected]","primary":"false","paymentType":"SERVICE","accountId":"6LBSVJQNVE9DA"},"pendingRefund":"false"}]}
I tried setting the "actionType" to "PAY_PRIMARY" and it gave me this error:
"message":"Invalid request parameter: action type PAY_PRIMARY can only be used in chained payments","parameter":["PAY_PRIMARY"]
It's getting quite frustrating as I've looked it up on youtube, stackoverflow, some forum websites, etc and haven't found much helpful info.
Thank you very much to anyone who will take the time to read this and help me!
it's really frustrating
welcome to the world of Paypal. – Martin