Android - ESewa SDK Documentation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Mobile​ ​Payment​ ​SDK​ ​Documentation

For​ ​Android
Table​ ​Of
Contents
Chapter​ ​1​ ​Introduction 2-4
General​ ​Description 2
Transaction​ ​Flow 3
System​ ​Interaction 3
Call​ ​back​ ​url 4
Transaction​ ​Verification 4
Chapter​ ​2​ ​Implementation 5-9
Overview 5
Prerequisite 6
​ ​Call​ ​back​ ​url​ ​Pattern 6
Transaction​ ​Verification​ ​API 7-8
Error​ ​Cases​ ​and​ ​Handling 8
During​ ​Final​ ​Verification 9
Chapter​ ​3​ ​Appendix 10-12
Appendix​ ​A 10
Appendix​ ​B 11
Appendix​ ​C 12
Chapter​ ​4​ ​FAQ 13-15
For​ ​Merchants 13
For​ ​Users 15

1
Chapter​ ​1 Introduction

Introduction
This document is intended to be used as a reference in the planning and building of applications wishing to
integrate eSewa SDK. This information should help accelerate the integration efforts of eSewa System with
merchant​ ​application.

The focus of this document is to detail how partner applications establish connectivity to eSewa and outline
the transaction process with verification process. A full and detailed description of the transactions and
associated​ ​data​ ​elements​ ​is​ ​included.

This​ ​document​ ​is​ ​intended​ ​for​ ​partner​ ​merchant/clients​ ​seeking​ ​to​ ​integrate​ ​and​ ​transact​ ​with​ ​the​ ​eSewa.
It​ ​should​ ​be​ ​used​ ​as​ ​a​ ​reference​ ​during​ ​the​ ​planning,​ ​building,​ ​and​ ​testing​ ​of​ ​such​ ​applications.​ ​eSewa
enables​ ​partner​ ​merchant/clients​ ​to​ ​perform​ ​transaction​ ​initiated​ ​by​ ​customers​ ​having​ ​eSewa​ ​account​ ​in
secure​ ​environment.​ ​The​ ​transaction​ ​amount​ ​is​ ​deposited​ ​into​ ​their​ ​eSewa​ ​merchant​ ​wallet​ ​or​ ​bank​ ​account.

Overview
General​ ​Description
The​ ​eSewa​ ​Mobile​ ​SDK​ ​enable​ ​native​ ​android​ ​to​ ​easily​ ​accept​ ​eSewa​ ​payments.
The​ ​SDK​ ​supports​ ​only​ ​one​ ​use​ ​case​ ​for​ ​making​ ​payment​ ​–​ ​Single​ ​Payment​ ​(i.e.​ ​One​ ​payment​ ​per​ ​one​ ​user​ ​log​ ​in).

Transaction​ ​Flow
1​.​ ​Client​ ​Mobile​ ​Application​ ​initiates​ ​eSewa​ ​Payment​ ​procedure​ ​by​ ​sending​ ​their​ ​client_id​​ ​and​​ ​client_secret
along​ ​with​ ​product/service​ ​name​,​ ​product/service​ ​price​,​ ​product_​ ​id​​ ​and​ ​callback-url​ ​to​ ​sdk.

*​client_id​​ ​and​ ​client_secret​​ ​values​ ​are​ ​provided​ ​by​ ​eSewa​ ​to​ ​its​ ​merchant/client.

2. SDK verifies merchant/client credentials with eSewa server, proceeds to next step if verification succeeds else
freezes​ ​with​ ​appropriate​ ​error​ ​message.
3.​ ​ ​User​ ​login​ ​in​ ​eSewa.
4.​ ​ ​User​ ​makes​ ​payment​ ​if​ ​sufficient​ ​balance​ ​is​ ​available​ ​.
5. If successful payment is made, SDK receives (from eSewa server) and forwards proof of payment to client mobile
application (in the form of transaction details shown in Appendix C) and at the same time, eSewa server also
sends the same copy to merchant/client application server in the callback-url. (* This proof of payment is
significant​ ​for​ ​payment​ ​ ​verification).
6. Client/merchant verifies the transaction with eSewa through a verification api. This final verification procedure
is​ ​strongly​ ​recommended​ ​before​ ​product/service​ ​delivery.
7.​ ​Deliver​ ​Product/Service​ ​to​ ​user.

