Skip to content

Instantly share code, notes, and snippets.

@oozzal
Created September 18, 2014 11:53
Show Gist options
  • Save oozzal/c513aafb6fdb236d192c to your computer and use it in GitHub Desktop.
Save oozzal/c513aafb6fdb236d192c to your computer and use it in GitHub Desktop.

:: The Flow of the esewa payment system

When customer chooses esewa as on-line payment option from merchant site, then s/he(user) is temporarily redirected to eSewa, where user have to login and confirm the transaction to proceed. After successful transaction in esewa, the user is redirected back to merchant site(success page). If transaction fails due to any reason, the user is informed by failure message and redirected back to merchant site(failure page).

For every successful transaction by user, the merchant account is credited accordingly and notified via email about transaction with details.

:: Integrating eSewa epay feature into merchant site

When user chooses esewa as on-line payment, the merchant site calls following URL with nine different parameters

URL : (For TEST environment) - http://esewa.f1dev.com/epay/main

      (For LIVE environment) - https://esewa.com.np/epay/main

Parameters :
a) amt       - Amount(NRs) of the product/item which user have selected from merchant site for purchase/order.

b) txAmt     - Tax amount(NRs) on the selected product/item.

c) psc        - Product service charge, or service charge.

d) pdc        - Product delivery charge, amount to be charge in case product/item have to be home delivered or so.

e) tAmt        - Total amount(NRs), it is the final price after sum of base price, tax, and other charges.
          Eg : tAmt = amt + txAmt + psc + pdc  esewa will provide merchant with a code/id that will represent the merchant during transaction.

          For TEST, merchant can use "testmerchant" as merchant code.
          For LIVE, please contact esewa management to receive the code.

g)pid        - Product ID, a unique id/code that represents the item.
          Eg : 121234 or MER121234 or soon


h)su         - Success URL, a url to redirect after successful transaction in esewa. The merchant will recieve three different parameters as query string.
          Eg : http://www.merchantsite.com/success?q=su&oid=121234&amt=100&refId=110761
          Where,
            oid = pid (sent by merchant)
            amt = total amount (tAmt)
            refId = unique Id send by eSewa.

i)fu        - Failure URL, a url to redirect after failed transaction in esewa & with no parameters as query string.

NOTE ::  i.  All parameters are of type String.
     ii. Parameters (amt, tAmt, scd, pid, su & fu) are required/mandatory.
     iii.Parameters (txAmt, psc, pdc value should be '0' if not required by merchant)
  1. Sample code for integration of esewa into merchant site

    -- Written in HTML, refer this as source and develop your application accordingly --

    -- Code start --

    -- Code end --

  2. Merchant can verify the every transaction(s) occurred through eSewa using our verification method.

:: How to ? As already stated, for every successful transaction by users from eSewa, they are redirect to merchant success page with query string containing parameters, namely : " oid, amt & refId " Store these parameters value, and send a request to given url with following parameters : (Verification process should be automated behind the scene, unknown to user)

URL :  For test : "http://esewa.f1dev.com/epay/transrec"
       For Live : "https://esewa.com.np/epay/transrec"

Parameters     Description
m    :    set value to "ver", always!
amt     :     transaction amount
pid    :     product id (oid you received or pid merchant send to eSewa for transaction)
rid     :     reference id (refId received by merchant after successful transaction)
scd     :     merchant code that esewa provides

Sample code :
<form action = "http://esewa.f1dev.com/epay/transrec" method="POST">
           <input type="hidden" value="ver" name="m"/>
        <input type="hidden" value="testmerchant" name="scd"/>
        <input type="hidden" value="121234" name="pid"/>
        <input type="hidden" value="100" name="amt">
        <input type="hidden" value="12345" name="rid">
        <input value="Verify" type="submit">
</form>

P.S :: For further technical help please contact F1Soft International.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment