Hope this save some time for someone.
The concept is for each products there will be one or more subscription plan. End users will be presented with the Subscription plans. And they will buy the subscription.
The subscription plans can be created from both Paypal Dashboard and using REST API. Here is the REST API method.
Request URL
https://api-m.paypal.com/v1/billing/plans/
Method
Post
Header
Authorization: Bearer A3xxxxxxxxxxr-LXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXcOFiuF7__PXXXXXXXXXXXXX_YuJNIHYHGTJG
PayPal-Request-Id: TEST-REQ-ID-12345 —- This is optional. Passing this will make consequent requests work on same initial Request. Better to omit it.
BODY
{
"product_id": "PRODCUCT ID OF CORRESPONDING PRODUCT",
"name": "THE NAME of Subscription Plan GOES HERE",
"description": "THE DESCRIPTION Subscription Plan GOES HERE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1, //sequence is important when there are trials. Trials will be 1 and regular packages can be 2 onwards.
"total_cycles": 0, // 0 means unlimited
"pricing_scheme": {
"fixed_price": {
"value": "1.99",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "0",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 1
},
"taxes": {
"percentage": "0",
"inclusive": false
}
}
Return
This will return the auto-generated Plan-ID. The plan id will be needed for integration in frontend. The Plan-ID can also be found from the Paypal Dashboard's subscription section.