Paypal 自适应链式支付 - 发件人的金额是主要收款人的金额,而不是总金额。怎么修?

Posted

技术标签:

【中文标题】Paypal 自适应链式支付 - 发件人的金额是主要收款人的金额,而不是总金额。怎么修?【英文标题】:Paypal Adaptive Chained Payments - Sender's amount is primary receiver's amount not the total amount. How to fix? 【发布时间】:2012-04-25 03:45:06 【问题描述】:

我正在开发一项服务,其中发送方支付一定金额,其中 95% 支付给一个接收方,5% 支付给另一个接收方。 (例如,支付 100 美元,初级费用减少 95 美元,二级费用减少 5 美元。)在此示例中,发件人将 95 美元视为他要支付的金额,而不是 100 美元,我不明白为什么。

这里将金额设置在一个数组中,该数组对应于另一个 Paypal 电子邮件地址数组。

$receiverAmountArray = array(
        .5*$backing_amount,
        .95*$backing_amount
        );

第二个电子邮件地址设置为主。最大金额的接收者必须是主要的。

$receiverPrimaryArray = array(
        'false',
        'true'
        );

CallPay(来自 Paypal 的库)被调用:

$resArray = CallPay ($actionType, $cancelUrl, $returnUrl, $currencyCode, $receiverEmailArray,
                        $receiverAmountArray, $receiverPrimaryArray, $receiverInvoiceIdArray,
                        $feesPayer, $ipnNotificationUrl, $memo, $pin, $preapprovalKey,
                        $reverseAllParallelPaymentsOnError, $senderEmail, $trackingId
);

这里是 CallPay 功能。抱歉,篇幅较长:

function CallPay( $actionType, $cancelUrl, $returnUrl, $currencyCode, $receiverEmailArray, $receiverAmountArray,
                        $receiverPrimaryArray, $receiverInvoiceIdArray, $feesPayer, $ipnNotificationUrl,
                        $memo, $pin, $preapprovalKey, $reverseAllParallelPaymentsOnError, $senderEmail, $trackingId )
    
        /* Gather the information to make the Pay call.
            The variable nvpstr holds the name value pairs
        */

        // required fields
        $nvpstr = "actionType=" . urlencode($actionType) . "&currencyCode=" . urlencode($currencyCode);
        $nvpstr .= "&returnUrl=" . urlencode($returnUrl) . "&cancelUrl=" . urlencode($cancelUrl);

        if (0 != count($receiverAmountArray))
        
            reset($receiverAmountArray);
            while (list($key, $value) = each($receiverAmountArray))
            
                if ("" != $value)
                
                    $nvpstr .= "&receiverList.receiver(" . $key . ").amount=" . urlencode($value);
                
            
        

        if (0 != count($receiverEmailArray))
        
            reset($receiverEmailArray);
            while (list($key, $value) = each($receiverEmailArray))
            
                if ("" != $value)
                
                    $nvpstr .= "&receiverList.receiver(" . $key . ").email=" . urlencode($value);
                
            
        

        if (0 != count($receiverPrimaryArray))
        
            reset($receiverPrimaryArray);
            while (list($key, $value) = each($receiverPrimaryArray))
            
                if ("" != $value)
                
                    $nvpstr = $nvpstr . "&receiverList.receiver(" . $key . ").primary=" . urlencode($value);
                
            
        

        if (0 != count($receiverInvoiceIdArray))
        
            reset($receiverInvoiceIdArray);
            while (list($key, $value) = each($receiverInvoiceIdArray))
            
                if ("" != $value)
                
                    $nvpstr = $nvpstr . "&receiverList.receiver(" . $key . ").invoiceId=" . urlencode($value);
                
            
        

        // optional fields
        if ("" != $feesPayer)
        
            $nvpstr .= "&feesPayer=" . urlencode($feesPayer);
        

        if ("" != $ipnNotificationUrl)
        
            $nvpstr .= "&ipnNotificationUrl=" . urlencode($ipnNotificationUrl);
        

        if ("" != $memo)
        
            $nvpstr .= "&memo=" . urlencode($memo);
        

        if ("" != $pin)
        
            $nvpstr .= "&pin=" . urlencode($pin);
        

        if ("" != $preapprovalKey)
        
            $nvpstr .= "&preapprovalKey=" . urlencode($preapprovalKey);
        

        if ("" != $reverseAllParallelPaymentsOnError)
        
            $nvpstr .= "&reverseAllParallelPaymentsOnError=" . urlencode($reverseAllParallelPaymentsOnError);
        

        if ("" != $senderEmail)
        
            $nvpstr .= "&senderEmail=" . urlencode($senderEmail);
        

        if ("" != $trackingId)
        
            $nvpstr .= "&trackingId=" . urlencode($trackingId);
        

        /* Make the Pay call to PayPal */
        $resArray = hash_call("Pay", $nvpstr);

        /* Return the response array */
        return $resArray;
    

这是调用前 $nvpstr 的值。 Paypal 是否可能只是将付款金额作为主要付款?这在链式支付的情况下没有意义。

actionType=PAY¤cyCode=USD&returnUrl=https%3A%2F%2F.com%2Fview_profile.php&cancelUrl=https%3A%2F%2Fexamplefunding.com%2Fview_profile.php&receiverList.receiver(0).amount=95&receiverList.receiver(1).amount=5&receiverList.receiver(0).email=recip_1334204171_biz%40example.com&receiverList.receiver(1).email=example_1334201682_biz%40example.com&receiverList.receiver(0).primary=true&receiverList.receiver(1).primary=false&receiverList.receiver(0).invoiceId=5c4e2902cbe484a0db37284f0144994c&receiverList.receiver(1).invoiceId=6f3d8ce65d1a59b41f8822ba6129ea58&feesPayer=PRIMARYRECEIVER&memo=New+Draft+Lines+-+ExampleFunding.com&senderEmail=paypal_1334201496_per%40example.com&trackingId=mqN8SSgIq

【问题讨论】:

【参考方案1】:

根据Paypal's Adaptive Payments Documentation:

在链式支付中,发送方向主要接收方支付一定金额, 主要收款人向次要收款人付款。发件人 只知道主接收器,不知道辅助接收器。

因此,这是按预期工作的。为了向二级收款人支付总金额的 5%,我必须更改:

$receiverAmountArray = array(
        .05*$backing_amount,
        .95*$backing_amount
        );

到这里:

$receiverAmountArray = array(
        .05*$backing_amount,
        $backing_amount
        );

认为总金额是数组中各个接收者金额的总和是我的错误。

【讨论】:

【参考方案2】:

示例:total_amount = 100;

如果我们设置receiverList.receiver(0).primary=true 那么receiverList.receiver(0).amount = total_amount;

和receiverList.receiver(1).amount=95%*total_amount

【讨论】:

以上是关于Paypal 自适应链式支付 - 发件人的金额是主要收款人的金额,而不是总金额。怎么修?的主要内容,如果未能解决你的问题,请参考以下文章

PayPal自适应支付链式支付错误

Paypal 自适应延迟链式支​​付

PayPal API 错误 - 此付款请求必须由发件人授权

沙盒中的 PayPal 自适应链式支付

Paypal 自适应/链式支付工作流程

PHP PayPal 自适应支付 - 链式支付