[Note:

2
After​ ​the​ ​completion​ ​of​ ​login,​ ​if​ ​the​ ​device​ ​stays​ ​ideal​ ​for​ ​more​ ​than​ ​1​ ​minute​ ​before​ ​confirming​ ​the​ ​payment,​ ​the​ ​particular​ ​session​ ​will
be​ ​time​ ​out​ ​and​ ​user​ ​have​ ​to​ ​re-login​ ​to​ ​confirm​ ​the​ ​payment.]

System​ ​Flow​ ​Diagram:


The​ ​interactions​ ​required​ ​to​ ​complete​ ​a​ ​transaction​ ​followed​ ​by​ ​verification​ ​process​ ​are​ ​shown​ ​below:

1. Client/Merchant​ ​app​ ​triggers​ ​sdk​ ​with​ ​required​ ​params​ ​as​ ​mentioned​ ​in​ ​step​ ​one​ ​of​ ​transaction​ ​flow.
2. Sdk​ ​(​ ​in​ ​communication​ ​with​ ​eSewa​ ​server)​ ​verifies​ ​merchant,​ ​proceeds​ ​to​ ​login​ ​eventually​ ​landing​ ​at
payment​ ​confirmation.
3. User​ ​confirms​ ​payment.​ ​With​ ​payment​ ​being​ ​successful,​ ​eSewa​ ​server​ ​sends​ ​a​ ​proof​ ​of​ ​payment​ ​to
Client/Merchant​ ​Server​ ​in​ ​their​ ​provided​ ​callback-url.
4. At​ ​the​ ​same​ ​time,​ ​the​ ​same​ ​copy​ ​is​ ​also​ ​sent​ ​to​ ​eSewa​ ​SDK.
5. eSewa​ ​SDK​ ​forwards​ ​the​ ​payment​ ​response​ ​to​ ​client/merchant​ ​mobile​ ​app.
6. Transaction​ ​verification​ ​is​ ​strongly​ ​recommended​ ​before​ ​the​ ​delivery​ ​of​ ​any​ ​product/service.

