> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Sample Capture and Void Flows ## Article: Sample Capture and Void Flows ## Article Link: https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/sample-capture-and-void-flows.md ## Article Content: # Sample Capture and Void Flows This article shows how to handle payment capture and voiding when implementing the [Capture Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/capture-transaction.md) and [Void Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/void-transaction.md) endpoints. For general information about these endpoints, see [Capturing and Voiding Payments](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/capturing-and-voiding-payments.md). This article outlines the following flows: - [Requests to create and capture a transaction](#requests-to-create-and-capture-a-transaction) - [Requests to create and void a transaction](#requests-to-create-and-void-a-transaction) - [Requests to capture or void an already captured or voided transaction](#requests-to-capture-or-void-an-already-captured-or-voided-transaction) > **Note:** The following examples use a [card payment method](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/sample-payment-flows.md#card-payments), but they can be applied to other payment methods. ## Requests to create and capture a transaction To handle requests to create and capture transactions as separate actions: ### Step 1 | Requests to create a transaction 1. Wix calls [Create Transaction](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/transactions/create-transaction.md). The total amount for the payment, the credit card details, and `authorizeOnly` are included in the request body as follows: ```js { //... "order": { //... "description": { "totalAmount": 1540, "currency": "USD" //... } }, //... "paymentMethodData": { "card": { "number": "4111111111111111", "year": 2030, "month": 12, "cvv": "777", "holderName": "John Smith" } }, //... authorizeOnly: true } ``` 1. The PSP authorizes the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "pluginTransactionId": "e89b-12d3-a456-42665", "reasonCode": 5010 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "transaction": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "pluginTransactionId": "e89b-12d3-a456-42665" "reasonCode": 5010 } } }' ``` ### Step 2 | Requests to capture a transaction 1. Wix calls [Capture Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/capture-transaction.md). The total amount for the payment is included in the request body as follows: ```json { "wixTransactionId": "a57c2c68-61d2-480c-930b-9982b058730d", "pluginTransactionId" : "bb5fd2a7-05a7-4958-bf3f-66daf4db0a4a", "captureAmount": 1540, "merchantCredentials": { "client_id": "e89b-12d3-a456-42665", "client_secret": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1" } } ``` 1. The PSP captures the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "reasonCode": 0 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "capture": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "reasonCode": 0 } } }' ``` ## Requests to create and void a transaction To handle requests to create and void transactions as separate actions: ### Step 1 | Requests to create a transaction 1. Wix calls [Create Transaction](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/transactions/create-transaction.md). The total amount for the payment, the credit card details, and `authorizeOnly` are included in the request body as follows: ```js { //... "order": { //... "description": { "totalAmount": 1540, "currency": "USD" //... } }, //... "paymentMethodData": { "card": { "number": "4111111111111111", "year": 2030, "month": 12, "cvv": "777", "holderName": "John Smith" } }, //... authorizeOnly: true } ``` 1. The PSP authorizes the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "pluginTransactionId": "e89b-12d3-a456-42665", "reasonCode": 5010 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "transaction": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "pluginTransactionId": "e89b-12d3-a456-42665" "reasonCode": 5010 } } }' ``` ### Step 2 | Requests to void a transaction 1. Wix calls [Void Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/void-transaction.md). The total amount for the payment is included in the request body as follows: ```json { "wixTransactionId": "a57c2c68-61d2-480c-930b-9982b058730d", "pluginTransactionId" : "bb5fd2a7-05a7-4958-bf3f-66daf4db0a4a", "captureAmount": 1540, "merchantCredentials": { "client_id": "e89b-12d3-a456-42665", "client_secret": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1" } } ``` 1. The PSP voids the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "reasonCode": 0 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "void": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "reasonCode": 0 } } }' ``` ## Requests to capture or void an already captured or voided transaction If Wix knows that a transaction has already been captured or voided, there's no reason to make additional calls because they return an error. However, sometimes Wix may not know the result of a previous call due to network issues, so it makes an additional call. The following flows demonstrate how a PSP should handle those cases: - [Capture requests for an already captured transaction](#capture-requests-for-an-already-captured-transaction) - [Capture requests for an already voided transaction](#capture-requests-for-an-already-voided-transaction) - [Void requests for an already captured transaction](#void-requests-for-an-already-captured-transaction) - [Void requests for an already voided transaction](#void-requests-for-an-already-voided-transaction) ### Capture requests for an already captured transaction This flow shows how to respond to a capture request for a transaction that has already been captured: 1. Wix calls [Capture Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/capture-transaction.md). The total amount for the payment is included in the request body as follows: ```json { "wixTransactionId": "a57c2c68-61d2-480c-930b-9982b058730d", "pluginTransactionId" : "bb5fd2a7-05a7-4958-bf3f-66daf4db0a4a", "captureAmount": 1540, "merchantCredentials": { "client_id": "e89b-12d3-a456-42665", "client_secret": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1" } } ``` 1. The PSP captures the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "reasonCode": 3049 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "capture": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "reasonCode": 3049 } } }' ``` ### Capture requests for an already voided transaction This flow shows how to respond to a capture request for a transaction that has already been voided: 1. Wix calls [Capture Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/capture-transaction.md). The total amount for the payment is included in the request body as follows: ```json { "wixTransactionId": "a57c2c68-61d2-480c-930b-9982b058730d", "pluginTransactionId" : "bb5fd2a7-05a7-4958-bf3f-66daf4db0a4a", "captureAmount": 1540, "merchantCredentials": { "client_id": "e89b-12d3-a456-42665", "client_secret": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1" } } ``` 1. The PSP captures the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "reasonCode": 3051 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "capture": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "reasonCode": 3051 } } }' ``` ### Void requests for an already captured transaction This flow shows how to respond to a void request for a transaction that has already been captured: 1. Wix calls [Void Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/void-transaction.md). The total amount for the payment is included in the request body as follows: ```json { "wixTransactionId": "a57c2c68-61d2-480c-930b-9982b058730d", "pluginTransactionId" : "bb5fd2a7-05a7-4958-bf3f-66daf4db0a4a", "captureAmount": 1540, "merchantCredentials": { "client_id": "e89b-12d3-a456-42665", "client_secret": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1" } } ``` 1. The PSP voids the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "reasonCode": 3049 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "void": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "reasonCode": 3049 } } }' ``` ### Void requests for an already voided transaction This flow shows how to respond to a void request for a transaction that has already been voided: 1. Wix calls [Void Transaction](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/transactions/void-transaction.md). The total amount for the payment is included in the request body as follows: ```json { "wixTransactionId": "a57c2c68-61d2-480c-930b-9982b058730d", "pluginTransactionId" : "bb5fd2a7-05a7-4958-bf3f-66daf4db0a4a", "captureAmount": 1540, "merchantCredentials": { "client_id": "e89b-12d3-a456-42665", "client_secret": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1" } } ``` 1. The PSP voids the payment and responds with an HTTP status code of `200`, and this JSON object: ```json { "reasonCode": 3051 } ``` 1. The PSP sends this webhook to [Submit Event](https://dev.wix.com/docs/api-reference/business-management/payments/payment-service-provider-service-plugin/callbacks/submit-event.md): ```bash curl -X POST 'https://www.wixapis.com/payments/v1/provider-platform-events' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -H 'User-Agent: banana-pay/1.0.0' \ -d '{ "event": { "void": { "wixTransactionId": "a15a3ee3-22d3-4a3f-920e-2186e13a19d1", "reasonCode": 3051 } } }' ```