eSewa website payment gateway| wooCommerce WordPress plugin

0
244
esewa payment gateway

With the increase in online digital selling business in Nepal, there is a high demand for trustable and reliable online payment gateway. And when it comes to reliability, Nepal No.1 digital wallet; eSewa comes in. It provides a wide and easy payment solution for your online business like online shopping sites and apps. This can be the easiest payment gateway for Nepalese digital sellers as receiving local payment. Some advantage of using eSewa payment gateway are listed below:

  • Get paid instantly and easily to your account.
  • Gain more local customers.
  • Track and view payment history.

Manual integration for eSewa payment gateway:

HTML Code

<body>
    <form action="https://uat.esewa.com.np/epay/main" method="POST">
    <input value="100" name="tAmt" type="hidden">
    <input value="90" name="amt" type="hidden">
    <input value="5" name="txAmt" type="hidden">
    <input value="2" name="psc" type="hidden">
    <input value="3" name="pdc" type="hidden">
    <input value="epay_payment" name="scd" type="hidden">
    <input value="ee2c3ca1-696b-4cc5-a6be-2c40d929d453" name="pid" type="hidden">
    <input value="http://merchant.com.np/page/esewa_payment_success?q=su" type="hidden" name="su">
    <input value="http://merchant.com.np/page/esewa_payment_failed?q=fu" type="hidden" name="fu">
    <input value="Submit" type="submit">
    </form>
</body>

Javascript Integration

var path="https://uat.esewa.com.np/epay/main";
var params= {
    amt: 100,
    psc: 0,
    pdc: 0,
    txAmt: 0,
    tAmt: 100,
    pid: "ee2c3ca1-696b-4cc5-a6be-2c40d929d453",
    scd: "epay_payment",
    su: "http://merchant.com.np/page/esewa_payment_success",
    fu: "http://merchant.com.np/page/esewa_payment_failed"
}

function post(path, params) {
    var form = document.createElement("form");
    form.setAttribute("method", "POST");
    form.setAttribute("action", path);

    for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);
        form.appendChild(hiddenField);
    }

    document.body.appendChild(form);
    form.submit();
}

Code for Python

#!/usr/bin/python3
import requests as req

url ="https://uat.esewa.com.np/epay/main"
d = {'amt': 100,
    'pdc': 0,
    'psc': 0,
    'txAmt': 0,
    'tAmt': 100,
    'pid':'ee2c3ca1-696b-4cc5-a6be-2c40d929d453',
    'scd':'epay_payment',
    'su':'http://merchant.com.np/page/esewa_payment_success?q=su',
    'fu':'http://merchant.com.np/page/esewa_payment_failed?q=fu'}
resp = req.post(url, d)

PHP integration

$url = "https://uat.esewa.com.np/epay/main";
$data =[
    'amt'=> 100,
    'pdc'=> 0,
    'psc'=> 0,
    'txAmt'=> 0,
    'tAmt'=> 100,
    'pid'=>'ee2c3ca1-696b-4cc5-a6be-2c40d929d453',
    'scd'=> 'epay_payment',
    'su'=>'http://merchant.com.np/page/esewa_payment_success?q=su',
    'fu'=>'http://merchant.com.np/page/esewa_payment_failed?q=fu'
]

    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);

eSewa payment integration using wordpress plugin

It has become far more easier with the integration of online payment in business site with the releasing of wordpress plugin. You can simply intall and setup for establishing a payment gateway solution.