douba4275 2016-08-09 06:39
浏览 31

当我在php中实现链式支付时,我得到错误“主接收器的数量必须更大”

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;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)