{"id":10633,"date":"2024-07-08T12:16:03","date_gmt":"2024-07-08T06:31:03","guid":{"rendered":"https:\/\/nestnepal.com\/blog\/?p=10633"},"modified":"2024-07-09T14:34:13","modified_gmt":"2024-07-09T08:49:13","slug":"esewa-payment-integration-in-nodejs","status":"publish","type":"post","link":"https:\/\/nestnepal.com\/blog\/esewa-payment-integration-in-nodejs\/","title":{"rendered":"Esewa Payment Integration in Node.Js"},"content":{"rendered":"<p style=\"text-align: left;\">Esewa payment integration in Node.js application offers a popular Nepalese payment gateway for users to perform transactions. In this guide, we will learn how to integrate <a href=\"https:\/\/esewa.com.np\/#\/home\" rel=\"nofollow noopener\" target=\"_blank\">Esewa<\/a> payment using Node.js. By Esewa payment integration in your <a href=\"https:\/\/nestnepal.com\/nodejs-hosting-in-nepal\/\">Node.js<\/a> application using the Express.js framework, you can seamlessly handle payments, enhance user experience, and ensure that your online business transactions are reliable and secure.<\/p>\n<p style=\"text-align: left;\">Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to build server-side and network applications using JavaScript. Similarly, Express.js is an efficient and flexible web framework for Node.js that simplifies the development of <a href=\"https:\/\/nestnepal.com\/web-hosting\/\">web<\/a> applications and APIs. When it comes to payment integration, Express.js offers a streamlined approach to handle payment processing, secure transactions, and manage callback URLs.<\/p>\n<h2 style=\"text-align: left;\">Requirements<\/h2>\n<ul style=\"text-align: left;\">\n<li>Node.js installed on your machine.<\/li>\n<li>Familiarity with Express.js framework.<\/li>\n<li>Basic understanding of JavaScript.<\/li>\n<\/ul>\n<h2 style=\"text-align: left;\">Steps for Esewa Payment Integration in Node.js<\/h2>\n<p style=\"text-align: left;\">Here is the step by step process on how to integrate Esewa with Node.js using Express.js framework.<\/p>\n<h3 style=\"text-align: left;\">Step 1: Initialize a new Node.js project using npm package<\/h3>\n<p style=\"text-align: left;\">Write the following command in your terminal to initialize Node.js project with <a href=\"https:\/\/www.npmjs.com\/\" target=\"_blank\" rel=\"noopener\">npm<\/a> package.<\/p>\n<pre>npm init -y<\/pre>\n<h3 style=\"text-align: left;\">Step 2: Set up a development Environment using Nodemon<\/h3>\n<p style=\"text-align: left;\">Nodemon is a tool in Node.js based applications that automatically restarts the node application when file changes in the directory are detected. It helps in automatically restarting the server on file changes.<\/p>\n<pre>npm install -d nodemon<\/pre>\n<p style=\"text-align: left;\">Again, you have to add dev int the script keys inside package.json,<\/p>\n<pre>\"scripts\": {\r\n\"dev\": \"nodemon index.js\"\r\n},<\/pre>\n<h3 style=\"text-align: left;\">Step 3: Set up backend server with Express js<\/h3>\n<p style=\"text-align: left;\">In order to use Express framework, first install Express using npm command:<\/p>\n<pre>npm install express<\/pre>\n<p style=\"text-align: left;\">Now, write the following code inside new file name &#8220;<strong>index.js<\/strong>&#8220;. We use Express.js to create a simple server that listens on port 3000.<\/p>\n<pre>const express= require(\"express\")\r\nconst app=express()\r\napp.use(express.json())\r\napp.listen(3000, ()=&gt;{\r\n\u00a0 \u00a0 console.log(\"Server in port 3000\")\r\n})\r\n\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"x0tUafu2wL\"><a href=\"https:\/\/nestnepal.com\/blog\/what-is-304-status-code-how-to-fix-it\/\">What is 304 Status Code: How to Fix It?<\/a><\/blockquote><iframe class=\"wp-embedded-content lazyload\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;What is 304 Status Code: How to Fix It?&#8221; &#8212; Nest WebHost Blogs\" data-src=\"https:\/\/nestnepal.com\/blog\/what-is-304-status-code-how-to-fix-it\/embed\/#?secret=E8TP5eFNLw#?secret=x0tUafu2wL\" data-secret=\"x0tUafu2wL\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" data-load-mode=\"1\"><\/iframe>\r\n\r\n<\/pre>\n<h3 style=\"text-align: left;\">Step 4: Setup the Route<\/h3>\n<p style=\"text-align: left;\">Setting up the route is another essential step while setting up the project as it helps to handle requests between client and server side. Here, we define three routes: <strong>\/pay-with-esewa<\/strong> for initiating payments,<strong> \/success<\/strong> for handling successful payments, and <strong>\/failure<\/strong> for handling failed payments.<\/p>\n<pre>app.get(\"\/pay-with-esewa\",(req,res,next)=&gt;{\r\n})\r\n\r\napp.get(\"\/success\",()=&gt;{\r\n\/\/handle success callback\r\n})\r\n\r\napp.get(\"\/failure\",()=&gt;{\r\n\/\/handle failure callback\r\n})<\/pre>\n<h3 style=\"text-align: left;\">Step 5: Set up the Payment Form<\/h3>\n<p style=\"text-align: left;\">In this code, the HTML form includes all necessary parameters and a cryptographic signature to ensure secure and reliable payment processing. In the &#8220;\/pay-with-esewa&#8221; route, we generate a form that submits payment details to Esewa.<\/p>\n<div style=\"text-align: left;\">\n<pre>app.get(\"\/pay-with-esewa\",(req,res,next)=&gt;{\r\n  \u00a0 let order_price=req.query.price\r\n  \u00a0 let tax_amount=0\r\n  \u00a0 let amount=order_price\r\n  \u00a0 let transaction_uuid=generateRandomString()\r\n  \u00a0 let product_code=\"EPAYTEST\"\r\n  \u00a0 let product_service_charge = 0\r\n  \u00a0 let product_delivery_charge = 0\r\n  \u00a0 let secretKey=\"8gBm\/:&amp;EnhH.1\/q\"\r\n\u00a0 \u00a0 let signature=generateSignature(`total_amount=${amount},transaction_uuid=${transaction_uuid},product_code=${product_code}`,secretKey)\r\n\r\n \r\n\u00a0 \u00a0 res.send(`\r\n\u00a0 \u00a0 &lt;body&gt;\r\n  \u00a0 \u00a0 \u00a0 &lt;form action=\"https:\/\/rc-epay.esewa.com.np\/api\/epay\/main\/v2\/form\" method=\"POST\"&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"amount\" name=\"amount\" value=\"${amount}\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"tax_amount\" name=\"tax_amount\" value =\"${tax_amount}\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"total_amount\" name=\"total_amount\" value=\"${amount}\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"transaction_uuid\" name=\"transaction_uuid\" value=\"${transaction_uuid}\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"product_code\" name=\"product_code\" value =\"EPAYTEST\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"product_service_charge\" name=\"product_service_charge\" value=\"${product_service_charge}\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"product_delivery_charge\" name=\"product_delivery_charge\" value=\"${product_delivery_charge}\" required&gt;\\\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"success_url\" name=\"success_url\" value=\"http:\/\/localhost:3000\/success\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"failure_url\" name=\"failure_url\" value=\"http:\/\/localhost:3000\/failure\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"signed_field_names\" name=\"signed_field_names\" value=\"total_amount,transaction_uuid,product_code\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input type=\"text\" id=\"signature\" name=\"signature\" value=\"${signature}\" required&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;input value=\"Submit\" type=\"submit\"&gt;\r\n  \u00a0 \u00a0 \u00a0 \u00a0&lt;\/form&gt;\r\n  \u00a0 &lt;\/body&gt;\r\n  \u00a0 `)\r\n\u00a0 \u00a0 })\r\n\r\nThe form in the frontend looks like this:<\/pre>\n<\/div>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-10655 lazyload\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/aaa-1.webp\" alt=\"Esewa Payment Integration in Node.js\" width=\"381\" height=\"500\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/aaa-1.webp 381w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/aaa-1-229x300.webp 229w\" data-sizes=\"(max-width: 381px) 100vw, 381px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 381px; --smush-placeholder-aspect-ratio: 381\/500;\" \/><\/p>\n<p style=\"text-align: left;\">In the above HTML code, we have initialized the variables:<strong>\u00a0<\/strong><\/p>\n<p style=\"text-align: left;\"><strong>order_price:<\/strong> Retrieves the price query parameter from the request.<\/p>\n<p style=\"text-align: left;\"><strong>amount:<\/strong> Assigns the order_price to amount.<\/p>\n<p style=\"text-align: left;\"><strong>tax_amount:<\/strong> Indicates the amount of tax applied to the order, initialized to 0 assuming no tax in this example. It will be added to the order price to sum up with the total transaction.<\/p>\n<p style=\"text-align: left;\"><strong>transaction_uuid:<\/strong> Generates a random string using the generateRandomString() function. This UUID uniquely identifies each transaction.<\/p>\n<p style=\"text-align: left;\"><strong>product_code:<\/strong> Sets a static product code (EPAYTEST in this case).<\/p>\n<p style=\"text-align: left;\"><strong>secretKey:<\/strong> Represents a secret key used for generating the signature parameter.<\/p>\n<p style=\"text-align: left;\"><strong>Signature Generation:\u00a0<\/strong>Generates a cryptographic signature using the generateSignature() function. It concatenates total_amount, transaction_uuid, and product_code along with secretKey to ensure data integrity and authenticity when submitting the form.<\/p>\n<p style=\"text-align: left;\"><strong>product_service_charge and product_delivery_charge: <\/strong>Charges, if any, related to services or delivery associated with the product. These values are initialized to 0, assuming no additional charges in this scenario. They could be adjusted based on business logic or user inputs if applicable.<\/p>\n<p style=\"text-align: left;\"><strong>Success Url:<\/strong> This is the URL where eSewa redirects users after a successful payment transaction. It allows\u00a0application to handle and display a success message or perform additional actions upon successful completion of the payment process.<\/p>\n<p style=\"text-align: left;\"><strong>Failure URL:<\/strong> This is the URL where eSewa redirects users if the payment transaction fails or is canceled. It Enables the application to inform users about the failure and possibly provide instructions or options to retry the payment or contact support.<\/p>\n<p style=\"text-align: left;\"><strong>Form Construction:<\/strong><\/p>\n<p style=\"text-align: left;\">The route responds with an HTML form (&lt;form&gt;) that submits data to Esewa&#8217;s API <strong>(https:\/\/rc-epay.esewa.com.np\/api\/epay\/main\/v2\/form)<\/strong> using the POST method.<br \/>\nVarious &lt;input&gt; fields are included for essential parameters such as amount, transaction_uuid, product_code, success_url, failure_url, signed_field_names, and signature.<br \/>\nA submit button (&lt;input type=&#8221;submit&#8221;&gt;) initiates the form submission to start the payment process.<\/p>\n<p style=\"text-align: left;\">After clicking the submit button, the working esewa form will be displayed:<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-10652 lazyload\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js.webp\" alt=\"Esewa Payment Integration in Node.js\" width=\"1024\" height=\"614\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js.webp 1024w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js-300x180.webp 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js-768x461.webp 768w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js-380x228.webp 380w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js-550x330.webp 550w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.js-800x480.webp 800w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/614;\" \/><\/p>\n<p style=\"text-align: left;\">Login to your account. You will be asked the verification code. Enter your token.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-10653 lazyload\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1.webp\" alt=\"Esewa Payment Integration in Node.Js\" width=\"1024\" height=\"591\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1.webp 1024w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1-300x173.webp 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1-768x443.webp 768w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1-380x219.webp 380w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1-550x317.webp 550w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/Esewa-Payment-Integration-in-Node.Js-1-800x462.webp 800w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/591;\" \/><\/p>\n<p style=\"text-align: left;\">Here, all the information of the user will be displayed. Press the continue button and proceed with the form.<\/p>\n<p style=\"text-align: left;\">If the payment is successful, a payment success from will be displayed. If not, the form with failure message will be displayed.<\/p>\n<h3 style=\"text-align: left;\">Step 6: Handling Payment Responses<\/h3>\n<p style=\"text-align: left;\">The \/success and \/failure routes handle the responses from Esewa. If the payment is successful, the \/success route will return a success message; if the payment fails, the \/failure route will return a failure message.<\/p>\n<p style=\"text-align: left;\"><strong>Failure Message<\/strong><\/p>\n<pre>app.get(\"\/failure\", (req, res) =&gt; {\r\n\u00a0 \u00a0 console.log(req.query);\r\n\u00a0 \u00a0 res.json({ message: \"Payment failed\" });\r\n});\r\n<img decoding=\"async\" class=\"alignnone size-full wp-image-10658 lazyload\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/cancell.webp\" alt=\"Esewa Payment Integration in Node.js\" width=\"586\" height=\"757\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/cancell.webp 586w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/cancell-232x300.webp 232w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/cancell-380x491.webp 380w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/cancell-550x710.webp 550w\" data-sizes=\"(max-width: 586px) 100vw, 586px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 586px; --smush-placeholder-aspect-ratio: 586\/757;\" \/><\/pre>\n<p style=\"text-align: left;\"><strong>Explanation:<\/strong><\/p>\n<p style=\"text-align: left;\">This route is defined with Express.js to handle GET requests at \/failure. In the payment form (&lt;form&gt;), the failure_url is specified as http:\/\/localhost:3000\/failure (or your server\u2019s URL). This ensures that if the payment fails, eSewa redirects the user back to this route.<br \/>\nThe user sees the message &#8220;Payment failed&#8221; returned by the server, indicating the unsuccessful completion of the transaction.<\/p>\n<p style=\"text-align: left;\">({ message: &#8220;Payment failed&#8221; }): Sends a JSON response back to the client\/browser with a simple message indicating that the payment failed.<\/p>\n<p style=\"text-align: left;\"><strong>Success Message<\/strong><\/p>\n<pre>app.get(\"\/success\", (req, res) =&gt; {\r\n\u00a0 \u00a0 let token = req.query.data;\r\n\u00a0 \u00a0 let queryBody = JSON.parse(Buffer.from(token, \"base64\").toString(\"ascii\"));\r\n\u00a0 \u00a0 res.json({ \"message\": `Payment Info ${queryBody}` });\r\n});<\/pre>\n<p style=\"text-align: left;\"><strong><img decoding=\"async\" class=\"alignnone size-full wp-image-10657 lazyload\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/6.webp\" alt=\"Esewa Payment Integration in Node.js\" width=\"556\" height=\"837\" data-srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/6.webp 556w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/6-199x300.webp 199w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/6-380x572.webp 380w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2024\/07\/6-550x828.webp 550w\" data-sizes=\"(max-width: 556px) 100vw, 556px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 556px; --smush-placeholder-aspect-ratio: 556\/837;\" \/><\/strong><\/p>\n<p style=\"text-align: left;\"><strong>Explanation<\/strong><\/p>\n<p style=\"text-align: left;\">This route is defined with Express.js to handle GET requests at \/success. It is typically set as the success_url in the payment form submitted to eSewa. In the payment form (&lt;form&gt;), the success_url is specified as http:\/\/localhost:3000\/success (or your server\u2019s URL). This ensures that if the payment is successful, eSewa redirects the user back to this route. The user sees the payment information returned by the server, confirming the successful completion of the transaction.<\/p>\n<p style=\"text-align: left;\">&#8211; let token = req.query.data;: Retrieves the data query parameter from the request URL, which typically contains a token or encoded data sent by eSewa.<br \/>\n&#8211; Buffer.from(token, &#8220;base64&#8221;).toString(&#8220;ascii&#8221;): Decodes the token from Base64 encoding to ASCII string format. This converts the encoded payment information into a readable format.<\/p>\n<p style=\"text-align: left;\">&#8211;\u00a0 JSON.parse(&#8230;): Converts the decoded ASCII string (queryBody) into a JavaScript object. This object contains the details of the successful payment transaction.<\/p>\n<h3 style=\"text-align: left;\">Step 7: Complete the Transaction Process<\/h3>\n<p style=\"text-align: left;\">These JSON examples represent responses and data payloads that you receive from eSewa upon completing a payment transaction.<\/p>\n<pre>{\r\ntransaction_code: '0008040',\r\nstatus: 'COMPLETE',\r\ntotal_amount: '10.0',\r\ntransaction_uuid: '9b836129fe011f4d694f',\r\nproduct_code: 'EPAYTEST',\r\nsigned_field_names: 'transaction_code,status,total_amount,transaction_uuid,product_code,signed_field_names',\r\nsignature: 'nfj+XVxqA8Y2U2eQQ4S1q+2\/gYcT7RF7HSrUpT56Ts0='\r\n}\r\n\r\n{\r\ndata: 'eyJ0cmFuc2FjdGlvbl9jb2RlIjoiMDAwODA0MCIsInN0YXR1cyI6IkNPTVBMRVRFIiwidG90YWxfYW1vdW50IjoiMTAuMCIsInRyYW5zYWN0aW9uX3V1aWQiOiI5YjgzNjEyOWZlMDExZjRkNjk0ZiIsInByb2R1Y3RfY29kZSI6IkVQQVlURVNUIiwic2lnbmVkX2ZpZWxkX25hbWVzIjoidHJhbnNhY3Rpb25fY29kZSxzdGF0dXMsdG90YWxfYW1vdW50LHRyYW5zYWN0aW9uX3V1aWQscHJvZHVjdF9jb2RlLHNpZ25lZF9maWVsZF9uYW1lcyIsInNpZ25hdHVyZSI6Im5maitYVnhxQThZMlUyZVFRNFMxcSsyL2dZY1Q3UkY3SFNyVXBUNTZUczA9In0='\r\n}<\/pre>\n<p style=\"text-align: left;\">The second portion <strong>&#8220;data&#8221;<\/strong> is Base64 encoded version of the first portion, used for secure transmission of the transaction data provided by Esewa.<\/p>\n<p style=\"text-align: left;\">The first portion is Human-readable JSON data of the transaction. Once received the encoded data, this data can be decoded back to its original JSON format (first portion) to verify and use the transaction details.<\/p>\n<h2 style=\"text-align: left;\">Conclusion<\/h2>\n<p style=\"text-align: left;\">In this way, we can integrate eSewa in Node.js for seamless transaction using Express.js as the framework. This integration includes setting up a Node.js project, configuring an Express server, creating necessary routes, and handling payment responses. It doesn&#8217;t only simplifies payment processing but also builds trust with your users by providing a reliable and secure payment solution. Following the above simple guidance can help you integrate your own payment gateway that allows users to use the most wildly accepted platform &#8216;Esewa&#8217;.<\/p>\n<blockquote><p><strong>Learn more on <a href=\"https:\/\/nestnepal.com\/blog\/installing-nixos-on-hetzner-vps\/\">How to Install NixOs on Hetzner VPS?<\/a><\/strong><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Esewa payment integration in Node.js application offers a popular Nepalese payment gateway for users to perform transactions. In this guide,&#8230;<\/p>\n","protected":false},"author":15,"featured_media":10667,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[390,393,391,392],"class_list":["post-10633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud","tag-esewa-integration","tag-gateway","tag-node-js","tag-payment"],"_links":{"self":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/10633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/comments?post=10633"}],"version-history":[{"count":22,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/10633\/revisions"}],"predecessor-version":[{"id":10669,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/10633\/revisions\/10669"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/media\/10667"}],"wp:attachment":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/media?parent=10633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/categories?post=10633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/tags?post=10633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}