paypal - 不能使用多个字段来指定接收者

标签 paypal paypal-adaptive-payments chained-payments

我正在尝试通过 C# 中的 PayPal 自适应支付 API 实现延迟链式支​​付。 我收到的错误没有任何意义,我在 .NET 上找不到任何解决问题的方法。

错误信息是: 无效请求:不能使用多个字段指定接收者

这是我要发送的请求:

    requestEnvelope.errorLanguage=en_US
    &actionType=PAY_PRIMARY
    &cancelUrl=http%3a%2f%2flocalhost%2fccc%2fProgramsandServices%2fCommunityFundingInitiative%2fOopsSome        thingWentWrong!.aspx ¤cyCode=USD
    &feesPayer=EACHRECEIVER
    &ipnNotificationUrl=http%3a%2f%2flocalhost%2fccc%2fdesktopmodules%2fUCU_ProjectManagement%2fPayPalIPN.aspx
    &receiverList.receiver(0).amount=10.00
    &receiverList.receiver(0).email=A_VALID_SANDBOX_EMAIL_ACCOUNT_ADDRESS_FOR_BUSINESS_OWNER
    &receiverList.receiver(0).phone.countryCode=001
    &receiverList.receiver(0).phone.phoneNumber=VALID_PHONE_NUMBER
    &receiverList.receiver(0).primary=true
    &receiverList.receiver(0).invoiceId=51%7c1%7c6%2f16%2f2013+4%3a35%3a56+PM
    &receiverList.receiver(0).paymentType=GOODS

    &receiverList.receiver(1).amount=9.5000
    &receiverList.receiver(1).email=A_VALID_SANDBOX_EMAIL_ACCOUNT_ADDRESS
    &receiverList.receiver(1).phone.countryCode=001
    &receiverList.receiver(1).phone.phoneNumber=VALID_PHONE_NUMBER
    &receiverList.receiver(1).primary=false
    &receiverList.receiver(1).invoiceId=51%7c1%7c6%2f16%2f2013+4%3a35%3a56+PM
    &receiverList.receiver(1).paymentType=GOODS
    &reverseAllParallelPaymentsOnError=false
    &senderEmail=A_VALID_SANDBOX_PERSONAL_EMAIL_ACCOUNT
    &returnUrl=http%3a%2f%2flocalhost%2fccc%2fProgramsandServices%2fCommunityFundingInitiative%2fThankYouforYourDonation.aspx
    &trackingId=51%7c0%7c6%2f16%2f2013+4%3a35%3a56+PM&

我指定了两个接收器,一个是Primary,另一个不是。
我错过了什么? 我已经尝试将 PAY 和 PAY_PRIMARY 作为操作类型。两者的结果相同。 如果我只使用一个接收器,它就可以工作。

