Sam
Sam

Reputation: 20486

PayPal CreateRecurringPaymentProfile Error 11502 - Invalid Token

I am setting up a Recurring Payment with PayPal's API. First I send the following parameters to SetExpressCheckout:

Array
(
    [METHOD] => SetExpressCheckout
    [USER] => XXX
    [PWD] => XXX
    [SIGNATURE] => XXX
    [VERSION] => 98.0
    [AMT] => 0
    [MAXAMT] => 99.00
    [RETURNURL] => http://google.com
    [CANCELURL] => http://google.com
    [L_BILLINGTYPE0] => RecurringPayments
    [L_BILLINGAGREEMENTDESCRIPTION0] => 99.00 per month till stopped
)

This generates a response like the following:

Array
(
    [TOKEN] => EC-90P39652RF345525U
    [TIMESTAMP] => 2013-02-08T17:09:24Z
    [ACK] => Success
    [VERSION] => 98.0
)

Using the description and token from the created billing agreement, I send the following parameters to CreateRecurringPaymentsProfile:

Array
    (
    [METHOD] => CreateRecurringPaymentsProfile
    [USER] => XXX
    [PWD] => XXX
    [SIGNATURE] => XXX
    [TOKEN] => EC-90P39652RF345525U
    [PROFILESTARTDATE] => Feb 22 2013 17:09:24
    [DESC] => 99.00 per month till stopped
    [BILLINGPERIOD] => Month
    [BILLINGFREQUENCY] => 12
    [AMT] => 99.00
    [CURRENTCYCODE] => USD
    [CREDITCARDTYPE] => VISA
    [ACCT] => 1234123412341234
    [EXPDATE] => 012014
    [CVV2] => 123
    [EMAIL] => [email protected]
    [STREET] => 123 Main St
    [CITY] => New York City
    [STATE] => NY
    [COUNTRYCODE] => US
    [ZIP] => 12345
)

All looks well to me, but it fails:

Array
(
    [TIMESTAMP] => 2013-02-08T17:09:24Z
    [ACK] => Failure
    [VERSION] => 98.0
    [L_ERRORCODE0] => 11502
    [L_SHORTMESSAGE0] => Invalid Token
    [L_LONGMESSAGE0] => The token is invalid
    [L_SEVERITYCODE0] => Error
)

Any help is greatly appreciated!

Upvotes: 3

Views: 2385

Answers (1)

Matt Cole
Matt Cole

Reputation: 2562

You need to redirect the buyer to PayPal to approve the recurring payment before you call CreateRecurringPaymentsProfile. The timestamps on both of your API responses are the same, which tells me that you called CreateRecurringPaymentsProfile as soon as you got your response from SetExpressCheckout. You need to redirect the buyer to PayPal after you get your response back from SetExpressCheckout.

Upvotes: 6

Related Questions