Step 5 – Payment Button Callback

The last parameter that you must configure to use the payment button, it will be the callback through which it will describe the function that will be executed the customer’s payment has been made. For this configuration copy the following code specification of the algorithm to be executed.

CryptoBucks.onPaymentReceived = function (data) {
//validations to perform with the received data
};

 

The information returned by the callback to perform the validations is the following:

{

“crypto”: “string”,
“cryptoAmount”: 0.0,
“cryptoFee”: 0.0,
“fiatAmount”: 0.0,
“fiatRate”: 0.0,
“hash”: “string”,
“invoice”: “string”,
“invoiceStatus”: “string”

}

 

  • crypto: string (crypto currency symbol)
  • cryptoAmount: number (amount received in crypto)
  • cryptoFee: number (the fee charged by the blockchain, this is charged to the client by the blockchain)
  • fiatAmount: number (cryptoAmount*fiatRate)
  • fiatRate: number (conversion rate at which the transaction was converted to USD)
  • hash: string (blockchain hash transaction)
  • invoice: string (CryptoBucks invoice ID)
  • invoiceStatus: enum
    • created: “When the merchant makes the request to create a new invoice, meaning the invoice is just created”
    • Sent: “when the invoices is sent through email or sms, does not apply for web payment button”
    • Open: “When the invoice is opened in the payment portal, or in the payment button when the modal is opened”
    • Processing: “As soon as the payment has been received”
    • trading: “a trading of the crypto amount has been initiated to convert into fiat currency”
    • pendingSettlement: “after the trading completes, a settlement request is initiated to the merchant”
    • completed: “The invoice has been settled”
    • expired: “The invoice expires after 15min of not being paid”

At this point it is important to consider that the validations on the completeness of the payment must be programmed based on the responses of the callback, and it will be the responsibility of the merchant to take the corresponding actions according to their tolerance for the dispatch or discount of merchandise, according to the results of the same.