1.0.3 • Published 7 years ago
payger-merchant-javascript-sdk v1.0.3
PAYGER - Merchant Javascript SDK
Welcome to our merchant sdk tutorial.
What is this SDK?
Javascript SDK to easily connect to Payger Merchant API.
Here can find the API documentation.
Instalation
Node.js
Merchant Javascript SDK is available on npm. To install it try:
$ npm payger-merchant-javascript-sdkUsage
Import the library in your code, and then start a new merchant to get new communication:
const merchant = new Merchant(environment, oauth2, basicAuth);You need to specify the environment (test or production).
For reference here is described how to start oauth2 and basic authentication:
const oauth2 = {
apiKey: "<your_api_key>",
apiSecret: "<your_api_secret>"
};
const basicAuth = {
user: "<your_basic_auth_user>",
psw: "<your_basic_auth_psw>"
};Services available
To make easier to call every actions define an object like these
const actions = {
getBalances: "GET_BALANCES", // get all balances
getCurrencies: "GET_CURRENCIES", // get currencies (all or filtered)
getCurrency: "GET_CURRENCY", // get a specific currency
getExchangeRate: "GET_EXCHANGERATES", // get exchange rates ( by filters )
getPaymentLimits: "GET_PAYMENTLIMITS", // get payment limits
getAllTransactions: "GET_ALLTRANSACTIONS", // get transactions (all)
getTransactions: "GET_TRANSACTIONS", // get transactions (paginated)
getTransaction: "GET_TRANSACTION", // get a specific transaction
getPayments: "GET_PAYMENTS", // get payments (paginated)
savePayment: "SAVE_PAYMENTS", // create a payment
getPayment: "GET_PAYMENT", // get a specific payment
updatePayment: "UPDATE_PAYMENT", // update a specific payment
cancelPayment: "CANCEL_PAYMENT", // cancel a specific payment
addAddress: "ADD_ADDRESS", // add an address to payment
getFees: "GET_FEES", // get Fees
};Here you have all available actions.
How to call an action
Is really simple to call an action. Just use your js merchant const declared before.
merchant.call(actions.<whatever_action>, data);Every call retrieve a promise.
Fill speficic data parameter
Each method is prepared to receive a specific object.
Definition for every
Get Balances
None
Get Currencies
from: String
- specific currency (I.E.: DASH)
- Nullable: true
Get Currency
String
- specific currency (I.E.: DASH)
- Nullable: falseGet Exchange Rates
productCurrency: String
- specific currency (I.E.: DASH)
- Nullable: false
amount: integer
- Nullable: false
applyLimits: boolean
- Nullable: true
paymentCurrencies: string
- specific currency (I.E.: DASH)
- Nullable: trueGet Payment Limits
page: integer
- Nullable: false
size: integer
- Nullable: false
sort: boolean
- Nullable: trueGet All Transactions
None
Get Transactions
page: integer
- Nullable: false
size: integer
- Nullable: false
sort: boolean
- Nullable: trueGet Transaction
id: integer
- Nullable: false Get Payments
page: integer
- Nullable: false
size: integer
- Nullable: false
sort: boolean
- Nullable: trueSave Payment
payment = {
externalId: string,
description: string,
paymentCurrency: string,
productCurrency: string,
source: string,
productAmount: float,
buyerName: string,
buyerEmailAddress : string,
ipAddress: string,
latitude: string,
longitude: string,
callback : {
url : string,
method : string,
params : {
orderID: string
}
},
metadata : {
a : string
}
}
- Nullable: falseGet Payment
id: integer
- Nullable: false Update Payment
update = {
id: integer
- Nullable: false
values: {
externalId: string,
description : string,
metadata : {
"aaa" : "bbb"
}
}
}
- Nullable: falseCancel Payment
id: integer
- Nullable: false Add address
data = {
id: integer
- Nullable: false
address: {
paymentCurrency: string,
productCurrency: string,
productAmount: string
}
}
- Nullable: falseGet Fees
feeRequest = {
paymentCurrency: string,
productCurrency: string,
productAmount: string
}
}
- Nullable: false