1.0.6 • Published 6 years ago
payger-merchant-sdk v1.0.6
PAYGER - Merchant SDK
Welcome to our merchant sdk github tutorial.
What is this SDK?
Javascript SDK to easily connect to Payger Merchant API.
Here can find the API documentation.
Instalation
Node.js
Merchant SDK
is available on npm. To install it try:
$ npm install payger-merchant-sdk
Usage
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: false
Get 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: true
Get Payment Limits
page: integer
- Nullable: false
size: integer
- Nullable: false
sort: boolean
- Nullable: true
Get All Transactions
None
Get Transactions
page: integer
- Nullable: false
size: integer
- Nullable: false
sort: boolean
- Nullable: true
Get Transaction
id: integer
- Nullable: false
Get Payments
page: integer
- Nullable: false
size: integer
- Nullable: false
sort: boolean
- Nullable: true
Save 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: false
Get Payment
id: integer
- Nullable: false
Update Payment
update = {
id: integer
- Nullable: false
values: {
externalId: string,
description : string,
metadata : {
"aaa" : "bbb"
}
}
}
- Nullable: false
Cancel Payment
id: integer
- Nullable: false
Add address
data = {
id: integer
- Nullable: false
address: {
paymentCurrency: string,
productCurrency: string,
productAmount: string
}
}
- Nullable: false
Get Fees
feeRequest = {
paymentCurrency: string,
productCurrency: string,
productAmount: string
}
}
- Nullable: false