{"id":853,"date":"2021-06-18T22:37:29","date_gmt":"2021-06-18T21:37:29","guid":{"rendered":"https:\/\/www.kolkataonweb.com\/code-bank\/?p=853"},"modified":"2021-06-18T22:38:24","modified_gmt":"2021-06-18T21:38:24","slug":"json-for-creating-paypal-subscription-plan","status":"publish","type":"post","link":"https:\/\/www.kolkataonweb.com\/code-bank\/php\/json-for-creating-paypal-subscription-plan\/","title":{"rendered":"JSON for Creating Paypal Subscription Plan"},"content":{"rendered":"<p>Hope this save some time for someone.<\/p>\n<p>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.<\/p>\n<p>The subscription plans can be created from both Paypal Dashboard and using REST API. Here is the REST API method.<\/p>\n<p><strong>Request URL<br \/>\n<\/strong>https:\/\/api-m.paypal.com\/v1\/billing\/plans\/<\/p>\n<p><strong>Method<br \/>\n<\/strong>Post<\/p>\n<p><strong>Header<\/strong><br \/>\n<span style=\"color: #0000ff;\">Authorization:<\/span>\u00a0 <em>Bearer A3xxxxxxxxxxr-LXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXcOFiuF7__PXXXXXXXXXXXXX_YuJNIHYHGTJG<\/em><br \/>\n<span style=\"color: #0000ff;\">PayPal-Request-Id:<\/span> <em>TEST-REQ-ID-12345\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;-\u00a0 This is optional. Passing this will make consequent requests work on same initial Request. Better to omit it. <\/em><\/p>\n<p><strong>BODY<\/strong><\/p>\n<pre class='wp-code-highlight prettyprint'>{\r\n  \"product_id\": \"PRODCUCT ID OF CORRESPONDING PRODUCT\",\r\n  \"name\": \"THE NAME of Subscription Plan GOES HERE\",\r\n  \"description\": \"THE DESCRIPTION Subscription Plan GOES HERE\",\r\n  \"billing_cycles\": [\r\n    <span style=\"color: #800080;\">{\r\n      \"frequency\": {\r\n        \"interval_unit\": \"MONTH\",\r\n        \"interval_count\": 1\r\n      },\r\n      \"tenure_type\": \"REGULAR\",\r\n      \"sequence\": 1,    <span style=\"color: #339966;\">\/\/sequence is important when there are trials. Trials will be 1 and regular packages can be 2 onwards.<\/span>\r\n      \"total_cycles\": 0,  <span style=\"color: #339966;\">\/\/ 0 means unlimited<\/span>\r\n      \"pricing_scheme\": {\r\n        \"fixed_price\": {\r\n          \"value\": \"1.99\",\r\n          \"currency_code\": \"USD\"\r\n        }\r\n      }\r\n    }<\/span>\r\n  ],\r\n  \"payment_preferences\": {\r\n    \"auto_bill_outstanding\": true,\r\n    \"setup_fee\": {\r\n      \"value\": \"0\",\r\n      \"currency_code\": \"USD\"\r\n    },\r\n    \"setup_fee_failure_action\": \"CONTINUE\",\r\n    \"payment_failure_threshold\": 1\r\n  },\r\n  \"taxes\": {\r\n    \"percentage\": \"0\",\r\n    \"inclusive\": false\r\n  }\r\n}\r\n\r\n<\/pre>\n<p><strong>Return<\/strong><\/p>\n<pre class='wp-code-highlight prettyprint'>This will return the auto-generated Plan-ID. The plan id will be needed for integration in frontend.\r\nThe Plan-ID can also be found from the Paypal Dashboard's subscription section.<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.kolkataonweb.com\/code-bank\/miscellaneous\/paypal-rest-api-get-token\/\">How to get Token with Paypal Rest API<\/a><\/p>\n<p><a href=\"https:\/\/www.kolkataonweb.com\/code-bank\/php\/paypal-rest-api-create-products\/\">How to create products with Paypal Rest API<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip; <a class=\"more-link\" href=\"https:\/\/www.kolkataonweb.com\/code-bank\/php\/json-for-creating-paypal-subscription-plan\/\">Continue reading <span class=\"screen-reader-text\">JSON for Creating Paypal Subscription Plan<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[317,318],"class_list":["post-853","post","type-post","status-publish","format-standard","hentry","category-php","tag-paypal","tag-paypal-rest-api","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/comments?post=853"}],"version-history":[{"count":2,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/853\/revisions"}],"predecessor-version":[{"id":863,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/853\/revisions\/863"}],"wp:attachment":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/media?parent=853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/categories?post=853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/tags?post=853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}