3
Call​ ​Back​ ​Url
Callback-url​ ​is​ ​an​ ​API​ ​exposed​ ​at​ ​merchant/client`server​ ​at​ ​which​ ​eSewa​ ​sends​ ​a​ ​copy​ ​of​ ​proof​ ​of​ ​payment​ ​after
successful​ ​payment;​ ​the​ ​client/merchant​ ​must​ ​send​ ​a​ ​callback-url​​ ​while​ ​initiating​ ​the​ ​payment​ ​through​ ​eSewa.​ ​The
sent​ ​callback-url​ ​is​ ​ ​later​ ​used​ ​by​ ​eSewa​ ​to​ ​send​ ​a​ ​copy​ ​of​ ​proof​ ​of​ ​payment​ ​after​ ​a​ ​payment​ ​is​ ​received. The
callback-url​ ​must​ ​be​ ​an​ ​API​ ​with​ ​Request​ ​Method​ ​POST​.​ ​The​ ​pattern​ ​in​ ​which​ ​eSewa​ ​sends​ ​the​ ​proof​ ​of​ ​payment​ ​is
described​ ​in​ ​Chapter​ ​2​ ​(Implementation).

Transaction​ ​Verification
Clients using eSewa SDK are requested to go through final verification by comparing all the parameters proof
of payment obtained by application through SDK and that obtained by client application server through
eSewa. Clients/merchants are ​strongly recommended to send verification request for each successful
payment with required parameters to eSewa Server before product/service delivery. This can be done
through​ ​verification​ ​api​ ​which​ ​is​ ​shown​ ​in​ ​Chapter​ ​2​ ​(Implementation).
The​ ​partner​ ​merchant​ ​will​ ​receive​ ​transaction​ ​details​ ​on​ ​success​ ​or​ ​error​ ​message​ ​on​ ​failure​ ​response.

4
Chapter​ ​2 Implementation

Implementation

Overview

eSewa​ ​integration​ ​on​ ​partner​ ​merchant’s​ ​application​ ​is​ ​the​ ​process​ ​of​ ​implementing​ ​eSewa​ ​as
payment​ ​option.​ ​The​ ​integration​ ​process​ ​itself​ ​is​ ​performed​ ​in​ ​two​ ​phases,​ ​namely:

1. Staging​ ​(Testing)​ ​Environment

2. Live​ ​(Production)​ ​Environment

● Staging​ ​(Testing)​ ​Environment

This​ ​phase​ ​is​ ​intended​ ​to​ ​test​ ​process​ ​flow,​ ​transactions​ ​and​ ​other​ ​integration​ ​results.​ ​A​ ​test​ ​merchant​ ​id
&​ ​secret​ ​key​ ​along​ ​with​ ​a​ ​test​ ​eSewa​ ​Id​ ​&​ ​password​ ​will​ ​be​ ​provided​ ​to​ ​the​ ​partner​ ​merchant​ ​to​ ​test​ ​the
payments​ ​through​ ​eSewa.

The​ ​primary​ ​objectives​ ​of​ ​this​ ​stage​ ​are:


​ ​ ​ ​ ​ ​Whether​ ​merchant​ ​requests​ ​are​ ​getting​ ​acknowledged​ ​by​ ​eSewa​ ​system​ ​or​ ​not.
Whether merchant is getting response of either a successful or failure
transaction.​ ​Implementation​ ​and​ ​testing​ ​of​ ​verification​ ​process.

​ ​ ​ ​ ​ ​•​ ​Live​ ​(Production)​ ​Environment

After successful testing phase, the partner merchant will be provided with production environment
merchant​ ​id​ ​&​ ​secret​ ​key.

Partner merchants have to modify the eSewa Environment from test to production to use live
environment merchant credentials. Then, partner merchant will be able to start accepting payments using
eSewa​ ​SDK.

5
Integration
Prerequisite​ ​for​ ​Android​ ​Applications

It is required for clients to provide eSewa with two email ids. Those emails will be used for creating merchant and
end user in test environment. During this phase, client will use test user credentials to login in eSewa and process
the transaction. Adequate balance will be updated to test user account. SDK will support minimum android version
of​ ​2.3.

Add​ ​SDK​ ​to​ ​your​ ​project


Client will be provided with eSewa Android SDK that includes .aar file and documentation copy. The .aar file must
be added to libs folder of your project. The code, which should be added in your build.gradle file, is given in
appendix​ ​A.

Calling​ ​on​ ​callback-url​ ​to​ ​send​ ​proof​ ​of​ ​payment


The​ ​api​ ​pattern​ ​in​ ​which​ ​eSewa​ ​server​ ​send​ ​the​ ​proof​ ​of​ ​payment​ ​after​ ​a​ ​successful​ ​payment​ ​made​ ​through​ ​eSewa
is​ ​shown​ ​below:

Url:​ ​{callback-url​ ​sent​ ​by​ ​merchant​ ​while​ ​initiating​ ​payment​ ​}

Request​ ​method:​ ​POST

Headers:​ ​{
Content-Type:​ ​application/json
merchantId:​ ​{merchant_id}
merchantSecret:​ ​{merchant_secret_key}

Request​ ​Body:
​ ​ ​ ​ ​{
​ ​"productId":"productId",
​ ​"productName":"productName",
​ ​"totalAmount":"10.0",
​ ​"environment":"live",
​ ​"Code":"00",
"merchantName":"​merchantName​",
​ ​"message":​ ​{
"successMessage":"Your​ ​transaction​ ​has​ ​been​ ​completed.",
"technicalSuccessMessage":"Your​ ​transaction​ ​has​ ​been​ ​completed."
​ ​},

6
"transactionDetails":​ ​{
"status":"COMPLETE",
"referenceId":"00X3XHG",
"date":"2016-11-17​ ​12:38:18.0"
}
}

Transaction​ ​Verification​ ​API


In​ ​case,​ ​no​ ​request​ ​appears​ ​in​ ​the​ ​callback-url​,​ ​transaction(s)​​ ​can​ ​be​ ​still​ ​authenticated​ ​with​ ​following​ ​two​ ​APIs:

1. API​ ​for​ ​transaction​ ​verification​ ​with​ ​reference​ ​Id:

Request​ ​URI:
Live​ ​environment​:​ ​ ​https://esewa.com.np/mobile/transaction?txnRefId=​{txnReferenceId}
Test​ ​environment​:​ ​ ​https://ir-user.esewa.com.np/mobile/transaction?txnRefId=​{txnReferenceId}
Request​ ​Method​​ ​:​ ​GET
Headers​​ ​:​ ​{
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​Content-Type:​ ​application/json
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​merchantId:​ ​{merchant_id}
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​merchantSecret:​ ​{merchant_secret_key}
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}

In​ ​success​,​ ​the​ ​response​ ​is​ ​the​ ​transaction​ ​detail​ ​for​ ​queried​ ​reference​ ​Id​ ​ ​as​ ​in​ ​appendix​ ​C

In​ ​failure​,​ ​response​ ​is​ ​as:


{
​ ​ ​ ​ ​"code":​ ​1,
​ ​ ​ ​"message":​ ​"Transaction​ ​not​ ​found."
}

2.​ ​API​ ​for​ ​transaction​ ​verification​ ​with​ ​product​ ​Id​ ​&​ ​amount:

Live​ ​environment​​ ​:​ ​ ​https://esewa.com.np/mobile/transaction?productId=​{productId}&amount={amount}


Test​ ​environment​:​ ​https://​ir-user​.esewa.com.np/mobile/transaction?productId=​{productId}&amount={amount}
Request​ ​Method:​ ​GET
Request​ ​Headers​:​ ​{
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​Content-Type:​ ​application/json
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​merchantId:​ ​UEVRTQIcBksdDAoEGw5dCRAKFhYSFg==
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​merchantSecret:​ ​UEVRTQIcBksdDAoEGw5dCRAKFhYSFltHUw==

​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​}

In​ ​success​,​ ​the​ ​response​ ​is​ ​the​ ​transaction​ ​detail​ ​for​ ​queried​ ​reference​ ​Id​ ​ ​as​ ​in​ ​appendix​ ​C.

7
In​ ​failure​,​ ​response​ ​is​ ​as:

"code":​ ​1,
"message":​ ​"Transaction​ ​not​ ​found."

Test​ ​merchant​ ​ID​ ​and​ ​merchant​ ​secret​ ​key​ ​and​ ​a​ ​test​ ​eSewa​ ​Id​ ​with​ ​password​ ​will​ ​be​ ​provided​ ​to​ ​the
partner​ ​merchant​ ​to​ ​complete​ ​the​ ​transaction.

Error​ ​Cases​ ​and​ ​Handling


Here​ ​are​ ​the​ ​error​ ​cases​ ​that​ ​can​ ​occur​ ​in​ ​each​ ​of​ ​the​ ​step​ ​during​ ​implementation​ ​of
eSewa​ ​SDK​ ​implementation.

During​ ​Merchant​ ​Verification

1.​ ​Invalid​ ​Merchant​ ​Id​ ​or​ ​Secret​ ​Key


SDK​ ​gets​ ​JSON​ ​response​ ​from​ ​server​ ​including​ ​errorMessage​​ ​and​ ​technicalErrorMessage​.​ ​ErrorMessage
contains​ ​message​ ​”Sorry​ ​your​ ​request​ ​failed.​ ​Contact​ ​your​ ​service​ ​provider.”​ ​which​ ​is​ ​shown​ ​to​ ​end​ ​user
and​ ​technicalErrorMessage​ ​contains​ ​message​ ​“Invalid​ ​Merchant​ ​Credential”​ ​which​ ​is​ ​returned​ ​to​ ​mobile
application​ ​as​ ​result​ ​with​ ​result​ ​code​ ​EsewaPayment.RESULT_EXTRAS_INVALID.

2.​ ​No​ ​Internet​ ​Connection


SDK​ ​shows​ ​dialog​ ​box​ ​with​ ​message​ ​“Internet​ ​not​ ​available”​ ​to​ ​end​ ​user​ ​and​ ​returns​ ​same​ ​message​ ​to​ ​mobile
application​ ​as​ ​result.

3.​ ​Invalid​ ​Test​ ​Environment


If​ ​environment​ ​of​ ​EsewaConfiguration​ ​is​ ​set​ ​to​ ​value​ ​other​ ​than​ ​ENVIRONMENT_TEST​​ ​or
ENVIRONMENT_​ ​PRODUCTION​,​ ​SDK​ ​shows​ ​message​ ​”Sorry​ ​your​ ​request​ ​failed.​ ​Contact​ ​your​ ​service
provider.”​ ​to​ ​end​ ​user​ ​and​ ​message​ ​“Invalid​ ​Test​ ​Environment”​ ​which​ ​is​ ​returned​ ​to​ ​mobile​ ​application
as​ ​result​ ​with​ ​result​ ​code​ ​EsewaPayment.​ ​RESULT_EXTRAS_INVALID.

During​ ​User​ ​Login

1.​ ​No​ ​Internet​ ​Connection


SDK​ ​shows​ ​dialog​ ​box​ ​with​ ​message​ ​“Internet​ ​not​ ​available”​ ​to​ ​end​ ​user.

2.​ ​Invalid​ ​user​ ​name​ ​or​ ​password


SDK​ ​shows​ ​message​ ​Invalid​ ​username​ ​or​ ​password​ ​to​ ​end​ ​user​ ​and​ ​clears​ ​password​ ​field.

8
3.​ ​Canceled​ ​by​ ​user
If end user presses Back Button or Cancel button then user is returned to previous mobile application’s
activity​ ​and​ ​result​ ​code​ ​RESULT_CANCELED​​ ​is​ ​returned​ ​to​ ​mobile​ ​application.

During​ ​Payment​ ​Confirmation

1.​ ​No​ ​Internet​ ​Connection


SDK shows dialog box with message “Internet not available” to end user. User can turn on Internet and
proceed​ ​to​ ​confirming​ ​their​ ​payment.

2.​ ​Insufficient​ ​Balance


SDK compares the current balance of user with the total amount of the product or service. Payment request is sent if
and only if the user has sufficient balance else the following message will be shown to user “Your balance is less than
required​ ​total​ ​amount”​ ​and​ ​user​ ​will​ ​be​ ​bound​ ​to​ ​cancel​ ​the​ ​payment.

And if user has sufficient balance initially but balance is expended via other parties before confirming the
payment, message “Transaction could not be completed” is shown to user and message “Insufficient user
balance” which is returned to mobile application as result with result code
EsewaPayment.​RESULT_EXTRAS_INVALID​.

3.​ ​Canceled​ ​by​ ​user


If end user presses Back Button or Cancel button then user is returned to previous
mobile application’s activity and result code ​RESULT_CANCELED is returned to mobile
application.

4.​ ​Session​ ​Timeout


If the device is kept ideal for at least 5 minutes including in both login page and confirmation page then the
particular session for payment expires and user has to re-process the payment again. Message “The session
is expired. Please try again later” is shown to user and message “Session Timeout” which is returned to
mobile​ ​application​ ​as​ ​result​ ​with​ ​result​ ​code​ ​EsewaPayment.​RESULT_​ ​EXTRAS_INVALID​.

During​ ​Final​ ​Verification


This verification is done after SDK returns proof of payment after a successful transaction. Although payment
is already completed, this verification plays a vital role to avoid fraud transactions. The verification can be
done by comparing parameters of the response obtained by application from eSewa SDK with the
transaction detail obtained at application server. If all the parameters are equivalent then the
product/service is ready for delivery else it can be fraud transaction so you are requested to stop the
product/service delivery. If mobile application server fails to receive proof of payment from eSewa Server or
eSewa server fails to send proof of payment to application server then the request for verification can be
sent​ ​later​ ​too.​ ​The​ ​process​ ​of​ ​sending​ ​verification​ ​request​ ​to​ ​eSewa​ ​is​ ​explained​ ​above​ ​in​ ​detail.

9
Chapter​ ​3 Appendix

I. Appendix
​ ​Appendix​ ​A
Code​ ​in​ ​build.gradle​ ​to​ ​add​ ​SDK

repositories
{​ ​flatDir​ ​{

dirs​ ​"libs"

}
}
dependencies​ ​{

compile(name:​ ​"eSewaSdk"​,​ ​ext:​ ​"aar"​)

Appendix​ ​B

Add​ ​permissions​ ​to​ ​your​ ​Android​ ​Manifest.xml​ ​file

<​uses-permission​​ ​android​:name=​"android.permission.INTERNET"​​ ​/>


<​uses-permission​​ ​android​:name=​"android.permission.ACCESS_NETWORK_STATE"​​ ​/>

Create​ ​a​ ​ESewaConfiguration​ ​object

Start​ ​with​ ​test​ ​environment.​ ​When​ ​application​ ​is​ ​ready,​ ​you​ ​can​ ​switch​ ​it​ ​to
live​ ​(​ENVIRONMENT_PRODUCTION​)

ESewaConfiguration​ ​eSewaConfiguration​ ​=​ ​new​​ ​ESewaConfiguration()


.clientId(​"<Your​ ​Client​ ​Id>”)
.secretKey(​"<Your​ ​Secret​ ​Key"​)
.environment(ESewaConfiguration.​ENVIRONMENT_TEST​);
);

10
Create​ ​the​ ​payment​ ​and​ ​launch​ ​the​ ​payment​ ​intent​ ​on​ ​some​ ​action​ ​done​ ​(for​ ​example​ ​when​ ​button
is​ ​pressed)

Button​ ​button​ ​=​ ​(Button)​ ​findViewById(R.id.​button_buy​);


button.setOnClickListener(​new​​ ​View.OnClickListener()​ ​{
@Override
public​ ​void​ ​onClick(View​ ​view)​ ​{
ESewaPayment​ ​eSewaPayment​ ​=​ ​new​​ ​ESewaPayment(​"<Product​ ​Price>"​,​ ​"<Product​ ​Name>"​,
"<Product​ ​Id>",​ ​“<Callback-url>”​);

Intent​ ​intent​ ​=​ ​new​​ ​Intent(SampleActivity.​this​,​ ​ESewaPaymentActivity.​class​);


intent.putExtra(ESewaConfiguration.​ESEWA_CONFIGURATION​,
eSewaConfiguration​);
intent.putExtra(ESewaPayment.​ESEWA_PAYMENT​,​ ​eSewaPayment);
startActivityForResult(intent,​ ​REQUEST_CODE_PAYMENT​);

}
});
Where,
Product​ ​Price​ ​:​ ​Price​ ​of​ ​Product​ ​or​ ​Service
Product​ ​Name​ ​:​ ​Name​ ​of​ ​Product​ ​or​ ​Service
ProductId​ ​:​ ​Set​ ​a​ ​unique​ ​Id​ ​for​ ​your​ ​particular​ ​product​ ​or​ ​services
Callback-url​​ ​:​ ​API​ ​exposed​ ​at​ ​merchant/client`server​ ​where​ ​eSewa​ ​sends​ ​a​ ​copy​ ​of​ ​proof​ ​of​ ​payment​ ​after
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​successful​ ​payment

