MonetizationEvent.incomingPayments
Experimental
incomingPayments
is experimental technology. Check the Browser Compatibility Table before using.
The incomingPayments
property of the Monetization Event interface returns a URL representing an incoming payment at the monetization receiver.
Value
A string that represents a URL that can be used to verify payment at the monetization receiver via the Open Payments API standard.
Examples
/** @type {MonetizationEvent} event */
async function verifyPayment(event) {
// Legacy receivers don't support returning incoming payment URLs
if (!event.incomingPayment) {
throw new Error('No incoming payment URL')
}
const response = await fetch(event.incomingPayment, {
method: 'GET',
credentials: 'same-origin',
mode: 'same-origin',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
})
if (response.ok) {
// The incoming payment was fetched successfully
const { receivedAmount } = JSON.parse(response.json())
const { amount, assetCode, assetScale } = receivedAmount
console.log(`Received ${assetCode}${amount / Math.pow(10, assetScale)}.`)
}
}
Specifications
Specification |
---|
Web Monetization API #verifying-a-payment |
Browser compatibility
desktop | mobile | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | Puma Browser | |
receipt | Yes | Yes | Yes | No | Yes | No | No | No | No | No | No | No | Yes |
- Full Support
- No Support
- You'll need to use a Web Monetization Extension