0.2.14 • Published 3 years ago

@anypayinc/widget v0.2.14

Weekly downloads
16
License
ISC
Repository
github
Last release
3 years ago

Add the following to your page's head tag:

<script src="https://unpkg.com/@anypayinc/widget/anypay.min.js"></script>

Then, whenever you want to trigger an anypay invoice widget, just call:

anypay.collectPayment({
  accountId: '1177',
  amount: 0.01
})
.once('loaded', () => {
  console.log('Anypay iFrame loaded');
})
.once('canceled', () => {
  // This will only fire if the server marks
  // the invoice with status: 'canceled'
  console.log('Invoice was canceld');
})
.once('underpaid', () => {
  console.log('Invoice underpaid');
})
.once('overpaid', () => {
  console.log('Invoice overpaid');
  setTimeout(() => {
    anypay.close();
  }, 2000);
})
.once('expired', () => {
  console.log('Invoice expired');
})
.once('paid', () => {
  console.log('Invoice paid');
  setTimeout(() => {
    anypay.close();
  }, 2000);
})

Using Platform Semantics

anypay.newPayment([{ currency: 'BSV', to: { address: '', amount: 0.01, currency: 'USD' }, { address: '', amount: 0.05, currency: 'USD' }, { address: '', amount: 10.15, currency: 'USD' } }]) .once('loaded', () => { console.log('Anypay iFrame loaded'); }) .once('canceled', () => { // This will only fire if the server marks // the invoice with status: 'canceled' console.log('Invoice was canceld'); }) .once('underpaid', () => { console.log('Invoice underpaid'); }) .once('overpaid', () => { console.log('Invoice overpaid'); setTimeout(() => { anypay.close(); }, 2000); }) .once('expired', () => { console.log('Invoice expired'); }) .once('paid', () => { console.log('Invoice paid'); setTimeout(() => { anypay.close(); }, 2000); }) .once('closed', () => { console.log('Anypay iFrame closed'); })

You can also add the following options to the widget:

anypay.collectPayment({
  moneyButton: false,
  relayX: false,
  qrCode: false,

  accountId: '1177',
  amount: 0.01
});

Then to minimize the anypay.js and anypay.css files, bump the versions and publish to unpkg.com, first run:

npm install

Then run:

./build
0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.9

3 years ago