🛰️
xPay.Stream
  • 📡xPay.Stream
  • 📌Prerequisites
  • Authentication API
  • Wallets
    • Create Wallet
    • Update Wallet
    • Get Wallet Info
    • Search Wallets
  • Billing
    • Create Bill
    • Cancel Bill
    • Get Bill Info
    • Search Bills
  • Transactions
    • 〰️Preview Transaction
    • ✔️Broadcast Transaction
    • 🔎Search Transactions
  • Notifications
    • Webhook
    • Email Alerts
Powered by GitBook
On this page
  1. Billing

Create Bill

Create a new Invoice for billing, supporting USDT (over TRON) or Bitcoin Lightning

PreviousBillingNextCancel Bill

Last updated 9 months ago

API Endpoint

POST


Request Headers:

Authorization: Bearer

Content-Type: application/json Request Body:

{
     amount: "1000000", // USD with 6 decimals uint, 1USD = 1000000
     tag: "bill-tag",   // Some useful tag for searching
     expireInMinutes: "30" // Bill Expires After 30 Minutes
     reference: "unique-ref" // Unique Non Reusable Bill Reference
     useLightning: true // when payment via bitcoin lightning network
}

Success Response You will get under the created wallet details under thesuccess.data

Wallet Address: success.data.address.base58

Wallet Identifier: success.data.uuid

Sample Below:

{
    "success": {
        "message": "bill created",
        "data": {
            "uuid": "827c5bce-a0f4-47b3-a4fe-aa16897882ae",
            "username": "user@xpay.stream",
            "wallet": "68e457c5-d8fb-4d62-ac5b-62fd6fd46484",
            "hex": "", // case of USDT TRON - Address to Pay
            "address": "", // case of USDT TRON - Address to Pay
            "createdAt": 1724149286283,
            "billRef": "1bdce316",
            "billAmount": 10000000,
            "paidAmount": 0,
            "testnet": false,
            "tag": "XPAY-83cd",
            "starting": 1724149226283,
            "until": 1724151086283,
            "closed": false,
            "canceled": false,
            "cooldown": 0,
            "txs": [],
            "lnInvoice": { // case of BTC Lightning Invoice to Pay
                "createdAt": 1724149286,
                "externalId": "68bc2ddf8b2cddbc0efee6d82fb43f81ac57259023f5d3822103d6b6b2701bdd",
                "paymentRequest": "lnbc164540n1pnvgm3xpp5dz7zmhut9nwmcrh7umvzldplsxk9wfvsy06a8q3pq0ttdvnsr0wsdp68qerwce4vf3k2ttpxpnrgtf5xa3rxttpx3nx2ttpvycnvwpexuursvnpv5cqzpuxqrpkvsp54e6ds39frtcjrhg3msydq07vjtdgv7wzv8zjjqv8nmngmah5tvyq9qxpqysgqp62fy08w5jxv3cgd720euaa4xp5jjwa369c8rmaryxl302ralz6rknhk9ffgmaxwrhhgdcu0n7z34y04gevsdguwd6jd9r9pvyc20wsqhw3mt5",
                "paymentHash": "68bc2ddf8b2cddbc0efee6d82fb43f81ac57259023f5d3822103d6b6b2701bdd",
                "paymentSecret": "ae74d844a91af121dd11dc08d03fcc92da8679c261c52901879ee68df6f45b08",
                "paymentStatus": "PENDING",
                "satoshis": 16454,
                "dollars": 10
            },
            "callbackURL": "https://mycallback.com/bill-alert", // Customer - xPAY Web Redirect
            "email": "user@gmail.com" // Send Invoice To Customer
        }
    },
    "uuid": "08d3b9c9-602d-403e-ba86-d1edbd50feec"
}

curl 'https://apis.xpay.stream/client/bills/save' \
  -H 'Content-Type: application/json'               \
  -H 'Authorization: Bearer <access_token>'         \
  --data-raw '{"amount":10000000,"tag":"XPAY-83cd","expireInMinutes":"30","reference":"1bdce316","email":"customer@gmail.com","callbackURL":"https://mycallback.com/bill-alert","useLightning":true}'              
// npm i cross-fetch
const fetch = require("cross-fetch");

const API_URL = "https://apis.xpay.stream/client/wallets/save";

const method = "POST";

const headers = { 
    "Content-Type": "application/json",
    "Authorization": "Bearer <access_token>"
};

const body = JSON.stringify({ 
   "amount":10000000,
   "tag":"XPAY-83cd",
   "expireInMinutes":"30",
   "reference":"1bdce316",
   "email":"customer@gmail.com",
   "callbackURL":"https://mycallback.com/bill-alert",
   "useLightning":true
});

fetch(API_URL, { headers, body, method })
.then(async res =>  await res.json())
.then(result => {
    if(result.error)
        console.log("Bill Creation Error", result);
    if(result.success)
        console.log("Bill Created", result);
})
.catch((err) => {
    console.error("Bill Create API Exception", err);
});

/client/bills/save
<access_token>