Request Invoice for Quote

Request a Lightning Network invoice from the UPI provider. The web app provides the payment amount either in satoshis or in INR, and the function returns a BOLT-11 invoice. The function could also optionally provide a price quote in INR.

Method

POST https://prod.ninjapay.me/sapi/v1/requestQuote

Parameters


{
  quote_id: string; // The quote ID obtained from the requestQuoteID() method.
  callback_url?: string // Add webhook to get response on successful payment.
}

Response


{
  "tid": int, // The transaction id of this quote
  "sending_asset": string; // "btc" or "usdt" for btc/usdt to inr conversion.
  "sending_asset_amount": int; // The amount to pay for fiat conversion.
  "fiat_amount": int; // The fiat amount that the upi id will receive.
  "lightning_invoice": string, // The Lightning invoice to pay.
  "onchain_address": string, // The on-chain address to pay if lightning payment not possible..
  "onchain_address_network": string, // BTC, ERC20, BEP20...
  "expires_at": int, // The expiry time for the payment quote.
  "callback_url": string // The webhook url to get response on successful payment.
  "receiver_upi_id": string, // The UPI ID to which the fiat amount will be sent.
  "receiver_ninjatag": string // The Ninjatag of the recipient you want quote for.
}

Note: After the Lightning invoice payment, in case the UPI payment transfer fails, the BTC funds will be sent back to the merchant wallet mentioned during the Quote ID request.

Payment Success Response

Upon successful payment, the Ninjapay platform sends the fiat amount to the provided UPI ID and gives a success response to the callback_url.

Response


{
  "tid": int, // The transaction ID for the successful payment.
  "status": string // you get "success" 
  "receiver_upi_id": string, // The UPI ID to which the fiat amount was sent.
}

Code Example


const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'API_KEY'
  },
  body: '{""quote_id":"aa1728acff604222a96d1343f9246c12","callback_url":"https://yourwebhook.com"}'
};

fetch('https://prod.ninjapay.me/sapi/v1/requestQuote', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  

In this version of the function, the amount to be paid can only be specified in INR. The Ninjapay exchange provider will then generate a Lightning Network invoice quote for that amount. The specifics of the implementation would again depend on the particular Business and the exchange rate used.

Last updated