I want to implement chained payment in php. There is primary receiver has 10% commission amount from total amount and secondary receiver has 90% amount from total amount. But I got error from paypal
"The amount for the primary receiver must be greater than or equal to the total of other chained receiver amounts".
Please give me solution for this problem.
$memo = "Adaptive Payment";
$actionType = "PAY";
$currencyCode = "USD";
if ($_POST['booking'] == 'fh') {
$receiverEmail = array("chandvadariya@gmail.com", "chandanivadaria1213@gmail.com");
$receiverAmount = array("3.00", "2.00");
$primaryReceiver = array("true", "false");
$_SESSION['facilty_provider'] = array("AirGo Airline's Test Store", "Hotel TheCompany's Test Store");
} else {
$receiverEmail = array("chandvadariya@gmail.com");
$receiverAmount = array("3.00");
$primaryReceiver = array("false");
$_SESSION['facilty_provider'] = array("AirGo Airline's Test Store");
}
if (isset($receiverEmail)) {
$receiver = array();
for ($i = 0; $i < count($receiverEmail); $i++) {
$receiver[$i] = new Receiver();
$receiver[$i]->email = $receiverEmail[$i];
$receiver[$i]->amount = $receiverAmount[$i];
$receiver[$i]->primary = $primaryReceiver[$i];
}
$receiverList = new ReceiverList($receiver);
}
$payRequest = new PayRequest(new RequestEnvelope("en_US"), $actionType, $cancelUrl, $currencyCode, $receiverList, $returnUrl);
if ($memo != "") {
$payRequest->memo = $memo;
}
$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
try {
/ wrap API method calls on the service object with a try catch /
$response = $service->Pay($payRequest);
$ack = strtoupper($response->responseEnvelope->ack);
if ($ack == "SUCCESS") {
$_SESSION['pay_key'] = $payKey = $response->payKey;
$payKey = $response->payKey;
$payPalURL = PAYPAL_REDIRECT_URL . '_ap-payment&paykey=' . $payKey;
header('Location: ' . $payPalURL);
}
} catch (Exception $ex) {
require_once '../Common/Error.php';
exit;
}