MonetizationEvent
The MonetizationEvent
interface of the Web Monetization API is the event object for web monetization events, which contains the details to facilitate payments.
Properties
- amount (deprecated) : An integer amount delivered by an ILP packet.
- amountSent : A dictionary containing the currency code and amount sent.
- assetCode (deprecated) : A string representing the currency code (eg USD, EUR) of the received amount.
- assetScale (deprecated)
: The scale of the received amount.
- [incomingPayments](/docs/monetization-event-incoming-payments) : A string containing the URL representing an incoming payment at the monetization receiver.
- receipt (deprecated) : The base-64 encoded Interledger Stream receipt that the browser received.
- paymentPointer : A URL representing the payment end-point.
Examples
<link rel="monetization" href="https://example.com/pay" />
<script>
// Checking via DOMTokenList
const link =
document.querySelector('link[rel="monetization"]') ||
document.createElement('link')
if (link.relList.supports('monetization')) {
console.log('Web Monetization is supported.')
}
// Checking global scope for MonetizationEvent
if (window.MonetizationEvent) {
console.log('Web Monetization is supported.')
}
// Checking if it's a global event handler
if (window.hasOwnProperty('onmonetization')) {
console.log('Web Monetization is supported.')
}
</script>