Implement​ ​onActivityResult()

Returns proof of payment in case of successful transaction and reason for failure in case of transaction failure
( In case of ( result == RESULT_CANCEL ) no additional in-formation will be sent on intent and in case of
successful and unsuccessful payment proof of payment and reason of failure are sent respectively to string
value​ ​Esewa-Payment.EXTRA_RESULT_MESSAGE).

Sample​ ​Code:

@Override
protected​ ​void​ ​onActivityResult(​int​ ​requestCode,​​ ​int​ ​resultCode,
Intent​ ​data)​ ​{​ ​super​.onActivityResult(requestCode,​ ​resultCode,​ ​data);
if​ ​(requestCode​ ​==​​ ​REQUEST_CODE_PAYMENT​)​ ​{
if​ ​(resultCode​ ​==​​ ​RESULT_OK​)​ ​{
String​ ​s​ ​=​ ​data.getStringExtra(ESewaPayment.​EXTRA_RESULT_MESSAGE​);
Log.​i​(​"Proof​ ​of​ ​Payment"​,​ ​s);

Toast.​makeText​(​this​,​ ​"SUCCESSFUL​ ​PAYMENT"​,​ ​Toast.​LENGTH_SHORT​).show();​ ​}

11
else​ ​if​​ ​(resultCode​ ​==​ ​RESULT_CANCELED​)​ ​{

Toast.​makeText​(​this​,​ ​"Canceled​ ​By​ ​User"​,​ ​Toast.​LENGTH_SHORT​).show();​ ​}​ ​else


if​​ ​(resultCode​ ​==​ ​ESewaPayment.​RESULT_EXTRAS_INVALID​)​ ​{
String​ ​s​ ​=​ ​data.getStringExtra(ESewaPayment.​EXTRA_RESULT_MESSAGE​);
Log.​i​(​"Proof​ ​of​ ​Payment"​,​ ​s);
}
}
}

