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

时间:2014-05-08 16:14:26

标签: c# paypal paypal-adaptive-payments

经过两天的测试,谷歌搜索等等,我决定写在这里。我很抱歉我的英语不好:)

我从http://paypal.github.io/sdk/#adaptive-payments下载了 .NET PayPal自适应支付SDK ,我用 Visual Studio Ultimate 2012 打开了解决方案尝试样品。不幸的是,链式示例不起作用,出现以下错误:

  

无效的请求参数:操作类型PAY_PRIMARY只能用于链式付款

我研究了文档并尝试了一些更改,没有任何结果。

我使用此代码https://devtools-paypal.com/guide/ap_chained_payment/dotnet?interactive=ON&env=sandbox

创建了新项目

我的代码是

        ReceiverList receiverList = new ReceiverList();

        receiverList.receiver = new List<Receiver>();

        Receiver secondaryReceiver = new Receiver((decimal?)1.00);
        secondaryReceiver.email = "platfo_1255170694_biz@gmail.com";
        secondaryReceiver.primary = false;
        secondaryReceiver.paymentType = "SERVICE";
        receiverList.receiver.Add(secondaryReceiver);

        Receiver primaryReceiver = new Receiver((decimal?)2.00);
        primaryReceiver.email = "platfo_1255612361_per@gmail.com";
        primaryReceiver.primary = true;
        primaryReceiver.paymentType = "GOODS";
        primaryReceiver.invoiceId = "123456789";
        receiverList.receiver.Add(primaryReceiver);

        RequestEnvelope requestEnvelope = new RequestEnvelope("it_IT");
        string actionType = "PAY";
        string returnUrl = "https://devtools-paypal.com/guide/ap_chained_payment/dotnet?success=true";
        string cancelUrl = "https://devtools-paypal.com/guide/ap_chained_payment/dotnet?cancel=true";
        string currencyCode = "EUR";
        PayRequest payRequest = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);

        payRequest.ipnNotificationUrl = "http://replaceIpnUrl.com";

        payRequest.feesPayer = "PRIMARYRECEIVER";
        payRequest.trackingId = "123456789";

        Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
        sdkConfig.Add("mode", "sandbox");
        sdkConfig.Add("account1.apiUsername", "jb-us-seller_api1.paypal.com");
        sdkConfig.Add("account1.apiPassword", "WX4WTU3S8MY44S7F");
        sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
        sdkConfig.Add("account1.applicationId", "APP-80W284485P519543T");

        AdaptivePaymentsService service = new AdaptivePaymentsService(sdkConfig);
        PayResponse response = service.Pay(payRequest);

        string redirectUrl = null;

        if (!response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
        {
            redirectUrl = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" + response.payKey;
        }

我尝试将属性feesPayer设置为PRIMARYRECEIVER,但出现以下错误:

  

付款人PRIMARYRECEIVER只能在指定主要接收人时使用

此代码的请求是

requestEnvelope.errorLanguage=it_IT&
actionType=PAY
cancelUrl=https://devtools-paypal.com/guide/ap_chained_payment/dotnet?cancel=true&
currencyCode=EUR&
feesPayer=PRIMARYRECEIVER&
ipnNotificationUrl=http://replaceIpnUrl.com&
receiverList.receiver(0).amount=1&
receiverList.receiver(0).email=platfo_1255170694_biz@gmail.com&
receiverList.receiver(0).primary=False&
receiverList.receiver(0).paymentType=SERVICE&
receiverList.receiver(1).amount=2&
receiverList.receiver(1).email=platfo_1255612361_per@gmail.com&
receiverList.receiver(1).primary=True&
receiverList.receiver(1).invoiceId=123456789&
receiverList.receiver(1).paymentType=GOODS&
returnUrl=https://devtools-paypal.com/guide/ap_chained_payment/dotnet?success=true&
trackingId=123456789&

响应是

responseEnvelope.timestamp=2014-05-08T09:05:04.204-07:00&
responseEnvelope.ack=Failure&
responseEnvelope.correlationId=1a4d172eb110d&
responseEnvelope.build=10680030&
error(0).errorId=580023&
error(0).domain=PLATFORM&
error(0).subdomain=Application&
error(0).severity=Error&
error(0).category=Application&
error(0).message=The fee payer PRIMARYRECEIVER can only be used if a primary receiver is specified&
error(0).parameter(0)=feesPayer&
error(0).parameter(1)=PRIMARYRECEIVER

我的C#代码中的行primaryReceiver.primary = true;似乎不起作用...有什么想法吗?有没有人遇到过这类问题?

提前谢谢。

0 个答案:

没有答案