宝经常性支付交易错误:11502:令牌无效 [英] Paypal Recurring Payment Transaction Error: 11502 : Token is invalid

查看:238
本文介绍了宝经常性支付交易错误:11502:令牌无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的PayPal和我需要实现一个订阅(​​定期付款)为我client.I我使用贝宝沙箱及其实施。我跟着的贝宝坚持创建定期付款的个人资料的方式。在得到来自SETEX pressCheckout,GETEX pressCheckOut和DoEx pressCheckOut成功acknowlegment。我试图创建与DoEx pressCheckOutpayment响应令牌周期性付款资料,但是从CreateRecurrinpayment轮廓响应返回失败,说明在ivnalid的土气。我试图通过设置BILLINGAGREEMENTDESCRIPTION和BILLINGTYPE = RecurringPayments我的前集preSS结账要求,也是同样的错误仍然存​​在。

I am new to paypal and I need to implement a subscription ( recurring payment) for my client.I am using paypal sandbox for its implementation. I followed the way that the paypal insists for creating a recurring payment profile. On getting "success" acknowlegment from SetExpressCheckout, GetExpressCheckOut and DoExpressCheckOut . I have tried to create the Recurring Payment Profile with the token from the DoExpressCheckOutpayment response, but the response from the CreateRecurrinpayment profile returns failure, stating that the toke in ivnalid. I tried by setting "BILLINGAGREEMENTDESCRIPTION and BILLINGTYPE=RecurringPayments" on my set express checkout request but also the same error persists.

请找到code我用来实现下面的经常性存款。

Please find the code I used to implement the recurring deposit below.

SETEX pressCheckout

{
NameValueCollection values = new NameValueCollection();

            values["METHOD"] = "SetExpressCheckout";

            values["RETURNURL"] = PayPalSettings.ReturnUrl;

            values["CANCELURL"] = PayPalSettings.CancelUrl;

            values["PAYMENTACTION"] = "Sale";

            values["CURRENCYCODE"] = "USD";

            values["BUTTONSOURCE"] = "PP-ECWizard";

            values["USER"] = PayPalSettings.Username;

            values["PWD"] = PayPalSettings.Password;

            values["SIGNATURE"] = PayPalSettings.Signature;

            values["SUBJECT"] = "";

            values["L_NAME0"] = "MyName";

            values["L_AMT0"] = "20.00";

            values["VERSION"] = "2.3";

            values["AMT"] = PayPalSettings.OrderAmount;

            values["L_BILLINGTYPE0"] = "RecurringPayments";

            values["L_BILLINGAGREEMENTDESCRIPTION0"] = "Test subscription";





            values = Submit(values);



            string ack = values["ACK"].ToLower();



            if (ack == "success" || ack == "successwithwarning")

            {

                return new PayPalRedirect

                {

                    Token = values["TOKEN"],
                    Url = String.Format("https://{0}/cgi-bin/webscr?cmd=_express-checkout&token={1}",
                       PayPalSettings.CgiDomain, values["TOKEN"])
                 };
            }
             else
            {
            throw new Exception(values["L_LONGMESSAGE0"]);
            }
}

提交

private static NameValueCollection Submit(NameValueCollection values)

        {

            string data = String.Join("&", values.Cast<string>()

              .Select(key => String.Format("{0}={1}", key, HttpUtility.UrlEncode(values[key]))));



            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(

               String.Format("https://{0}/nvp", PayPalSettings.ApiDomain));



            request.Method = "POST";

            request.ContentLength = data.Length;



            using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))

            {

                writer.Write(data);

            }



            using (StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream()))

            {

                return HttpUtility.ParseQueryString(reader.ReadToEnd());

            }

        }

GETEX pressCheckout

