4.0.0 • Published 9 months ago
@confirmo/overlay v4.0.0
Confirmo
npm
npm install @confirmo/overlay
yarn
yarn add @confirmo/overlay
CDN
<script src="https://cdn.jsdelivr.net/npm/@confirmo/overlay@4.0.0/dist/confirmo.js"></script>
Overlay
Bundlers
import { Invoice } from '@confirmo/overlay';
/**
* Opens Confirmo invoice overlay
*
* @param {string} invoice_url - URL of invoice.
* @param {callback} [callback_fnc] - Optional - callback which is called when overlay was closed
*
* @example
*
* // URL of invoice created from REST API
* const invoice_url = 'https://confirmo.demo/#/public/invoice/invv9e1rxdz8';
*
* // Callback which is called when overlay was closed
* const callback_fnc = () => alert('Overlay has been closed');
*/
const overlay = Invoice.open(invoice_url, callback_fnc);
/**
* Closes Confirmo invoice overlay
*/
overlay.close();
Script Tag
<script>
const overlay = Confirmo.Invoice.open(invoice_url, callback_fnc);
overlay.close();
</script>
Payment button
HTML
<div id="placeholder-for-button"></div>
Bundlers
import { PaymentButton } from '@confirmo/overlay';
/**
* Creates Confirmo payment button
*/
const button = PaymentButton.initialize(
{
id: 'placeholder-for-button',
paymentButtonId: 'pbt16354asde',
buttonType: 'SIMPLE',
values: {
productName: 'Some cool product',
productDescription: 'Simple description',
reference: 'merchantRef',
returnUrl: 'https://my-cool-eshop.com/?q=this+is+return+url',
},
},
() => {
console.log('Overlay has been closed!');
}
);
/**
* Removes Confirmo payment button
*/
button.remove();
Script Tag
<script>
const button = Confirmo.PaymentButton.initialize(
{
id: 'placeholder-for-button',
paymentButtonId: 'pbt16354asde',
buttonType: 'SIMPLE',
values: {
productName: 'Some cool product',
productDescription: 'Simple description',
reference: 'merchantRef',
returnUrl: 'https://my-cool-eshop.com/?q=this+is+return+url',
},
},
() => {
console.log('Overlay has been closed!');
}
);
button.remove();
</script>