1.1.0 • Published 1 year ago

ecopay v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ecopay

Integrate this ecopay SDK to make payment with EcoPay gateway

Install

npm install ecopay

Payment transaction

Create payment transaction:

import { EcoPaySDK } from 'ecopay';

const ecopayIns = new EcoPaySDK({
  // config parameters
});

const sampleData: IInitTransactionRequiredData & IInitTransactionExtraData = {
  // your data here
};

ecopayIns.initTransaction(sampleData); // Promise<ICommonResponseData>

Check status of transaction

// other import like above
...
ecopayIns.checkTransaction("<merchant_order_id>");  // Promise<ICommonResponseData>

Tokenization transaction

Initialize Tokenization from EcoPaySDK or separate Tokenization class:

import { EcoPaySDK } from 'ecopay';
...
const token = new EcoPaySDK.Tokenization({
    // config parameters
});

or

import { TokenizationSDK } from 'ecopay';
...
const token = new TokenizationSDK({
    // config parameters
});

Methods

EcoPaySDK

SignatureDescription
EcoPaySDK(config: IInitSdkConfig)Init SDK
initTransaction(params: IInitTransactionRequiredData & IInitTransactionExtraData)Create payment transaction
checkTransaction(params: string)Check status of payment transaction
getSupportBanks(params: IGetSupportBanks)Get list of supported banks

TokenizationSDK

* These methods can be called directly on EcoPaySDK instance for short. Example: ecopaySDKInstance.initTokenization,... | Signature | Description | | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | | TokenizationSDK(params: IInitSdkConfig) | Init SDK | | initTokenization(params: IInitTokenizationData) | Create tokenization transaction | | updateTokenzation(id: string, params: IUpdateTokenizationData) | Update tokenization information | | getTokenizations(params: IGetTokenization, id?: string) | Get a list of tokenizations if id is omitted, otherwise get a detail of tokenization with id |

Return type

All the above methods have return data of type of Promise<ICommonResponseData>

Interface

(*) required

IInitSdkConfig

EcoPaySDK init params

FieldTypeDescription
secretKeystringMerchant secret key
merchantCodestringMerchant code

IInitTransactionRequiredData

Required parameters when creating payment transaction

FieldTypeDescription
platform(*)stringDevice platform. Value one of: 'web', 'mobile' or "desktop"
payment_channel(*)stringPayment channel: - 'atm': atm payment - 'qrcode': qrcode payment - 'eco_merchant' or 'eco_consumer': payment through app eco merchant or consumer - 'installment': convert to installment - 'all': select later
merchant_order_id(*)stringUnique order ID
amount(*)numberAmount of transaction
description(*)stringDescription of transaction
redirect_url(*)stringUrl to notify transaction result to merchant
currency(*)stringCurreny. 'VND' supported only
store_label(*)stringStore label
store_code(*)stringStore code
terminal_label(*)stringTerminal label
terminal_code(*)stringTerminal code

IInitTransactionExtraData

Other optional parameters for creating payment transaction

FieldTypeDescription
purpose_of_transactionstringPurpose of transaction. Required when payment channel is qrcode
bank_typestringBank type. Value: - 'domestic': Payment with domestic bank accounts - 'international': Payment with international card such as VISA, MasterCard, JCB,... Required when payment channel is qrcode or atm
bank_codestringBank code. Required when payment channel is qrcode
payment_typestringPayment type. Default is '05'
installment_infoIInstallmentInfoGoods info when payment channel is installment. More detail below

IInstallmentInfo

Installment info

FieldTypeDescription
products(*)IProduct[]Array of products

IProduct

Installment products info

FieldTypeDescription
code(*)stringCode of product. Example: 'LAPTOP01'
name(*)stringName of product. Example: 'Laptop Gaming'
category(*)stringArray of products. Example: 'LAPTOP'
quantity(*)numberQuantity
unit_price(*)numberPrice of a single product

IGetSupportBanks

FieldTypeDescription
disabled_pagingbooleanPagination or not. Default false
page_sizenumberPage size. Default: 20
codestringBank code
partner_codestringPartner code
sortstringSort field. Example: 'created_at'
statusstringStatus: 'active' or 'inactive'
typestringType of bank: 'domestic' or 'international'

IInitTokenizationData

FieldTypeDescription
merchant_user_id(*)stringMerchant user id
redirect_url(*)stringRedirect url to merchant
description(*)stringDescription
bank_type(*)stringBank type. Value: 'domestic' or 'international'
platform(*)stringDevice platform
bank_codestringBank code
store_codestringStore code
merchant_transidstringMerchant transaction id to create tokenization

IUpdateTokenizationData

FieldTypeDescription
merchant_user_id(*)stringMerchant user id when create tokenization
bank_type(*)stringBank type. Value: 'domestic' or 'international'
status(*)stringTokenization status

IGetTokenization

FieldTypeDescription
merchant_user_id(*)stringUser id
bank_type(*)stringBank type. Value: 'domestic' or 'international'
statusstringTokenization status
pageSizenumberPage size
currentPagestringCurrent page to get data. Default 1

ICommonResponseData

FieldTypeDescription
result_code(*)stringResult code. Example: '010200'
message_key(*)stringResult message key. Example: 'SUCCESS', 'FAILED', 'UNKNOWN',...
message(*)stringDetail result message
dataArray or ObjectData return
signaturestringChecksum of data. Use this to validate integrity of field data

Fields of data when init payment transaction or tokenization successfully:

FieldTypeDescription
payment_url(*)stringPayment url
transid(*)stringTransaction id in EcoPay system
status(*)stringTransaction status
expired_at(*)stringTime when transaction is expired
expired_time(*)numberTime duration until expired_at
1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago