Though the process is very well detailed on Paypal docs.
The code is like this: The docs states that - When a customer is ready to check out -
Request
-------
Endpoint URL: https://api-3t.sandbox.paypal.com/nvp
HTTP method: POST
POST data:
USER=insert_merchant_user_name_here
&PWD=insert_merchant_password_here
&SIGNATURE=insert_merchant_signature_value_here
&METHOD=SetExpressCheckout
&VERSION=86
&L_BILLINGTYPE0=RecurringPayments #The type of billing agreement
&L_BILLINGAGREEMENTDESCRIPTION0=FitnessMembership #The description of the billing agreement
&cancelUrl=http://www.yourdomain.com/cancel.html #For use if the consumer decides not to proceed with payment
&returnUrl=http://www.yourdomain.com/success.html #For use if the consumer proceeds with payment
Response
--------
TOKEN=EC%2d2B984685J43051234
&ACK=Success
...
I am able to create this call and obtain the token. what I am confused is when actually this call is to be initiated. What event should trigger this call.
As in the second step - it mentions redirect the customer to Paypal for Authorization.
Step3 - If the customer provides authorization - the customer is redirected to return URL - obtain customer detail.
Step4 - Create Recurring Profile.
so I feel little lost the flow how should handle that.
but here is the confusion. when the user clicks on subscribe, the API call is initiated and a token is obtained and I need to redirect the customer to Paypal for authoization.
Ok I can achived that as well. but when the user is redirected to Paypal the profile is not created. Only he authorizes for the payment and redirected back to my site.
Here the main confusion, what and how I will interact with the customer who is back to my site, who has already subscribed at the first instance.
The first step that you do is SetExpressCheckout, which is basically to get a token from PayPal and redirecting customer to PayPal checkout page to authorize the payment.
Express checkout is a entry point for several of PayPal integration which are:
1) One time payment ( SetExpressCheckout -> DoExpressCheckoutPayment )
2) Reference Transaction ( SetExpressCheckout -> CreateBillingAgreement -> DoReferenceTransaction )
3) Recurring payment ( SetExpressCheckout -> CreateRecurringPaymentsProfile )
For you case, since you want to create a recurring profile, once your customer is redirected back to your site, you need to call for CreateRecurringPaymentsProfile.