代码如下:

    WebClient webClient = new WebClient();

        // Receivers
        ReceiverList receiverList = new ReceiverList();

        // Primary Receiver
        Receiver receiver = new Receiver();
        receiver.accountId = null;
        receiver.amount = Convert.ToDecimal(txtPledgeAmount.Text.Trim());
        receiver.invoiceId = Convert.ToString(SelectedProjectId) + "|" + Convert.ToString(PortalSettings.AdministratorId) + "|" + Convert.ToString(DateTime.Now.ToUniversalTime());
        //receiver.paymentSubType = null;
        receiver.paymentType = "GOODS";
        receiver.primary = true;

        if (!String.IsNullOrEmpty(PRIMARY_RECEIVER_PHONE_NUMBER))
        {
            receiver.phone = new PhoneNumberType();new PhoneNumberType("001",PRIMARY_RECEIVER_PHONE_NUMBER);
        }
        if (!String.IsNullOrEmpty(PRIMARY_RECEIVER_EMAIL_ADDRESS))
        {
            receiver.email = PRIMARY_RECEIVER_EMAIL_ADDRESS;
        }

        receiverList.receiver.Add(receiver);

        // Secondary Receiver
        string receiverEmail = "";
        string receiverPhone = VALID_PHONE_NUMBER;
        String receiverUserName = MembershipServices.Business.SharedFunctions.GetUserNameEmail(PortalId, SelectedProject.ProjectOwnerID, MembershipServices.SharedEnums.DisplayNameFormat_Type.FullName, ref receiverEmail);
        Receiver receiver2 = new Receiver(Decimal.Parse(this.txtPledgeAmount.Text.Trim()) * SECONDARY_RECEIVER_PERCENTAGE);
        if (!String.IsNullOrEmpty(receiverPhone))
        {
            receiver2.phone = receiver.phone = new PhoneNumberType("001", receiverPhone);
        }
        if (!String.IsNullOrEmpty(receiverEmail))
        {
            receiver2.email = receiverEmail;
        }
        receiver2.primary = Boolean.Parse("false");
        receiver2.invoiceId = Convert.ToString(SelectedProjectId) + "|" + Convert.ToString(SelectedProject.ProjectOwnerID) + "|" + Convert.ToString(DateTime.Now.ToUniversalTime()); ;
        receiver2.paymentType = "GOODS";

        receiverList.receiver.Add(receiver2);

        String PortalAlias = PortalSettings.PortalAlias.HTTPAlias;
        if (!PortalAlias.EndsWith("/"))
        {
            PortalAlias = PortalAlias + "/";
        }

        if (Request.IsSecureConnection)
        {
            PortalAlias = @"https://" + PortalAlias;
        }
        else
        {
            PortalAlias =  @"http://" + PortalAlias;
        }

        string actionType = "PAY_PRIMARY";

        PayRequest req = new PayRequest(new RequestEnvelope("en_US"), actionType,
                            PortalAlias + CANCEL_URL, SharedEnums.CurrencyCode_Type.USD.ToString(),
                            receiverList, PortalAlias + RETURN_URL);

        req.ipnNotificationUrl = PortalAlias + IPN_NOTIFICATION_URL;

        //(Optional) A note associated with the payment (text, not HTML). 
        // Maximum length: 1000 characters, including newline characters 
        if (!String.IsNullOrEmpty(txtPledgeMessage.Text.Trim()))
        {
            req.memo = txtPledgeMessage.Text.Trim();
        }
        else
        {
            req.memo = null;
        }


        // set optional parameters
        //(Optional) Whether to reverse parallel payments if an error occurs with a payment. 
        //Allowable values are:
        //true – Each parallel payment is reversed if an error occurs
        //false – Only incomplete payments are reversed (default)
        req.reverseAllParallelPaymentsOnError = false;

        req.feesPayer = "EACHRECEIVER";

        // Sender's email address 
        =req.senderEmail = SENDER_EMAIL_ADDRESS;

        //(Optional) A unique ID that you specify to track the payment.
        //Note: You are responsible for ensuring that the ID is unique.
        //Maximum length: 127 characters 
        string trackingId = Convert.ToString(SelectedProjectId + "|" + Convert.ToString(SelectedUserId) + "|" + Convert.ToString(DateTime.Now.ToUniversalTime()));
        req.trackingId = trackingId;


        // All set. Fire the request            
        AdaptivePaymentsService service = new AdaptivePaymentsService();
        PayResponse resp = null;
        try
        {
            resp = service.Pay(req);
        }
        catch (System.Exception e)
        {
            Response.Write(e.Message);
            return;
        }

如果您已解决此问题或发现错误,请告诉我! 谢谢。

最佳答案

删除电话号码字段会返回成功的响应。我不确定电话号码字段是否不应该在延迟链接支付交易中可用。我将不得不联系 Adaptive Payments 的产品团队并从他们那里找出答案。

编辑:电话号码必须是经过确认的手机号码。您遇到的错误是因为电话号码字段也可用于定义接收者,因此您实际上是在尝试定义接收者两次。

我测试的请求(与您的请求相同,但设置了沙盒电子邮件地址)-

requestEnvelope.errorLanguage=en_US
actionType=PAY_PRIMARY
cancelUrl=http://localhost/ccc/ProgramsandServices/CommunityFundingInitiative/OopsSomethingWentWrong!.aspx
currencyCode=USD
feesPayer=EACHRECEIVER
ipnNotificationUrl=http://localhost/ccc/desktopmodules/UCU_ProjectManagement/PayPalIPN.aspx
receiverList.receiver(0).amount=10.00
receiverList.receiver(0).email=bending@bender.com
receiverList.receiver(0).primary=true
receiverList.receiver(0).invoiceId=51|1|6/16/2013 4:35:56 PM
receiverList.receiver(0).paymentType=GOODS
receiverList.receiver(1).amount=9.50
receiverList.receiver(1).email=stuff@stuffers.com
receiverList.receiver(1).primary=false
receiverList.receiver(1).invoiceId=51|1|6/16/2013 4:35:56 PM
receiverList.receiver(1).paymentType=GOODS
reverseAllParallelPaymentsOnError=false
senderEmail=testingAccess8x@paypal.com
returnUrl=http://localhost/ccc/ProgramsandServices/CommunityFundingInitiative/ThankYouforYourDonation.aspx
trackingId=51|0|6/16/2013 4:35:56 PM

关于paypal - 不能使用多个字段来指定接收者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17135550/

相关文章:

php - Paypal 休息沙盒错误

Paypal NVP : how use SunX509 on IBM JRE

authentication - 如何通过第三方权限服务获得卖家的退款权限

symfony - JMSPaymentPaypalBundle 是否支持链式支付?

php - PayPal API - 使用 PayFlow Pro 在单次结帐中处理一次性付款和定期付款

php - Paypal IPN Sandbox - 交易完成前接收状态已完成

Paypal 自适应支付 : transactionStatus vs senderTransactionStatus

php - 此付款请求必须由发件人授权 - Paypal

php - 推荐的 paypal php sdk 版本,提供 poodle sslv3 错误并实际工作