Using Raw API
This method is the most flexible way to make a MixPay payment.
It's suitable for scenarios that can not use a browser, such as the Mobile Native App.
Constructing the accept payment view
When a customer makes a purchase, on your App check-out page, show a "Pay with Crypto" button. When the customer clicks the button, you should construct an App view like our MixPay payment page.
In this view:
- Using Quote Assets API to fetch the price in any supported cryptocurrency;
- Using Payment Assets API to let customers select which cryptocurrency they want to pay;
- Tip: Above API calls can all happen on your App Side.
When the customer clicks to choose a payment method, based on which wallet has been chosen:
If the customer chooses "Mixin Wallet", you can call our accepting-payments API to create a payment;
If the customer chooses other payment methods, you should call our on-chain-payments API to create a payment;
When payment is created successfully, your App base the response and performs corresponding actions to collect user payments (This step will explain later).
When the customer finishes paying crypto ( depending on what cryptocurrency the customer chooses to pay, the delay varies from 5 seconds to 30mins or more), showing a "Waiting Payment Processing" hint to the customer;
In the meantime, the App client uses the
orderIdto call payments-results API for checking payment results. Or using the Payment Callback on your server side.
It's recommended to make the Payments Results API call every two seconds.
Pay with Mixin wallet
In step 3, if the customer is selecting Pay using Mixin Wallet, your App should call accepting-payments API.
When getting the MixPay API result, your App client has to call Mixin App using URL Schema(What is URL Schema? ) to finish the payment:
As you can see, there are parameters in the Mixin URL Schema, those parameter value are matching Accepting Payments response as following:
// Mixin Param = MixPay Accepting Payments API result
Just passing the key value correspondingly, and the URL Schema will do the rest.
For more info for Mixin URL Schema, please read this article.
Pay with other payment methods
In step 3, if the customer chooses other payment methods, your App should call on-chain payment API.
Note: on-chain-payments API and accepting-payments API use the same endpoint; the only difference is the on-chain payment API payload with an
isChainkey set to
At the on-chain-payments API JSON Response, there is a key call
destination; this is the Address customer has to transfer the cryptocurrency.
You can reference the following UI to construct your App View:
Note: If the payment assets are EOS, you can use the
destinationfrom the API result.
There are two kinds of expiration on creating a MixPay payment.
1. Payment expired (closed)
In online shopping flow, sometimes you have this business logic - when your order expired, you need to release the inventory.
You can provide the
expiredTimestamp parameter, to keep the MixPay payment in sync with your order expiration time.
When MixPay payment expired, the user will not be able to able to pay. (You need to construct the UI on your side.)
If you leave
expiredTimestamp parameter empty, this payment will be valid.
2. Tolerate period expired (refresh needed)
If the customer's payment asset is different than the settlement assets, let's say the payment asset is BTC and the settlement asset is ETH. MixPay will convert BTC to ETH internally for the merchants.
But due to the risk of crypto price fluctuations, for example, if the customer is finishing the payment after 24 hours, and the BTC price drops from $25000 to $22000.
So we need to set a reasonable expiration time, otherwise, we may suffer tremendous loss. This expiration time we call it "tolerate period".
"tolerate period" is defined internally. When creating a payment, will have there two fields in the response:
// Unit Timestamp for accuracy
// A little helper for setting up the countdown
When the "tolerate period" is expired, you must request the create payment API with the same parameters. MixPay will recalculate the
If a customer pays with a "tolerate period" expired payment, if is "Pay with Mixin wallet", the crypto assets will refund, and the payment result will be
payment overtime. If is "Pay using an on-chain Wallet", due to the crypto transfer's nature, we can not refund the money directly, we must get the customer's wallet address first, in this scenario, you can instruct the customer to contact our customer service.
Getting the result
At this point, customers are paying crypto using our Paylink; how can you get the paying results?
On your server side, you can loop through the payments-results API using
It's recommended to implement the Payment Callback flow, for better performance.