JSFiddle - React, Tailwind, and code Playground

by Hemanth HM

HTML

<button id="pay">PAY</button>

JavaScript

const pay = document.querySelector('#pay');
pay.addEventListener('click', async () => {
  const request = new PaymentRequest([{
     supportedMethods: 'https://bobpay.xyz/pay'
  }], {
    total: { label: 'Total', amount: {
      currency: 'USD', value: '1.00',
    }}
  });
  try {
    // if (await request.canMakePayment()) {
      const result = await request.show();
      console.log(result);
      result.complete('success');
    // } else {
    //   console.error('Not able to make payment');
    // }
  } catch (e) {
    console.error(e);
  }
});