Displaying Invoices
After creating a new invoice via the POST /merchant/invoices route, you will receive a checkoutLink
in the response, to be displayed to your clients.
There are two primary methods to display this invoice:
Embedded IFrame
With an IFrame, you can embed this invoice directly within your site, and customize the display as you see fit.
To create an IFrame, simply use the <iframe>
element within your HTML, supplying the checkoutLink
to the src
attribute.
<iframe title="CoinPayments Checkout" src="https://coinpayments.net/checkout/?invoice-id={id}" allow="clipboard-write"></iframe>
External Pop-Up Window
Alternatively, you can create an external pop-up window to display this invoice, and listen to select events on the new Window
object (such as load
, unload
, focus
, etc.).
To create an external pop-up window, you can get started with the code snippet below:
const url = "https://coinpayments.net/checkout/?invoice-id={id}";
const windowFeatures = "width=500,height=600,resizable=yes,scrollbars=yes,status=yes";
const newWindow = window.open(url, '_blank', windowFeatures);
newWindow.focus();