How do I set up Express Checkout with Recurring Billing in Payflow?
This article will help you use Recurring Billing with the Payflow API for Express Checkout. Using Recurring Billing with Payflow is much like Recurring Payments with the PayPal API; you're just passing different variables, but the logic itself is much the same.
First, as always when working with Express Checkout, you need to set up the transaction.
- In the PayPal API, use the SetExpressCheckout method.
- In Payflow, use the "S" ACTION Request.
Note: You can't create Express Checkout Recurring Billing Profiles within PayPal Manager.
"S" ACTION request
USER=MERCHANTLOGIN PWD=PASSWORD VENDOR=MERCHANTLOGIN PARTNER=PayPal TRXTYPE=S TENDER=P ACTION=S AMT=10.00 CURRENCY=USD RETURNURL=https://www.yoursite.com/return.php CANCELURL=https://localhost ORDERDESC=test order BILLINGTYPE=RecurringBilling
"S" ACTION response
Array (  => RESULT=0  => RESPMSG=Approved  => TOKEN=EC-4X323426LW1559921  => CORRELATIONID=c85296249209a )
As you can see, you're returned a Token.
You then take that Token and append it to the PayPal URL:
Where <Token> is the value of the Token returned from the API call:
At this point, the user is redirected and taken to PayPal.com, where they sign in to their account or create an account through our account creation flow.
Throughout checkout, the user sees a box reminding them that they're signing up to be recurringly billed from your service, where Your Business Name is the business name on your PayPal account.
The user then clicks Agree and Continue and they're sent to your RETURNURL as set in the "S" call:
When they return, your URL is then posted some data:
You get back the Token and PayerID in the querystring.
You then invoke the "G" ACTION or GetExpressCheckoutDetails API call.
"G" ACTION request
USER=MERCHANTLOGIN PWD=PASSWORD VENDOR=MERCHANTLOGIN PARTNER=PayPal TRXTYPE=S TENDER=P ACTION=G TOKEN=EC-4X323426LW1559921
"G" ACTION response
Array (  => RESULT=0  => RESPMSG=Approved  => AVSADDR=Y  => AVSZIP=Y  => TOKEN=EC-4X323426LW1559921  => PAYERID=5X4X6FQUMKFVA  => CORRELATIONID=366aff557d376  => EMAILfirstname.lastname@example.org  => PAYERSTATUS=verified  => PHONENUM=408-983-5678  => FIRSTNAME=Nate  => LASTNAME=Tester  => SHIPTOBUSINESS=Nate's Test Acct  => SHIPTOSTREET=1 Main St  => SHIPTOCITY=San Jose  => SHIPTOSTATE=CA  => SHIPTOZIP=95131  => SHIPTOCOUNTRY=US  => SHIPTONAME=Nate's Test Acct  => COUNTRYCODE=US  => ADDRESSSTATUS=Y )
You then parse out that information and display it to the user.
They click Confirm and you make the "D" ACTION call or DoExpressCheckoutPayment call:
"D" ACTION request
USER=MERCHANTLOGIN PWD=PASSWORD VENDOR=MERCHANTLOGIN PARTNER=PayPal TRXTYPE=S TENDER=P ACTION=D TOKEN=EC-4X323426LW1559921 PAYERID=5X4X6FQUMKFVA AMT=10.00 CURRENCY=USD ORDERDESC=test order
"D" ACTION response
Array (  => RESULT=0  => PNREF=E34P0A4153B8  => RESPMSG=Approved  => AVSADDR=Y  => AVSZIP=Y  => TOKEN=EC-4X323426LW1559921  => PAYERID=5X4X6FQUMKFVA  => PPREF=0BM04086WX4520323  => CORRELATIONID=1b39c472948c5  => FEEAMT=0.59  => BAID=B-0LT60093PA8952305  => PAYMENTTYPE=instant  => PENDINGREASON=completed )
In the API response for the "D" ACTION, you get a BAID, which you'll need to use to create the Recurring Billing Profile call.
To create the Recurring Billing Profile, you use an "A" ACTION to Add a Recurring Billing Profile. Use a TRXTYPE of R to specify "Recurring," and you'll pass the BAID as the Reference Point for the TENDER of P for "PayPal."
"A" ACTION request
USER=MERCHANTLOGIN PWD=PASSWORD VENDOR=MERCHANTLOGIN PARTNER=PayPal ACTION=A TENDER=P TRXTYPE=R PROFILENAME=UserProfile BAID=B-0LT60093PA8952305 AMT=1.00 START=03112011 TERM=0 PAYPERIOD=MONT MAXFAILEDPAYMENTS=0 RETRYNUMDAYS=5 EMAILemail@example.com DESC=RecurringProfile COMPANYNAME=CustomerCompany
"A" ACTION response
Array (  => RESULT=0  => RPREF=R2550A40FC1D  => PROFILEID=RT0000000006  => RESPMSG=Approved )
The PROFILEID is the PROFILE ID that you see in your https://manager.paypal.com account.
For more information, consult the Express Checkout for Payflow Guide.