The hosted payment page is the quickest way to accept stablecoins. Your server creates a payment, you redirect the customer to a Triple-A page where they pick a coin and pay, and a signed webhook tells you when to deliver. This blueprint takes you from your first access token to going live.
You need the following.
These pages explain the product and walk through the same flow as a tutorial.
What the product does and how a payment flows from payer to settlement.
The same checkout as a tutorial, with more detail on each step.
Follow these steps in order.
POST /oauth/token
Every call needs an OAuth access token. To get one, call POST /oauth/token from your server with your Client ID and Client Secret. The highlighted line sets grant_type, which must be client_credentials.
curl --request POST \
--url https://api.triple-a.io/api/v2/oauth/token \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=YOUR_CLIENT_ID' \
--data-urlencode 'client_secret=YOUR_CLIENT_SECRET' \
--data-urlencode 'grant_type=client_credentials'The response holds the token and its lifetime in seconds. The highlighted line is the access_token to send as Authorization: Bearer YOUR_ACCESS_TOKEN in every later request.
{
"access_token": "1ba8...",
"token_type": "bearer",
"expires_in": 3600
}Cache the token and refresh it shortly before expires_in runs out, rather than requesting a new one for every call. Never put the Client Secret in client-side code.
POST /payment
Call POST /payment from your server with type set to triplea. The highlighted lines set up the hosted page. type asks for the hosted page, and success_url and cancel_url are where Triple-A sends the customer afterwards.
curl --request POST \
--url https://api.triple-a.io/api/v2/payment \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"type": "triplea",
"merchant_key": "YOUR_MERCHANT_KEY",
"order_currency": "USD",
"order_amount": 10,
"order_id": "ORDER-1001",
"notify_url": "https://your-server.example.com/webhook",
"notify_secret": "a-long-random-secret",
"success_url": "https://your-shop.example.com/success",
"cancel_url": "https://your-shop.example.com/cancel",
"sandbox": true
}'The table below describes the fields in this request.
| Field | Required | Notes |
|---|---|---|
type | Yes | triplea redirects the customer to a Triple-A hosted page. |
merchant_key | Yes | Identifies your merchant account. You receive it when you sign up. |
order_currency, order_amount | Yes | The price, with a 3-character ISO 4217 currency code. |
order_id | Optional | Your own reference, up to 255 characters. |
notify_url, notify_secret | Optional | Where Triple-A sends the webhook and the secret that signs it. Without them, Triple-A uses your account’s webhook URL and generates a secret for this payment. |
success_url, cancel_url | For triplea | Where Triple-A sends the customer after the payment. |
sandbox | For testing | true marks a test payment. |
You don’t send a coin or network, because the customer picks one on the hosted page. Save the payment_reference and hosted_url from the response.
The following is an example response. The highlighted lines are the payment_reference to store and the hosted_url to send your customer to.
{
"payment_reference": "AQH-100306-PMT",
"order_currency": "USD",
"order_amount": 10,
"expiry_date": "2020-04-22T08:52:11.842Z",
"access_token": "736511b8...",
"token_type": "Bearer",
"expires_in": 1499,
"hosted_url": "https://triple-a.io/app/v1/payment_form?payment_reference=AQH-100306-PMT&access_token=..."
}The access_token in this response belongs to the payment form. It isn’t your API access token.
Redirect the customer’s browser to hosted_url. On the hosted page, the customer picks a digital currency and network and pays from their wallet. Triple-A then sends them to your success_url, or to your cancel_url when the form expires without a payment or the customer paid too little.
The success_url redirect is a front-end event that fires when a payment is detected. Treat it as hold, not as confirmed, and wait for the webhook before you fulfil.
Triple-A sends an HTTP POST to your notify_url each time the payment status changes. Your endpoint verifies the signature and responds with a 2xx status. Follow these steps in your handler.
Triplea-Signature header with your notify_secret. See Verify the signature.payment_reference and status from the body.The following body is a shortened example of a payment notification. The highlighted lines are the payment_reference that matches your order and the status you act on.
{
"event": "payment",
"api_id": "HA123456789012_t",
"payment_reference": "AQH-100306-PMT",
"order_currency": "USD",
"order_amount": 10,
"crypto_currency": "testBTC",
"payment_currency": "USD",
"payment_amount": 10,
"status": "good"
}If you don’t respond with a 2xx status, Triple-A retries up to five times. The same notification can then arrive more than once, so make your handler safe to run twice for the same payment.
GET /payment/{payment_reference}
Webhooks are the recommended way to learn about status changes. You can also read the payment directly, for example when a webhook never arrives. The highlighted line is the payment_reference you saved when you created the payment.
curl --request GET \
--url https://api.triple-a.io/api/v2/payment/AQH-100306-PMT \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN'The response describes the payment and its current status. The following is a shortened example response. The highlighted line is the status to act on.
{
"payment_reference": "AQH-100306-PMT",
"order_currency": "USD",
"order_amount": 10,
"crypto_currency": "testBTC",
"payment_currency": "USD",
"payment_amount": 10,
"status": "good"
}Deliver only when the status is good. Any other status means you wait or don’t deliver, as described in Payment statuses. When the status is good, follow these steps.
payment_reference.Reconcile on payment_currency and payment_amount, not on order_currency. They hold the guaranteed amount in your settlement currency.
Sandbox payments use testnet Bitcoin (testBTC) and move no real funds. They use the same host as live payments, and "sandbox": true in the payment request marks a payment as a test. In a sandbox payment, crypto_currency shows testBTC.
To pay a sandbox payment, follow these steps.
crypto_address shown on the payment form, for the amount shown.Test a payment you pay in full and a payment you leave unpaid until the form expires. Check that your integration handles the webhook and the status of each one.
Live payments use the same host and the same calls as the sandbox. To switch, follow these steps.
"sandbox": true from your payment requests, or call Make a payment request (specific account) with your Live API ID.These are the problems you’re most likely to meet in this flow.
401 with unauthorized means the access token is missing, invalid, or expired. Request a new token, and check that the header reads Authorization: Bearer YOUR_ACCESS_TOKEN.409 with cannot_process means the payment has unfulfilled requirements, such as KYC.success_url redirect ships orders that aren’t paid yet. Wait for a good status.These pages are the best places to go next.
The same payment, with the Triple-A form inside your page.
Every webhook field, retries, and a signature verification example.