@bitcoin-suisse/pay
Version:
Bitcoin Suisse Pay plugin for crypto payments
59 lines (50 loc) • 2.31 kB
HTML
<html>
<head>
<title>Bitcoin Suisse Pay - Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- If lib is added directly and not compiled into a larger codebase, then include exports snippet below. -->
<script>
var exports = { __esModule: true };
</script>
<script type="text/javascript" src="../../../dist/libs/pay-plugin/src/index.js"></script>
</head>
<body>
<div id="terminal-container"></div>
<script>
new CryptoPayments({
terminalId: '123456789',
auth: '0000...',
paymentId: '0000000001',
amount: 1337,
fromCurrency: 'CHF',
paymentCallbackUrl: 'https://www.example.com',
language: 'en',
target: document.getElementById('terminal-container'),
referenceId: '12345-12345-12345',
})
.create()
.then(data => {
console.log('data:', data);
// This is called when a payment has been successfully interacted with.
// The terminal view will remove itself.
// Payment states 👇
// "crypto-payments-status-PAID":
// "crypto-payments-status-PAIDOVER":
// "crypto-payments-status-PAIDLATE":
// "crypto-payments-status-PAIDPARTIAL":
// Up to the client if they want to redirect to a certain success URL or update SPA accordingly.
})
.catch(errorData => {
console.log('data:', errorData);
// This is called when a payment has an error
// Terminal view will remove itself
// Payment states 👇
// "crypto-payments-status-CANCELED":
// "crypto-payments-status-EXPIRED":
// Up to the client if they want to redirect to a certain error URL up update SPA accordingly.
});
</script>
</body>
</html>