Skip to content

Instantly share code, notes, and snippets.

@Crashthatch
Created March 5, 2014 23:06
Show Gist options
  • Save Crashthatch/9378624 to your computer and use it in GitHub Desktop.
Save Crashthatch/9378624 to your computer and use it in GitHub Desktop.
Recurring payment Paypal subscription with instant confirmation of first month
First Call:
USER: '***',
PWD: '***',
SIGNATURE: '***',
METHOD: 'SetExpressCheckout',
VERSION: 86,
L_BILLINGTYPE0: 'RecurringPayments',
L_BILLINGAGREEMENTDESCRIPTION0: 'Recurring Monthly Subscription - Small',
PAYMENTREQUEST_0_AMT: 19.95,
PAYMENTREQUEST_0_TAXAMT: 3.32,
PAYMENTREQUEST_0_CURRENCYCODE: 'GBP',
PAYMENTREQUEST_0_DESC: 'Monthly Subscription - Small - First Month',
PAYMENTREQUEST_0_ITEMAMT: 16.63,
PAYMENTREQUEST_0_PAYMENTACTION: 'Sale',
L_PAYMENTREQUEST_0_NAME0: 'Monthly Subscription - Small - First Month',
L_PAYMENTREQUEST_0_AMT0: 16.63,
L_PAYMENTREQUEST_0_TAXAMT0: 3.32,
NOSHIPPING: 1,
cancelUrl: 'http://localhost/app#/myaccount',
returnUrl: 'http://localhost/subscriptionreturn'
Then forward user to https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<TOKEN>
Then make the following 3 calls:
Get the user's details:
USER: '***',
PWD: '***',
SIGNATURE: '***',
METHOD: 'GetExpressCheckoutDetails',
VERSION: 86,
TOKEN: token
Set up a recurring payment:
USER: '***',
PWD: '***',
SIGNATURE: '***',
METHOD: 'CreateRecurringPaymentsProfile',
VERSION: 86,
TOKEN: <token>,
PAYERID: <payerId>,
PROFILESTARTDATE: aMonthsTime.toISOString(),
DESC: 'Recurring Monthly Subscription - Small', //Description must match the description in billing agreement above.
BILLINGPERIOD: 'Month',
BILLINGFREQUENCY: 1,
AMT: 16.63,
TAXAMT: 3.32,
CURRENCYCODE: 'GBP',
MAXFAILEDPAYMENTS: 1,
AUTOBILLOUTAMT: 'AddToNextBilling'
And finally confirm/take the initial payment:
USER: '***',
PWD: '***',
SIGNATURE: '***',
METHOD: 'DoExpressCheckoutPayment',
VERSION: 86,
TOKEN: <token>,
PAYERID: <payerId>,
PAYMENTREQUEST_0_AMT: 19.95,
PAYMENTREQUEST_0_ITEMAMT: 16.63,
PAYMENTREQUEST_0_TAXAMT: 3.32,
PAYMENTREQUEST_0_CURRENCYCODE: 'GBP',
PAYMENTREQUEST_0_PAYMENTACTION: 'Sale'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment