> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# SubmitEvent

# Package: paymentServiceProviderServicePlugin

# Namespace: ProviderPlatformEventsService

# Method link: https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md

## Introduction

This Wix API is used by a Payment Service Provider (PSP) to send webhooks about payment and refund states to Wix.

Calls to this endpoint must include a `User-Agent` header with the name of the PSP and the integration version in this format: `{PSP}/{version}`.
PSP's create their own version numbers.

> You cannot try out this endpoint because an `Authorization` header value has to be obtained
> with the OAuth 2.0 client credentials flow for a specific scope.
> So please ignore the **Authorization** section below as well as the **Try It Out** button.

---

## REST API

### Schema

```
 Method: submitEvent
 Description: This Wix API is used by a Payment Service Provider (PSP) to send webhooks about payment and refund states to Wix.  Calls to this endpoint must include a `User-Agent` header with the name of the PSP and the integration version in this format: `{PSP}/{version}`. PSP's create their own version numbers.  > You cannot try out this endpoint because an `Authorization` header value has to be obtained > with the OAuth 2.0 client credentials flow for a specific scope. > So please ignore the **Authorization** section below as well as the **Try It Out** button.
 URL: https://www.wixapis.com/payments/v1/provider-platform-events
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  event
 Method parameters: 
   param name: event | type: ProviderPlatformEvent | description: Provider platform event | required: true 
    - ONE-OF: - required: true
     - name: refund | type: RefundEvent | description: Refund event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  
        - name: pluginRefundId | type: string | description: PSP refund GUID.  
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/api/rest/all-apis/provider-platform/reason-codes#all-apis_provider-platform_reason-codes_refund-declined) indicating a failed request.  
        - name: amount | type: string | description: Refunded amount.  
        - name: wixRefundId | type: string | description: Wix refund GUID. This field is only required when a merchant initiates a refund from the Wix dashboard.  
        - name: errorCode | type: string | description: PSP-specific error code.  
        - name: errorMessage | type: string | description: PSP-specific error message.  
     - name: transaction | type: TransactionEvent | description: Transaction event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  
        - name: pluginTransactionId | type: string | description: PSP transaction GUID.  
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/api/rest/all-apis/provider-platform/reason-codes) indicating a failed or pending request.  
        - name: errorCode | type: string | description: PSP-specific error code.  
        - name: errorMessage | type: string | description: PSP-specific error message.  
        - name: credentialsOnFile | type: CredentialsOnFile | description: Token data for stored payment method.  
           - ONE-OF: 
              - name: cardReference | type: CardReference | description: Network token data.  
                 - name: networkTransactionId | type: string | description: Network token.  
                 - name: dsTransactionId | type: string | description: Directory Server transaction GUID  
                 - name: transactionLinkId | type: string | description: Transaction Link Identifier assigned by Mastercard.  | validation: minLength 1, maxLength 22
              - name: paymentMethodReference | type: PaymentMethodReference | description: Provider generated token data.  
                 - name: token | type: string | description: Payment method token created by the PSP.  
           - name: paymentMethod | type: string | description: Payment method (for example `creditCard`) to use for future payments, when it differs from the current one.  | validation: minLength 1, maxLength 100
        - name: cardDetails | type: CardDetails | description: Details of actual customer's card, obtained from a Funding PAN as opposed to a Device PAN.  
           - name: bin | type: string | description: Issuer (business) identification number. First 6 or 8 digits of the card's number.  | validation: minLength 6, maxLength 8
           - name: lastFour | type: string | description: Last 4 digits of the card's number.  | validation: minLength 4, maxLength 4
        - name: authorizedAmount | type: string | description: Total amount authorized in a currency's minor units. Required for partial authorization events. Learn more about [currencies](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/currencies.md).  | validation: format int64
     - name: capture | type: CaptureEvent | description: Capture event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  | validation: format GUID
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/reason-codes.md) indicating request's status.  
        - name: amount | type: string | description: Total amount captured in a currency’s minor units. Learn more about [currencies](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/currencies.md).  
        - name: errorCode | type: string | description: PSP-specific error code.  | validation: maxLength 50
        - name: errorMessage | type: string | description: PSP-specific error message.  | validation: maxLength 300
     - name: void | type: VoidEvent | description: Void event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  | validation: format GUID
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/reason-codes.md) indicating request's status.  
        - name: amount | type: string | description: Total amount voided in a currency’s minor units. Learn more about [currencies](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/currencies.md).  
        - name: errorCode | type: string | description: PSP-specific error code.  | validation: maxLength 50
        - name: errorMessage | type: string | description: PSP-specific error message.  | validation: maxLength 300
        - name: siteId | type: string | description: Wix site GUID.  | validation: format GUID
 Return type: SubmitEventResponse
  EMPTY-OBJECT {}


```

