Create an invoice
POST /invoices
Facade POS
MERCHANT
HTTP Request
Example code to create invoice
let buyer = new Buyer();
buyer.email = "[email protected]";
buyer.name = "Bily Matthews";
buyer.address1 = "168 General Grove";
buyer.address2 = "";
buyer.locality = "Port Horizon";
buyer.region = "New Port";
buyer.postalCode = "KY7 1TH";
buyer.country = "AD";
buyer.phone = "+990123456789";
buyer.notify = true;
let invoiceData = new BitPaySDKLight.Models.Invoice(6.02, Currencies.USD);
invoiceData.buyer = buyer;
invoiceData.orderId = '65f5090680f6';
invoiceData.fullNotifications = true;
invoiceData.extendedNotifications = true;
invoiceData.notificationURL = "https://hookb.in/1gw8aQxYQDHj002yk79K";
invoiceData.redirectURL = "https://hookb.in/1gw8aQxYQDHj002yk79K";
invoiceData.itemDesc = 'Ab tempora sed ut.';
invoiceData.notificationEmail = '[MERCHANT EMAIL ADDRESS]';
let invoice;
invoice = await client.CreateInvoice(invoiceData);
HTTP Response
{
"facade": "pos/invoice",
"data": {
"url": "https://bitpay.com/invoice?id=KSnNNfoMDsbRzd1U9ypmVH",
"status": "new",
"price": 10,
"currency": "USD",
"orderId": "20210511_abcde",
"invoiceTime": 1620734545366,
"expirationTime": 1620735445366,
"currentTime": 1620734545415,
"id": "KSnNNfoMDsbRzd1U9ypmVH",
"lowFeeDetected": false,
"amountPaid": 0,
"displayAmountPaid": "0",
"exceptionStatus": false,
"redirectURL": "https://merchantwebsite.com/shop/return",
"refundAddressRequestPending": false,
"buyerProvidedInfo": {},
"paymentSubtotals": {
"BTC": 18200,
"BCH": 744500,
"ETH": 2535000000000000,
"GUSD": 1000,
"PAX": 10000000000000000000,
"BUSD": 10000000000000000000,
"USDC": 10000000,
"XRP": 7084249,
"DOGE": 2068707100,
"DAI": 9990000000000000000,
"WBTC": 18100
},
"paymentTotals": {
"BTC": 29800,
"BCH": 744500,
"ETH": 2535000000000000,
"GUSD": 1000,
"PAX": 10000000000000000000,
"BUSD": 10000000000000000000,
"USDC": 10000000,
"XRP": 7084249,
"DOGE": 2068707100,
"DAI": 9990000000000000000,
"WBTC": 18100
},
"paymentDisplayTotals": {
"BTC": "0.000298",
"BCH": "0.007445",
"ETH": "0.002535",
"GUSD": "10.00",
"PAX": "10.00",
"BUSD": "10.00",
"USDC": "10.00",
"XRP": "7.084249",
"DOGE": "20.687071",
"DAI": "9.99",
"WBTC": "0.000181"
},
"paymentDisplaySubTotals": {
"BTC": "0.000182",
"BCH": "0.007445",
"ETH": "0.002535",
"GUSD": "10.00",
"PAX": "10.00",
"BUSD": "10.00",
"USDC": "10.00",
"XRP": "7.084249",
"DOGE": "20.687071",
"DAI": "9.99",
"WBTC": "0.000181"
},
"exchangeRates": {
"BTC": {
"USD": 55072.459995,
"EUR": 45287.42496000001,
"BCH": 40.884360403999914,
"ETH": 13.953840617367156,
"GUSD": 55072.459995,
"PAX": 55072.459995,
"BUSD": 55072.459995,
"USDC": 55072.459995,
"XRP": 38907.54307403195,
"DOGE": 113694.39064944115,
"DAI": 55018.486859390934,
"WBTC": 0.9983514430763876
},
"BCH": {
"USD": 1343.1537000000003,
"EUR": 1104.481875,
"BTC": 0.02437664632426631,
"ETH": 0.34031805835672807,
"GUSD": 1343.1537000000003,
"PAX": 1343.1537000000003,
"BUSD": 1343.1537000000003,
"USDC": 1343.1537000000003,
"XRP": 948.9100440136494,
"DOGE": 2772.8748903518513,
"DAI": 1341.8373575522414,
"WBTC": 0.024348638771359274
},
"ETH": {
"USD": 3944.6466899999996,
"EUR": 3242.8077850000004,
"BTC": 0.07159065804331831,
"BCH": 2.9284029977060646,
"GUSD": 3944.6466899999996,
"PAX": 3944.6466899999996,
"BUSD": 3944.6466899999996,
"USDC": 3944.6466899999996,
"XRP": 2786.8105223000134,
"DOGE": 8143.529484384802,
"DAI": 3940.7807840508463,
"WBTC": 0.07150840394174397
},
...
},
"supportedTransactionCurrencies": {
"BTC": {
"enabled": true
},
"BCH": {
"enabled": true
},
"ETH": {
"enabled": true
},
...
},
"minerFees": {
"BTC": {
"satoshisPerByte": 79.152,
"totalFee": 11600
},
"BCH": {
"satoshisPerByte": 0,
"totalFee": 0
},
"ETH": {
"satoshisPerByte": 0,
"totalFee": 0
},
...
},
"jsonPayProRequired": false,
"paymentCodes": {
"BTC": {
"BIP72b": "bitcoin:?r=https://bitpay.com/i/KSnNNfoMDsbRzd1U9ypmVH",
"BIP73": "https://bitpay.com/i/KSnNNfoMDsbRzd1U9ypmVH"
},
"BCH": {
"BIP72b": "bitcoincash:?r=https://bitpay.com/i/KSnNNfoMDsbRzd1U9ypmVH",
"BIP73": "https://bitpay.com/i/KSnNNfoMDsbRzd1U9ypmVH"
},
"ETH": {
"EIP681": "ethereum:?r=https://bitpay.com/i/KSnNNfoMDsbRzd1U9ypmVH"
},
...
},
"token": "8nPJSGgi7omxcbGGZ4KsSgqdi6juypBe9pVpSURDeAwx4VDQx1XfWPy5qqknDKT9KQ"
}
}
To get the generated invoice url and status
let invoiceUrl = invoice.url;
let status = invoice.status;
WARNING:
If you get the following error when initiating the client for first time:
"500 Internal Server Error` response: {"error":"Account not setup completely yet."}"
Please, go back to your BitPay account and complete the required steps.
More info here