public ActionResult Success(string token)

    {

        GetExpressCheckout getExpressCheckout = new GetExpressCheckout();

        GetExpressCheckoutDetailsResponseType getExpressCheckoutResponse = getExpressCheckout.ECGetExpressCheckoutCode(token);



        if (getExpressCheckoutResponse.Ack == AckCodeType.Success)

        {

            ExpressCheckout expressCheckout = new ExpressCheckout();

            DoExpressCheckoutPaymentResponseType doExpressCheckoutResponse = expressCheckout.DoExpressCheckoutPayment

                                                        (

                                                            token,

                                                            getExpressCheckoutResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID,

                                                            PayPalSettings.OrderAmount,

                                                            PaymentActionCodeType.Sale,

                                                            CurrencyCodeType.USD

                                                        );



            if (doExpressCheckoutResponse.Ack == AckCodeType.Success)

            {

CreateRecurringPaymentsProfile createRecurringPaymentsProfile = new CreateRecurringPaymentsProfile();               

                CreateRecurringPaymentsProfileResponseType recurringPaymentProfileResponse = createRecurringPaymentsProfile.CreateRecurringPaymentsProfileCode(

                                                                                                doExpressCheckoutResponse.DoExpressCheckoutPaymentResponseDetails.Token,

                                                                                                doExpressCheckoutResponse.Timestamp,

                                                                                                PayPalSettings.OrderAmount,

                                                                                                1,

                                                                                                BillingPeriodType.Month,

                                                                                                CurrencyCodeType.USD

                                                                                                );

                if (recurringPaymentProfileResponse.Ack == AckCodeType.Success)

                {
}

CreateReEcurringPaymentsProfile

public CreateRecurringPaymentsProfileResponseType CreateRecurringPaymentsProfileCode(string token, DateTime date, string amount, int BF, BillingPeriodType BP, CurrencyCodeType currencyCodeType)

              {

                     CallerServices caller = new CallerServices();



                     IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();



            // Set up your API credentials, PayPal end point, and API version.

            profile.APIUsername = PayPalSettings.Username;

            profile.APIPassword = PayPalSettings.Password;

            profile.APISignature = PayPalSettings.Signature;

                     profile.Environment="sandbox";

                     caller.APIProfile = profile;





                     // Create the request object.

                    CreateRecurringPaymentsProfileRequestType pp_request=new CreateRecurringPaymentsProfileRequestType();

                     pp_request.Version="51.0";



            // Add request-specific fields to the request.

                     pp_request.CreateRecurringPaymentsProfileRequestDetails= new CreateRecurringPaymentsProfileRequestDetailsType();

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.Token=token;

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.RecurringPaymentsProfileDetails=new RecurringPaymentsProfileDetailsType();

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.RecurringPaymentsProfileDetails.BillingStartDate=date;

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails=new ScheduleDetailsType();

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod=new BillingPeriodDetailsType();

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount=new BasicAmountType();

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount.Value =amount ;

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.Amount.currencyID= currencyCodeType;//Enum for currency code is  CurrencyCodeType.USD

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.BillingFrequency=BF;

                     pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.PaymentPeriod.BillingPeriod=BP;////Enum for BillingPeriod is  BillingPeriodType.Day

            //pp_request.Version = "51.0";



            pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.Description = "Test subscription";

            //pp_request.CreateRecurringPaymentsProfileRequestDetails.ScheduleDetails.Description



            // Execute the API operation and obtain the response.

                     CreateRecurringPaymentsProfileResponseType pp_response=new CreateRecurringPaymentsProfileResponseType();

                     pp_response= (CreateRecurringPaymentsProfileResponseType) caller.Call("CreateRecurringPaymentsProfile", pp_request);

                     return pp_response;

              }

任何帮助将大大AP preciated。

Any help will be greatly appreciated.

在此先感谢

推荐答案

Sujth,正确的版本给出的51.0您的需要。
编码快乐!

Sujth , The correct version to be given is 51.0 for your need. Happy Coding!

这篇关于宝经常性支付交易错误:11502:令牌无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