An event that fires when a payment's transaction status is changed.
The onPaymentUpdate()
event handler runs when a payment's transaction status has changed.
The received PaymentUpdateEvent
object contains information about the payment transaction.
Note: Backend events don't work when previewing your site.
function onPaymentUpdate(event: PaymentUpdateEvent): void;
The payment data.
// Place this code in the events.js file
// of your site's Backend section.
export function wixPay_onPaymentUpdate(event) {
let paymentId = event.payment.id;
let newTransactionStatus = event.status;
}
/* Full event object:
* {
* "payment": {
* "id": "8b3c1a90-c09e-4cd7-ae9d-9801151d8ad9",
* "amount": 15.99,
* "currency": "USD",
* "items": [
* {
* "name": "Baseball Bat",
* "quantity": 1,
* "price": 15.99
* }
* ]
* },
* "userInfo": {
* "firstName": "Mike",
* "lastName": "Trout",
* "countryCode": "USA",
* "phone": null,
* "email": "mike.trout@email.com"
* },
* "status": "Successful",
* "transactionId": "83f1830a-c74e-4abe-894d-3ee388b7e985"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.