Eve
Eve

Reputation: 13

Getting "Invalid Token" error for CreateRecurringPaymentsProfile

I am using angelleye php library to CreateRecurringPaymentsProfile and following the 4 step process:

1, SetExpressCheckout

2, Redirecting to www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=tokenvalue

3, GetExpressCheckoutDetails

4, DoExpressCheckoutPayment

5, CreateRecurringPaymentsProfile

All the above steps are passing except CreateRecurringPaymentsProfile...I am running out of ideas, help is appreciated.

Raw values of my request/response are:

RAWREQUEST

    USER=hide.hide-facilitator_api1.gmail.com
    PWD=hide
    VERSION=98.0
    BUTTONSOURCE=AngellEYE_PHPClass
    SIGNATURE=hide
    METHOD=GetExpressCheckoutDetails
    TOKEN=EC-55V363450P8173204 

RAWRESPONSE

    TOKEN=EC-55V363450P8173204
    BILLINGAGREEMENTACCEPTEDSTATUS=0
    CHECKOUTSTATUS=PaymentActionNotInitiated
    TIMESTAMP=2014-07-01T21:26:27Z
    CORRELATIONID=88436244ae580
    ACK=Success
    VERSION=98.0
    BUILD=11624049
    EMAIL=%40yahoo.com
    PAYERID=hide
    PAYERSTATUS=verified
    FIRSTNAME=Jacqueline
    LASTNAME=Dias
    COUNTRYCODE=US
    CURRENCYCODE=USD
    AMT=10.00
    ITEMAMT=10.00
    SHIPPINGAMT=0.00
    HANDLINGAMT=0.00
    TAXAMT=0.00
    CUSTOM=1%7c1%7c8561112555243
    DESC=Plan%20Details:%201-8561112555243
    INVNUM=8561112555243
    NOTIFYURL=PayPalIPN
    INSURANCEAMT=0.00
    SHIPDISCAMT=0.00
    L_NAME0=Plan%20Details:%201-8561112555243
    L_NUMBER0=na
    L_QTY0=1
    L_TAXAMT0=0.00
    L_AMT0=10.00
    L_DESC0=Plan%20Details:%201-8561112555243
    L_ITEMWEIGHTVALUE0=%20%20%200.00000
    L_ITEMLENGTHVALUE0=%20%20%200.00000
    L_ITEMWIDTHVALUE0=%20%20%200.00000
    L_ITEMHEIGHTVALUE0=%20%20%200.00000
    L_ITEMCATEGORY0=Digital
    PAYMENTREQUEST_0_CURRENCYCODE=USD
    PAYMENTREQUEST_0_AMT=10.00
    PAYMENTREQUEST_0_ITEMAMT=10.00
    PAYMENTREQUEST_0_SHIPPINGAMT=0.00
    PAYMENTREQUEST_0_HANDLINGAMT=0.00
    PAYMENTREQUEST_0_TAXAMT=0.00
    PAYMENTREQUEST_0_CUSTOM=1%7c1%7c8561112555243
    PAYMENTREQUEST_0_DESC=Plan%20Details:%201-8561112555243
    PAYMENTREQUEST_0_INVNUM=8561112555243
    PAYMENTREQUEST_0_NOTIFYURL=PayPalIPN
    PAYMENTREQUEST_0_INSURANCEAMT=0.00
    PAYMENTREQUEST_0_SHIPDISCAMT=0.00
    PAYMENTREQUEST_0_NOTETEXT=This%20is%20a%20test%20note%20before%20ever%20having%20left%20the%20web%20site.
    PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false
    PAYMENTREQUEST_0_ADDRESSNORMALIZATIONSTATUS=None
    L_PAYMENTREQUEST_0_NAME0=Plan%20Details:%201-8561112555243
    L_PAYMENTREQUEST_0_NUMBER0=na
    L_PAYMENTREQUEST_0_QTY0=1
    L_PAYMENTREQUEST_0_TAXAMT0=0.00
    L_PAYMENTREQUEST_0_AMT0=10.00
    L_PAYMENTREQUEST_0_DESC0=Plan%20Details:%201-8561112555243
    L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0=%20%20%200.00000
    L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0=%20%20%200.00000
    L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0=%20%20%200.00000
    L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0=%20%20%200.00000
    L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital
    PAYMENTREQUESTINFO_0_ERRORCODE=0 

RAWREQUEST

    USER=hide.hide-facilitator_api1.gmail.com
    PWD=hide
    VERSION=98.0
    BUTTONSOURCE=AngellEYE_PHPClass
    SIGNATURE=hide
    METHOD=DoExpressCheckoutPayment
    TOKEN=EC-55V363450P8173204
    PAYERID=hide
    RETURNFMFDETAILS=1
    BUTTONSOURCE=hide
    PAYMENTREQUEST_0_AMT=10.00
    PAYMENTREQUEST_0_CURRENCYCODE=USD
    PAYMENTREQUEST_0_ITEMAMT=10.00
    PAYMENTREQUEST_0_DESC=Plan+Details:+1-8561112555243
    PAYMENTREQUEST_0_INVNUM=8561112555243
    PAYMENTREQUEST_0_NOTIFYURL=PayPalIPN
    PAYMENTREQUEST_0_PAYMENTACTION=Sale
    L_PAYMENTREQUEST_0_NAME0=Plan+Details:+1-8561112555243
    L_PAYMENTREQUEST_0_DESC0=Plan+Details:+1-8561112555243
    L_PAYMENTREQUEST_0_AMT0=10.00
    L_PAYMENTREQUEST_0_NUMBER0=na
    L_PAYMENTREQUEST_0_QTY0=1 