Appendix​ ​C
Proof​ ​of​ ​Payment​ ​Sample:
{
​ ​ ​ ​ ​"code"​:​"00"​,
​ ​ ​ ​ ​"merchantName"​:​"SDKTESTING​ ​"​,
"productName"​:​"SomeProductName"​,
"productId"​:​"​ ​SomeProductId"​,
"totalAmount"​:​"500.0"​,

"message"​:{
"successMessage"​:​"Your​ ​transaction​ ​has​ ​been​ ​completed."​,
"technicalSuccessMessage"​:"​ Your​ ​transaction​ ​has​ ​been​ ​completed."
},
"transactionDetails"​:{
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​"status"​:​"COMPLETE"​,
"referenceId"​:​"00CPPAT"​,
"date"​:​"2016-11-23​ ​16:34:44.0"
}
}

[​Note​:​ ​reference​ ​Id​ ​is​ ​also​ ​called​ ​as​ ​transaction​ ​id]

12
Chapter​ ​4 FAQ

For​ ​Merchants
i. What​ ​is​ ​eSewa​ ​Mobile​ ​Payment​ ​SDK?
eSewa Mobile payment SDK is the payment gateway for the native android applications. It enables native
android​ ​application​ ​to​ ​easily​ ​accept​ ​eSewa​ ​payments.

