Search.../

submitEvent( )

Developer Preview

Updates the status of a transaction or refund.

Description

The submitEvent() function returns a Promise that resolves to void when the status of a transaction or refund is updated.

Use this function with the Payment Provider SPI and HTTP functions to allow payment providers to send your site updates about refunds and transactions.

The status of a transaction or refund is updated based on the properties included in the argument passed to this function. See the code examples for details.

Learn more about implementing a Payment Provider Custom Extension.

Syntax

function submitEvent(submitEventRequest: SubmitEventRequest): Promise<void>

submitEvent Parameters

NAME
TYPE
DESCRIPTION
submitEventRequest
SubmitEventRequest

Submit event request object.

Returns

Return Type:

Promise<void>

Was this helpful?

Update the status of a transaction or refund

Copy Code
1import wixPaymentProviderBackend from 'wix-payment-provider-backend';
2/*
3 * Sample submitEventRequest value for a transaction:
4 * {
5 * event : {
6 * transaction: {
7 * wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
8 * pluginTransactionId: '22001-123123'
9 * }
10 * }
11 * }
12 */
13
14export async function updateTransaction(submitEventRequest) {
15 try {
16 await wixPaymentProviderBackend.submitEvent(submitEventRequest);
17 console.log('Transaction updated successfully.');
18 return ;
19 } catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23
24}
25
26/* Promise resolves to void */
Transaction approved

Copy Code
1// submitEventRequest value for a successful transaction:
2{
3 event: {
4 transaction : {
5 wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
6 pluginTransactionId: 'e89b-12d3-a456-42665'
7 }
8 }
9}
Transaction declined

Copy Code
1// submitEventRequest value for a declined transaction:
2
3{
4 event: {
5 transaction: {
6 wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
7 pluginTransactionId: 'e89b-12d3-a456-42665',
8 reasonCode: 3012,
9 errorCode: 'INSUFFICIENT_FUNDS',
10 errorMessage: 'Insufficient funds'
11 }
12 }
13}
Transaction pending

Copy Code
1// submitEventRequest value for a pending payment
2
3{
4 event: {
5 transaction: {
6 wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
7 pluginTransactionId: 'e89b-12d3-a456-42665',
8 reasonCode: 5005
9 }
10 }
11}
Transaction canceled

Copy Code
1// submitEventRequest value for a canceled transaction:
2
3{
4 event: {
5 transaction: {
6 wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
7 pluginTransactionId: 'e89b-12d3-a456-42665',
8 reasonCode: 3030,
9 errorCode: 'BUYER_CANCELED',
10 errorMessage: 'Buyer canceled the transaction.'
11 }
12 }
13}
Refund succeeded, initiated from a site's dashboard

Copy Code
1// submitEventRequest value for a successful refund that was initiated from a site's dashboard:
2
3{
4 'event': {
5 'refund': {
6 'wixTransactionId': '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
7 'pluginRefundId': '123123-123123123',
8 'amount': '1000',
9 'wixRefundId': 'baeb40f5-a48a-4424-cec2-253c9772ad42'
10 }
11 }
12}
Refund failed, initiated from a site's dashboard

Copy Code
1// submitEventRequest value for a failed refund that was initiated from a site's dashboard:
2
3{
4 event: {
5 refund: {
6 wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
7 pluginRefundId: '1231231-55432',
8 amount: '1000',
9 wixRefundId: 'baeb40f5-a48a-4424-cec2-253c9772ad42',
10 reasonCode: 3025,
11 errorCode: 'INSUFFICIENT_FUNDS_FOR_REFUND',
12 errorMessage: 'Insufficient funds for refund.'
13 }
14 }
15}
Refund succeeded, initiated by a payment provider

Copy Code
1// submitEventRequest value for a successful refund that was initiated by a payment provider:
2
3{
4 event: {
5 refund: {
6 wixTransactionId: '3e01dda6-134e-4cc9-a37f-ed2bf756c684',
7 pluginRefundId: '123123-123123',
8 amount: '1000'
9 }
10 }
11}