Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

webpayments

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpayments

Polyfill for proposed Web Payments API

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

webpayments-polyfill

Experimental web payments polyfill

WARNING: The Web Payments spec is still under heavy development. This implementation (and its API) will change often and without notice.

Example

navigator.requestPayment(['interledger'], {
  amount: '100',
  currencyCode: 'USD',
  countryCode: 'US'
}, {
  interledger: {
    account: 'https://localhost:3001/accounts/mellie'
  }
})

Installation

Quickstart

The fastest way to include the polyfill is with a script tag:

<script src="https://web-payments.net/polyfill.js"></script>

Webpack/Browserify

If you are using a tool like webpack or browserify, you can also just install this library from NPM:

npm install -S webpayments

Async embed code

The basic script tag method will be blocking. A non-blocking alternative is the following embed code:

<script>
(function(w,e,b,p,a,y) {
  w[p] = w[p] || (function (cb) { this.push(cb); return this }).bind([]);
  a = e.createElement(b); a.async = 1; a.src = '//web-payments.net/polyfill.js';
  y = e.getElementsByTagName(b)[0]; y.parentNode.insertBefore(a,y);
})(window,document,'script','WebPaymentsOnLoad');
</script>

You can then register a callback to be called when the polyfill has been loaded:

<script>
WebPaymentsOnLoad(function () {
  navigator.requestPayment(/* ... */)
})
</script>

Usage

TODO: Add API documentation

For now, please see the spec: http://discourse.wicg.io/t/rfc-proposal-for-new-web-payments-api/1100

Keywords

web-payments

FAQs

Package last updated on 05 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts