- JDK 8 or above
- json package (
org.json
) - Gradle v7.4 (If you have a different Gradle version, you can use
gradle wrapper
to download a wrapper)
Before using this SDK, you should assemble SDK by running gradle assemble
.
For using this SDK, you might copy all files in src folder and paste it to your project. Then you should import 2 classes MerchantIntegrationOnline
, MerchantIntegrationOffline
in src/main/java/com/merchantsdk/payment
folder.
env
: EnvironmentType : either production or staging, values provided through theEnvironmentType
enum.country
: Country : ISO 3166-1 Alpha-2 country code of the merchant location. Values provided through theCountry
enumpartnerId
: String - Unique ID for a partner. Retrieve from Developer HomepartnerSecret
: String - Secret key for a partner. Retrieve from Developer HomemerchantId
: String - Retrieve from Developer HometerminalId
: String - Retrieve from Developer Home (POS only)clientId
: String - Retrieve from Developer Home (OTC only)clientSecret
: String - Retrieve from Developer Home (OTC only)redirectUrl
: String - The url configured in Developer Home (OTC only)
String partnerTxID = "partnerTxID";
String partnerGroupTxID = "partnerGroupTxID";
long amount = 2000;
String currency = "CUR";
String description = "this is testing";
String origPartnerTxID = "origPartnerTxID";
String msgID = "msgID";
MerchantIntegrationOnline merchantIntegrationOnline = new MerchantIntegrationOnline(EnvirionmentType.STAGING, Country.MALAYSIA, partnerId, partnerSecret, merchantId, clientId, clientSecret, redirectUrl);
The values for metaInfo
, items
, shippingDetails
, hidePaymentMethods
, state
are left as null
in the examples below as they are optional parameters.
- chargeInit
merchantIntegrationOnline.chargeInit(partnerTxID, partnerGroupTxID, amount, currency, description, metaInfo, items, shippingDetails, hidePaymentMethods)
Example request:
JSONObject response = merchantIntegrationOnline.chargeInit(partnerTxID, partnerGroupTxID, amount, currency, codeVerifier, description, null, null, null, null);
- generateWebUrl
merchantIntegrationOnline.generateWebUrl(partnerTxID, partnerGroupTxID, amount, currency, codeVerifier, description, metaInfo, items, shippingDetails, hidePaymentMethods, state)
Example request:
JSONObject response = merchantIntegrationOnline.generateWebUrl(partnerTxID, partnerGroupTxID, amount, currency, codeVerifier, description, null, null, null, null, null);
- getOAuth2Token
merchantIntegrationOnline.getOAuth2Token(String code, String codeVerifier);
Merchant get code in redirected url after successfully pay
Example request:
String code = "a09a6c1da7c843519d03978d659c60d8" ;
JSONObject response = merchantIntegrationOnline.getOAuth2Token(code, codeVerifier);
- chargeComplete
merchantIntegrationOnline.chargeComplete(String partnerTxID, String accessToken)
Merchant get accessToken from getOAuth2Token API response
Example request:
JSONObject response = merchantIntegrationOnline.chargeComplete(partnerTxID, accessToken);
- getChargeStatus
merchantIntegrationOnline.getChargeStatus(String partnerTxID, String currency, String accessToken)
Merchant get accessToken from getOAuth2Token API response
Example request:
JSONObject response = merchantIntegrationOnline.getChargeStatus(partnerTxID, currency, accessToken);
- Refund
merchantIntegrationOnline.refund(String partnerTxID, String partnerGroupTxID,long amount,String currency, String txID, String description, String accessToken)
Merchant get accessToken from getOAuth2Token API response
Merchant get txID from chargeComplete or getChargeStatus API response
Example request:
JSONObject response = merchantIntegrationOnline.refund(partnerTxID, partnerGroupTxID, amount, currency, txID, description, accessToken);
- getRefundStatus
merchantIntegrationOnline.getRefundStatus(partnerTxID, currency, accessToken)
Merchant get accessToken from getOAuth2Token API response
Example request:
JSONObject response = merchantIntegrationOnline.getRefundStatus(partnerTxID, accessToken, currency);
- getOTCStatus
merchantIntegrationOnline.getOTCStatus(String partnerTxID, accessToken, String currency)
Merchant get accessToken from getOAuth2Token API response
Example request:
JSONObject response = merchantIntegrationOnline.getOTCStatus(partnerTxID, accessToken, currency);
MerchantIntegrationOffline merchantIntegrationOffline = new MerchantIntegrationOffline(stage, country, partner_id, partner_secret, merchant_id, terminal_id)
- createQrCode
merchantIntegrationOffline.createQrCode(String msgID, String partnerTxID, long amount, String currency)
Example request:
JSONObject response = merchantIntegrationOffline.createQrCode(msgID, partnerTxID, amount, currency);
- performQrCode
merchantIntegrationOffline.performQrCode(String msgID, String partnerTxID, long amount, String currency, String code)
Example request:
JSONObject response = merchantIntegrationOffline.performQrCode(msgID, partnerTxID, amount, currency, code);
- cancel
merchantIntegrationOffline.cancel(String msgID, String partnerTxID,String origPartnerTxID,String origTxID,String currency)
Example request:
JSONObject response = merchantIntegrationOffline.cancel(msgID, partnerTxID, origPartnerTxID, origTxID, currency);
- refund
merchantIntegrationOffline.refund(msgID, partnerTxID, amount, currency, origPartnerTxID, description)
Example request:
JSONObject response = merchantIntegrationOffline.refund(msgID, partnerTxID, amount, currency, origPartnerTxID, description);
- getTxnDetails
merchantIntegrationOffline.getTxnDetails(String msgID, String partnerTxID, String currency)
Example request:
JSONObject response = merchantIntegrationOffline.getTxnDetails(msgID, partnerTxID, currency);
- getRefundDetails
merchantIntegrationOffline.getRefundDetails(String msgID, String partnerTxID, String currency)
Example request:
JSONObject response = merchantIntegrationOffline.getRefundDetails(msgID, partnerTxID, currency);
© 2022 GrabTaxi Holdings Pte Ltd. All rights reserved. Any use of such assets are governed by the API Terms and Conditions (available at Grab Developer).