> 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

# VoidOrderPaymentRequest

# Package: orders

# Namespace: OrderPaymentRequestsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-payment-requests/void-order-payment-request.md

## Permission Scopes:
Manage eCommerce - all permissions: SCOPE.DC-ECOM-MEGA.MANAGE-ECOM

## Introduction

Voids the given order payment request.

Only `UNPAID` order payment requests can be voided. Voiding an order payment request that is already `VOIDED` succeeds without making any changes. Voiding a `PAID` or `EXPIRED` order payment request fails.

---

## REST API

### Schema

```
 Method: voidOrderPaymentRequest
 Description: Voids the given order payment request.  Only `UNPAID` order payment requests can be voided. Voiding an order payment request that is already `VOIDED` succeeds without making any changes. Voiding a `PAID` or `EXPIRED` order payment request fails.
 URL: https://www.wixapis.com/ecom/v1/order-payment-requests/void
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  orderPaymentRequestId
 Method parameters: 
   param name: orderPaymentRequestId | type: orderPaymentRequestId | description: GUID of the order payment request to void. | required: true | validation: format GUID
 Return type: VoidOrderPaymentRequestResponse
  EMPTY-OBJECT {}

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ORDER_PAYMENT_REQUEST_NOT_FOUND | Description: Couldn't find the order payment request.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_VOID_EXPIRED_ORDER_PAYMENT_REQUEST | Description: Order payment requests with a `status` of `EXPIRED` can't be voided.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_VOID_PAID_ORDER_PAYMENT_REQUEST | Description: Order payment requests with a `status` of `PAID` can't be voided.


```

### Examples

### Void Order Payment Request
Voids an unpaid order payment request, preventing it from being paid. Voiding an already-voided request succeeds without making any changes.

```curl
curl -X POST \
  'https://www.wixapis.com/ecom/v1/order-payment-requests/void' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "orderPaymentRequestId": "3c8f1a2e-7b4d-4f9e-8c61-5d2e9a0b1c3f"
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.orderPaymentRequests.voidOrderPaymentRequest(orderPaymentRequestId)
 Description: Voids the given order payment request.  Only `UNPAID` order payment requests can be voided. Voiding an order payment request that is already `VOIDED` succeeds without making any changes. Voiding a `PAID` or `EXPIRED` order payment request fails.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  orderPaymentRequestId
 Method parameters: 
   param name: orderPaymentRequestId | type: string | description: GUID of the order payment request to void. | required: true | validation: format GUID
 Return type: PROMISE<VoidOrderPaymentRequestResponse>
  EMPTY-OBJECT {}

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ORDER_PAYMENT_REQUEST_NOT_FOUND | Description: Couldn't find the order payment request.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_VOID_EXPIRED_ORDER_PAYMENT_REQUEST | Description: Order payment requests with a `status` of `EXPIRED` can't be voided.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_VOID_PAID_ORDER_PAYMENT_REQUEST | Description: Order payment requests with a `status` of `PAID` can't be voided.


```

### Examples

### Void an order payment request
Voids an unpaid order payment request, preventing the customer from paying it. Voiding an already-voided request succeeds without making any changes.

```javascript

import { orderPaymentRequests } from '@wix/ecom';

const orderPaymentRequestId = '3c8f1a2e-7b4d-4f9e-8c61-5d2e9a0b1c3f';

export async function myVoidOrderPaymentRequestFunction() {
  try {
    await orderPaymentRequests.voidOrderPaymentRequest(orderPaymentRequestId);
    console.log('Success! Order payment request voided.');
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {}
 */

```

### voidOrderPaymentRequest (self-hosted)
Self-hosted 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 { orderPaymentRequests } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function voidOrderPaymentRequest(orderPaymentRequestId) {
  const response = await myWixClient.orderPaymentRequests.voidOrderPaymentRequest(orderPaymentRequestId);
};
```

---