Skip to content

superuserdev/WebPayment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

43ae615 · Mar 6, 2018

History

4 Commits
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018
Mar 6, 2018

Repository files navigation

WebPayment

Build Status


Progressive enhancement for the Web Payment API

Creates a payment form, complete with autocomplete attributes, in a <dialog> to provide a polyfill for the Web Payment API.

import PaymentRequest from './PaymentRequest.js';
document.getElementById('buy-now').addEventListener('click', async () => {
  try {
    const endpoint = new URL('/pay/', location.origin);
    const pay = new PaymentRequest(/* ... */);
    const payment = await pay.show();
    const resp = await fetch(endpoint, {
      method: 'POST',
      body: payment
    });
  } catch(error) {
    console.error(error);
  }
});

About

Progressive enhancement for the Payment Request API

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published