Search...
onOrderPaymentStatusUpdated( )
Triggered when an order's payment status is updated to "PAID"
.
Description
The onOrderPaymentStatusUpdated()
event handler runs when an order's payment status is updated to "PAID"
. 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.
Syntax
function wixEcom_onOrderPaymentStatusUpdated(event: OrderPaymentStatusUpdated): void
onOrderPaymentStatusUpdated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
OrderPaymentStatusUpdated
Information about the updated order.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event fired when an order's payment status is updated
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixEcom_onOrderPaymentStatusUpdated(event) {6 const orderId = event.data.order._id;7 const currentPaymentStatus = event.data.order.paymentStatus;8 const previousPaymentStatus = event.data.previousPaymentStatus;9 const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount;10 const eventId = event.metadata.id;11 console.log('Order payment status updated', event)12}131415/* Full event object:16 *17 * {18 * "metadata": {19 * "id": "5a521f73-0824-40b8-af4c-86da30219db8",20 * "entityId": "7a8b195e-ab73-4138-b9da-cdf5e864a451",21 * "eventTime": "2023-01-16T14:40:02.119716Z",22 * "triggeredByAnonymizeRequest": false23 * },24 * "data": {25 * "order": {26 * "_id": "7a8b195e-ab73-4138-b9da-cdf5e864a451",27 * "number": "10003",28 * "_createdDate": "2023-01-16T13:53:10.776Z",29 * "_updatedDate": "2023-01-16T14:40:01.997Z",30 * "lineItems": [31 * {32 * "_id": "00000000-0000-0000-0000-000000000001",33 * "productName": {34 * "original": "Watch",35 * "translated": "Watch"36 * },37 * "catalogReference": {38 * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",39 * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",40 * "options": {41 * "options": {42 * "Size": "Medium",43 * "Color": "Black"44 * },45 * "variantId": "e309b2f2-2166-4927-a137-0e5dfb870627"46 * }47 * },48 * "quantity": 1,49 * "totalDiscount": {50 * "amount": "0",51 * "formattedAmount": "$0.00"52 * },53 * "descriptionLines": [54 * {55 * "name": {56 * "original": "Size",57 * "translated": "Size"58 * },59 * "plainText": {60 * "original": "Medium",61 * "translated": "Medium"62 * },63 * "lineType": "PLAIN_TEXT",64 * "plainTextValue": {65 * "original": "Medium",66 * "translated": "Medium"67 * }68 * },69 * {70 * "name": {71 * "original": "Color",72 * "translated": "Color"73 * },74 * "colorInfo": {75 * "original": "Black",76 * "translated": "Black"77 * },78 * "lineType": "COLOR",79 * "color": "Black"80 * }81 * ],82 * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000",83 * "physicalProperties": {84 * "sku": "217537123517253",85 * "shippable": true86 * },87 * "itemType": {88 * "preset": "PHYSICAL"89 * },90 * "refundQuantity": 0,91 * "price": {92 * "amount": "30.00",93 * "formattedAmount": "$30.00"94 * },95 * "priceBeforeDiscounts": {96 * "amount": "30.00",97 * "formattedAmount": "$30.00"98 * },99 * "totalPriceBeforeTax": {100 * "amount": "30.00",101 * "formattedAmount": "$30.00"102 * },103 * "totalPriceAfterTax": {104 * "amount": "30.00",105 * "formattedAmount": "$30.00"106 * },107 * "paymentOption": "FULL_PAYMENT_ONLINE",108 * "taxDetails": {109 * "taxableAmount": {110 * "amount": "30.00",111 * "formattedAmount": "$30.00"112 * },113 * "taxRate": "0.0",114 * "totalTax": {115 * "amount": "0.0",116 * "formattedAmount": "$0.00"117 * }118 * }119 * }120 * ],121 * "buyerInfo": {122 * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615",123 * "email": "janedoe8@gmail.com",124 * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"125 * },126 * "paymentStatus": "PAID",127 * "fulfillmentStatus": "NOT_FULFILLED",128 * "buyerLanguage": "en",129 * "weightUnit": "KG",130 * "currency": "USD",131 * "taxIncludedInPrices": false,132 * "priceSummary": {133 * "subtotal": {134 * "amount": "30.00",135 * "formattedAmount": "$30.00"136 * },137 * "shipping": {138 * "amount": "10.0",139 * "formattedAmount": "$10.00"140 * },141 * "tax": {142 * "amount": "0.0",143 * "formattedAmount": "$0.00"144 * },145 * "discount": {146 * "amount": "0.0",147 * "formattedAmount": "$0.00"148 * },149 * "totalPrice": {150 * "amount": "40.00",151 * "formattedAmount": "$40.00"152 * },153 * "total": {154 * "amount": "40.00",155 * "formattedAmount": "$40.00"156 * },157 * "totalWithGiftCard": {158 * "amount": "40.00",159 * "formattedAmount": "$40.00"160 * },161 * "totalWithoutGiftCard": {162 * "amount": "40.00",163 * "formattedAmount": "$40.00"164 * },165 * "totalAdditionalFees": {166 * "amount": "0",167 * "formattedAmount": "$0.00"168 * }169 * },170 * "billingInfo": {171 * "address": {172 * "addressLine1": "525 5th Avenue",173 * "city": "New York",174 * "subdivision": "US-NY",175 * "country": "US",176 * "postalCode": "10173"177 * },178 * "contactDetails": {179 * "firstName": "Jane",180 * "lastName": "Doe",181 * "phone": "0555555555"182 * }183 * },184 * "shippingInfo": {185 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",186 * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",187 * "title": "Standard US Shipping",188 * "logistics": {189 * "deliveryTime": "",190 * "shippingDestination": {191 * "address": {192 * "addressLine1": "525 5th Avenue",193 * "city": "New York",194 * "subdivision": "US-NY",195 * "country": "US",196 * "postalCode": "10173"197 * },198 * "contactDetails": {199 * "firstName": "Jane",200 * "lastName": "Doe",201 * "phone": "0555555555"202 * }203 * }204 * },205 * "cost": {206 * "price": {207 * "amount": "10",208 * "formattedAmount": "$10.00"209 * },210 * "totalPriceBeforeTax": {211 * "amount": "10",212 * "formattedAmount": "$10.00"213 * },214 * "totalPriceAfterTax": {215 * "amount": "10.0",216 * "formattedAmount": "$10.00"217 * },218 * "taxDetails": {219 * "taxRate": "0.0",220 * "totalTax": {221 * "amount": "0.0",222 * "formattedAmount": "$0.00"223 * }224 * },225 * "discount": {226 * "amount": "0",227 * "formattedAmount": "$0.00"228 * }229 * },230 * "region": {231 * "name": "USA shipping"232 * }233 * },234 * "status": "APPROVED",235 * "archived": false,236 * "taxSummary": {237 * "totalTax": {238 * "amount": "0.0",239 * "formattedAmount": "$0.00"240 * }241 * },242 * "appliedDiscounts": [],243 * "activities": [244 * {245 * "_createdDate": "2023-01-16T13:53:10.776Z",246 * "type": "ORDER_PLACED"247 * },248 * {249 * "_createdDate": "2023-01-16T14:38:48.249Z",250 * "type": "EMAIL_EDITED"251 * }252 * ],253 * "attributionSource": "UNSPECIFIED",254 * "createdBy": {255 * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"256 * },257 * "channelInfo": {258 * "type": "WEB"259 * },260 * "seenByAHuman": true,261 * "checkoutId": "9f24eba1-5b05-4c9e-90c5-1789a8239912",262 * "customFields": [],263 * "cartId": "eb8086a0-9389-4e92-91cb-5ce7bd9b3db8",264 * "payNow": {265 * "subtotal": {266 * "amount": "30.00",267 * "formattedAmount": "$30.00"268 * },269 * "shipping": {270 * "amount": "10.0",271 * "formattedAmount": "$10.00"272 * },273 * "tax": {274 * "amount": "0.0",275 * "formattedAmount": "$0.00"276 * },277 * "discount": {278 * "amount": "0.0",279 * "formattedAmount": "$0.00"280 * },281 * "totalPrice": {282 * "amount": "40.00",283 * "formattedAmount": "$40.00"284 * },285 * "total": {286 * "amount": "40.00",287 * "formattedAmount": "$40.00"288 * },289 * "totalWithGiftCard": {290 * "amount": "40.00",291 * "formattedAmount": "$40.00"292 * },293 * "totalWithoutGiftCard": {294 * "amount": "40.00",295 * "formattedAmount": "$40.00"296 * }297 * },298 * "balanceSummary": {299 * "balance": {300 * "amount": "0.00",301 * "formattedAmount": "$0.00"302 * }303 * },304 * "additionalFees": []305 * },306 * "previousPaymentStatus": "NOT_PAID"307 * }308 * }309 *310 */