Triggered when an order's payment status is updated.
The onOrderPaymentStatusUpdated()
event handler runs when an order's payment status is updated. The received OrderPaymentStatusUpdated
object contains information about the order, the previous payment status, and event metadata.
Note: Backend events don't work when previewing your site.
function wixEcom_onOrderPaymentStatusUpdated(
event: OrderPaymentStatusUpdated,
): void;
Information about the updated order.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixEcom_onOrderPaymentStatusUpdated(event) {
const orderId = event.data.order._id;
const currentPaymentStatus = event.data.order.paymentStatus;
const previousPaymentStatus = event.data.previousPaymentStatus;
const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount;
const eventId = event.metadata.id;
console.log("Order payment status updated", event);
}
/* Full event object:
*
* {
* "metadata": {
* "id": "5a521f73-0824-40b8-af4c-86da30219db8",
* "entityId": "7a8b195e-ab73-4138-b9da-cdf5e864a451",
* "eventTime": "2023-01-16T14:40:02.119716Z",
* "triggeredByAnonymizeRequest": false
* },
* "data": {
* "order": {
* "_id": "7a8b195e-ab73-4138-b9da-cdf5e864a451",
* "number": "10003",
* "_createdDate": "2023-01-16T13:53:10.776Z",
* "_updatedDate": "2023-01-16T14:40:01.997Z",
* "lineItems": [
* {
* "_id": "00000000-0000-0000-0000-000000000001",
* "productName": {
* "original": "Watch",
* "translated": "Watch"
* },
* "catalogReference": {
* "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
* "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
* "options": {
* "options": {
* "Size": "Medium",
* "Color": "Black"
* },
* "variantId": "e309b2f2-2166-4927-a137-0e5dfb870627"
* }
* },
* "quantity": 1,
* "totalDiscount": {
* "amount": "0",
* "formattedAmount": "$0.00"
* },
* "descriptionLines": [
* {
* "name": {
* "original": "Size",
* "translated": "Size"
* },
* "plainText": {
* "original": "Medium",
* "translated": "Medium"
* },
* "lineType": "PLAIN_TEXT",
* "plainTextValue": {
* "original": "Medium",
* "translated": "Medium"
* }
* },
* {
* "name": {
* "original": "Color",
* "translated": "Color"
* },
* "colorInfo": {
* "original": "Black",
* "translated": "Black"
* },
* "lineType": "COLOR",
* "color": "Black"
* }
* ],
* "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000",
* "physicalProperties": {
* "sku": "217537123517253",
* "shippable": true
* },
* "itemType": {
* "preset": "PHYSICAL"
* },
* "refundQuantity": 0,
* "price": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "priceBeforeDiscounts": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "totalPriceBeforeTax": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "totalPriceAfterTax": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "paymentOption": "FULL_PAYMENT_ONLINE",
* "taxDetails": {
* "taxableAmount": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "taxRate": "0.0",
* "totalTax": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* }
* }
* }
* ],
* "buyerInfo": {
* "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615",
* "email": "janedoe8@gmail.com",
* "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"
* },
* "paymentStatus": "PAID",
* "fulfillmentStatus": "NOT_FULFILLED",
* "buyerLanguage": "en",
* "weightUnit": "KG",
* "currency": "USD",
* "taxIncludedInPrices": false,
* "priceSummary": {
* "subtotal": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "shipping": {
* "amount": "10.0",
* "formattedAmount": "$10.00"
* },
* "tax": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* },
* "discount": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* },
* "totalPrice": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "total": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "totalWithGiftCard": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "totalWithoutGiftCard": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "totalAdditionalFees": {
* "amount": "0",
* "formattedAmount": "$0.00"
* }
* },
* "billingInfo": {
* "address": {
* "addressLine1": "525 5th Avenue",
* "city": "New York",
* "subdivision": "US-NY",
* "country": "US",
* "postalCode": "10173"
* },
* "contactDetails": {
* "firstName": "Jane",
* "lastName": "Doe",
* "phone": "0555555555"
* }
* },
* "shippingInfo": {
* "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",
* "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",
* "title": "Standard US Shipping",
* "logistics": {
* "deliveryTime": "",
* "shippingDestination": {
* "address": {
* "addressLine1": "525 5th Avenue",
* "city": "New York",
* "subdivision": "US-NY",
* "country": "US",
* "postalCode": "10173"
* },
* "contactDetails": {
* "firstName": "Jane",
* "lastName": "Doe",
* "phone": "0555555555"
* }
* }
* },
* "cost": {
* "price": {
* "amount": "10",
* "formattedAmount": "$10.00"
* },
* "totalPriceBeforeTax": {
* "amount": "10",
* "formattedAmount": "$10.00"
* },
* "totalPriceAfterTax": {
* "amount": "10.0",
* "formattedAmount": "$10.00"
* },
* "taxDetails": {
* "taxRate": "0.0",
* "totalTax": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* }
* },
* "discount": {
* "amount": "0",
* "formattedAmount": "$0.00"
* }
* },
* "region": {
* "name": "USA shipping"
* }
* },
* "status": "APPROVED",
* "archived": false,
* "taxSummary": {
* "totalTax": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* }
* },
* "appliedDiscounts": [],
* "activities": [
* {
* "_createdDate": "2023-01-16T13:53:10.776Z",
* "type": "ORDER_PLACED"
* },
* {
* "_createdDate": "2023-01-16T14:38:48.249Z",
* "type": "EMAIL_EDITED"
* }
* ],
* "attributionSource": "UNSPECIFIED",
* "createdBy": {
* "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"
* },
* "channelInfo": {
* "type": "WEB"
* },
* "seenByAHuman": true,
* "checkoutId": "9f24eba1-5b05-4c9e-90c5-1789a8239912",
* "customFields": [],
* "cartId": "eb8086a0-9389-4e92-91cb-5ce7bd9b3db8",
* "payNow": {
* "subtotal": {
* "amount": "30.00",
* "formattedAmount": "$30.00"
* },
* "shipping": {
* "amount": "10.0",
* "formattedAmount": "$10.00"
* },
* "tax": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* },
* "discount": {
* "amount": "0.0",
* "formattedAmount": "$0.00"
* },
* "totalPrice": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "total": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "totalWithGiftCard": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* },
* "totalWithoutGiftCard": {
* "amount": "40.00",
* "formattedAmount": "$40.00"
* }
* },
* "balanceSummary": {
* "balance": {
* "amount": "0.00",
* "formattedAmount": "$0.00"
* }
* },
* "additionalFees": []
* },
* "previousPaymentStatus": "NOT_PAID"
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.