> 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

# GenerateReceipts

# Package: orders

# Namespace: OrderBillingService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/generate-receipts.md

## Permission Scopes:
Manage Orders: SCOPE.DC-STORES.MANAGE-ORDERS

## Introduction

Generates digital receipts for an order's completed payments.

Creates formal receipt documents for successful payments that can be provided to customers
for record-keeping and tax purposes.

> **Note:** Only `PAID` status payments with valid payment types can have receipts generated.

---

## REST API

### Schema

```
 Method: generateReceipts
 Description: Generates digital receipts for an order's completed payments.  Creates formal receipt documents for successful payments that can be provided to customers for record-keeping and tax purposes.  > **Note:** Only `PAID` status payments with valid payment types can have receipts generated.
 URL: https://www.wixapis.com/ecom/v1/order-billing/generate-receipts
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  orderId, paymentIds
 Method parameters: 
   param name: orderId | type: orderId | description: GUID of the order containing the payments to generate receipts for. | required: true | validation: format GUID
   param name: paymentIds | type: array<paymentIds> | description: IDs of the payments to generate receipts for.  Only successful payments with valid payment types can have receipts generated. | required: true | validation: minItems 1, maxItems 1, format GUID
 Return type: GenerateReceiptsResponse
  - name: receipts | type: array<ReceiptInfo> | description: Information about the generated receipts including receipt GUIDs for each payment.  
     - name: paymentId | type: string | description: GUID of the payment that the receipt was generated for.  | validation: format GUID
     - name: receiptId | type: string | description: Generated receipt GUID that can be used to retrieve the receipt details.  | validation: format GUID

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: PAYMENT_NOT_FOUND | Description: Couldn't find the payment.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ORDER_NOT_FOUND | Description: Couldn't find the order.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: RECEIPT_GENERATION_IN_PROGRESS | Description: Receipt generation is already in progress.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: RECEIPT_ALREADY_EXIST | Description: Receipt already exists.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_PAYMENT_STATUS | Description: Payment has an invalid status for receipt generation.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_PAYMENT_TYPE | Description: Payment has an invalid type for receipt generation.


```

### Examples

### Generate Receipts
Generate and send receipt for payment.

```curl
curl -X POST \
  'https://www.wixapis.com/ecom/v1/order-billing/generate-receipts' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
  	"orderId": "dc9aeef6-9d52-4a5b-8a3b-ab327151f343",
  	"paymentIds": [
    	"88425e4c-25f3-4dec-b474-9873a58813dc"
  	]
	}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.orderBilling.generateReceipts(orderId, options)
 Description: Generates digital receipts for an order's completed payments.  Creates formal receipt documents for successful payments that can be provided to customers for record-keeping and tax purposes.  > **Note:** Only `PAID` status payments with valid payment types can have receipts generated.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  orderId, options.paymentIds, options
 Method parameters: 
   param name: orderId | type: string | description: GUID of the order containing the payments to generate receipts for. | required: true | validation: format GUID
   param name: options | type: GenerateReceiptsOptions  none | required: true 
        - name: paymentIds | type: array<string> | description: IDs of the payments to generate receipts for.  Only successful payments with valid payment types can have receipts generated. | required: true | validation: minItems 1, maxItems 1, format GUID
 Return type: PROMISE<GenerateReceiptsResponse>
  - name: receipts | type: array<ReceiptInfo> | description: Information about the generated receipts including receipt GUIDs for each payment.  
     - name: paymentId | type: string | description: GUID of the payment that the receipt was generated for.  | validation: format GUID
     - name: receiptId | type: string | description: Generated receipt GUID that can be used to retrieve the receipt details.  | validation: format GUID

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: PAYMENT_NOT_FOUND | Description: Couldn't find the payment.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: ORDER_NOT_FOUND | Description: Couldn't find the order.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: RECEIPT_GENERATION_IN_PROGRESS | Description: Receipt generation is already in progress.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: RECEIPT_ALREADY_EXIST | Description: Receipt already exists.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_PAYMENT_STATUS | Description: Payment has an invalid status for receipt generation.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_PAYMENT_TYPE | Description: Payment has an invalid type for receipt generation.


```

### Examples

### Generate Receipts
Generate and send a receipt for a payment.

```javascript
import { orderBilling } from "@wix/ecom";

async function generateReceipts() {
  const response = await orderBilling.generateReceipts(
    "dc9aeef6-9d52-4a5b-8a3b-ab327151f343",
    {
      paymentIds: ["88425e4c-25f3-4dec-b474-9873a58813dc"],
    },
  );
  return response;
}

/* Promise resolves to:
 * {
 *   "receipts": [
 *     {
 *       "paymentId": "88425e4c-25f3-4dec-b474-9873a58813dc",
 *       "receiptId": "a7876c15-665b-4301-aae0-21f7022bf2b6"
 *     }
 *   ]
 * }
 */

```

### generateReceipts (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 { orderBilling } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function generateReceipts(orderId,options) {
  const response = await myWixClient.orderBilling.generateReceipts(orderId,options);
};
```

---