{"id":2485,"date":"2017-05-28T19:17:12","date_gmt":"2017-05-28T19:17:12","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=2485"},"modified":"2025-04-09T14:27:34","modified_gmt":"2025-04-09T14:27:34","slug":"paypal-subscriptions-payment-gateway-integration-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/","title":{"rendered":"PayPal Subscriptions Payment Gateway Integration in PHP"},"content":{"rendered":"<p><b>PayPal Subscriptions<\/b> payment lets you accept payment for your member subscription service. If you have a membership website and want to add a subscription feature, PayPal subscription API helps to do it easily. The PayPal Subscription button is a quick and effective way to allow your website&#8217;s members to purchase the membership online.<\/p>\n<p>PayPal subscription integration process is mostly the same as <a href=\"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/\">PayPal Standard Checkout<\/a>, by has some differences with the billing procedure. By integrating the PayPal subscriptions you can bill customers recurringly at regular intervals. PayPal subscription payment gateway makes it easier to allow the user to subscribe online and manage users&#8217; subscriptions on web applications. In this tutorial, we will show you how to integrate PayPal subscription payment gateway in PHP and accept online payment on the website.<\/p>\n<p>In the example script, we will use <b>PayPal JavaScript SDK and REST API<\/b> to set up recurring payments for subscription. The following functionality will be implemented to accept payment online and create subscriptions via PayPal Payment Gateway.<\/p>\n<ol>\n<li>Define an HTML element to attach the PayPal button.<\/li>\n<li>When the buyer clicks the button, the JS library launches the PayPal Checkout experience dialog.\n<ul>\n<li>The buyer completes the subscription agreement and payment.<\/li>\n<\/ul>\n<\/li>\n<li>Create a subscription with PayPal JavaScript SDK and execute REST API request with PHP.<\/li>\n<li>On success, subscription info is captured and posted to the backend server for verification.<\/li>\n<li>The backend server verifies the transaction using PayPal Billing REST API.<\/li>\n<li>Store subscription data in the database with PHP and MySQL.<\/li>\n<li>Show a confirmation message to the subscriber.<\/li>\n<\/ol>\n<h2>PayPal REST API Credentials<\/h2>\n<p>To get started with the PayPal REST API, you need to create a developer account on the <a href=\"https:\/\/developer.paypal.com\/developer\/applications\/\">PayPal Developer Dashboard<\/a>.<\/p>\n<p>PayPal provides two environments, Sandbox and Live. Sandbox environment allows developers to test the PayPal checkout process before making it Live for production usage. You can create sandbox Business and Personal accounts from the <a href=\"https:\/\/developer.paypal.com\/dashboard\/accounts\">Sandbox Accounts<\/a> section.<\/p>\n<p>In the PayPal Developer Dashboard, you can switch between the Sandbox and Live environment from the toggle button placed at the top-right corner.<\/p>\n<p><b>Create Sandbox Accounts:<\/b><\/p>\n<ul>\n<li>Sandbox Merchant Account: Create a sandbox business account with <u>Account type: Business<\/u>. This merchant account is required to attach at the time of the REST API app.<\/li>\n<li>Sandbox Buyer Account: Create a sandbox buyer account with <u>Account type: Personal<\/u>. This buyer account will be used to test payment.\n<ul>\n<li>After the sandbox buyer account creation, an email ID and password will be generated. You can use these credentials to log in at the time of testing the PayPal checkout.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><b>Create REST API App:<\/b><br \/>\nIn the <u>Apps &amp; Credentials<\/u> section, create a new REST API App with <u>Type: Merchant<\/u>.<\/p>\n<ul>\n<li>Select a business account under the <u>Sandbox Account<\/u> dropdown.<\/li>\n<\/ul>\n<p>After the App creation, the <b>Client ID<\/b> and <b>Secret<\/b> will be generated.<\/p>\n<ul>\n<li>Copy these API credentials to later use in the script.<\/li>\n<\/ul>\n<p><b>Live REST API Credentials:<\/b><br \/>\nAt the top right corner, toggle the switch to Live. Then navigate to the <u>Apps &amp; Credentials<\/u> section.<\/p>\n<ul>\n<li>Create a new REST API App, you will get the credentials (Client ID and Secret) for the Live environment.<\/li>\n<\/ul>\n<p>Before getting started to integrate <b>PayPal Subscription payment API in PHP<\/b>, take a look at the file structure.<\/p>\n<pre class=\"file-struc\">paypal_subscriptions_payment_with_php<span style=\"color:#794938\">\/<\/span>\r\n\u251c\u2500\u2500 config.php\r\n\u251c\u2500\u2500 dbConnect.php\r\n\u251c\u2500\u2500 index.php\r\n\u251c\u2500\u2500 payment-status.php\r\n\u251c\u2500\u2500 paypal_checkout_init.php\r\n\u251c\u2500\u2500 PaypalCheckout.class.php\r\n\u2514\u2500\u2500 css<span style=\"color:#794938\">\/<\/span>\r\n    \u2514\u2500\u2500 style.css\r\n<\/pre>\n<h2>Create Database Tables<\/h2>\n<p>To store plans, members, and subscriptions information 3 tables are required in the database.<\/p>\n<p><b>1.<\/b> The following SQL creates a <code>plans<\/code> table to store the subscription plans info in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`plans`<\/span> (\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">5<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`price`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">float<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>,<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`interval`<\/span> enum(<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'DAY'<\/span>,<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'WEEK'<\/span>,<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'MONTH'<\/span>,<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'YEAR'<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COMMENT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'DAY(365) | WEEK(52) | MONTH(12) | YEAR(1)'<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`interval_count`<\/span> tinyint(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">1<\/span>,\r\n  PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<p><b>2.<\/b> The following SQL creates a <code>users<\/code> table to store the member&#8217;s information in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`users`<\/span> (\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`subscription_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">0<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COMMENT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'foreign key of \"user_subscriptions\" table'<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`first_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">25<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`last_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">25<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`email`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">50<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`password`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`gender`<\/span> enum(<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'Male'<\/span>,<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'Female'<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`phone`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">15<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`created`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`modified`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`status`<\/span> tinyint(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">1<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">1<\/span>,\r\n  PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<p><b>3.<\/b>The following SQL creates a <code>user_subscriptions<\/code> table to store the subscription and payment information in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`user_subscriptions`<\/span> (\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`user_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COMMENT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'foreign key of \"users\" table'<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`plan_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">5<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COMMENT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'foreign key of \"plans\" table'<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`paypal_order_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`paypal_plan_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`paypal_subscr_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`valid_from`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`valid_to`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`paid_amount`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">float<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>,<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`currency_code`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`subscriber_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`subscriber_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">50<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`subscriber_email`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">50<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`status`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">50<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`created`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`modified`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<h2>PayPal API and Database Configuration (config.php)<\/h2>\n<p>In the <code>config.php<\/code> file, constant variables of the Product, PayPal REST API and database settings are defined.<\/p>\n<p><b>PayPal REST API Constants:<\/b><\/p>\n<ul>\n<li>PAYPAL_SANDBOX &#8211; (TRUE\/FALSE) Set PayPal environment, Sandbox or Live.<\/li>\n<li>PAYPAL_SANDBOX_CLIENT_ID &#8211; Client ID of PayPal Sandbox REST API App.<\/li>\n<li>PAYPAL_SANDBOX_CLIENT_SECRET &#8211; Secret key of PayPal Sandbox REST API App.<\/li>\n<li>PAYPAL_PROD_CLIENT_ID &#8211; Client ID of PayPal Live REST API App.<\/li>\n<li>PAYPAL_PROD_CLIENT_SECRET &#8211; Secret key of PayPal Live REST API App.<\/li>\n<li>CURRENCY &#8211; Specify the currency code.<\/li>\n<\/ul>\n<p><b>Database Constants:<\/b><\/p>\n<ul class=\"bullet_disk_list\">\n<li>DB_HOST &#8211; Specify the database host.<\/li>\n<li>DB_USERNAME &#8211; Specify the database username.<\/li>\n<li>DB_PASSWORD &#8211; Specify the database password.<\/li>\n<li>DB_NAME &#8211; Specify the database name.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/*&nbsp;PayPal&nbsp;REST&nbsp;API&nbsp;configuration <br \/>&nbsp;*&nbsp;You&nbsp;can&nbsp;generate&nbsp;API&nbsp;credentials&nbsp;from&nbsp;the&nbsp;PayPal&nbsp;developer&nbsp;panel. <br \/>&nbsp;*&nbsp;See&nbsp;your&nbsp;keys&nbsp;here:&nbsp;https:\/\/developer.paypal.com\/dashboard\/ <br \/>&nbsp;*\/ <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_SANDBOX'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">);&nbsp;<\/span><span style=\"color: #FF8000\">\/\/TRUE=Sandbox&nbsp;|&nbsp;FALSE=Production <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_SANDBOX_CLIENT_ID'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Insert_PayPal_Client_ID_For_Sandbox_Here'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_SANDBOX_CLIENT_SECRET'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Insert_PayPal_Secret_Key_For_Sandbox_Here'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_PROD_CLIENT_ID'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Insert_Live_PayPal_Client_ID_Here'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_PROD_CLIENT_SECRET'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Insert_Live_PayPal_Secret_Key_Here'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'CURRENCY'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'USD'<\/span><span style=\"color: #007700\">);&nbsp; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;configuration&nbsp; <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'DB_HOST'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'localhost'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'DB_USERNAME'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'root'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'DB_PASSWORD'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'root'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'DB_NAME'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'codexworld_db'<\/span><span style=\"color: #007700\">); <br \/> <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Start&nbsp;session <br \/><\/span><span style=\"color: #007700\">if(!<\/span><span style=\"color: #0000BB\">session_id<\/span><span style=\"color: #007700\">()){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">session_start<\/span><span style=\"color: #007700\">(); <br \/>}&nbsp; <br \/> <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Database Connection (dbConnect.php)<\/h2>\n<p>The <code>dbConnect.php<\/code> file is used to connect the database using PHP and MySQL.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Connect&nbsp;with&nbsp;the&nbsp;database&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$db&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">mysqli<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">DB_HOST<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">DB_USERNAME<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">DB_PASSWORD<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">DB_NAME<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Display&nbsp;error&nbsp;if&nbsp;failed&nbsp;to&nbsp;connect&nbsp; <br \/><\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_errno<\/span><span style=\"color: #007700\">)&nbsp;{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">printf<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Connect&nbsp;failed:&nbsp;%s\\n\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit();&nbsp; <br \/>}<\/span><\/pre>\n<h2>PayPal Subscription Page (index.php)<\/h2>\n<p>First, include the configuration file to load the PayPal API variables and connect the database to fetch subscription plans.<\/p>\n<ul>\n<li>Fetch the subscription plans from the database.<\/li>\n<li>Retrieve the logged-in user ID from the session and set it in the <code>$loggedInUserID<\/code> variable.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;configuration&nbsp;file&nbsp; <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;connection&nbsp;file <br \/><\/span><span style=\"color: #007700\">include_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConnect.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;plans&nbsp;from&nbsp;the&nbsp;database <br \/><\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;*&nbsp;FROM&nbsp;plans\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">get_result<\/span><span style=\"color: #007700\">(); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;logged-in&nbsp;user&nbsp;ID&nbsp;from&nbsp;sesion <br \/>\/\/&nbsp;Session&nbsp;name&nbsp;need&nbsp;to&nbsp;be&nbsp;changed&nbsp;as&nbsp;per&nbsp;your&nbsp;system <br \/><\/span><span style=\"color: #0000BB\">$loggedInUserID&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$_SESSION<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'userID'<\/span><span style=\"color: #007700\">])?<\/span><span style=\"color: #0000BB\">$_SESSION<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'userID'<\/span><span style=\"color: #007700\">]:<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p>Load the PayPal JavaScript SDK, and set the Client ID and <code>intent=subscription<\/code> in the query string of the URL.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"https:\/\/www.paypal.com\/sdk\/js?client-id=<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX_CLIENT_ID<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">PAYPAL_PROD_CLIENT_ID<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>&amp;vault=true&amp;intent=subscription\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span><\/pre>\n<p>Define the select box dropdown and list all the subscription plans.<\/p>\n<ul>\n<li>Define a container element for the PayPal button (<code>paypal-button-container<\/code>).<\/li>\n<\/ul>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"panel\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"overlay hidden\"<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"overlay-content\"<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"css\/loading.gif\"<\/span> <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Processing...\"<\/span>\/&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"panel-heading\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h3<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"panel-title\"<\/span>&gt;<\/span>Subscription with PayPal<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h3<\/span>&gt;<\/span>\r\n        \r\n        <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- Subscription Plan Info --&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"form-group\"<\/span>&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>Select Subscription Plan:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">select<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"subscr_plan\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"form-control\"<\/span>&gt;<\/span>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(<\/span><span style=\"color: #0000BB\">$row&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">()){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$interval&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'interval'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$interval_count&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'interval_count'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$interval_str&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;(<\/span><span style=\"color: #0000BB\">$interval_count&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">$interval_count<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$interval<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'s'<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">$interval<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n                    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">option<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;[$'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'price'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$interval_str<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">']'<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">option<\/span>&gt;<\/span>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">select<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"panel-body\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- Display status message --&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"paymentResponse\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"hidden\"<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n        \r\n        <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- Set up a container element for the button --&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"paypal-button-container\"<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span><\/pre>\n<p><u>Process subscription payment with PayPal JavaScript SDK library:<\/u><br \/>\nThe <code>paypal.Buttons()<\/code> method of PayPal JavaScript SDK is used to process the checkout operations.<\/p>\n<ul>\n<li>The button container is attached by the element ID (<code>#paypal-button-container<\/code>) using the <code>render()<\/code> method.<\/li>\n<\/ul>\n<p><b><code>createSubscription()<\/code>:<\/b><\/p>\n<ul>\n<li>The selected plan ID is posted to the server-side script (<code>paypal_checkout_init.php<\/code>) to create a subscription plan using PayPal REST API.<\/li>\n<li>Initiate <code>actions.subscription.create()<\/code> method and pass plan_id to create subscription on PayPal.<\/li>\n<\/ul>\n<p><b><code>onApprove()<\/code>:<\/b><\/p>\n<ul>\n<li>The subscriptionID is sent to the server-side script (<code>paypal_checkout_init.php<\/code>) via HTTP request.<\/li>\n<li>If the subscription and payment are verified successfully, redirect the user to the subscription status page.<\/li>\n<\/ul>\n<p>The <code>encodeFormData()<\/code>, <code>setProcessing()<\/code>, and <code>resultMessage()<\/code> are the helper functions used in the checkout process.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span>\r\n<span style=\"color: rgb(110, 107, 94);\">paypal.Buttons({\r\n    createSubscription: <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">async<\/span> (data, actions) =&gt; {\r\n        setProcessing(<span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">true<\/span>);\r\n\r\n        <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Get the selected plan ID<\/span>\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">let<\/span> subscr_plan_id = <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.getElementById(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"subscr_plan\"<\/span>).value;\r\n        \r\n        <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Send request to the backend server to create subscription plan via PayPal API<\/span>\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">let<\/span> postData = {request_type: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'create_plan'<\/span>, plan_id: subscr_plan_id};\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">const<\/span> PLAN_ID = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">await<\/span> fetch(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"paypal_checkout_init.php\"<\/span>, {\r\n            method: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"POST\"<\/span>,\r\n            headers: {<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'Accept'<\/span>: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'application\/json'<\/span>},\r\n            body: encodeFormData(postData)\r\n        })\r\n        .then((res) =&gt; {\r\n            <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> res.json();\r\n        })\r\n        .then((result) =&gt; {\r\n            setProcessing(<span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">false<\/span>);\r\n            <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">if<\/span>(result.status == <span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">1<\/span>){\r\n                <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> result.data.id;\r\n            }<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">else<\/span>{\r\n                resultMessage(result.msg);\r\n                <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">false<\/span>;\r\n            }\r\n        });\r\n\r\n        <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Creates the subscription<\/span>\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> actions.subscription.create({\r\n            <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'plan_id'<\/span>: PLAN_ID,\r\n            <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'custom_id'<\/span>: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'&lt;?php echo $loggedInUserID; ?&gt;'<\/span>\r\n        });\r\n    },\r\n    onApprove: (data, actions) =&gt; {\r\n        setProcessing(<span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">true<\/span>);\r\n\r\n        <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Send request to the backend server to validate subscription via PayPal API<\/span>\r\n        <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> postData = {request_type:<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'capture_subscr'<\/span>, order_id:data.orderID, subscription_id:data.subscriptionID, plan_id: <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.getElementById(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"subscr_plan\"<\/span>).value};\r\n        fetch(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'paypal_checkout_init.php'<\/span>, {\r\n            method: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'POST'<\/span>,\r\n            headers: {<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'Accept'<\/span>: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'application\/json'<\/span>},\r\n            body: encodeFormData(postData)\r\n        })\r\n        .then((response) =&gt; response.json())\r\n        .then((result) =&gt; {\r\n            <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">if<\/span>(result.status == <span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">1<\/span>){\r\n                <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Redirect the user to the status page<\/span>\r\n                <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">window<\/span>.location.href = <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"payment-status.php?checkout_ref_id=\"<\/span>+result.ref_id;\r\n            }<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">else<\/span>{\r\n                resultMessage(result.msg);\r\n            }\r\n            setProcessing(<span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">false<\/span>);\r\n        })\r\n        .catch(error =&gt; <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">console<\/span>.log(error));\r\n    }\r\n}).render(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'#paypal-button-container'<\/span>);\r\n\r\n<span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Helper function to encode payload parameters<\/span>\r\n<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">const<\/span> encodeFormData = (data) =&gt; {\r\n  <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> form_data = <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">new<\/span> FormData();\r\n\r\n  <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">for<\/span> ( <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> key <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">in<\/span> data ) {\r\n    form_data.append(key, data[key]);\r\n  }\r\n  <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> form_data;   \r\n}\r\n\r\n<span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Show a loader on payment form processing<\/span>\r\n<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">const<\/span> setProcessing = (isProcessing) =&gt; {\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">if<\/span> (isProcessing) {\r\n        <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\".overlay\"<\/span>).classList.remove(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"hidden\"<\/span>);\r\n    } <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">else<\/span> {\r\n        <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\".overlay\"<\/span>).classList.add(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"hidden\"<\/span>);\r\n    }\r\n}\r\n\r\n<span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Display status message<\/span>\r\n<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">const<\/span> resultMessage = (msg_txt) =&gt; {\r\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">const<\/span> messageContainer = <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#paymentResponse\"<\/span>);\r\n\r\n    messageContainer.classList.remove(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"hidden\"<\/span>);\r\n    messageContainer.textContent = msg_txt;\r\n    \r\n    setTimeout(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span> (<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\"><\/span>) <\/span>{\r\n        messageContainer.classList.add(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"hidden\"<\/span>);\r\n        messageContainer.textContent = <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"\"<\/span>;\r\n    }, <span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">5000<\/span>);\r\n}<\/span>    \r\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span><\/pre>\n<h2>PayPal REST API Handler Library (PaypalCheckout.class.php)<\/h2>\n<p>We will create a custom library to handle PayPal REST API execution with PHP. This PaypalCheckout library helps to generate Access Token, create plans, and retrieve subscription details with PayPal REST API using PHP. The cURL method is used to call the PayPal Subscription APIs in PHP.<\/p>\n<ul>\n<li><code>generateAccessToken()<\/code>: Fetch the access token from PayPal OAuth 2 API.<\/li>\n<li><code>createPlan()<\/code>: Initialize cURL request to create a product with Catalog Products API and plan with Billing API using PayPal REST API v2.<\/li>\n<li><code>getSubscription()<\/code>: Initialize cURL request to retrieve subscription details with PayPal Billing REST API v2 using PHP.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/**&nbsp; <br \/>&nbsp;*&nbsp; <br \/>&nbsp;*&nbsp;This&nbsp;PayPal&nbsp;Checkout&nbsp;API&nbsp;handler&nbsp;class&nbsp;is&nbsp;a&nbsp;custom&nbsp;PHP&nbsp;library&nbsp;to&nbsp;handle&nbsp;the&nbsp;PayPal&nbsp;REST&nbsp;API&nbsp;requests.&nbsp; <br \/>&nbsp;*&nbsp; <br \/>&nbsp;*&nbsp;@class&nbsp;&nbsp;&nbsp;PaypalCheckout&nbsp; <br \/>&nbsp;*&nbsp;@author&nbsp;&nbsp;CodexWorld&nbsp; <br \/>&nbsp;*&nbsp;@link&nbsp;&nbsp;&nbsp;&nbsp;https:\/\/www.codexworld.com&nbsp; <br \/>&nbsp;*&nbsp;@version&nbsp;1.0&nbsp; <br \/>&nbsp;*\/&nbsp; <br \/> <br \/>\/\/&nbsp;Include&nbsp;the&nbsp;configuration&nbsp;file <br \/><\/span><span style=\"color: #007700\">include_once&nbsp;<\/span><span style=\"color: #DD0000\">'config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/>class&nbsp;<\/span><span style=\"color: #0000BB\">PaypalCheckout<\/span><span style=\"color: #007700\">{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;<\/span><span style=\"color: #0000BB\">$paypalAuthAPI&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.sandbox.paypal.com\/v1\/oauth2\/token'<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.paypal.com\/v1\/oauth2\/token'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;<\/span><span style=\"color: #0000BB\">$paypalProductAPI&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.sandbox.paypal.com\/v1\/catalogs\/products'<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.paypal.com\/v1\/catalogs\/products'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;<\/span><span style=\"color: #0000BB\">$paypalBillingAPI&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.sandbox.paypal.com\/v1\/billing'<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.paypal.com\/v1\/billing'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;<\/span><span style=\"color: #0000BB\">$paypalClientID&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX_CLIENT_ID<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">PAYPAL_PROD_CLIENT_ID<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;<\/span><span style=\"color: #0000BB\">$paypalSecret&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX_CLIENT_SECRET<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">PAYPAL_PROD_CLIENT_SECRET<\/span><span style=\"color: #007700\">;&nbsp; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">generateAccessToken<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">();&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypalAuthAPI<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_HEADER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_SSL_VERIFYPEER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POST<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_USERPWD<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypalClientID<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\":\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypalSecret<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POSTFIELDS<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">\"grant_type=client_credentials\"<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$auth_response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">));&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_getinfo<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLINFO_HTTP_CODE<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">!=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$auth_response<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error<\/span><span style=\"color: #007700\">))&nbsp;{&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">Exception<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Failed&nbsp;to&nbsp;generate&nbsp;Access&nbsp;Token:&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$auth_response<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&nbsp;&gt;&gt;&gt;&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$auth_response<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error_description<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$auth_response<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$auth_response<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">access_token<\/span><span style=\"color: #007700\">;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">createPlan<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$planInfo<\/span><span style=\"color: #007700\">){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$accessToken&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">generateAccessToken<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(empty(<\/span><span style=\"color: #0000BB\">$accessToken<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$postParams&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array( <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"name\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">], <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"type\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">\"DIGITAL\"<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"category\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">\"SOFTWARE\" <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypalProductAPI<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_SSL_VERIFYPEER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">FALSE<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_HTTPHEADER<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Authorization:&nbsp;Bearer&nbsp;'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$accessToken<\/span><span style=\"color: #007700\">));&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POST<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POSTFIELDS<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$postParams<\/span><span style=\"color: #007700\">)); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$api_resp&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$pro_api_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$api_resp<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_getinfo<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLINFO_HTTP_CODE<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">!=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">!=&nbsp;<\/span><span style=\"color: #0000BB\">201<\/span><span style=\"color: #007700\">)&nbsp;{&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">Exception<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Failed&nbsp;to&nbsp;create&nbsp;Product&nbsp;('<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$http_code<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'):&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$api_resp<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$pro_api_data<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">id<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$postParams&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"product_id\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$pro_api_data<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">id<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"name\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">], <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"billing_cycles\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"frequency\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"interval_unit\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'interval'<\/span><span style=\"color: #007700\">],&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"interval_count\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'interval_count'<\/span><span style=\"color: #007700\">]&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;), <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"tenure_type\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">\"REGULAR\"<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"sequence\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"total_cycles\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">999<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"pricing_scheme\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"fixed_price\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"value\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'price'<\/span><span style=\"color: #007700\">], <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"currency_code\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">CURRENCY <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;), <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;), <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"payment_preferences\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"auto_bill_outstanding\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">true <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypalBillingAPI<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'\/plans'<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_SSL_VERIFYPEER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">FALSE<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_HTTPHEADER<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Authorization:&nbsp;Bearer&nbsp;'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$accessToken<\/span><span style=\"color: #007700\">));&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POST<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POSTFIELDS<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$postParams<\/span><span style=\"color: #007700\">));&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$api_resp&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$plan_api_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$api_resp<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_getinfo<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLINFO_HTTP_CODE<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">!=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">!=&nbsp;<\/span><span style=\"color: #0000BB\">201<\/span><span style=\"color: #007700\">)&nbsp;{&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">Exception<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Failed&nbsp;to&nbsp;create&nbsp;Product&nbsp;('<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$http_code<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'):&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$api_resp<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$plan_api_data<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">$plan_api_data<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">getSubscription<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$subscription_id<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$accessToken&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">generateAccessToken<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(empty(<\/span><span style=\"color: #0000BB\">$accessToken<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypalBillingAPI<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'\/subscriptions\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$subscription_id<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_SSL_VERIFYPEER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">FALSE<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_HTTPHEADER<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Authorization:&nbsp;Bearer&nbsp;'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$accessToken<\/span><span style=\"color: #007700\">));&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_CUSTOMREQUEST<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'GET'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$api_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_getinfo<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLINFO_HTTP_CODE<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">!=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$api_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'error'<\/span><span style=\"color: #007700\">]))&nbsp;{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">Exception<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Error&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$api_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'error'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">':&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$api_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'error_description'<\/span><span style=\"color: #007700\">]);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$api_data<\/span><span style=\"color: #007700\">)&nbsp;&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$http_code&nbsp;<\/span><span style=\"color: #007700\">==&nbsp;<\/span><span style=\"color: #0000BB\">200<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #0000BB\">$api_data<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>} <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Process PayPal Subscription (paypal_checkout_init.php)<\/h2>\n<p>This server-side script is accessed by the client-side Fetch API defined in <code>createSubscription()<\/code> and <code>onApprove()<\/code> methods in the client-side JavaScript code to process the subscription with PayPal REST API using PHP.<\/p>\n<ul>\n<li>Include the PaypalCheckout custom PHP library to handle the PayPal REST API operations.<\/li>\n<li>If the <code>create_plan<\/code> request is submitted:\n<ul>\n<li>Fetch the DB plan info based on the selected plan reference ID.<\/li>\n<li>Create a billing plan on PayPal using the <code>createPlan()<\/code> function of the PaypalCheckout class.<\/li>\n<li>Return subscription plan info to the client side.<\/li>\n<\/ul>\n<\/li>\n<li>If the <code>capture_subscr<\/code> request is submitted:\n<ul>\n<li>Retrieve the subscription info using the <code>getSubscription()<\/code> function of the PaypalCheckout class.<\/li>\n<li>Verify the subscription and payment status.<\/li>\n<li>Insert the subscription data with validity and the next billing date in the database.<\/li>\n<li>Return Order ID in base64 encoded format to the client side.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;configuration&nbsp;file&nbsp; <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'config.php'<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;connection&nbsp;file&nbsp; <br \/><\/span><span style=\"color: #007700\">include_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConnect.php'<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;PayPal&nbsp;API&nbsp;library&nbsp; <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'PaypalCheckout.class.php'<\/span><span style=\"color: #007700\">;&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$paypal&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">PaypalCheckout<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(<\/span><span style=\"color: #DD0000\">'status'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'msg'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Request&nbsp;Failed!'<\/span><span style=\"color: #007700\">);&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$api_error&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">;&nbsp; <br \/>if(!empty(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'request_type'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'request_type'<\/span><span style=\"color: #007700\">]&nbsp;==&nbsp;<\/span><span style=\"color: #DD0000\">'create_plan'<\/span><span style=\"color: #007700\">){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$plan_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'plan_id'<\/span><span style=\"color: #007700\">];&nbsp; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;plan&nbsp;details&nbsp;from&nbsp;the&nbsp;database&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;`name`,`price`,`interval`,`interval_count`&nbsp;FROM&nbsp;plans&nbsp;WHERE&nbsp;id=?\"<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_param<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"i\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$plan_id<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_result<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$planName<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$planPrice<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$planInterval<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$intervalCount<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch<\/span><span style=\"color: #007700\">();&nbsp; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$plan_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array( <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'name'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planName<\/span><span style=\"color: #007700\">,&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'price'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planPrice<\/span><span style=\"color: #007700\">,&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'interval'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$planInterval<\/span><span style=\"color: #007700\">,&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'interval_count'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$intervalCount<\/span><span style=\"color: #007700\">,&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;);&nbsp; <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;plan&nbsp;with&nbsp;PayPal&nbsp;API&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">try&nbsp;{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_plan&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypal<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">createPlan<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$plan_data<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;catch(<\/span><span style=\"color: #0000BB\">Exception&nbsp;$e<\/span><span style=\"color: #007700\">)&nbsp;{&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$api_error&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$e<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getMessage<\/span><span style=\"color: #007700\">();&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$subscr_plan<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'status'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">,&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'data'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_plan&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'msg'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$api_error<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>}elseif(!empty(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'request_type'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'request_type'<\/span><span style=\"color: #007700\">]&nbsp;==&nbsp;<\/span><span style=\"color: #DD0000\">'capture_subscr'<\/span><span style=\"color: #007700\">){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$order_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'order_id'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscription_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subscription_id'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$db_plan_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'plan_id'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;&amp;&nbsp;validate&nbsp;subscription&nbsp;with&nbsp;PayPal&nbsp;API&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">try&nbsp;{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypal<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getSubscription<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$subscription_id<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;catch(<\/span><span style=\"color: #0000BB\">Exception&nbsp;$e<\/span><span style=\"color: #007700\">)&nbsp;{&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$api_error&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$e<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getMessage<\/span><span style=\"color: #007700\">();&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$plan_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'plan_id'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$custom_user_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'custom_id'<\/span><span style=\"color: #007700\">]; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$create_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'create_time'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$dt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">DateTime<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$create_time<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$created&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$dt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">format<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Y-m-d&nbsp;H:i:s\"<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$start_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'start_time'<\/span><span style=\"color: #007700\">];&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$dt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">DateTime<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$start_time<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$valid_from&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$dt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">format<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Y-m-d&nbsp;H:i:s\"<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subscriber'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subscriber'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_email&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'email_address'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_id'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$given_name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">trim<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$subscriber<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'given_name'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$surname&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">trim<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$subscriber<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'surname'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">trim<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$given_name<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$surname<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Insert&nbsp;user&nbsp;details&nbsp;if&nbsp;not&nbsp;exists&nbsp;in&nbsp;the&nbsp;DB&nbsp;users&nbsp;table&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(empty(<\/span><span style=\"color: #0000BB\">$custom_user_id<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"INSERT&nbsp;INTO&nbsp;users&nbsp;(first_name,last_name,email,created)&nbsp;VALUES&nbsp;(?,?,?,NOW())\"<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_param<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"sss\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$given_name<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$surname<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_email<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$insertUser&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">$insertUser<\/span><span style=\"color: #007700\">){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$custom_user_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">insert_id<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'billing_info'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$billing_info&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'billing_info'<\/span><span style=\"color: #007700\">]; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'outstanding_balance'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$outstanding_balance_value&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'outstanding_balance'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'value'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$outstanding_balance_curreny&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'outstanding_balance'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'currency_code'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'last_payment'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$last_payment_amount&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'last_payment'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'amount'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'value'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$last_payment_curreny&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'last_payment'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'amount'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'currency_code'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$next_billing_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$billing_info<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'next_billing_time'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$dt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">DateTime<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$next_billing_time<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$valid_to&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$dt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">format<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Y-m-d&nbsp;H:i:s\"<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$subscr_id<\/span><span style=\"color: #007700\">)&nbsp;&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">==&nbsp;<\/span><span style=\"color: #DD0000\">'ACTIVE'<\/span><span style=\"color: #007700\">){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;if&nbsp;any&nbsp;subscription&nbsp;data&nbsp;exists&nbsp;with&nbsp;the&nbsp;same&nbsp;ID&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;id&nbsp;FROM&nbsp;user_subscriptions&nbsp;WHERE&nbsp;paypal_order_id&nbsp;=&nbsp;?\"<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">);&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_param<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"s\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$order_id<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_result<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row_id<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$payment_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$row_id<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$payment_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$row_id<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Insert&nbsp;subscription&nbsp;data&nbsp;into&nbsp;the&nbsp;database&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"INSERT&nbsp;INTO&nbsp;user_subscriptions&nbsp;(user_id,plan_id,paypal_order_id,paypal_plan_id,paypal_subscr_id,valid_from,valid_to,paid_amount,currency_code,subscriber_id,subscriber_name,subscriber_email,status,created,modified)&nbsp;VALUES&nbsp;(?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())\"<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_param<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"iisssssdssssss\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$custom_user_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$db_plan_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$order_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$plan_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$valid_from<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$valid_to<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$last_payment_amount<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$last_payment_curreny<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_name<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subscriber_email<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$status<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$created<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$insert&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">$insert<\/span><span style=\"color: #007700\">){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$user_subscription_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">insert_id<\/span><span style=\"color: #007700\">;&nbsp; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Update&nbsp;subscription&nbsp;ID&nbsp;in&nbsp;users&nbsp;table&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"UPDATE&nbsp;users&nbsp;SET&nbsp;subscription_id=?&nbsp;WHERE&nbsp;id=?\"<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_param<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"ii\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$user_subscription_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$custom_user_id<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$update&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$user_subscription_id<\/span><span style=\"color: #007700\">)){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ref_id_enc&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base64_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$order_id<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(<\/span><span style=\"color: #DD0000\">'status'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'msg'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Subscription&nbsp;created!'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'ref_id'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$ref_id_enc<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'msg'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$api_error<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp; <br \/>}&nbsp; <br \/>echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$response<\/span><span style=\"color: #007700\">);&nbsp; <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span>&nbsp;<\/span><\/pre>\n<h2>Subscription Status (payment-status.php)<\/h2>\n<p>Based on the status return by the subscription API, the subscriber is redirected to this page.<\/p>\n<ul>\n<li>Fetch subscription data from the database using PHP and MySQL.<\/li>\n<li>Display subscription details (subscription ID, validity, billing date, subscriber name &#038; email, etc.) on the web page.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;configuration&nbsp;file&nbsp; <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;connection&nbsp;file&nbsp; <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConnect.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'error'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;whether&nbsp;the&nbsp;DB&nbsp;reference&nbsp;ID&nbsp;is&nbsp;not&nbsp;empty <br \/><\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$_GET<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'checkout_ref_id'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$paypal_order_id&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base64_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$_GET<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'checkout_ref_id'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;subscription&nbsp;data&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sqlQ&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;S.*,&nbsp;P.name&nbsp;as&nbsp;plan_name,&nbsp;P.price&nbsp;as&nbsp;plan_price,&nbsp;P.interval,&nbsp;P.interval_count&nbsp;FROM&nbsp;user_subscriptions&nbsp;as&nbsp;S&nbsp;LEFT&nbsp;JOIN&nbsp;plans&nbsp;as&nbsp;P&nbsp;ON&nbsp;P.id=S.plan_id&nbsp;WHERE&nbsp;paypal_order_id&nbsp;=&nbsp;?\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sqlQ<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">bind_param<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"s\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$paypal_order_id<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">get_result<\/span><span style=\"color: #007700\">(); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'success'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Your&nbsp;Subscription&nbsp;Payment&nbsp;has&nbsp;been&nbsp;Successful!'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"Subscription&nbsp;has&nbsp;been&nbsp;failed!\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">header<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Location:&nbsp;index.php\"<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n\r\n<span style=\"color: rgb(95, 94, 78);\"><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">)){&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$status<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span>&gt;<\/span>\r\n\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>Payment Information<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Reference Number:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> #<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Subscription ID:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paypal_subscr_id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>TXN ID:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paypal_order_id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Paid Amount:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paid_amount'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency_code'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Status:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    \r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>Subscription Information<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Plan Name:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'plan_name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Amount:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'plan_price'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">CURRENCY<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Plan Interval:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'interval_count'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'interval'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Period Start:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'valid_from'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Period End:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'valid_to'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    \r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>Payer Information<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Name:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subscriber_name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Email:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$subscr_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subscriber_email'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}else{&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"error\"<\/span>&gt;<\/span>Your Subscription failed!<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"error\"<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/span>\r\n<\/pre>\n<h2>Make PayPal Subscription Payment Gateway Live<\/h2>\n<p>Once the integration is completed and the subscription process is working properly, follow the below steps to make PayPal checkout live.<br \/>\n<b>1.<\/b> Go to the PayPal Developer Dashboard Stripe account.<\/p>\n<ul>\n<li>Switch to the Live environment using the toggle button at the top-right corner.<\/li>\n<li>Navigate to the <b>Apps &#038; Credentials<\/b> section and collect the REST API credentials (Client ID and Secret) for the Live environment.<\/li>\n<\/ul>\n<p><b>2.<\/b> In the <code>config.php<\/code> file,<\/p>\n<ul>\n<li>Set the PAYPAL_SANDBOX to FALSE.<\/li>\n<li>Specify the REST API keys (Client ID and Secret key) in PAYPAL_PROD_CLIENT_ID and PAYPAL_PROD_CLIENT_SECRET variables.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_SANDBOX'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">FALSE<\/span><span style=\"color: #007700\">); <br> <br><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_PROD_CLIENT_ID'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Insert_Live_PayPal_Client_ID_Here'<\/span><span style=\"color: #007700\">); <br><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_PROD_CLIENT_SECRET'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Insert_Live_PayPal_Secret_Key_Here'<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/paypal-advanced-checkout-card-payments-integration-in-php\/\">PayPal Advanced Checkout Card Payments Integration in PHP<\/a><\/span><\/p>\n<h2>Conclusion<\/h2>\n<p>PayPal Subscription REST API is the easiest option to accept payment online for the membership subscription. It allows you to handle the subscription payment recurringly via PayPal. With this checkout system, you can create subscriptions on PayPal to bill customers recurringly at specific intervals. Our example code will help you to integrate subscription payment system with PayPal and PHP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PayPal Subscriptions payment lets you accept payment for your member subscription service. If you have a membership website and want to add a subscription feature, PayPal subscription API helps to do it easily. The PayPal <\/p>\n","protected":false},"author":1,"featured_media":5564,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72],"tags":[19,76,73,14,341],"class_list":["post-2485","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-paypal","tag-mysql","tag-payment-gateway","tag-paypal","tag-php","tag-subscription","cat-72-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PayPal Subscriptions Payment Gateway Integration in PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"PayPal subscriptions payment gateway integration - Create PayPal subscription for recurring billing in PHP and insert member subscription data in the MySQL database using PayPal JavaScript SDK and REST API.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PayPal Subscriptions Payment Gateway Integration in PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"PayPal subscriptions payment gateway integration - Create PayPal subscription for recurring billing in PHP and insert member subscription data in the MySQL database using PayPal JavaScript SDK and REST API.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-28T19:17:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-09T14:27:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"PayPal Subscriptions Payment Gateway Integration in PHP\",\"datePublished\":\"2017-05-28T19:17:12+00:00\",\"dateModified\":\"2025-04-09T14:27:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/\"},\"wordCount\":1372,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png\",\"keywords\":[\"MySQL\",\"Payment Gateway\",\"PayPal\",\"PHP\",\"Subscription\"],\"articleSection\":[\"PayPal\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/\",\"name\":\"PayPal Subscriptions Payment Gateway Integration in PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png\",\"datePublished\":\"2017-05-28T19:17:12+00:00\",\"dateModified\":\"2025-04-09T14:27:34+00:00\",\"description\":\"PayPal subscriptions payment gateway integration - Create PayPal subscription for recurring billing in PHP and insert member subscription data in the MySQL database using PayPal JavaScript SDK and REST API.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png\",\"width\":1920,\"height\":1080,\"caption\":\"paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-subscriptions-payment-gateway-integration-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PayPal Subscriptions Payment Gateway Integration in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PayPal Subscriptions Payment Gateway Integration in PHP - CodexWorld","description":"PayPal subscriptions payment gateway integration - Create PayPal subscription for recurring billing in PHP and insert member subscription data in the MySQL database using PayPal JavaScript SDK and REST API.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/","og_locale":"en_US","og_type":"article","og_title":"PayPal Subscriptions Payment Gateway Integration in PHP - CodexWorld","og_description":"PayPal subscriptions payment gateway integration - Create PayPal subscription for recurring billing in PHP and insert member subscription data in the MySQL database using PayPal JavaScript SDK and REST API.","og_url":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2017-05-28T19:17:12+00:00","article_modified_time":"2025-04-09T14:27:34+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"PayPal Subscriptions Payment Gateway Integration in PHP","datePublished":"2017-05-28T19:17:12+00:00","dateModified":"2025-04-09T14:27:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/"},"wordCount":1372,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png","keywords":["MySQL","Payment Gateway","PayPal","PHP","Subscription"],"articleSection":["PayPal"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/","url":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/","name":"PayPal Subscriptions Payment Gateway Integration in PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png","datePublished":"2017-05-28T19:17:12+00:00","dateModified":"2025-04-09T14:27:34+00:00","description":"PayPal subscriptions payment gateway integration - Create PayPal subscription for recurring billing in PHP and insert member subscription data in the MySQL database using PayPal JavaScript SDK and REST API.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png","width":1920,"height":1080,"caption":"paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"PayPal Subscriptions Payment Gateway Integration in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/paypal-subscriptions-payments-gateway-integration-in-php-with-javascript-sdk-rest-api-library-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-E5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=2485"}],"version-history":[{"count":21,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2485\/revisions"}],"predecessor-version":[{"id":5772,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2485\/revisions\/5772"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/5564"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=2485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=2485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=2485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}