Search.../

onPaymentUpdate( )

An event that fires when a payment's transaction status is changed.

Description

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.

Syntax

function onPaymentUpdate(event: PaymentUpdateEvent): void

onPaymentUpdate Parameters

NAME
TYPE
DESCRIPTION
event

PaymentUpdateEvent

The payment data.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event fired when a payment transaction status is changed

Code Example

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3
4export function wixPay_onPaymentUpdate(event) {
5 let paymentId = event.payment.id;
6 let newTransactionStatus = event.status;
7}
8
9/* Full event object:
10 * {
11 * "payment": {
12 * "id": "8b3c1a90-c09e-4cd7-ae9d-9801151d8ad9",
13 * "amount": 15.99,
14 * "currency": "USD",
15 * "items": [
16 * {
17 * "name": "Baseball Bat",
18 * "quantity": 1,
19 * "price": 15.99
20 * }
21 * ]
22 * },
23 * "userInfo": {
24 * "firstName": "Mike",
25 * "lastName": "Trout",
26 * "countryCode": "USA",
27 * "phone": null,
28 * "email": "mike.trout@email.com"
29 * },
30 * "status": "Successful",
31 * "transactionId": "83f1830a-c74e-4abe-894d-3ee388b7e985"
32 * }
33 */