amountSent
The monetization
event’s amountSent
attribute returns you the amount (value
) and currency
) of the Web Monetization payment sent to you.
Value
The value
uses the same data structure as the PaymentCurrencyAmount
dictionary in the Payment Request API. The returned value is the value it was initialized with.
Example
<link rel="monetization" href="https://wallet.example/alice" />
<script>
const link = document.querySelector('link[rel="monetization"]')
link.addEventListener('monetization', (event) => {
// See how much was sent and in what currency
const {
amountSent: { value, currency },
} = event
console.log(`Browser sent ${currency} ${value}.`)
})
</script>
Specifications
Specification |
---|
Web Monetization #amountsent-attribute |