### Examples

### Payment Captured
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-H 'User-Agent: banana-pay/1.0.0' \
-d '{
  "event": {
    "capture": {
      "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
      "reasonCode": 0,
      "amount": "1540"
    }
  }
}'
```

### Payment Authorized
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-H 'User-Agent: banana-pay/1.0.0' \
-d '{
  "event": {
    "transaction": {
      "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
      "pluginTransactionId": "e89b-12d3-a456-42665"
      "reasonCode": 5010
    }
  }
}'
```

### Refund succeeded (initiated by PSP)
```curl
curl -X POST https://www.wixapis.com/payments/v1/provider-platform-events \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "refund": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginRefundId": "ce590272-87bf-428f-943a-0ff594059712",
           "amount": "1000"
         }
       }
     }'
```

### Refund failed (initiated by Wix)
```curl
curl -X POST https://www.wixapis.com/payments/v1/provider-platform-events \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "refund": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginRefundId": "ce590272-87bf-428f-943a-0ff594059712",
           "amount": "1000",
           "wixRefundId": "fcd2655f-e261-4c5b-8129-72a241461a27",
           "reasonCode": "3025",
           "errorCode": "INSUFFICIENT_FUNDS_FOR_REFUND",
           "errorMessage": "Insufficient funds for refund."
         }
       }
     }'
```

### Refund succeeded (initiated by Wix)
```curl
curl -X POST https://www.wixapis.com/payments/v1/provider-platform-events \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "refund": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginRefundId": "ce590272-87bf-428f-943a-0ff594059712",
           "amount": "1000",
           "wixRefundId": "fcd2655f-e261-4c5b-8129-72a241461a27"
         }
       }
     }'
```

### Payment canceled
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "transaction": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginTransactionId": "e89b-12d3-a456-42665",
           "reasonCode": 3030,
           "errorCode": "BUYER_CANCELED",
           "errorMessage": "Buyer canceled"
         }
       } 
     }'
```

### Payment pending
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "transaction": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginTransactionId": "e89b-12d3-a456-42665",
           "reasonCode": 5005
         }
       }
     }'
```

### Payment declined
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "transaction": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginTransactionId": "e89b-12d3-a456-42665",
           "reasonCode": 3012,
           "errorCode": "INSUFFICIENT_FUNDS",
           "errorMessage": "Insufficient funds"
         }
       }
     }'
```

### Payment Voided
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-H 'User-Agent: banana-pay/1.0.0' \
-d '{
  "event": {
    "void": {
      "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
      "reasonCode": 0,
      "amount": "1540"
    }
  }
}'
```