RAWRESPONSE

    TOKEN=EC-55V363450P8173204
    SUCCESSPAGEREDIRECTREQUESTED=false
    TIMESTAMP=2014-07-01T21:26:30Z
    CORRELATIONID=c299c1d456a1f
    ACK=Success
    VERSION=98.0
    BUILD=11624049
    INSURANCEOPTIONSELECTED=false
    SHIPPINGOPTIONISDEFAULT=false
    PAYMENTINFO_0_TRANSACTIONID=7WV52893XW736654U
    PAYMENTINFO_0_TRANSACTIONTYPE=cart
    PAYMENTINFO_0_PAYMENTTYPE=instant
    PAYMENTINFO_0_ORDERTIME=2014-07-01T21:26:30Z
    PAYMENTINFO_0_AMT=10.00
    PAYMENTINFO_0_FEEAMT=0.59
    PAYMENTINFO_0_TAXAMT=0.00
    PAYMENTINFO_0_CURRENCYCODE=USD
    PAYMENTINFO_0_PAYMENTSTATUS=Completed
    PAYMENTINFO_0_PENDINGREASON=None
    PAYMENTINFO_0_REASONCODE=None
    PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible
    PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None
    PAYMENTINFO_0_SECUREMERCHANTACCOUNTID=hide
    PAYMENTINFO_0_ERRORCODE=0
    PAYMENTINFO_0_ACK=Success 

RAWREQUEST

    USER=hide.hide-facilitator_api1.gmail.com
    PWD=hide
    VERSION=98.0
    BUTTONSOURCE=AngellEYE_PHPClass
    SIGNATURE=hide
    METHOD=CreateRecurringPaymentsProfile
    TOKEN=EC-55V363450P8173204
    PROFILESTARTDATE=2014-07-01T21:27:30Z
    DESC=Plan+Details:+1-8561112555243
    AUTOBILLAMT=1
    BILLINGPERIOD=Year
    BILLINGFREQUENCY=1
    TOTALBILLINGCYCLES=0
    AMT=10.00
    CURRENCYCODE=USD
    PAYERID=hide
    COUNTRYCODE=US
    L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital
    L_PAYMENTREQUEST_0_NAME0=Plan+Details:+1-8561112555243
    L_PAYMENTREQUEST_0_DESC0=Plan+Details:+1-8561112555243
    L_PAYMENTREQUEST_0_AMT0=10.00
    L_PAYMENTREQUEST_0_NUMBER0=na
    L_PAYMENTREQUEST_0_QTY0=1 

RAWRESPONSE

    TIMESTAMP=2014-07-01T21:26:31Z
    CORRELATIONID=79d7deb94f82f
    ACK=Failure
    VERSION=98.0
    BUILD=11457922
    L_ERRORCODE0=11502
    L_SHORTMESSAGE0=Invalid%20Token
    L_LONGMESSAGE0=The%20token%20is%20invalid
    L_SEVERITYCODE0=Error

Upvotes: 1

Views: 626

Answers (1)

Drew Angell
Drew Angell

Reputation: 26056

I don't see your SetExpressCheckout request here..??

You need to make sure the SEC request includes the billing agreement parameters that enable it for recurring payments. Since you're using my library, look in the SetExpressCheckout.php template for the following:

$BillingAgreements = array();
$Item = array(
              'l_billingtype' => '',                            // Required.  Type of billing agreement.  For recurring payments it must be RecurringPayments.  You can specify up to ten billing agreements.  For reference transactions, this field must be either:  MerchantInitiatedBilling, or MerchantInitiatedBillingSingleSource
              'l_billingagreementdescription' => '',            // Required for recurring payments.  Description of goods or services associated with the billing agreement.  
              'l_paymenttype' => '',                            // Specifies the type of PayPal payment you require for the billing agreement.  Any or IntantOnly
              'l_billingagreementcustom' => ''                  // Custom annotation field for your own use.  256 char max.
              );

array_push($BillingAgreements, $Item);

You just need to use the value "RecurringPayments" for the billing type, and then create a description as well. The description will need to match exactly with the description you send in CreateRecurringPaymentsProfile at the end. Of course, you'll need to make sure you add $BillingAgreements to the $PayPalRequestData so that it is passed accordingly.

Once you've added the billing agreement params to the SEC request the token will be valid for CRPP.

Upvotes: 2

Related Questions