OxaPay

With the OxaPay merchant webservice, you can accept crypto payments from your customers in a fast, secure and hassle-free way, without the need for KYC.
Try out the sample bot and see for yourself how OxaPay can simplify your crypto payment experience
You can install and test demo bot with this lib.
Please see Store > Crypto > OxapayLibSampleBot

Initial setup

  1. 1.
    Register in OxaPay
  2. 2.
    Log in to your OxaPay account and create a merchant key by filling in the fields and selecting accepted coins on the merchants page.
  3. 3.
    In “your merchant keys” table, copy the generated merchant key.
  4. 4.
    Install OxaPay lib and write /setup command that run the below code:
Libs.OxaPayLib.setMerchantKey("YOUR_MERCHANT_KEY");
You can use ‘oxapay’ as the merchant key to test the merchants webservice (Crypto Payment Gateway).
Just run the bot and execute this command /setup. Then you can remove it.

Methods

setMerchantKey
Set your merchant key to setup the merchant gateway
createTransaction
Register order informations and returns payment info such as trackId and payLink to connect OxaPay payment gateway.
transfer
Transfer funds to other accounts without fee (OxaPay internal transaction).
getTxInfo
Returns report of a payment session such as status, pay time, amount, etc.
getAcceptedCoins
Returns the list of your merchant's accepted coins.

Receiving Payments

To create a payment link, you must first install Webhook Lib from the Libs and then receive your payment link by executing the createTransaction method with sending payment parameters!
The payment parameters are as follows:
Amount (require)
Float
Total amount (as dollar if currency filed was not filled. Otherwise amount should be filled with your specified currency amount)
currency
String
If you want that your invoice to be paid by a specified currency fill in this field with its symbols (Find the list of currencies symbol in the accepted coins section)
description
String
Order details (will be shown in different reports)
orderId
String
Your unique order ID (optional - used in reports)
email
String
User's email for the report
The above parameters are set in the `fields` property and onCreatePayment property is also needed to be run after creating the payment. It will return the payment information including the following fields.
result
Request result. Read more
message
The message containing the result of the request.
trackId
The unique identifier of each payment session of the OxaPay payment gateway, which can be used to query the payment status and report requests (if the request be successful).
payLink
The set payment page link according to the trackId field (if the request is successful).
You need to define the command that should be called when the payment is created and in that command, you will get the above information.
You also need the onCompletePayment command to get the transaction information after the payment has been made to the address.

For example:

Command /pay
let amount = 100; // amount in TRX
options = {
fields: {
amount: amount, // amount in TRX
// you can set the rest of the fields as optiona
// currency: "trx",
// description: "Hello World!",
// orderId: "AB-1122",
// email: "[email protected]"
},
onCreatePayment: '/onCreatePayment',
}
Libs.OxaPayLib.createTransaction(options);
Command /onCreatePayment
// for security we need to check that this command runned only by lib
// user can not run command with options
if (!options) return
// You can inspect all options:
Bot.inspect(options)
// You can send message with pay link
Bot.sendMessage("Payment link:\n" + options.payLink)
// You can send message with web app
Api.sendMessage({
text: "Pay in web app",
reply_markup: {
inline_keyboard: [[{ text: "Pay", web_app: { url: options.payLink } }]]
}
})
// You can store this information for future inquiries
Command /onCompletePayment
// for security we need to check that this command runned only by lib
// user can not run command with options
if(!options) return
Libs.OxaPayLib.getTxInfo(
{ fields: { trackId: options.trackId },
onSuccess: "/onTxSuccess" }
)
Command /onTxSuccess
// for security we need to check that this command runned only by lib
// user can not run command with options
if (!options) return
// 100 - payment done
if (options.result == 100){
Bot.sendMessage(options.transaction.amount + " " +
options.transaction.coin + " paid successfully!")
}
// 203 - Invalid trackId
if (options.result == 203){
Bot.sendMessage(options.message)
}

Transaction Info

You can query the entire payment information by the getTxInfo method. for this purpose, you need payment trackId. The information includes the following fields.
message
The message containing the result of the request
result
Request result. Read more
paidAt
Order payment date - in ISODate format (if the payment is successful)
verifiedAt
Order verify date - in ISODate format (if the payment is successful)
status
Payment status (you can check the status values through the status table)
amount
Order amount (as dollar, if currency filed was not filled. Otherwise, amount should be filled with your specified currency amount)
currency
If you want that your invoice to be paid by a specified currency fill in this field with its symbol (Find the list of currencies symbol in the accepted coins section)
orderId
Order ID (if the payment is successful and sent in the request gateway)
description
Transaction description (if the payment is successful and sent in the request gateway)
email
User's email for report (if the payment is successful and sent in the request gateway)
wage
How to deduct fees 0: deduction from the transaction, 1: Deduction from the fee wallet, 2: In charge of the customer
createdAt
Order create date - in ISODate format
transaction
This property contains 3 fields: Coin // Paid currency symbol
Amount // Paid currency amount
txId // Paid transaction hash

Transactions status table

-3
Canceled by the user
-2
Unsuccessful payment
-1
Payment pending
1
Paid, verified
2
Paid, Not verified

For example:

Command /txInfo
options = {
fields: {
trackId: YOUR_TRACK_ID
},
onSuccess: "/onTxInfo"
}
Libs.OxaPayLib.getTxInfo(options)
Command /onTxInfo
// for security we need to check that this command runned only by lib
// user can not run command with options
if(!options) return
// You can inspect all options
Bot.inspect(options)

Accepted coins

Use getAcceptedCoins method to get the list of your merchant's accepted coins.

For example:

Command /acceptedCoins
Libs.OxaPayLib.getAcceptedCoins({ onSuccess: "/onAcceptedCoins" })
Command /onAcceptedCoins
// for security we need to check that this command runned only by lib
// user can not run command with options
if(!options) return
Bot.sendMessage("Your merchant's accepted coins are " + options.allowed.join(','))
// You can also send the list to the user to choose the coins for payment