{"id":5390,"date":"2023-07-14T08:54:17","date_gmt":"2023-07-14T08:54:17","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=5390"},"modified":"2026-01-16T14:45:39","modified_gmt":"2026-01-16T14:45:39","slug":"paypal-standard-checkout-integration-in-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/","title":{"rendered":"PayPal Standard Checkout Integration with PHP Using JS-SDK"},"content":{"rendered":"<p>PayPal is one of the most popular payment gateways, and it allows website owners to accept payments online. PayPal Standard Checkout with the JavaScript SDK is one of the simplest and most secure ways to accept online payments in PHP applications. Unlike older PayPal standards, the JS-SDK instantly renders smart buttons, handles client-side approval, and completes the order through server-side API calls \u2014 making it PCI-friendly and developer-efficient.<\/p>\n<p><b>PayPal Standard Checkout<\/b> uses JavaScript SDK to integrate payment button in the webpage. The buyer can use this button to make payment with their PayPal account or debit\/credit card. Integrate PayPal Standard Checkout system to allow buyers to purchase online and make the payment from the website. In this tutorial, we will show you how to integrate PayPal Standard Checkout in PHP. Here we will provide a step-by-step guide for <b>PayPal Standard Checkout Integration with PHP<\/b> Using JS-SDK.<\/p>\n<p>In this step-by-step guide, we will integrate:<br \/>\n\u2714 PayPal JS-SDK (Smart Buttons)<br \/>\n\u2714 Server-side Order Creation (PHP)<br \/>\n\u2714 Server-side Capture API (PHP)<br \/>\n\u2714 Saving Transactions to Database (MySQL)<br \/>\n\u2714 Displaying Payment Success Page<br \/>\n\u2714 Using PayPal Sandbox &#038; Production Credentials<\/p>\n<h2>\ud83d\ude80 Understanding the Workflow<\/h2>\n<p>Below is how PayPal Standard Checkout works with PHP:<\/p>\n<pre>\r\nUser Clicks PayPal Button\r\n           \u2193\r\nJS-SDK requests `create_order.php`\r\n           \u2193\r\nServer contacts PayPal \u2192 Creates Order\r\n           \u2193\r\nUser approves payment on PayPal popup\r\n           \u2193\r\nJS-SDK sends OrderID to `capture_order.php`\r\n           \u2193\r\nServer captures the payment & stores it in DB\r\n           \u2193\r\nReturns success \u2192 Redirects user to success.php\r\n<\/pre>\n<h2>\ud83d\udcc1 Folder Structure<\/h2>\n<p>This PayPal Checkout tutorial references the following PHP structure:<\/p>\n<pre class=\"file-struc\">paypal_checkout_with_php<span style=\"color:#794938\">\/<\/span>\r\n\u251c\u2500\u2500 index.php\r\n\u251c\u2500\u2500 config.php\r\n\u251c\u2500\u2500 paypal_api.php\r\n\u251c\u2500\u2500 create_order.php\r\n\u251c\u2500\u2500 capture_order.php\r\n\u251c\u2500\u2500 success.php\r\n\u2514\u2500\u2500 css<span style=\"color:#794938\">\/<\/span>\r\n    \u2514\u2500\u2500 style.css\r\n<\/pre>\n<h2>Requirements<\/h2>\n<p>Before you begin, ensure you have:<\/p>\n<ul>\n<li>PHP 7.4+<\/li>\n<li>cURL enabled<\/li>\n<li>MySQL database<\/li>\n<li>A PayPal Business Sandbox Account<\/li>\n<li>Your PayPal Client ID and Secret Key<\/li>\n<\/ul>\n<h2>Step 1: Set Up PayPal Developer Account<\/h2>\n<p>To get started, you need to create a PayPal Developer account and set up a sandbox environment (PayPal REST API app) for testing purposes.<\/p>\n<ol>\n<li>Go to the <a href=\"https:\/\/developer.paypal.com\/\" target=\"_blank\">PayPal Developer Website<\/a> and sign up for a developer account.<\/li>\n<li>Once logged in, navigate to the <u>Dashboard<\/u> and create a new app under the <u>Apps &#038; Credentials<\/u> section.\n<ul>\n<li>Select <u>Type:Merchant<\/u> to get Client ID and Secret Key for server-side API calls.<\/li>\n<\/ul>\n<\/li>\n<li>Note down your Client ID and Secret Key for sandbox testing.<\/li>\n<\/ol>\n<p><b><u>Sandbox test account:<\/u><\/b><br \/>\nNavigate to the <u>Testing Tools \u2192 Sandbox Accounts<\/u> section in the PayPal Developer Dashboard and create a personal sandbox account to simulate buyer transactions during testing.<\/p>\n<h2>Step 2: Create Database and Table<\/h2>\n<p>Create a MySQL database and a table to store transaction details. Use the following SQL query to create the <code>transactions<\/code> table:<\/p>\n<pre style=\"color: rgb(68, 68, 68);\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">TABLE<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">IF<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">NOT<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">EXISTS<\/span> <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`transactions`<\/span> (\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">int<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span> AUTO_INCREMENT,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`order_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">255<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`transaction_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">255<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`payer_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">255<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`payer_email`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">255<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`payer_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">255<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`amount`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">decimal<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">12<\/span>,<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">2<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`currency`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">10<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`status`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">50<\/span>) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`created_at`<\/span> datetime <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">CURRENT_TIMESTAMP<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`raw_response`<\/span> longtext,\r\n  PRIMARY <span class=\"hljs-keyword\" style=\"font-weight: 700;\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`id`<\/span>),\r\n  <span class=\"hljs-keyword\" style=\"font-weight: 700;\">UNIQUE<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">KEY<\/span> <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`order_id`<\/span> (<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`order_id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"font-weight: 700;\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">CHARSET<\/span>=utf8mb4;<\/pre>\n<h2>Step 3: Configuration (config.php)<\/h2>\n<p>Create a <code>config.php<\/code> file to store your PayPal API credentials, DB connection settings and product details. Also, create a utility function to establish a MySQLi connection.<\/p>\n<ul>\n<li><b>Product Details:<\/b> Define constants for product name (PRODUCT_NAME), price (PRODUCT_PRICE), and currency (PRODUCT_CURRENCY).<\/li>\n<li><b>Database Settings:<\/b> Define constants for database host (DB_HOST), user (DB_USER), password (DB_PASS), and name (DB_NAME).<\/li>\n<li><b>PayPal REST API Credentials:<\/b> Define constants for PayPal Client ID (PAYPAL_CLIENT_ID), Secret (PAYPAL_SECRET), and Sandbox mode (PAYPAL_SANDBOX: Set to FALSE for live mode).<\/li>\n<li><b>Utility Function:<\/b> Create a function to establish and return a MySQLi connection.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Product&nbsp;details&nbsp;(example) <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PRODUCT_NAME'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'Example&nbsp;Product'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PRODUCT_PRICE'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'9.99'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PRODUCT_CURRENCY'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'USD'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;settings <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_USER'<\/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_PASS'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">''<\/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\">'paypal_checkout_db'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;PayPal&nbsp;REST&nbsp;API&nbsp;credentials <br \/>\/\/&nbsp;For&nbsp;testing&nbsp;use&nbsp;sandbox&nbsp;credentials&nbsp;and&nbsp;set&nbsp;sandbox&nbsp;true <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_CLIENT_ID'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_PAYPAL_CLIENT_ID'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_SECRET'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_PAYPAL_SECRET'<\/span><span style=\"color: #007700\">); <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 \/> <br \/>\/\/&nbsp;Utility:&nbsp;create&nbsp;mysqli&nbsp;connection <br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">get_db_connection<\/span><span style=\"color: #007700\">()&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli&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_USER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">DB_PASS<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">DB_NAME<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_errno<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">http_response_code<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">500<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'error'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Database&nbsp;connection&nbsp;failed:&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">set_charset<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'utf8mb4'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">; <br \/>} <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Step 4: PayPal API Helper (paypal_api.php)<\/h2>\n<p>Create a <code>paypal_api.php<\/code> file to handle PayPal API interactions. This file will include functions to get an access token, create an order, and capture payment.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;config&nbsp;for&nbsp;constants <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Define&nbsp;PayPal&nbsp;API&nbsp;base&nbsp;URL <br \/><\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">PAYPAL_SANDBOX<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_BASE'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.sandbox.paypal.com'<\/span><span style=\"color: #007700\">); <br \/>}&nbsp;else&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_BASE'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'https:\/\/api-m.paypal.com'<\/span><span style=\"color: #007700\">); <br \/>} <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;PayPal&nbsp;access&nbsp;token <br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">paypal_get_access_token<\/span><span style=\"color: #007700\">()&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_BASE&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/v1\/oauth2\/token'<\/span><span style=\"color: #007700\">; <br \/> <br \/>&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\">(<\/span><span style=\"color: #0000BB\">$url<\/span><span style=\"color: #007700\">); <br \/>&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\">); <br \/>&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\">PAYPAL_CLIENT_ID&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">':'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_SECRET<\/span><span style=\"color: #007700\">); <br \/>&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\">); <br \/>&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;[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'Accept:&nbsp;application\/json'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'Accept-Language:&nbsp;en_US'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;]); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response&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\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$response&nbsp;<\/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;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$httpCode&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\">); <br \/>&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;if&nbsp;(<\/span><span style=\"color: #0000BB\">$httpCode&nbsp;<\/span><span style=\"color: #007700\">&gt;=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$httpCode&nbsp;<\/span><span style=\"color: #007700\">&lt;&nbsp;<\/span><span style=\"color: #0000BB\">300<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$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\">$response<\/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;return&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'access_token'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>} <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;PayPal&nbsp;order <br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">paypal_create_order<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$amount<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$currency&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'USD'<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$token&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">paypal_get_access_token<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!<\/span><span style=\"color: #0000BB\">$token<\/span><span style=\"color: #007700\">)&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_BASE&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/v2\/checkout\/orders'<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$body&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'intent'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'CAPTURE'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'purchase_units'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;[[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'amount'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;[ <br \/>&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<\/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\">'value'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$amount<\/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\">'breakdown'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&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\">'item_total'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&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\">'currency_code'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$currency<\/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: #DD0000\">'value'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$amount<\/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;], <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;], <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'items'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;[[ <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\">PRODUCT_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\">'unit_amount'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&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\">'currency_code'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$currency<\/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\">'value'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$amount<\/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: #DD0000\">'quantity'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'1'<\/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;]], <br \/>&nbsp;&nbsp;&nbsp;&nbsp;]; <br \/> <br \/>&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\">(<\/span><span style=\"color: #0000BB\">$url<\/span><span style=\"color: #007700\">); <br \/>&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\">); <br \/>&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;[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'Authorization:&nbsp;Bearer&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$token<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;]); <br \/>&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\">); <br \/>&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\">$body<\/span><span style=\"color: #007700\">)); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response&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\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$response&nbsp;<\/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;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$httpCode&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\">); <br \/>&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;if&nbsp;(<\/span><span style=\"color: #0000BB\">$httpCode&nbsp;<\/span><span style=\"color: #007700\">&gt;=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$httpCode&nbsp;<\/span><span style=\"color: #007700\">&lt;&nbsp;<\/span><span style=\"color: #0000BB\">300<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$response<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>} <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Capture&nbsp;PayPal&nbsp;order <br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">paypal_capture_order<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$orderId<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$token&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">paypal_get_access_token<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!<\/span><span style=\"color: #0000BB\">$token<\/span><span style=\"color: #007700\">)&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">PAYPAL_BASE&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/v2\/checkout\/orders\/'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">urlencode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$orderId<\/span><span style=\"color: #007700\">)&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">'\/capture'<\/span><span style=\"color: #007700\">; <br \/> <br \/>&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\">(<\/span><span style=\"color: #0000BB\">$url<\/span><span style=\"color: #007700\">); <br \/>&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\">); <br \/>&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;[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'Authorization:&nbsp;Bearer&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$token<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;]); <br \/>&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\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$response&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\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$response&nbsp;<\/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;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$httpCode&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\">); <br \/>&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;if&nbsp;(<\/span><span style=\"color: #0000BB\">$httpCode&nbsp;<\/span><span style=\"color: #007700\">&gt;=&nbsp;<\/span><span style=\"color: #0000BB\">200&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$httpCode&nbsp;<\/span><span style=\"color: #007700\">&lt;&nbsp;<\/span><span style=\"color: #0000BB\">300<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$response<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>} <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Step 5: Client-Side Checkout Page (index.php)<\/h2>\n<p>In this step, we create a simple client-side checkout page using PHP. This page will include a button that, when clicked, will initiate the payment process by calling the server-side script.<\/p>\n<ul>\n<li>This code sets up a PayPal button on your checkout page. When the button is clicked, it creates an order on the server and, upon approval, captures the order. It also includes basic status message handling to inform the user of the payment process status.<\/li>\n<\/ul>\n<p>Include the configuration file (<code>config.php<\/code>) at the beginning of your PHP script to access the product details defined earlier.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/config.php'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span> <\/span><\/pre>\n<p>Next, create the HTML structure for the checkout page. Use PHP to dynamically display the product name and price using the constants defined in <code>config.php<\/code>.<\/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);\">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);\">\"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);\">h1<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">PRODUCT_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);\">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>&gt;<\/span>Price: <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">PRODUCT_CURRENCY&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">PRODUCT_PRICE<\/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);\">strong<\/span>&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);\">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);\">\"status-message\"<\/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 PayPal 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>Next, include the PayPal JavaScript SDK by adding the following script tag. Make sure to replace the placeholders with your actual PayPal client ID and currency code using PHP.<\/p>\n<pre style=\"color: rgb(95, 94, 78); padding: 0.5em;\"><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\">urlencode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">PAYPAL_CLIENT_ID<\/span><span style=\"color: #007700\">);&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>&amp;currency=<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">urlencode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">PRODUCT_CURRENCY<\/span><span style=\"color: #007700\">);&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/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>Now, add the JavaScript code to handle the PayPal button rendering and payment process. This code will create and capture the order by communicating with the server-side scripts we created earlier.<\/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(68, 68, 68);\"><span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ Create order on the server<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span> <span class=\"hljs-title\" style=\"color: rgb(136, 0, 0); font-weight: 700;\">createOrderOnServer<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{\r\n    hideStatus();\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> fetch(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'create_order.php'<\/span>, {\r\n        method: <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'post'<\/span>,\r\n        headers: { <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Content-Type'<\/span>: <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'application\/json'<\/span> },\r\n        body: <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">JSON<\/span>.stringify({\r\n            amount: <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'&lt;?php echo PRODUCT_PRICE; ?&gt;'<\/span>,\r\n            currency: <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'&lt;?php echo PRODUCT_CURRENCY; ?&gt;'<\/span>\r\n        })\r\n    }).then(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">res<\/span>)<\/span>{\r\n        <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> res.json();\r\n    }).catch(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">err<\/span>)<\/span>{\r\n        showStatus(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Could not create order. Please try again.'<\/span>, <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'error'<\/span>);\r\n        <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">console<\/span>.error(err);\r\n        <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">Promise<\/span>.reject(err);\r\n    });\r\n}\r\n\r\n<span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ Capture order on the server<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span> <span class=\"hljs-title\" style=\"color: rgb(136, 0, 0); font-weight: 700;\">captureOrderOnServer<\/span>(<span class=\"hljs-params\">orderID<\/span>) <\/span>{\r\n    hideStatus();\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> fetch(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'capture_order.php'<\/span>, {\r\n        method: <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'post'<\/span>,\r\n        headers: { <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Content-Type'<\/span>: <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'application\/json'<\/span> },\r\n        body: <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">JSON<\/span>.stringify({ orderID: orderID })\r\n    }).then(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">res<\/span>)<\/span>{\r\n        <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> res.json();\r\n    }).catch(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">err<\/span>)<\/span>{\r\n        showStatus(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Payment processing failed. Please try again or contact support.'<\/span>, <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'error'<\/span>);\r\n        <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">console<\/span>.error(err);\r\n        <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">Promise<\/span>.reject(err);\r\n    });\r\n}\r\n\r\npaypal.Buttons({\r\n    createOrder: <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">data, actions<\/span>) <\/span>{\r\n        <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> createOrderOnServer().then(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">data<\/span>) <\/span>{\r\n            <span class=\"hljs-keyword\" style=\"font-weight: 700;\">if<\/span> (data &amp;&amp; data.id) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> data.id;\r\n            <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> actions.reject();\r\n        });\r\n    },\r\n    onApprove: <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">data, actions<\/span>) <\/span>{\r\n        <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span> captureOrderOnServer(data.orderID).then(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">res<\/span>)<\/span>{\r\n            <span class=\"hljs-keyword\" style=\"font-weight: 700;\">if<\/span> (res &amp;&amp; res.success &amp;&amp; res.db_id) {\r\n                <span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ redirect to success page with DB id<\/span>\r\n                showStatus(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Payment successful \u2014 redirecting...'<\/span>, <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'success'<\/span>);\r\n                <span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ small delay to show message then redirect<\/span>\r\n                setTimeout(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>{\r\n                    <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">window<\/span>.location.href = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'success.php?id='<\/span> + <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">encodeURIComponent<\/span>(res.db_id);\r\n                }, <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">700<\/span>);\r\n            } <span class=\"hljs-keyword\" style=\"font-weight: 700;\">else<\/span> {\r\n                showStatus(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Capture failed. See console for details.'<\/span>, <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'error'<\/span>);\r\n                <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">console<\/span>.log(res);\r\n            }\r\n        }).catch(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">err<\/span>)<\/span>{\r\n            <span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ errors already handled in captureOrderOnServer; ensure visible<\/span>\r\n            showStatus(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Capture failed. See console for details.'<\/span>, <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'error'<\/span>);\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">console<\/span>.error(err);\r\n        });\r\n    },\r\n    onError: <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span>(<span class=\"hljs-params\">err<\/span>) <\/span>{\r\n        <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">console<\/span>.error(err);\r\n        showStatus(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'An error occurred during payment. Please try again.'<\/span>, <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'error'<\/span>);\r\n    }\r\n}).render(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#paypal-button-container'<\/span>);\r\n\r\n<span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ Helper UI functions: show and hide status messages<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span> <span class=\"hljs-title\" style=\"color: rgb(136, 0, 0); font-weight: 700;\">showStatus<\/span>(<span class=\"hljs-params\">message, type<\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">var<\/span> el = <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.getElementById(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'status-message'<\/span>);\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">if<\/span> (!el) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span>;\r\n    el.textContent = message;\r\n    el.style.display = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'block'<\/span>;\r\n    <span class=\"hljs-comment\" style=\"color: rgb(136, 136, 136);\">\/\/ basic styling for types<\/span>\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">if<\/span> (type === <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'error'<\/span>) {\r\n        el.style.background = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#ffe6e6'<\/span>;\r\n        el.style.color = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#a00'<\/span>;\r\n        el.style.border = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'1px solid #f5c2c2'<\/span>;\r\n    } <span class=\"hljs-keyword\" style=\"font-weight: 700;\">else<\/span> <span class=\"hljs-keyword\" style=\"font-weight: 700;\">if<\/span> (type === <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'success'<\/span>) {\r\n        el.style.background = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#e6ffea'<\/span>;\r\n        el.style.color = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#047a12'<\/span>;\r\n        el.style.border = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'1px solid #bfe6c8'<\/span>;\r\n    } <span class=\"hljs-keyword\" style=\"font-weight: 700;\">else<\/span> {\r\n        el.style.background = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#eef3ff'<\/span>;\r\n        el.style.color = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'#0b3d91'<\/span>;\r\n        el.style.border = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'1px solid #c9d9ff'<\/span>;\r\n    }\r\n}\r\n\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"font-weight: 700;\">function<\/span> <span class=\"hljs-title\" style=\"color: rgb(136, 0, 0); font-weight: 700;\">hideStatus<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">var<\/span> el = <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.getElementById(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'status-message'<\/span>);\r\n    <span class=\"hljs-keyword\" style=\"font-weight: 700;\">if<\/span> (!el) <span class=\"hljs-keyword\" style=\"font-weight: 700;\">return<\/span>;\r\n    el.style.display = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'none'<\/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>Step 6: Server-Side Order Creation (create_order.php)<\/h2>\n<p>In this step, we create a server-side PHP script to handle the creation of PayPal orders. This script will receive the order details from the client-side, call the PayPal API to create the order, and return the order ID to the client.<\/p>\n<ul>\n<li>This code processes a request to create a PayPal order. It reads the amount and currency from the request, calls the PayPal API to create the order, and returns the order ID in JSON format.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;PayPal&nbsp;API&nbsp;functions <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/paypal_api.php'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;configuration&nbsp;file <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;response&nbsp;content&nbsp;type&nbsp;to&nbsp;JSON <br \/><\/span><span style=\"color: #0000BB\">header<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;amount&nbsp;and&nbsp;currency&nbsp;from&nbsp;request,&nbsp;or&nbsp;use&nbsp;defaults <br \/><\/span><span style=\"color: #0000BB\">$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\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'php:\/\/input'<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$amount&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;isset(<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'amount'<\/span><span style=\"color: #007700\">])&nbsp;?&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'amount'<\/span><span style=\"color: #007700\">]&nbsp;:&nbsp;<\/span><span style=\"color: #0000BB\">PRODUCT_PRICE<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$currency&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;isset(<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency'<\/span><span style=\"color: #007700\">])&nbsp;?&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency'<\/span><span style=\"color: #007700\">]&nbsp;:&nbsp;<\/span><span style=\"color: #0000BB\">PRODUCT_CURRENCY<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;PayPal&nbsp;order <br \/><\/span><span style=\"color: #0000BB\">$order&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">paypal_create_order<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$amount<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$currency<\/span><span style=\"color: #007700\">); <br \/>if&nbsp;(!<\/span><span style=\"color: #0000BB\">$order<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">http_response_code<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">500<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'error'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Could&nbsp;not&nbsp;create&nbsp;order'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/> <br \/>echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$order<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Step 7: Server-Side Order Capture (capture_order.php)<\/h2>\n<p>Finally, we create another server-side PHP script to handle the capture of PayPal orders. This script will receive the order ID from the client-side, call the PayPal API to capture the payment, store the transaction details in the database, and return a success response to the client.<\/p>\n<ul>\n<li>This code processes a request to capture a PayPal order. It reads the order ID from the request, calls the PayPal API to capture the order, stores the transaction details in a database, and returns a success response in JSON format.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;PayPal&nbsp;API&nbsp;functions <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/paypal_api.php'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;configuration&nbsp;file <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;response&nbsp;content&nbsp;type&nbsp;to&nbsp;JSON <br \/><\/span><span style=\"color: #0000BB\">header<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;orderID&nbsp;from&nbsp;request <br \/><\/span><span style=\"color: #0000BB\">$input&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'php:\/\/input'<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/>if&nbsp;(!isset(<\/span><span style=\"color: #0000BB\">$input<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'orderID'<\/span><span style=\"color: #007700\">]))&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">http_response_code<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">400<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'error'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'orderID&nbsp;required'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/><\/span><span style=\"color: #0000BB\">$orderID&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$input<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'orderID'<\/span><span style=\"color: #007700\">]; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Capture&nbsp;PayPal&nbsp;order <br \/><\/span><span style=\"color: #0000BB\">$capture&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">paypal_capture_order<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$orderID<\/span><span style=\"color: #007700\">); <br \/>if&nbsp;(!<\/span><span style=\"color: #0000BB\">$capture<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">http_response_code<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">500<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'error'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Capture&nbsp;failed'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Extract&nbsp;payer&nbsp;and&nbsp;transaction&nbsp;info <br \/><\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$capture<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$payer&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$capture<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;[]; <br \/><\/span><span style=\"color: #0000BB\">$payer_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$payer<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_id'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;(<\/span><span style=\"color: #0000BB\">$payer<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_id'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$payer_email&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$payer<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'email_address'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$payer_name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>if&nbsp;(isset(<\/span><span style=\"color: #0000BB\">$payer<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">]))&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$payer_name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">trim<\/span><span style=\"color: #007700\">((<\/span><span style=\"color: #0000BB\">$payer<\/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\">]&nbsp;??&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">)&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">'&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;(<\/span><span style=\"color: #0000BB\">$payer<\/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\">]&nbsp;??&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">)); <br \/>} <br \/> <br \/><\/span><span style=\"color: #0000BB\">$purchase_unit&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$capture<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'purchase_units'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$payments&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$purchase_unit<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payments'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$captures&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/>if&nbsp;(<\/span><span style=\"color: #0000BB\">$payments&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;isset(<\/span><span style=\"color: #0000BB\">$payments<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'captures'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]))&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$captures&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$payments<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'captures'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">]; <br \/>} <br \/> <br \/><\/span><span style=\"color: #0000BB\">$transaction_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$captures<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$amount&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$captures<\/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\">]&nbsp;??&nbsp;(<\/span><span style=\"color: #0000BB\">$purchase_unit<\/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\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$currency&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$captures<\/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\">]&nbsp;??&nbsp;(<\/span><span style=\"color: #0000BB\">$purchase_unit<\/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\">]&nbsp;??&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Store&nbsp;to&nbsp;database&nbsp;using&nbsp;MySQLi&nbsp;prepared&nbsp;statements <br \/><\/span><span style=\"color: #0000BB\">$mysqli&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">get_db_connection<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"INSERT&nbsp;INTO&nbsp;transactions <br \/>&nbsp;&nbsp;&nbsp;&nbsp;(order_id,&nbsp;transaction_id,&nbsp;payer_id,&nbsp;payer_email,&nbsp;payer_name,&nbsp;amount,&nbsp;currency,&nbsp;status,&nbsp;raw_response) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;VALUES&nbsp;(?,&nbsp;?,&nbsp;?,&nbsp;?,&nbsp;?,&nbsp;?,&nbsp;?,&nbsp;?,&nbsp;?)\"<\/span><span style=\"color: #007700\">); <br \/>if&nbsp;(!<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">http_response_code<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">500<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'error'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'DB&nbsp;prepare&nbsp;failed:&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/><\/span><span style=\"color: #0000BB\">$raw_response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$capture<\/span><span style=\"color: #007700\">); <br \/><\/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\">'sssssssss'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$orderID<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$transaction_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$payer_id<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$payer_email<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$payer_name<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$amount<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$currency<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$status<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$raw_response<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$exec&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\">(); <br \/>if&nbsp;(!<\/span><span style=\"color: #0000BB\">$exec<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">http_response_code<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">500<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'error'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'DB&nbsp;insert&nbsp;failed:&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">error<\/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\">close<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/><\/span><span style=\"color: #0000BB\">$db_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\">; <br \/><\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">close<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">close<\/span><span style=\"color: #007700\">(); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Return&nbsp;success&nbsp;response&nbsp;with&nbsp;encoded&nbsp;DB&nbsp;id <br \/><\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([<\/span><span style=\"color: #DD0000\">'success'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'db_id'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">base64_encode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$db_id<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #DD0000\">'capture'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$capture<\/span><span style=\"color: #007700\">]); <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Step 8: Display Transaction Details (success.php)<\/h2>\n<p>After capturing the order and storing the transaction details, we can create a simple PHP page to display the transaction information to the user. This page will retrieve the transaction ID from the query parameters, fetch the details from the database, and display them in a readable format.<\/p>\n<ul>\n<li>This code retrieves transaction details from a database based on an ID provided in the query parameters and displays the information in an HTML format.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;configuration&nbsp;file <br \/><\/span><span style=\"color: #007700\">require_once&nbsp;<\/span><span style=\"color: #0000BB\">__DIR__&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'\/config.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;transaction&nbsp;ID&nbsp;from&nbsp;query&nbsp;parameter <br \/><\/span><span style=\"color: #0000BB\">$id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;isset(<\/span><span style=\"color: #0000BB\">$_GET<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">])&nbsp;?&nbsp;<\/span><span style=\"color: #0000BB\">intval<\/span><span style=\"color: #007700\">(<\/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\">'id'<\/span><span style=\"color: #007700\">]))&nbsp;:&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">; <br \/>if&nbsp;(<\/span><span style=\"color: #0000BB\">$id&nbsp;<\/span><span style=\"color: #007700\">&lt;=&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Invalid&nbsp;ID'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;exit; <br \/>} <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fetch&nbsp;transaction&nbsp;details&nbsp;from&nbsp;database <br \/><\/span><span style=\"color: #0000BB\">$mysqli&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">get_db_connection<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$stmt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">prepare<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'SELECT&nbsp;id,&nbsp;order_id,&nbsp;transaction_id,&nbsp;payer_id,&nbsp;payer_email,&nbsp;payer_name,&nbsp;amount,&nbsp;currency,&nbsp;status,&nbsp;created_at,&nbsp;raw_response&nbsp;FROM&nbsp;transactions&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;?'<\/span><span style=\"color: #007700\">); <br \/><\/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\">$id<\/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\">$res&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 \/><\/span><span style=\"color: #0000BB\">$row&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$res<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$stmt<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">close<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$mysqli<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">close<\/span><span style=\"color: #007700\">(); <br \/> <br \/>if&nbsp;(!<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Transaction&nbsp;not&nbsp;found'<\/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 class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span>&gt;<\/span>Payment Success<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>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span>Order ID:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'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);\">strong<\/span>&gt;<\/span>Transaction ID:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'transaction_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);\">strong<\/span>&gt;<\/span>Payer ID:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_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);\">strong<\/span>&gt;<\/span>Payer:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_name'<\/span><span style=\"color: #007700\">]&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">'&nbsp;('&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_email'<\/span><span style=\"color: #007700\">]&nbsp;.&nbsp;<\/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);\">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);\">strong<\/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);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency'<\/span><span style=\"color: #007700\">]&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">'&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'amount'<\/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);\">strong<\/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);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/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<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);\">strong<\/span>&gt;<\/span>Created:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">strong<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">htmlspecialchars<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'created_at'<\/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><\/span>\r\n<\/pre>\n<h2>Make PayPal Standard Checkout Payment Gateway Live<\/h2>\n<p>Once the integration is completed and the payment process works as expected in the sandbox environment, you can proceed to make the PayPal Standard Checkout payment gateway live for real transactions.<\/p>\n<p>To make the PayPal Standard Checkout payment gateway live, you need to switch from the PayPal sandbox environment to the live environment. This involves updating your API credentials in your configuration file.<\/p>\n<ol>\n<li>Log in to your PayPal Developer account and navigate to the &#8220;Apps &#038; Credentials&#8221; section.\n<ul>\n<li>Switch to the Live environment using the toggle at the top left corner.<\/li>\n<li>Locate your live REST API app or create a new one if you haven&#8217;t done so already.<\/li>\n<li>Copy the Client ID and Secret for the live app.<\/li>\n<\/ul>\n<\/li>\n<li>Update your configuration file (e.g., config.php) with the live API credentials:\n<pre><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_CLIENT_ID'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_PAYPAL_LIVE_CLIENT_ID'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">define<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'PAYPAL_SECRET'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_PAYPAL_LIVE_SECRET'<\/span><span style=\"color: #007700\">); <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\">FALSE<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<\/li>\n<\/ol>\n<h2>Advanced Settings: Disable Shipping Address for Debit\/Credit Card Payment Method<\/h2>\n<p>If you are using PayPal checkout for the DIGITAL_GOODS and want to disable the shipping address requirement for debit\/credit card payments through PayPal Checkout, you can do so by modifying the order creation request to include the appropriate parameters.<\/p>\n<ul>\n<li>When defining request body for creating an order (API: <code>checkout\/orders<\/code>), you can set the <code>application_context<\/code> to NO_SHIPPING indicate that no shipping address is needed.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">$body&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;... <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'shipping_preference'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'NO_SHIPPING' <br \/><\/span><span style=\"color: #007700\">];<\/span><\/pre>\n<h2>\ud83d\udee1\ufe0f Security and Best Practices<\/h2>\n<ul>\n<li>Never expose PayPal secret key on client side<\/li>\n<li>Always create &#038; capture orders server-side<\/li>\n<li>Validate currency and amount on server<\/li>\n<li>Log raw PayPal responses<\/li>\n<li>Use HTTPS on production<\/li>\n<li>Sanitize all database insertions<\/li>\n<\/ul>\n<h2>\ud83c\udf89 Conclusion<\/h2>\n<p>With the PayPal JS-SDK and PHP REST API integration, you can seamlessly accept payments on any website with minimal setup. This approach ensures:<\/p>\n<ul>\n<li>Fully secure server-side operations<\/li>\n<li>PCI-compliant checkout<\/li>\n<li>Simple user experience<\/li>\n<li>Easy switch between sandbox and live<\/li>\n<\/ul>\n<p>Whether you&#8217;re building an eCommerce system, selling digital goods, or implementing subscription billing, this PayPal Standard Checkout workflow is reliable, scalable, and production-ready. Happy coding! \ud83d\ude80<\/p>\n<p>If you want to explore more advanced features like subscriptions, vaulting, or PayPal advanced card payments, check out the other articles in this series.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.codexworld.com\/paypal-advanced-checkout-card-payments-integration-in-php\/\">PayPal Advanced Checkout Card Payments Integration in PHP<\/a><\/li>\n<li><a href=\"https:\/\/www.codexworld.com\/paypal-subscriptions-payment-gateway-integration-php\/\">PayPal Subscriptions Integration in PHP<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>PayPal is one of the most popular payment gateways, and it allows website owners to accept payments online. PayPal Standard Checkout with the JavaScript SDK is one of the simplest and most secure ways to <\/p>\n","protected":false},"author":1,"featured_media":6029,"comment_status":"open","ping_status":"open","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":[4],"tags":[76,73,14,361,273],"class_list":["post-5390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-payment-gateway","tag-paypal","tag-php","tag-rest-api","tag-sdk","cat-4-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 Standard Checkout Integration with PHP Using JS-SDK - CodexWorld<\/title>\n<meta name=\"description\" content=\"Implement PayPal Standard Checkout in PHP with the JS-SDK. Follow this complete tutorial to create orders, capture payments, and build a secure PayPal payment system using PHP and PayPal REST APIs.\" \/>\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-standard-checkout-integration-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PayPal Standard Checkout Integration with PHP Using JS-SDK - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Implement PayPal Standard Checkout in PHP with the JS-SDK. Follow this complete tutorial to create orders, capture payments, and build a secure PayPal payment system using PHP and PayPal REST APIs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-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=\"2023-07-14T08:54:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-16T14:45:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg\" \/>\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\/jpeg\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"PayPal Standard Checkout Integration with PHP Using JS-SDK\",\"datePublished\":\"2023-07-14T08:54:17+00:00\",\"dateModified\":\"2026-01-16T14:45:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/\"},\"wordCount\":1298,\"commentCount\":9,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg\",\"keywords\":[\"Payment Gateway\",\"PayPal\",\"PHP\",\"REST API\",\"SDK\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/\",\"name\":\"PayPal Standard Checkout Integration with PHP Using JS-SDK - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg\",\"datePublished\":\"2023-07-14T08:54:17+00:00\",\"dateModified\":\"2026-01-16T14:45:39+00:00\",\"description\":\"Implement PayPal Standard Checkout in PHP with the JS-SDK. Follow this complete tutorial to create orders, capture payments, and build a secure PayPal payment system using PHP and PayPal REST APIs.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg\",\"width\":1920,\"height\":1080,\"caption\":\"paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-standard-checkout-integration-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PayPal Standard Checkout Integration with PHP Using JS-SDK\"}]},{\"@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 Standard Checkout Integration with PHP Using JS-SDK - CodexWorld","description":"Implement PayPal Standard Checkout in PHP with the JS-SDK. Follow this complete tutorial to create orders, capture payments, and build a secure PayPal payment system using PHP and PayPal REST APIs.","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-standard-checkout-integration-in-php\/","og_locale":"en_US","og_type":"article","og_title":"PayPal Standard Checkout Integration with PHP Using JS-SDK - CodexWorld","og_description":"Implement PayPal Standard Checkout in PHP with the JS-SDK. Follow this complete tutorial to create orders, capture payments, and build a secure PayPal payment system using PHP and PayPal REST APIs.","og_url":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2023-07-14T08:54:17+00:00","article_modified_time":"2026-01-16T14:45:39+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg","type":"image\/jpeg"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"PayPal Standard Checkout Integration with PHP Using JS-SDK","datePublished":"2023-07-14T08:54:17+00:00","dateModified":"2026-01-16T14:45:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/"},"wordCount":1298,"commentCount":9,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg","keywords":["Payment Gateway","PayPal","PHP","REST API","SDK"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/","url":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/","name":"PayPal Standard Checkout Integration with PHP Using JS-SDK - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg","datePublished":"2023-07-14T08:54:17+00:00","dateModified":"2026-01-16T14:45:39+00:00","description":"Implement PayPal Standard Checkout in PHP with the JS-SDK. Follow this complete tutorial to create orders, capture payments, and build a secure PayPal payment system using PHP and PayPal REST APIs.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg","width":1920,"height":1080,"caption":"paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/paypal-standard-checkout-integration-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"PayPal Standard Checkout Integration with PHP Using JS-SDK"}]},{"@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\/2023\/07\/paypal-standard-checkout-integration-in-php-with-javascript-sdk-rest-api-codexworld.jpg","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-1oW","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/5390","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=5390"}],"version-history":[{"count":13,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/5390\/revisions"}],"predecessor-version":[{"id":5965,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/5390\/revisions\/5965"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/6029"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=5390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=5390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=5390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}