Crypto Invoices

Every request listed on this page requires authorization to be successfully completed.

Create crypto invoice (server-side)

POST https://public.api.0xpay.app/merchants/invoices/crypto

Returns a webpage URL on 0xpay.app domain for one-time payment.

Important note: crypto invoices will expire after 72 hours. However, the time displayed on payment page is 48 hours. Additional time is given to lower the risk of expiration in case of network delays.

Status Updates: Every invoice update will produce an invoice notification.

Request Body

{
    "id": "123e4567-e89b-12d3-a456-426614174000" //internal ID has been assigned to the invoice
     "url": "https://my.0xpay.app/invoices/crypto/123e4567-e89b-12d3-a456-426614174000" // feel free to redirect user to this URL for payment
}

Create crypto invoice via web form (client-side)

POST https://public.api.0xpay.app/merchants/invoices/crypto/form

Creates a cryptocurrency invoice using parameters from your HTML form defined defined parameters and redirects users to 0xpay URL for payment. on 0xpay.app domain for one-time payment. Instead of authorizing a request, just pass your merchantID along with other parameters.

Expiration time: 72 hours for crypto. However, the time displayed on payment page is 48 hours. Additional time is given to lower the risk of expiration in case of network delays.

Status Updates: Every invoice update will produce an invoice notification.

Request Body

Redirects to payment webpage URL

Crypto invoice web form example:

<!DOCTYPE html>
<html lang="en">
  <body>
    <script src="index.js"></script>
    <form method="post" action="https://public.api.0xpay.app/merchants/invoices/crypto/form">
      <input type="text" name="merchantId" value="806dbc17-d371-4179-8718-b208be848180" /> <br />
      <input type="number" name="value" value="0.01"> // optional value, can be hidden
      <input type="text" name="ticker" value="BTC"> // optional input, cn be hidden
      <input type="text" name="blockchain" value="BITCOIN"> // optional input, cn be hidden
      <input type="text" name="meta" value="user-id" /> <br />
      <input type="text" name="name" value="invoice name" /> <br />
      
      <!-- auto-targeting -->
      <!-- 
        here is, after depositing to invoice, 
        0.1 BTC will be exchanged for USDT and after this withdraw 
        to the address T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb in the TRON network
      -->
      <input type="text" name="targetTicker" value="USDT" /> // optional <br />
      <input type="text" name="targetAddress" value="T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb" /> // optional <br />
      <input type="text" name="targetBlockchain" value="TRON" /> // optional <br />
      <button type="submit">Pay!</button>
    </form>
  </body>
</html>

Find crypto invoice details by ID

GET https://public.api.0xpay.app/merchants/invoices/crypto/:id

This method is used to get invoice's data by it's id.

Path Parameters

When fetching an invoice, it can come with different status that can be equal to: | 1. CREATED 2. REGISTERED (address allocated) 3. PENDING (1 deposit at least catched) 4. PAID 5. EXPIRED (ran out of timeout)

{
    "id": "eb929d63-5f05-4d9f-9d3e-854384009ef1", //invoice id
    "name": "Order payment",
    "merchantId": "asdasd-asdasd-asdasd-asdad" 
    "company": {
        "name": "CompanyName",
        "url": "example.com"
    },
    "amount": {    //amount of assets to be paid via invoice
        "value": "0.4",
        "ticker": "BTC",
        "blockchain": "BITCOIN"
    },
    "fee": "0.0025", //only exists if status is PAID
    "paidAmount": "0.5", // amount received to the invoice. Note: paidAmount can be less then amount in case of underpayment and more then amount in case of overpayment
    "status": "PAID", //status of the invoice
    "createdAt": 1666091014270, //time of invoice creation
    "expiredAt": 1666350193695, //time of invoice expiration, exists after status changes to "REGISTERED"
    "meta": "i-want-to-know-about-that"
}

Close invoice

POST https://public.api.0xpay.app/merchants/invoices/crypto/:id/close

Close invoice on-demand. For example: the user paid half of the invoice amount and you want to close it before the full payment

The invoice will be immediately transferred to the "PAID" status

Last updated