### Payment approved
```curl
curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \
 -H 'Content-Type: application/json' \
 -H 'Authorization: <AUTH>' \
 -H 'User-Agent: banana-pay/1.0.0' \
 -d '{
       "event": {
         "transaction": {
           "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1",
           "pluginTransactionId": "e89b-12d3-a456-42665"
         }
       }
     }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.payments.pspCallbacks.submitEvent(event)
 Description: This Wix API is used by a Payment Service Provider (PSP) to send webhooks about payment and refund states to Wix.  Calls to this endpoint must include a `User-Agent` header with the name of the PSP and the integration version in this format: `{PSP}/{version}`. PSP's create their own version numbers.  > You cannot try out this endpoint because an `Authorization` header value has to be obtained > with the OAuth 2.0 client credentials flow for a specific scope. > So please ignore the **Authorization** section below as well as the **Try It Out** button.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  event
 Method parameters: 
   param name: event | type: ProviderPlatformEvent | description: Provider platform event | required: true 
    - ONE-OF: - required: true
     - name: refund | type: RefundEvent | description: Refund event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  
        - name: pluginRefundId | type: string | description: PSP refund GUID.  
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/api/rest/all-apis/provider-platform/reason-codes#all-apis_provider-platform_reason-codes_refund-declined) indicating a failed request.  
        - name: amount | type: string | description: Refunded amount.  
        - name: wixRefundId | type: string | description: Wix refund GUID. This field is only required when a merchant initiates a refund from the Wix dashboard.  
        - name: errorCode | type: string | description: PSP-specific error code.  
        - name: errorMessage | type: string | description: PSP-specific error message.  
     - name: transaction | type: TransactionEvent | description: Transaction event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  
        - name: pluginTransactionId | type: string | description: PSP transaction GUID.  
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/api/rest/all-apis/provider-platform/reason-codes) indicating a failed or pending request.  
        - name: errorCode | type: string | description: PSP-specific error code.  
        - name: errorMessage | type: string | description: PSP-specific error message.  
        - name: credentialsOnFile | type: CredentialsOnFile | description: Token data for stored payment method.  
           - ONE-OF: 
              - name: cardReference | type: CardReference | description: Network token data.  
                 - name: networkTransactionId | type: string | description: Network token.  
                 - name: dsTransactionId | type: string | description: Directory Server transaction GUID  
                 - name: transactionLinkId | type: string | description: Transaction Link Identifier assigned by Mastercard.  | validation: minLength 1, maxLength 22
              - name: paymentMethodReference | type: PaymentMethodReference | description: Provider generated token data.  
                 - name: token | type: string | description: Payment method token created by the PSP.  
           - name: paymentMethod | type: string | description: Payment method (for example `creditCard`) to use for future payments, when it differs from the current one.  | validation: minLength 1, maxLength 100
        - name: cardDetails | type: CardDetails | description: Details of actual customer's card, obtained from a Funding PAN as opposed to a Device PAN.  
           - name: bin | type: string | description: Issuer (business) identification number. First 6 or 8 digits of the card's number.  | validation: minLength 6, maxLength 8
           - name: lastFour | type: string | description: Last 4 digits of the card's number.  | validation: minLength 4, maxLength 4
        - name: authorizedAmount | type: string | description: Total amount authorized in a currency's minor units. Required for partial authorization events. Learn more about [currencies](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/currencies.md).  | validation: format int64
     - name: capture | type: CaptureEvent | description: Capture event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  | validation: format GUID
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/reason-codes.md) indicating request's status.  
        - name: amount | type: string | description: Total amount captured in a currency’s minor units. Learn more about [currencies](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/currencies.md).  
        - name: errorCode | type: string | description: PSP-specific error code.  | validation: maxLength 50
        - name: errorMessage | type: string | description: PSP-specific error message.  | validation: maxLength 300
     - name: void | type: VoidEvent | description: Void event data.  
        - name: wixTransactionId | type: string | description: Wix transaction GUID.  | validation: format GUID
        - name: reasonCode | type: integer | description: Wix [reason code](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/reason-codes.md) indicating request's status.  
        - name: amount | type: string | description: Total amount voided in a currency’s minor units. Learn more about [currencies](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/currencies.md).  
        - name: errorCode | type: string | description: PSP-specific error code.  | validation: maxLength 50
        - name: errorMessage | type: string | description: PSP-specific error message.  | validation: maxLength 300
        - name: siteId | type: string | description: Wix site GUID.  | validation: format GUID
 Return type: PROMISE<SubmitEventResponse>
  EMPTY-OBJECT {}


```

### Examples

### submitEvent
```javascript
import { pspCallbacks } from '@wix/payments';

async function submitEvent(event) {
  const response = await pspCallbacks.submitEvent(event);
};
```

### submitEvent (with elevated permissions)
```javascript
import { pspCallbacks } from '@wix/payments';
import { auth } from '@wix/essentials';

async function mySubmitEventMethod(event) {
  const elevatedSubmitEvent = auth.elevate(pspCallbacks.submitEvent);
  const response = await elevatedSubmitEvent(event);
}
```

### submitEvent (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { pspCallbacks } from '@wix/payments';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { pspCallbacks },
  // Include the auth strategy and host as relevant
});


async function submitEvent(event) {
  const response = await myWixClient.pspCallbacks.submitEvent(event);
};
```

---