Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CreateRecurringPaymentsProfile giving Error 11502: Invalid Token

I keep getting the Invalid Token Error when i call the CreateRecurringPaymentsProfile NVP API.

Please find the sequence of my API calls below:

SetExpressCheckout

METHOD = SetExpressCheckout
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
ReturnUrl = http://google.com
CANCELURL = http://google.com
PAYMENTREQUEST_0_PAYMENTACTION = Authorization
PAYMENTREQUEST_0_AMT = 100.00
PAYMENTREQUEST_0_CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID = [email protected]
LOCALECODE = US
L_BILLINGTYPE0 = RecurringPayments
L_BILLINGAGREEMENTDESCRIPTION0 = SameEveryTime

I get back a token with ACK=*Success* as response. I then navigate to the paypal website using the URL [https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=token] and login with a paypal account and click on "Agree and Continue".

After agreeing and successfully redirecting to the redirect URL, I make the GetExpressCheckoutDetails API call with the following parameters

METHOD = GetExpressCheckoutDetails
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>

After successfully getting the the payer details as response, i make the DoExpressCheckoutPayment API call

METHOD = DoExpressCheckoutPayment
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
PAYERID = <payer ID from the GetExpressCheckoutDetails response>
PAYMENTREQUEST_0_AMT = 100
PAYMENTREQUEST_0_PAYMENTACTION = Sale
PAYMENTREQUEST_0_CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID = [email protected]

I now make the CreateRecurringPaymentsProfile API call

METHOD = CreateRecurringPaymentsProfile
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
PAYERID = <payer ID from the GetExpressCheckoutDetails response>
DESC = SameEveryTime
BILLINGPERIOD = Month
BILLINGFREQUENCY = 1
PROFILESTARTDATE = 2013-05-16T00:00:00Z
MAXFAILEDPAYMENTS = 1
AMT = 100.00
CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
AUTOBILLAMT = AddToNextBilling

I keep getting the following response

TIMESTAMP = 2013-04-17T05:31:24Z
CORRELATIONID = d2c1d30c1d31
ACK = Failure
VERSION = 98
BUILD = 5650305
L_ERRORCODE0 = 11502
L_SHORTMESSAGE0 = Invalid Token
L_LONGMESSAGE0 = The token is invalid
L_SEVERITYCODE0 = Error

I have tried looking for a solution in many forums but could not figure out if i have missed any parameters.

Can anyone help me on this?

Thanks in advance, Rahul

like image 619
Rahul Katikineni Avatar asked Apr 17 '13 06:04

Rahul Katikineni


1 Answers

This error returned by Paypal is vague. Most common reason for this error is discrepancy between BillingDescription value in SetExpressCheckout call and ScheduleDEtails.Description in CreateRecurringprofile call. Make sure these two are exactly the same for this to work.

Eg:

public CreateRecurringPaymentsProfileResponseType createRecurringProfile(string tokenin){
        var scheduleDetails = new ScheduleDetailsType();
        scheduleDetails.PaymentPeriod = paymentPeriod;
        scheduleDetails.Description = "RecurringBilling"; 
}
public  SetExpressCheckoutResponseType setExpressCheckout()
{
 ....
 var billingAgreement = new BillingAgreementDetailsType();

            billingAgreement.BillingAgreementDescription = "RecurringBilling";
            billingAgreement.BillingType = BillingCodeType.RECURRINGPAYMENTS;
            billingAgreement.PaymentType = MerchantPullPaymentCodeType.ANY;

            ecDetails.BillingAgreementDetails.Add(billingAgreement);
 ...
 }
like image 64
Smi.Pol Avatar answered Nov 01 '22 18:11

Smi.Pol