ii.​ ​ ​What​ ​are​ ​the​ ​items​ ​I​ ​will​ ​get​ ​for​ ​implementing​ ​eSewa​ ​mobile​ ​payment​ ​SDK?
You​ ​will​ ​be​ ​provided​ ​with​ ​.aar​ ​file​ ​of​ ​eSewa​ ​SDK,​ ​documentation​ ​for​ ​integration,​ ​test​ ​merchant​ ​ID​ ​and
merchant​ ​key​ ​and​ ​test​ ​user​ ​ID​ ​with​ ​password​ ​for​ ​test​ ​transaction.

iii.​ ​ ​Can​ ​I​ ​use​ ​same​ ​SDK​ ​in​ ​multiple​ ​mobile​ ​applications?
No,​ ​one​ ​merchant​ ​Id​ ​and​ ​key​ ​is​ ​valid​ ​only​ ​for​ ​one​ ​android​ ​application.​ ​However​ ​merchant​ ​can​ ​get​ ​other​ ​id
and​ ​key​ ​from​ ​eSewa​ ​for​ ​integrating​ ​in​ ​multiple​ ​applications.

iv.​ ​Does​ ​eSewa​ ​provide​ ​payment​ ​integration​ ​in​ ​web​ ​applications?


Yes,​ ​eSewa​ ​also​ ​provides​ ​payment​ ​integration​ ​in​ ​web.​ ​You​ ​can​ ​refer​ ​our​ ​merchant​ ​team​ ​for​ ​its​ ​detail.

