Skip to main content

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

Browser compatibility