> 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 # 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 param name: paymentIds | type: array | description: IDs of the payments to generate receipts for. Only successful payments with valid payment types can have receipts generated. | required: true Return type: GenerateReceiptsResponse - name: receipts | type: array | 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. - name: receiptId | type: string | description: Generated receipt GUID that can be used to retrieve the receipt details. 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: ' \ -d '{ "orderId": "dc9aeef6-9d52-4a5b-8a3b-ab327151f343", "paymentIds": [ "88425e4c-25f3-4dec-b474-9873a58813dc" ] }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.orders.OrderBillingService.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: options | type: GenerateReceiptsOptions none | required: true - name: paymentIds | type: array | description: IDs of the payments to generate receipts for. Only successful payments with valid payment types can have receipts generated. | required: true param name: orderId | type: string | description: GUID of the order containing the payments to generate receipts for. | required: true Return type: PROMISE - name: receipts | type: array | 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. - name: receiptId | type: string | description: Generated receipt GUID that can be used to retrieve the receipt details. 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 ### generateReceipts ```javascript import { orderBilling } from '@wix/ecom'; async function generateReceipts(orderId,options) { const response = await orderBilling.generateReceipts(orderId,options); }; ``` ### generateReceipts (with elevated permissions) ```javascript import { orderBilling } from '@wix/ecom'; import { auth } from '@wix/essentials'; async function myGenerateReceiptsMethod(orderId,options) { const elevatedGenerateReceipts = auth.elevate(orderBilling.generateReceipts); const response = await elevatedGenerateReceipts(orderId,options); } ``` ### generateReceipts (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 { 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); }; ``` ---