v.​​ ​When​ ​Merchant​ ​servers​ ​must​ ​do​ ​validation​ ​with​ ​eSewa​ ​Server​ ​and​ ​Why?
In case, eSewa is unable to send proof of payment to client application server or client application server
is unable to receive proof of payment from eSewa then merchant server must validate the payment to
avoid fraud transactions and to ensure your account has actually received the expected payment. If you
don’t​ ​verify​ ​payments,​ ​you​ ​open​ ​yourself​ ​to​ ​fraud.​ ​Validation​ ​request​ ​can​ ​be​ ​sent​ ​to​ ​eSewa​ ​anytime.

vi.​​ ​What​ ​is​ ​the​ ​settlement​ ​mechanism​ ​from​ ​eSewa​ ​to​ ​Merchant​ ​Bank​ ​Account?
On successful transaction the balance from eSewa user is transferred to merchant account and merchant
can​ ​withdraw​ ​balance​ ​to​ ​respective​ ​bank​ ​account​ ​in​ ​free​ ​of​ ​cost​ ​i.e.​ ​without​ ​any​ ​withdrawal​ ​charges.

vii.​​ ​How​ ​eSewa​ ​provides​ ​support​ ​up​ ​on​ ​receiving​ ​any​ ​trouble​ ​because​ ​of​ ​eSewa​ ​mobile​ ​payment​ ​SDK?
eSewa​ ​provides​ ​24​ ​hours​ ​of​ ​customer​ ​support​ ​service​ ​.​ ​You​ ​can​ ​contact​ ​us​ ​in​ ​case​ ​of​ ​any​ ​inconvenience.

viii.​ ​How​ ​merchant​ ​can​ ​start​ ​testing​ ​eSewa​ ​mobile​ ​payment​ ​SDK?
Test​ ​merchant​ ​ID​ ​and​ ​merchant​ ​secret​ ​key​ ​and​ ​a​ ​test​ ​eSewa​ ​Id​ ​with​ ​password​ ​will​ ​be​ ​provided​ ​to​ ​the
partner​ ​merchant​ ​to​ ​complete​ ​the​ ​transaction.​ ​Test​ ​transaction​ ​can​ ​be​ ​made​ ​by​ ​setting
EsewaEnvironment​ ​to​ ​ESewaConfiguration.TEST​ ​during​ ​setting​ ​configuration.

