{"id":3775,"date":"2019-01-25T06:32:39","date_gmt":"2019-01-25T06:32:39","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=3775"},"modified":"2019-01-25T06:40:10","modified_gmt":"2019-01-25T06:40:10","slug":"2checkout-payment-gateway-integration-in-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/","title":{"rendered":"2Checkout Payment Gateway Integration in PHP"},"content":{"rendered":"<p><b>2Checkout Payment Gateway<\/b> provides an easy way to integrate the checkout system in the web application. The 2Checkout Payment API allows you to accept payment with credit cards on the web application. If you want to accept credit card payment from the website, 2Checkout API is the simplest solution.<\/p>\n<p>With 2Checkout payment gateway, you can allow the user to make the payment through their credit or debit card. 2Checkout PHP library helps to connect the Payment API, create a charge against credit card and process the payment. In this tutorial, we will show you how to <b>integrate 2Checkout payment gateway in PHP<\/b> for collecting payment online with credit card or debit card.<\/p>\n<p>In the <b>2Checkout payment gateway integration<\/b> process, the following functionality will be implemented.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Create an HTML form to collect credit card and user information.<\/li>\n<li>Create 2Checkout token to securely transmit card details.<\/li>\n<li>Submit the credit card form.<\/li>\n<li>Verify the card info and process charges using 2Checkout Payment API.<\/li>\n<li>Insert the transaction details in the database and display the payment status.<\/li>\n<\/ul>\n<h2>2Checkout Sandbox Account<\/h2>\n<p>2Checkout&#8217;s sandbox provides a test environment to check the 2Checkout integration process. Before taking your 2Checkout payment gateway live, you need to test the integration on sandbox environment. Follow the below steps to generate API Keys on Sandbox account to test the credit card payment process with 2Checkout API.<\/p>\n<ul class=\"step_list\">\n<li>Login to your <a href=\"https:\/\/sandbox.2checkout.com\/sandbox\" target=\"_blank\">2Checkout Sandbox account<\/a> or sign up if don&#8217;t have an account.<\/li>\n<li>Go to the API page and generate API keys <b>\u00bb<\/b> Switch to the <b>Settings<\/b> tab. In the <b>Key Generator<\/b> section, you will see the Publishable Key and Private Key.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3777\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-create-sandbox-account-publishable-private-key-codexworld.png\" alt=\"2checkout-create-sandbox-account-publishable-private-key-codexworld\" width=\"846\" height=\"439\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-create-sandbox-account-publishable-private-key-codexworld.png 846w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-create-sandbox-account-publishable-private-key-codexworld-300x156.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-create-sandbox-account-publishable-private-key-codexworld-768x399.png 768w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-create-sandbox-account-publishable-private-key-codexworld-200x104.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-create-sandbox-account-publishable-private-key-codexworld-346x180.png 346w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><\/div>\n<\/li>\n<li>Collect the <b>Publishable Key<\/b> and <b>Private key<\/b> to use later in the script.<\/li>\n<\/ul>\n<p>Before getting started to implement 2Checkout payment gateway in PHP, take a look the files structure.<\/p>\n<pre class=\"file-struc\">2checkout_integration_php<span style=\"color:#794938\">\/<\/span>\n\u251c\u2500\u2500 index.html\n\u251c\u2500\u2500 paymentSubmit.php\n\u251c\u2500\u2500 dbConfig.php\n\u2514\u2500\u2500 2checkout-php<span style=\"color:#794938\">\/<\/span>\n<\/pre>\n<h2>Create Database Table<\/h2>\n<p>To store the transaction details, a table needs to be created in the database. The following SQL creates an <code>orders<\/code> table with some basic fields in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`orders`<\/span> (\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">25<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`email`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">25<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`card_num`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">bigint<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">20<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`card_exp_month`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`card_exp_year`<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">year<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">4<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`card_cvv`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">3<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`item_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`item_number`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">25<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`item_price`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">float<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>,<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`currency`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`paid_amount`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`order_number`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">20<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`txn_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">50<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`payment_status`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`created`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`modified`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\n PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<h2>Database Configuration (dbConfig.php)<\/h2>\n<p>The <code>dbConfig.php<\/code> file is used to connect to the database. Specify the database host (<code>$dbHost<\/code>), username (<code>$dbUsername<\/code>), password (<code>$dbPassword<\/code>), and name (<code>$dbName<\/code>) as per your MySQL server credentials.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;configuration\n<\/span><span style=\"color: #0000BB\">$dbHost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"localhost\"<\/span><span style=\"color: #007700\">;\n<\/span><span style=\"color: #0000BB\">$dbUsername&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;\n<\/span><span style=\"color: #0000BB\">$dbPassword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;\n<\/span><span style=\"color: #0000BB\">$dbName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"codexworld\"<\/span><span style=\"color: #007700\">;\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;database&nbsp;connection\n<\/span><span style=\"color: #0000BB\">$db&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">mysqli<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$dbHost<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbUsername<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbPassword<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbName<\/span><span style=\"color: #007700\">);\n\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;connection\n<\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"Connection&nbsp;failed:&nbsp;\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">);\n}<\/span><\/pre>\n<h2>2Checkout Payment Form (index.html)<\/h2>\n<p>Include the jQuery library and 2Checkout JavaScript library to make the token request.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- jQuery library --&gt;<\/span>\n<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:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.2.1\/jquery.min.js\"<\/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>\n\n<span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- 2Checkout JavaScript library --&gt;<\/span>\n<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.2checkout.com\/checkout\/api\/2co.min.js\"<\/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>The following JavaScript code handles the token request call and attaches the token input to the credit card form before submission. Specify the <code>sandbox-seller-id<\/code> (Account Number) and <code>sandbox-publishable-key<\/code> (Publishable Key) as per your API credentials.<\/p>\n<pre style=\"color: rgb(110, 107, 94)\"><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>\n<span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Called when token created successfully.<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> successCallback = <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\">data<\/span>) <\/span>{\n  <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> myForm = <span class=\"hljs-built_in\" style=\"color: rgb(182, 86, 17);\">document<\/span>.getElementById(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'paymentFrm'<\/span>);\n  \n  <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Set the token as the value for the token input<\/span>\n  myForm.token.value = data.response.token.token;\n  \n  <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Submit the form<\/span>\n  myForm.submit();\n};\n\n<span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Called when token creation fails.<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> errorCallback = <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\">data<\/span>) <\/span>{\n  <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">if<\/span> (data.errorCode === <span class=\"hljs-number\" style=\"color: rgb(182, 86, 17);\">200<\/span>) {\n    tokenRequest();\n  } <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">else<\/span> {\n    alert(data.errorMsg);\n  }\n};\n\n<span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> tokenRequest = <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\"><\/span>) <\/span>{\n  <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Setup token request arguments<\/span>\n  <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> args = {\n    sellerId: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"sandbox-seller-id\"<\/span>,\n    publishableKey: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"sandbox-publishable-key\"<\/span>,\n    ccNo: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#card_num\"<\/span>).val(),\n    cvv: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#cvv\"<\/span>).val(),\n    expMonth: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#exp_month\"<\/span>).val(),\n    expYear: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#exp_year\"<\/span>).val()\n  };\n  \n  <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Make the token request<\/span>\n  TCO.requestToken(successCallback, errorCallback, args);\n};\n\n$(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\"><\/span>) <\/span>{\n  <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Pull in the public encryption key for our environment<\/span>\n  TCO.loadPubKey(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'sandbox'<\/span>);\n  \n  $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#paymentFrm\"<\/span>).submit(<span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\">e<\/span>) <\/span>{\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Call our token request function<\/span>\n    tokenRequest();\n   \n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Prevent form from submitting<\/span>\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">return<\/span> <span class=\"hljs-literal\" style=\"color: rgb(182, 86, 17);\">false<\/span>;\n  });\n});\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<p>Create a basic credit card form that allows the buyer to provide their card number, expiration month and year, and CVC. This form will be submitted to the server-side script (<code>paymentSubmit.php<\/code>) for processing the payment with 2Checkout API.<\/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);\">\"payment-frm\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h5<\/span>&gt;<\/span>Charge $25 USD with 2Checkout<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h5<\/span>&gt;<\/span>\n    \n    <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- credit card form --&gt;<\/span>\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">form<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"paymentFrm\"<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"post\"<\/span> <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"paymentSubmit.php\"<\/span>&gt;<\/span>\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>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>NAME<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"text\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"name\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"name\"<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Enter name\"<\/span> <span class=\"hljs-attr\">required<\/span> <span class=\"hljs-attr\">autofocus<\/span>&gt;<\/span>\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>\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>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>EMAIL<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"email\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"email\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"email\"<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Enter email\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\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>\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>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>CARD NUMBER<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"text\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"card_num\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"card_num\"<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Enter card number\"<\/span> <span class=\"hljs-attr\">autocomplete<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"off\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\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>\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>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>EXPIRY DATE<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"number\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"exp_month\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"exp_month\"<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"MM\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"number\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"exp_year\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"exp_year\"<\/span> <span class=\"hljs-attr\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"YY\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\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>\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>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>CVV<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"number\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"cvv\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"cvv\"<\/span> <span class=\"hljs-attr\">autocomplete<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"off\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\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>\n        \n        <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- hidden token input --&gt;<\/span>\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"token\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"token\"<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"hidden\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"\"<\/span>&gt;<\/span>\n        \n        <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- submit button --&gt;<\/span>\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"submit\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"btn btn-success\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Submit Payment\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">form<\/span>&gt;<\/span>\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<h2>2Checkout PHP library<\/h2>\n<p>The <a href=\"https:\/\/github.com\/2Checkout\/2checkout-php\" target=\"_blank\">2Checkout PHP library<\/a> is used to process the card transaction using Payment API. All the library files are included in our source code, don&#8217;t need to download it separately.<\/p>\n<h2>Validate and Process Payment (paymentSubmit.php)<\/h2>\n<p>Once the tokenized credit card information has been submitted to the server-side script (paymentSubmit.php), the charge authorization is processed using <b>2Checkout PHP library<\/b>.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Get token, card details and user info from the submitted form using <b>POST method in PHP<\/b>.<\/li>\n<li>Include the 2Checkout PHP library.<\/li>\n<li>Set your API credentials (Private Key and SellerId).<\/li>\n<li>Create an array with sale parameters and pass it in <b>auth()<\/b> method of <b>Twocheckout_Charge<\/b> class for authorization.<\/li>\n<li>Create a charge and retrieve the charge details.<\/li>\n<li>If the charge is successful, insert the order and transaction details in the database using PHP and MySQL.<\/li>\n<li>Show the payment status to the buyer.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php\n<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;whether&nbsp;token&nbsp;is&nbsp;not&nbsp;empty\n<\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'token'<\/span><span style=\"color: #007700\">])){\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Token&nbsp;info\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$token&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'token'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Card&nbsp;info\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$card_num&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'card_num'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$card_cvv&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'cvv'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$card_exp_month&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'exp_month'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$card_exp_year&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'exp_year'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Buyer&nbsp;info\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$email&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'email'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$phoneNumber&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'555-555-5555'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$addrLine1&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'123&nbsp;Test&nbsp;St'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$city&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Columbus'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$state&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'OH'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$zipCode&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'43123'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$country&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'USA'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Item&nbsp;info\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$itemName&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Premium&nbsp;Script&nbsp;CodexWorld'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$itemNumber&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'PS123456'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$itemPrice&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'25.00'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&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\">;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$orderID&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'SKA92712382139'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;2Checkout&nbsp;PHP&nbsp;library\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">require_once(<\/span><span style=\"color: #DD0000\">\"2checkout-php\/Twocheckout.php\"<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;API&nbsp;key\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">Twocheckout<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">privateKey<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'sandbox-private-key'<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">Twocheckout<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">sellerId<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'sandbox-seller-id'<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">Twocheckout<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">sandbox<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Charge&nbsp;a&nbsp;credit&nbsp;card\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$charge&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">Twocheckout_Charge<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">auth<\/span><span style=\"color: #007700\">(array(\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"merchantOrderId\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$orderID<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"token\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$token<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"currency\"&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$currency<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"total\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$itemPrice<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"billingAddr\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(\n&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\">$name<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"addrLine1\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$addrLine1<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"city\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$city<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"state\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$state<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"zipCode\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$zipCode<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"country\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$country<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"email\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$email<\/span><span style=\"color: #007700\">,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">\"phoneNumber\"&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$phoneNumber\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;whether&nbsp;the&nbsp;charge&nbsp;is&nbsp;successful\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$charge<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'response'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'responseCode'<\/span><span style=\"color: #007700\">]&nbsp;==&nbsp;<\/span><span style=\"color: #DD0000\">'APPROVED'<\/span><span style=\"color: #007700\">)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Order&nbsp;details\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$orderNumber&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$charge<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'response'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'orderNumber'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$total&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$charge<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'response'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'total'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$transactionId&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$charge<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'response'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'transactionId'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$currency&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$charge<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'response'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'currencyCode'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$charge<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'response'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'responseCode'<\/span><span style=\"color: #007700\">];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;database&nbsp;config&nbsp;file\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">include_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConfig.php'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Insert&nbsp;order&nbsp;info&nbsp;to&nbsp;database\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sql&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"INSERT&nbsp;INTO&nbsp;orders(name,&nbsp;email,&nbsp;card_num,&nbsp;card_cvv,&nbsp;card_exp_month,&nbsp;card_exp_year,&nbsp;item_name,&nbsp;item_number,&nbsp;item_price,&nbsp;currency,&nbsp;paid_amount,&nbsp;order_number,&nbsp;txn_id,&nbsp;payment_status,&nbsp;created,&nbsp;modified)&nbsp;VALUES('\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$name<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$email<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$card_num<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$card_cvv<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$card_exp_month<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$card_exp_year<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$itemName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$itemNumber<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"','\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$itemPrice<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$currency<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$total<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$orderNumber<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$transactionId<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$status<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;NOW(),&nbsp;NOW())\"<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$insert&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sql<\/span><span style=\"color: #007700\">);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$insert_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">insert_id<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;h2&gt;Thanks&nbsp;for&nbsp;your&nbsp;Order!&lt;\/h2&gt;'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;h4&gt;The&nbsp;transaction&nbsp;was&nbsp;successful.&nbsp;Order&nbsp;details&nbsp;are&nbsp;given&nbsp;below:&lt;\/h4&gt;'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"&lt;p&gt;Order&nbsp;ID:&nbsp;<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$insert_id<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&lt;\/p&gt;\"<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"&lt;p&gt;Order&nbsp;Number:&nbsp;<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$orderNumber<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&lt;\/p&gt;\"<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"&lt;p&gt;Transaction&nbsp;ID:&nbsp;<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$transactionId<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&lt;\/p&gt;\"<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"&lt;p&gt;Order&nbsp;Total:&nbsp;<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$total<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&nbsp;<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$currency<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&lt;\/p&gt;\"<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;catch&nbsp;(<\/span><span style=\"color: #0000BB\">Twocheckout_Error&nbsp;$e<\/span><span style=\"color: #007700\">)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;h2&gt;Transaction&nbsp;failed!&lt;\/h2&gt;'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;p&gt;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$e<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getMessage<\/span><span style=\"color: #007700\">().<\/span><span style=\"color: #DD0000\">'&lt;\/p&gt;'<\/span><span style=\"color: #007700\">;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;\n}else{\n&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"&lt;p&gt;Form&nbsp;submission&nbsp;error...&lt;\/p&gt;\"<\/span><span style=\"color: #007700\">;\n}\n<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\n\n<span style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-meta\" style=\"color: rgb(174, 115, 19);\">&lt;!DOCTYPE html&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"en-US\"<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">title<\/span>&gt;<\/span>2Checkout Payment Status<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">title<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"utf-8\"<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">body<\/span>&gt;<\/span>\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);\">\"container\"<\/span>&gt;<\/span>\n  <span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- Display payment status --&gt;<\/span>\n  <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\n  \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);\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"index.html\"<\/span>&gt;<\/span>Back to Payment<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">a<\/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>\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>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">html<\/span>&gt;<\/span>\n<\/span><\/pre>\n<h2>Test Card Details<\/h2>\n<p>To test the 2Checkout payment API integration, use any of the following test credit card information.<\/p>\n<pre>Credit Card Number: 4000000000000002\nExpiration date: 10\/2020\ncvv: 123\n<\/pre>\n<p>Use the following card information to test a failed authorization.<\/p>\n<pre>Credit Card Number: 4333433343334333\nExpiration date: 10\/2020\ncvv: 123\n<\/pre>\n<h2>Make 2Checkout Payment Gateway Live<\/h2>\n<p>Once testing is completed with Sandbox account, make the 2Checkout payment gateway live for production use.<\/p>\n<ul class=\"step_list\">\n<li>Login to your <a href=\"https:\/\/secure.2checkout.com\/cpanel\/\" target=\"_blank\">2Checkout account<\/a> and go to the API page.<\/li>\n<li>Generate API keys and switch to the <b>Settings<\/b> tab. From the Key Generator section, collect the <b>Publishable key<\/b> and <b>Private key<\/b>.<\/li>\n<\/ul>\n<p>In the <code>index.html<\/code> file,<\/p>\n<ul class=\"step_list\">\n<li>Change the <code>sellerId<\/code> (Account Number) and <code>publishableKey<\/code> (Publishable key) as per the API credentials of your live 2Checkout account.\n<pre style=\"color: rgb(110, 107, 94);\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> tokenRequest = <span class=\"hljs-function\"><span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">function<\/span>(<span class=\"hljs-params\" style=\"color: rgb(182, 86, 17);\"><\/span>) <\/span>{\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Setup token request arguments<\/span>\n    <span class=\"hljs-keyword\" style=\"color: rgb(184, 84, 212);\">var<\/span> args = {\n        sellerId: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"live-seller-id\"<\/span>,\n        publishableKey: <span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"live-publishable-key\"<\/span>,\n        ccNo: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#card_num\"<\/span>).val(),\n        cvv: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#cvv\"<\/span>).val(),\n        expMonth: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#exp_month\"<\/span>).val(),\n        expYear: $(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">\"#exp_year\"<\/span>).val()\n    };\n\n    <span class=\"hljs-comment\" style=\"color: rgb(125, 122, 104);\">\/\/ Make the token request<\/span>\n    TCO.requestToken(successCallback, errorCallback, args);\n};<\/pre>\n<\/li>\n<li>Set <code>production<\/code> key in loadPubKey() method.\n<pre style=\"color: rgb(110, 107, 94);\">TCO.loadPubKey(<span class=\"hljs-string\" style=\"color: rgb(96, 172, 57);\">'production'<\/span>);<\/pre>\n<\/li>\n<\/ul>\n<p>In the <code>paymentSubmit.php<\/code> file,<\/p>\n<ul class=\"step_list\">\n<li>Change the <code>sellerId<\/code> (Account Number) and <code>privateKey<\/code> (Private key) as per the API credentials of your live 2Checkout account.\n<pre><span style=\"color: #0000BB\">Twocheckout<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">privateKey<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'live-private-key'<\/span><span style=\"color: #007700\">);\n<\/span><span style=\"color: #0000BB\">Twocheckout<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">sellerId<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'live-seller-id'<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<\/li>\n<li>Set <code>false<\/code> in sandbox().\n<pre><span style=\"color: #0000BB\">Twocheckout<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">sandbox<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<\/li>\n<\/ul>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/stripe-payment-gateway-integration-php\/\">Stripe Payment Gateway Integration in PHP<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>2Checkout Payment Gateway provides an easy way to integrate the checkout system in the web application. The 2Checkout Payment API allows you to accept payment with credit cards on the web application. If you want <\/p>\n","protected":false},"author":1,"featured_media":3782,"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":[325,250,76,14],"class_list":["post-3775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-2checkout","tag-api","tag-payment-gateway","tag-php","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>2Checkout Payment Gateway Integration in PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"2Checkout Payment API Integration - Accept credit card payment in the website using 2Checkout PHP library. Example script to integrate 2Checkout payment gateway in PHP.\" \/>\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\/2checkout-payment-gateway-integration-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"2Checkout Payment Gateway Integration in PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"2Checkout Payment API Integration - Accept credit card payment in the website using 2Checkout PHP library. Example script to integrate 2Checkout payment gateway in PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/2checkout-payment-gateway-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=\"2019-01-25T06:32:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-01-25T06:40:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"2Checkout Payment Gateway Integration in PHP\",\"datePublished\":\"2019-01-25T06:32:39+00:00\",\"dateModified\":\"2019-01-25T06:40:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/\"},\"wordCount\":729,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/2checkout-payment-gateway-integration-php-api-codexworld.png\",\"keywords\":[\"2Checkout\",\"API\",\"Payment Gateway\",\"PHP\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/\",\"name\":\"2Checkout Payment Gateway Integration in PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/2checkout-payment-gateway-integration-php-api-codexworld.png\",\"datePublished\":\"2019-01-25T06:32:39+00:00\",\"dateModified\":\"2019-01-25T06:40:10+00:00\",\"description\":\"2Checkout Payment API Integration - Accept credit card payment in the website using 2Checkout PHP library. Example script to integrate 2Checkout payment gateway in PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/2checkout-payment-gateway-integration-php-api-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/2checkout-payment-gateway-integration-php-api-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"2checkout-payment-gateway-integration-php-api-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/2checkout-payment-gateway-integration-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"2Checkout Payment Gateway Integration in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"2Checkout Payment Gateway Integration in PHP - CodexWorld","description":"2Checkout Payment API Integration - Accept credit card payment in the website using 2Checkout PHP library. Example script to integrate 2Checkout payment gateway in PHP.","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\/2checkout-payment-gateway-integration-in-php\/","og_locale":"en_US","og_type":"article","og_title":"2Checkout Payment Gateway Integration in PHP - CodexWorld","og_description":"2Checkout Payment API Integration - Accept credit card payment in the website using 2Checkout PHP library. Example script to integrate 2Checkout payment gateway in PHP.","og_url":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2019-01-25T06:32:39+00:00","article_modified_time":"2019-01-25T06:40:10+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"2Checkout Payment Gateway Integration in PHP","datePublished":"2019-01-25T06:32:39+00:00","dateModified":"2019-01-25T06:40:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/"},"wordCount":729,"commentCount":3,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png","keywords":["2Checkout","API","Payment Gateway","PHP"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/","url":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/","name":"2Checkout Payment Gateway Integration in PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png","datePublished":"2019-01-25T06:32:39+00:00","dateModified":"2019-01-25T06:40:10+00:00","description":"2Checkout Payment API Integration - Accept credit card payment in the website using 2Checkout PHP library. Example script to integrate 2Checkout payment gateway in PHP.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png","width":1366,"height":768,"caption":"2checkout-payment-gateway-integration-php-api-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/2checkout-payment-gateway-integration-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"2Checkout Payment Gateway Integration in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/01\/2checkout-payment-gateway-integration-php-api-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-YT","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/3775","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=3775"}],"version-history":[{"count":5,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/3775\/revisions"}],"predecessor-version":[{"id":3781,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/3775\/revisions\/3781"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/3782"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=3775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=3775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=3775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}