13
ix.​​ ​What​ ​if​ ​Merchant​ ​server​ ​received​ ​payment​ ​confirmation​ ​only​ ​from​ ​Mobile​ ​application?
There​ ​may​ ​be​ ​the​ ​possibility​ ​of​ ​two​ ​cases:
a. eSewa Server not being able to send the proof of payment in callback-url or merchant server not
being
b. able​ ​to​ ​receive​ ​the​ ​proof​ ​of​ ​payment.
c. Fraud​ ​case

So, the first case must be cross checked for which the merchant server should call eSewa server with the given
product Id and product amount to know if the transaction for the sent id and amount of product/service has been
processed or not (as explained in Chapter 2). If yes, the response is a proof of payment (i.e. transaction detail as
show in appendix C) and if no, “no transaction found” error message is returned which may be the case b so
delivery​ ​of​ ​product/service​ ​must​ ​be​ ​stopped​ ​and​ ​one​ ​should​ ​contact​ ​as​ ​soon​ ​as​ ​possible.

x. What are you supposed to do if the payment amount confirmed by eSewa and transaction amount
requested​ ​by​ ​Mobile​ ​application​ ​are​ ​not​ ​equal?
This may be the case of fraud transaction so in this case service/product delivery must be stopped and
one​ ​should​ ​contact​ ​as​ ​soon​ ​as​ ​possible.

xi. Is eSewa SDK mobile platform dependent? Can we implement this on Android and iOS or do we have to take
different​ ​SDK​ ​for​ ​different​ ​platform?
eSewa SDK is now available for both native android and iOS applications. If you want to integrate eSewa sdk in
your​ ​IOS​ ​application​ ​as​ ​well;​ ​then​ ​you​ ​can​ ​consult​ ​our​ ​merchant​ ​team.

xii.​ ​What​ ​is​ ​the​ ​time​ ​per​ ​session​ ​to​ ​make​ ​successful​ ​payment?
User​ ​must​ ​complete​ ​login​ ​and​ ​payment​ ​process​ ​within​ ​5​ ​minutes​ ​or​ ​else​ ​will​ ​have​ ​to​ ​re-initiation​ ​the​ ​payment
process​ ​from​ ​the​ ​beginning.

14
​​For​ ​Users

i.​​ ​Should​ ​I​ ​have​ ​eSewaID​ ​and​ ​its​ ​credential​ ​to​ ​make​ ​payment​ ​by​ ​eSewa​ ​in​ ​Mobile​ ​application?
Yes​ ​users​ ​should​ ​be​ ​registered​ ​in​ ​eSewa​ ​and​ ​must​ ​have​ ​user​ ​ID​ ​(i.e.​ ​eSewa​ ​Id)​ ​and​ ​password​ ​for​ ​the
completing​ ​the​ ​transaction.

ii.​ ​How​ ​can​ ​I​ ​initiate​ ​payment​ ​by​ ​eSewa​ ​in​ ​Mobile​ ​application​ ​if​ ​I​ ​don’t​ ​have​ ​eSewaID?
User​ ​must​ ​register​ ​to​ ​eSewa​ ​using​ ​www.esewa.com.np​​ ​or​ ​bye​ ​typing​ ​REG​ ​and​ ​send​ ​it​ ​to​ ​32121​ ​via​ ​SMS.

iii.​ ​How​ ​can​ ​I​ ​load​ ​balance​ ​in​ ​eSewa​ ​for​ ​the​ ​payments?
User​ ​can​ ​load​ ​balance​ ​by​ ​transferring​ ​balance​ ​from​ ​our​ ​partner​ ​banks​ ​or​ ​by​ ​counter​ ​deposit​ ​directly​ ​from
some​ ​banks​ ​or​ ​deposit​ ​balance​ ​through​ ​eSewa​ ​Zone/​ ​Point.

iv.​​ ​Can​ ​I​ ​ensure​ ​that​ ​my​ ​eSewaID​ ​and​ ​credential​ ​is​ ​safe​ ​to​ ​payment​ ​by​ ​eSewa​ ​in​ ​third​ ​party​ ​Mobile
application?
Your​ ​eSewaID​​ ​and​ ​password​ ​are​ ​safe​ ​and​ ​secure​ ​as​ ​it​ ​travels​ ​in​ ​encrypted​ ​form​ ​and​ ​over​ ​HTTPS​ ​channel.

15
16

You might also like