> 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

# ChargeOrder

# Package: orders

# Namespace: OrderBillingService

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

## Introduction

Charges payments for an order using one or more payment methods.

Supports charging through multiple payment methods in a single request:
- **Regular payments**: Charges using the customer's payment method (credit card, PayPal, etc.).
- **Gift cards**: Redeems gift card codes
- **Memberships**: Charges membership credits or benefits for specific line items.

The method processes all specified payment types and returns the created payments
along with the updated order transactions.

A successful charge returns payments with a `status` of `APPROVED`, `AUTHORIZED`, `PENDING`, or `PENDING_MERCHANT`.
`PENDING` and `PENDING_MERCHANT` payments are confirmed asynchronously, so poll the order's transactions
or listen for payment events rather than treating the response as final.

---

## REST API

### Schema

```
 Method: chargeOrder
 Description: Charges payments for an order using one or more payment methods.  Supports charging through multiple payment methods in a single request: - **Regular payments**: Charges using the customer's payment method (credit card, PayPal, etc.). - **Gift cards**: Redeems gift card codes - **Memberships**: Charges membership credits or benefits for specific line items.  The method processes all specified payment types and returns the created payments along with the updated order transactions.  A successful charge returns payments with a `status` of `APPROVED`, `AUTHORIZED`, `PENDING`, or `PENDING_MERCHANT`. `PENDING` and `PENDING_MERCHANT` payments are confirmed asynchronously, so poll the order's transactions or listen for payment events rather than treating the response as final.
 URL: https://www.wixapis.com/ecom/v1/order-billing/charge-order
 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, regularCharge.amount, regularCharge.amount.amount, giftCards.giftCardCode, giftCards.amount, giftCards.amount.amount, memberships.membershipIdentifier, memberships.lineItemId
 Method parameters: 
   param name: giftCards | type: array<giftCards> | description: Gift card charges to apply to the order.  | validation: maxItems 100
              - name: giftCardCode | type: string | description: Gift card redemption code. | required: true | validation: minLength 8, maxLength 20
              - name: amount | type: Price | description: Amount to charge from the gift card. | required: true 
                 - name: amount | type: string | description: Amount. | required: true | validation: decimalValue {"gte":"0","lte":"1000000000000000"}
              - name: currencyConversionInfo | type: CurrencyConversionInfo | description: Details of the conversion from the gift card's currency to the order's currency.  Required if the order's currency differs from the gift card's currency.  When provided, the gift card is redeemed with `originalAmount`, otherwise with `amount`.  
                 - name: originalCurrency | type: string | description: Currency the amount was converted from, as a three-letter currency code in @ISO-4217 alphabetic format.  | validation: format CURRENCY
                 - name: originalAmount | type: string | description: Amount before conversion, in `originalCurrency`.  | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","lte":"1000000000000000","maxScale":4}
                 - name: conversionRate | type: string | description: Rate used to convert `originalAmount` to the order's currency. For example, `"1.08"`.  | validation: format DECIMAL_VALUE, decimalValue {"gt":"0","lte":"1000000000000000"}
   param name: idempotencyKey | type: idempotencyKey | description: Idempotency key to prevent duplicate charges, for example: checkoutId  | validation: format GUID
   param name: memberId | type: memberId | description: Member GUID associated with the order.  | validation: format GUID
   param name: memberships | type: array<memberships> | description: Membership charges to apply to the order.  | validation: maxItems 100
              - name: lineItemId | type: string | description:  | required: true | validation: format GUID
              - name: membershipIdentifier | type: MembershipIdentifier | description:  | required: true 
                 - ONE-OF: 
                    - name: existingMembership | type: ExistingMembershipIdentifier | description: An existing, already-provisioned membership.  
                       - name: appId | type: string | description: GUID of the app providing this membership payment option (e.g., Pricing Plans).  | validation: format GUID
                       - name: membershipId | type: string | description: GUID of existing membership.  | validation: minLength 1, maxLength 200
                    - name: futureMembership | type: FutureMembershipIdentifier | description: A future membership - no membership GUID yet; identified by the paying plan line item + selected benefit.  
                       - name: lineItemId | type: string | description: GUID of the Plan line item that is used to pay for the booking item.  | validation: format GUID
                       - name: benefitId | type: string | description: The selected unit within the Plan that will be redeemed.  | validation: maxLength 200
   param name: merchantInitiated | type: merchantInitiated | description: Specifies whether payment collection is initiated by Merchant or User of User  Default: `false`  
   param name: orderId | type: orderId | description: Order GUID to charge payments for. | required: true | validation: format GUID
   param name: regularCharge | type: RegularCharge    
    - ONE-OF: 
     - name: paymentIntentId | type: string | description: Payment intent GUID from the payment provider.  | validation: format GUID
     - name: delayedCharge | type: boolean | description: Whether to delay the charge. This starts a two-step flow: first preparing the payment, then charging later via Wix Pay startPayment() (https://dev.wix.com/docs/velo/apis/wix-pay-frontend/start-payment.md) function  
        - name: amount | type: Price | description: Amount to charge. | required: true 
        - name: redirectUrls | type: RedirectUrls | description: Redirect URLs for the payment flow.  
           - name: successUrl | type: string | description: URL to redirect the customer to after a successful payment transaction. Use this to show a confirmation page or thank you message.  | validation: maxLength 5000
           - name: cancelUrl | type: string | description: URL to redirect the customer to when they cancel the payment process. Typically redirects back to the checkout or cart page.  | validation: maxLength 5000
           - name: errorUrl | type: string | description: URL to redirect the customer to when the payment fails or is rejected. Use this to show an error page with retry options or alternative payment methods.  | validation: maxLength 5000
           - name: pendingUrl | type: string | description: URL to redirect the customer to when the payment is still being processed. Some payment methods require additional time for confirmation or verification.  | validation: maxLength 5000
        - name: delayedCaptureSettings | type: DelayedCaptureSettings | description: Automatic action settings for the authorization. Configure whether to automatically capture or void the authorization after a delay.  
           - name: scheduledAction | type: ScheduledAction | description: Automatic action to perform on the authorization after the specified delay period.  
                 - enum:
                 -     VOID: Automatically **void** the authorization after the delay period.  Use this when you want to automatically release the hold if payment isn't captured.
                 -     CAPTURE: Automatically **capture** (charge) the authorization after the delay period.  Use this for delayed billing or when you want to ensure payment is collected after fulfillment.
           - name: delayDuration | type: Duration | description: Time to wait before performing the scheduled action.  If not specified, the payment provider's default period will be used.  
              - name: count | type: integer | description: Amount of units. For example, 30 MINUTES, 1 HOURS, 7 DAYS, etc  | validation: minimum 1
              - name: unit | type: DurationUnit | description: Duration unit: MINUTES, HOURS and DAYS  
                     - enum: MINUTES, HOURS, DAYS
        - name: savePaymentMethod | type: boolean | description: Whether to save the payment method for future charges.  Default: `false`  
 Return type: ChargeOrderResponse
  - name: payments | type: array<Payment> | description: Payments created.  | validation: maxItems 100
     - ONE-OF: 
        - name: regularPaymentDetails | type: RegularPaymentDetails | description: Regular payment details.  
           - ONE-OF: 
              - name: creditCardDetails | type: CreditCardPaymentMethodDetails | description: Credit card details.  
                 - name: lastFourDigits | type: string | description: The last 4 digits of the card number.  | validation: maxLength 4
                 - name: brand | type: string | description: Card issuer's brand.  | validation: maxLength 100
           - name: paymentOrderId | type: string | description: Wix Payments order GUID.  | validation: maxLength 100
           - name: gatewayTransactionId | type: string | description: Payment gateway's transaction GUID. This field is only returned when the value of `offline_payment` is `false`.  | validation: maxLength 100
           - name: providerTransactionId | type: string | description: Transaction GUID in the payment provider's system. For example, at PayPal, Square, Stripe, etc. Not returned for offline payments.  | validation: maxLength 100
           - name: offlinePayment | type: boolean | description: Whether the payment was made offline. For example, when using cash or when marked as paid in the Business Manager.  
           - name: savedPaymentMethod | type: boolean | description: Whether there is a payment agreement that allows for future charges.  
           - name: authorizationDetails | type: AuthorizationDetails | description: Authorization details.  
              - name: delayedCapture | type: boolean | description: Whether the authorized payment is of a delayed capture.  | read-only: true 
              - name: authorizedDate | type: string | description: Date and time the payment was authorized in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  | validation: format date-time
              - name: captures | type: array<AuthorizationCapture> | description: List of captures associated with payment In case of failed it can be replaced with new one with PENDING or SUCCESS statuses  | validation: maxItems 1
                 - name: id | type: string | description: Capture GUID.  | read-only: true | validation: format GUID
                 - name: status | type: AuthorizationCaptureStatus | description: Status of this capture action  
                         - enum:
                         -     PENDING: Capture operation still in progress.
                         -     SUCCEEDED: Capture operation succeeded.
                         -     FAILED: Capture operation failed.
                 - name: amount | type: Price | description: Amount of this capture  | validation: immutable
                    - name: amount | type: string | description: Amount.  | validation: decimalValue {"gte":"0","lte":"1000000000000000"}
                    - name: formattedAmount | type: string | description: Amount formatted with currency symbol.  | read-only: true 
                 - name: createdDate | type: string | description: Date and time the capture was initiated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  | validation: format date-time
                 - name: failureDetails | type: AuthorizationActionFailureDetails | description: In case of status is FAILED may contain failure details  
                    - name: failureCode | type: string | description:   | validation: maxLength 100
              - name: void | type: AuthorizationVoid | description: Void associated with payment  
                 - name: status | type: AuthorizationVoidStatus | description: Status of this void action  
                         - enum:
                         -     PENDING: Void operation still in progress.
                         -     SUCCEEDED: Void operation succeeded.
                         -     FAILED: Void operation failed.
                 - name: voidedDate | type: string | description: Date and time the void was initiated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  | validation: format date-time
                 - name: failureDetails | type: AuthorizationActionFailureDetails | description: In case of status is FAILED may contain failure details  
                 - name: reason | type: Reason | description: Reason of void action  
                         - enum:
                         -     MANUAL: Authorization was voided by user.
                         -     SCHEDULED: Authorization passed execution date.
              - name: scheduledAction | type: ScheduledAction | description: Scheduled action for this transaction  
                 - name: actionType | type: ActionType | description: Type of the action.  
                         - enum: VOID, CAPTURE
                 - name: executionDate | type: string | description: The date and time of the action.  | validation: format date-time
           - name: chargebacks | type: array<Chargeback> | description: Record of chargebacks made by the buyer.  | validation: maxItems 6
              - name: id | type: string | description: Chargeback GUID.  | read-only: true | validation: format GUID, immutable
              - name: createdDate | type: string | description: Date and time the chargeback was created in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | read-only: true | validation: format date-time, immutable
              - name: updatedDate | type: string | description: Date and time the chargeback was updated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | read-only: true | validation: format date-time
              - name: amount | type: Price | description: Amount.  | read-only: true | validation: immutable
              - name: reversalAmount | type: Price | description: Reversal amount. Present only when status is REVERSED.  | read-only: true 
              - name: status | type: ChargebackStatus | description: Status.  Default: `"APPROVED"`.  
                     - enum:
                     -     APPROVED: Chargeback was approved.
                     -     REVERSED: Chargeback was reversed.
              - name: externalId | type: string | description: External chargeback GUID.  | read-only: true | validation: format GUID, immutable
           - name: platformFee | type: Price | description: Platform fee amount associated with this payment.  
           - name: paymentMethodName | type: PaymentMethodName | description: Payment method with buyer and optional owner translations. Non-exhaustive list of supported values: + `CreditCard`, `Alipay`, `AstropayCash`, `AstropayDBT`, `AstropayMBT`, `Bitcoin`, `BitPay`, `Cash`, `ConvenienceStore`, `EPay`, `Fake`, `Giropay`, `IDeal`, `InPerson`, `Klarna`, `MercadoPago`, `Netpay`, `NordeaSolo`, `Offline`, `PagSeguro`, `PayEasy`, `PayPal`, `Paysafecard`, `Paysafecash`, `PointOfSale`, `Poli`, `Privat24`, `Przelewy24`, `RapidTransfer`, `Sepa`, `Skrill`, `Sofort`, `Trustly`, `Neteller`, `Unionpay`, `UniPay`, `Yandex`  
              - name: buyerLanguageName | type: string | description: Translated payment method name in buyer language.  | validation: maxLength 150
              - name: siteLanguageName | type: string | description: Translated payment method name in site owner language.  | validation: maxLength 150
              - name: userDefinedName | type: UserDefinedPaymentMethodName | description: User-provided payment method name.  When set, takes precedence over `buyerLanguageName` and `siteLanguageName`.  
                 - ONE-OF: 
                    - name: predefined | type: PredefinedPaymentMethod | description: Predefined payment method.  
                             - enum:
                             -     CASH: Cash payment.
                             -     BANK_TRANSFER: Bank transfer.
                             -     CHECK: Payment by check.
                    - name: custom | type: string | description: Custom payment method name provided by user.  For example, `"Wire transfer"`, `"Money order"`, `"Venmo"` or any other custom name.  | validation: minLength 1, maxLength 150
        - name: giftcardPaymentDetails | type: GiftCardPaymentDetails | description: Gift card payment details.  
           - name: giftCardPaymentId | type: string | description: Gift card payment GUID.  | validation: maxLength 100
           - name: appId | type: string | description: GUID of the app that created the gift card.  | validation: format GUID
           - name: obfuscatedCode | type: string | description: Gift card code with all but the last four characters masked. For example, `************QXY1`.  | validation: maxLength 30, immutable
        - name: membershipPaymentDetails | type: MembershipPaymentDetails | description: Membership payment details.  
           - name: membershipId | type: string | description: Membership GUID.  | validation: maxLength 200
           - name: lineItemId | type: string | description: GUID of the line item this membership applies to.  | validation: minLength 1, maxLength 100
           - name: name | type: MembershipName | description: Membership name.  
              - name: original | type: string | description: Membership name.  | validation: maxLength 100
              - name: translated | type: string | description: Translated membership name. Defaults to `original` when not provided.  | validation: maxLength 100
           - name: externalTransactionId | type: string | description: The transaction GUID in the membership system. Can be used to void the transaction.  | validation: minLength 1, maxLength 100
           - name: providerAppId | type: string | description: GUID of the application providing this payment option.  | validation: format GUID
           - name: futureMembership | type: FutureMembershipDetails | description: Details of a membership that does not yet exist, allowing the payment to be held before the membership is created.  
              - name: lineItemId | type: string | description: GUID of the plan line item in the order from which the membership will be created.  | validation: format GUID
              - name: benefitId | type: string | description: GUID of the benefit the future membership will grant.  | validation: maxLength 200
     - name: id | type: string | description: Payment GUID.  | read-only: true | validation: format GUID
     - name: createdDate | type: string | description: Date and time the payment was created in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the payment was last updated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  | read-only: true | validation: format date-time
     - name: amount | type: Price | description: Payment amount.  
     - name: refundDisabled | type: boolean | description: Whether refunds for this payment are disabled. + `true`: This payment is not refundable. + `false`: This payment may be refunded. However, this ultimately depends on the payment provider.  
     - name: supportReceiptGeneration | type: boolean | description: Whether receipt generation is allowed for this payment. + `true`: This payment supports receipt generation. + `false`: This payment doesn't support receipt generation, or a receipt was already generated.  | read-only: true 
     - name: cashRounding | type: CashRoundingDetails | description: Details about cash rounding applied to this payment, when relevant.  
        - name: unroundedAmount | type: Price | description: Payment amount before cash rounding was applied. When provided, balance and status calculations use this value instead of `amount` to prevent false overpayment or underpayment due to rounding.  
        - name: roundingAdjustment | type: CashRounding | description: The difference between 'amount' and 'unroundedAmount' (amount minus unroundedAmount). A positive value indicates the price was rounded up; a negative value indicates a round-down.  | read-only: true 
           - name: amount | type: string | description: Amount, can be negative or positive.  | validation: decimalValue {"gte":"-1000000000000000","lte":"1000000000000000"}
           - name: formattedAmount | type: string | description: Amount formatted with currency symbol.  | read-only: true 
     - name: status | type: PaymentStatus | description: Overall payment status.  Gift card and membership payments support only `APPROVED`, `PENDING`, `CANCELED`, `DECLINED`, and `VOIDED`. The remaining values apply to regular payments.  
         - enum:
         -     APPROVED: Payment was charged successfully.
         -     PENDING: Payment is being processed and hasn't been confirmed yet.
         -     PENDING_MERCHANT: Payment is awaiting confirmation. For an offline payment, the merchant must confirm they received it. For an online payment, the payment provider hasn't confirmed it, which typically means the merchant's provider account setup isn't complete.
         -     CANCELED: Payment was canceled before it was charged.
         -     DECLINED: Payment was declined by the payment provider.
         -     REFUNDED: Payment was fully refunded.
         -     PARTIALLY_REFUNDED: Part of the payment amount was refunded.
         -     AUTHORIZED: Funds are held on the buyer's payment method but haven't been captured. Capture them with [Capture Authorized Payments](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/capture-authorized-payments.md) or release them with [Void Authorized Payments](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/void-authorized-payments.md). An authorized payment can't be refunded until it's captured.
         -     VOIDED: Payment was voided, releasing whatever it held or consumed: an authorization on the buyer's payment method, a gift card balance, or membership credits.  Gift card and membership payments don't support partial refunds, so a full refund of one is reported as `VOIDED` rather than `REFUNDED`.
     - name: chargeCorrelationId | type: string | description: GUID linking this payment to the charge request that created it. Matches the `idempotencyKey` sent in the Charge Order request.  | validation: format GUID
  - name: orderTransactions | type: OrderTransactions | description: Updated order transaction history reflecting all payments statuses  
     - name: orderId | type: string | description: Order GUID.  | validation: format GUID
     - name: payments | type: array<Payment> | description: Record of payments made to the merchant.  | validation: maxItems 100
     - name: refunds | type: array<Refund> | description: Record of refunds made to the buyer.  | validation: maxItems 300
        - name: id | type: string | description: Refund GUID.  | read-only: true | validation: format GUID
        - name: transactions | type: array<RefundTransaction> | description: List of transactions.  | validation: minItems 0, maxItems 50
           - name: paymentId | type: string | description: GUID of the payment associated with this refund.  | validation: format GUID, immutable
           - name: amount | type: Price | description: Refund amount.  | validation: immutable
           - name: refundStatus | type: RefundStatus | description: Refund status.  
                 - enum:
                 -     PENDING: Refund was initiated on payment provider side. PENDING status was assigned by provider.
                 -     SUCCEEDED: Refund transaction succeeded.
                 -     FAILED: Refund transaction failed.
                 -     SCHEDULED: Refund request acknowledged, and will be executed soon.
                 -     STARTED: Refund was initiated on payment provider side.
           - name: refundStatusInfo | type: RefundStatusInfo | description: Optional details of current refund status.  
              - name: paymentGatewayReasonCode | type: string | description: Reason code for the refund's current status.  Learn more about [reason codes](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/reason-codes.md).  | validation: minLength 1, maxLength 10
              - name: description | type: string | description: Free text explanation of current refund status.  | validation: minLength 1, maxLength 1000
           - name: gatewayRefundId | type: string | description: Payment gateway's refund GUID. This field is only returned when the value of `external_refund` is `false`.  | validation: format GUID
           - name: providerRefundId | type: string | description: GUID of the refund in the payment provider's system. For example, at PayPal, Square, Stripe, etc. Not returned for external refunds.  
           - name: externalRefund | type: boolean | description: Whether refund was made externally and manually on the payment provider's side.  | validation: immutable
        - name: details | type: RefundDetails | description: Refund business details.  
           - name: items | type: array<RefundItem> | description: Order line item GUIDs and quantities that were refunded.  | validation: minItems 0, maxItems 300
              - name: lineItemId | type: string | description: Line item GUID the refunded line item.  | validation: format GUID
              - name: quantity | type: integer | description: Line item quantity refunded.  | validation: minimum 1, maximum 100000
           - name: shippingIncluded | type: boolean | description: Whether the shipping fee was also refunded.  
           - name: reason | type: string | description: Reason for the refund, provided by customer (optional).  | validation: maxLength 200
           - name: lineItems | type: array<LineItemRefund> | description: Line items that were refunded.  | validation: minItems 0, maxItems 300
              - name: lineItemId | type: string | description: Line item GUID.  | validation: format GUID, immutable
              - name: quantity | type: integer | description: Refund quantity.  | validation: minimum 1, maximum 100000, immutable
           - name: additionalFees | type: array<AdditionalFeeRefund> | description: Additional fees that were refunded.  | validation: minItems 0, maxItems 100
              - name: additionalFeeId | type: string | description: Additional fee GUID.  | validation: format GUID, immutable
              - name: amount | type: Price | description: Refund amount.  | validation: immutable
           - name: shipping | type: ShippingRefund | description: Shipping amount that was refunded.  
              - name: amount | type: Price | description: Refund amount.  | validation: immutable
        - name: createdDate | type: string | description: Date and time the refund was created in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | read-only: true | validation: format date-time, immutable
        - name: summary | type: AggregatedRefundSummary | description: Aggregated refund summary.  | read-only: true 
           - name: requestedRefund | type: Price | description: Total amount requested for refund.  
           - name: pendingRefund | type: Price | description: Pending refund amount - the portion of `requestedRefund` that is still pending.  
           - name: refunded | type: Price | description: Refunded amount - the portion of `requestedRefund` that refunded successfully.  
           - name: failedRefundAmount | type: Price | description: Failed refund amount - the portion of `requestedRefund` that failed.  
           - name: pending | type: boolean | description: Whether at least one refund transaction is still in `"PENDING"` status.  
           - name: breakdown | type: RefundItemsBreakdown | description: Breakdown of refunded items. Available only after refund is complete.  
              - name: lineItems | type: array<LineItemRefundSummary> | description: Refunded line items and the amount refunded for each.  | validation: minItems 0, maxItems 300
                 - name: lineItemId | type: string | description: GUID of the refunded line item.  | validation: format GUID
                 - name: totalRefundedAmount | type: Price | description: Total refunded amount for the line item.  
        - name: requestingServiceAppId | type: string | description: GUID of the app that initiated this refund.  | read-only: true | validation: format GUID, immutable
  - name: regularChargeResponseToken | type: string | description: (Optional) Charge response token (for regular charge) from payment gateway. Present when non-delayed charge is requested.  | validation: minLength 1, maxLength 300

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PAYMENT_INTENT_ID_REQUIRED | Description: Payment intent GUID is required for regular charges. payment intent is required only when delayedCharge is false
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_AMOUNT | Description: Charge amount is invalid.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: GIFT_CARD_NOT_FOUND | Description: Couldn't find the gift card.
   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: LINE_ITEM_PAID | Description: Requested line item is already paid with membership.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: ALREADY_REDEEMED | Description: Gift card was already redeemed.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: GIFT_CARD_ALREADY_APPLIED | Description: Gift card was already applied to the order.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_ALREADY_IN_PROGRESS | Description: A payment for this order is already in progress. Wait for it to reach a final status before charging again.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_ALREADY_APPROVED | Description: The payment was already approved. Unlike `ORDER_PAID`, the order isn't necessarily fully paid. Retrieve the order's payments instead of charging again.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_METHOD_UNAVAILABLE | Description: Payment method is unavailable. It's either disabled or not connected to the site.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_ATTEMPT_EXPIRED | Description: The payment attempt expired before it could be charged. Collect the payment details again and retry the charge.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MEMBERSHIP_NOT_ELIGIBLE | Description: Membership eligibility check failed.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_GIFT_CARD_CURRENCY | Description: Gift card currency is different from order currency.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_FUNDS | Description: Gift card has insufficient funds.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: GIFT_CARD_DISABLED | Description: Gift card is disabled.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: GIFT_CARD_EXPIRED | Description: Gift card is expired.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_HAS_CHARGEBACKS | Description: Order has chargebacks and can't be charged.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_PAID | Description: Order was already paid.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_CANCELED | Description: Order was already canceled.


```

### Examples

### Charge Order
Charge order using credit card, membership and gift card.

```curl
curl -X POST \
  'https://www.wixapis.com/ecom/v1/order-billing/charge-order' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "orderId": "c8be6e35-227e-4c9e-89a9-936b5f568d81",
    "regularCharge": {
      "amount": {
        "amount": "9.99"
      },
      "paymentIntentId": "5dd3717a-1030-4508-a86a-663d2f316e53",
      "redirectUrls": {
        "cancelUrl": "https://www.cancel.com",
        "errorUrl": "https://www.error.com",
        "pendingUrl": "https://www.pending.com",
        "successUrl": "https://www.success.com"
      },
      "savePaymentMethod": false
    },
    "memberships": [
      {
        "lineItemId": "00000000-0000-0000-0000-000000000002",
        "membershipIdentifier": {
          "existingMembership": {
            "appId": "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3",
            "membershipId": "E7aAmgntEU1i8EynJ7KVoTdWmx84CF9vnpn5LNeiMHBGQJWp3XFK2bdG6NYklX8v3gtWo33WswnN1qYfjR5XSFZ4ffKU2ryTsVi"
          }
        }
      }
    ],
    "giftCards": [
      {
        "amount": {
          "amount": "10.0"
        },
        "giftCardCode": "TESTGIFTCARD0001"
      }
    ],
    "idempotencyKey": "ca6baead-b619-4c4a-811d-e12a4e4dda72",
    "memberId": "aab64a42-4a04-4e6a-bb60-346acc5a3d47",
    "merchantInitiated": false
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.orderBilling.chargeOrder(orderId, options)
 Description: Charges payments for an order using one or more payment methods.  Supports charging through multiple payment methods in a single request: - **Regular payments**: Charges using the customer's payment method (credit card, PayPal, etc.). - **Gift cards**: Redeems gift card codes - **Memberships**: Charges membership credits or benefits for specific line items.  The method processes all specified payment types and returns the created payments along with the updated order transactions.  A successful charge returns payments with a `status` of `APPROVED`, `AUTHORIZED`, `PENDING`, or `PENDING_MERCHANT`. `PENDING` and `PENDING_MERCHANT` payments are confirmed asynchronously, so poll the order's transactions or listen for payment events rather than treating the response as final.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  orderId, options.regularCharge.amount, options.regularCharge.amount.amount, options.giftCards.giftCardCode, options.giftCards.amount, options.giftCards.amount.amount, options.memberships.membershipIdentifier, options.memberships.membershipIdentifier.existingMembership.appId, options.memberships.membershipIdentifier.existingMembership.membershipId, options.memberships.membershipIdentifier.futureMembership.lineItemId, options.memberships.membershipIdentifier.futureMembership.benefitId, options.memberships.lineItemId
 Method parameters: 
   param name: options | type: ChargeOrderOptions  none  
        - name: memberId | type: string | description: Member GUID associated with the order.  | validation: format GUID
        - name: regularCharge | type: RegularCharge | description: Regular payment charge details.  
           - ONE-OF: - required: true
              - name: paymentIntentId | type: string | description: Payment intent GUID from the payment provider.  | validation: format GUID
              - name: delayedCharge | type: boolean | description: Whether to delay the charge. This starts a two-step flow: first preparing the payment, then charging later via Wix Pay startPayment() (https://dev.wix.com/docs/velo/apis/wix-pay-frontend/start-payment.md) function  
           - name: amount | type: Price | description: Amount to charge. | required: true 
              - name: amount | type: string | description: Amount. | required: true | validation: decimalValue {"gte":"0","lte":"1000000000000000"}
           - name: redirectUrls | type: RedirectUrls | description: Redirect URLs for the payment flow.  
              - name: successUrl | type: string | description: URL to redirect the customer to after a successful payment transaction. Use this to show a confirmation page or thank you message.  | validation: maxLength 5000
              - name: cancelUrl | type: string | description: URL to redirect the customer to when they cancel the payment process. Typically redirects back to the checkout or cart page.  | validation: maxLength 5000
              - name: errorUrl | type: string | description: URL to redirect the customer to when the payment fails or is rejected. Use this to show an error page with retry options or alternative payment methods.  | validation: maxLength 5000
              - name: pendingUrl | type: string | description: URL to redirect the customer to when the payment is still being processed. Some payment methods require additional time for confirmation or verification.  | validation: maxLength 5000
           - name: delayedCaptureSettings | type: DelayedCaptureSettings | description: Automatic action settings for the authorization. Configure whether to automatically capture or void the authorization after a delay.  
              - name: scheduledAction | type: ScheduledAction | description: Automatic action to perform on the authorization after the specified delay period.  
                     - enum:
                     -     VOID: Automatically **void** the authorization after the delay period.  Use this when you want to automatically release the hold if payment isn't captured.
                     -     CAPTURE: Automatically **capture** (charge) the authorization after the delay period.  Use this for delayed billing or when you want to ensure payment is collected after fulfillment.
              - name: delayDuration | type: Duration | description: Time to wait before performing the scheduled action.  If not specified, the payment provider's default period will be used.  
                 - name: count | type: integer | description: Amount of units. For example, 30 MINUTES, 1 HOURS, 7 DAYS, etc  | validation: minimum 1
                 - name: unit | type: DurationUnit | description: Duration unit: MINUTES, HOURS and DAYS  
                         - enum: MINUTES, HOURS, DAYS
           - name: savePaymentMethod | type: boolean | description: Whether to save the payment method for future charges.  Default: `false`  
        - name: giftCards | type: array<GiftCardCharge> | description: Gift card charges to apply to the order.  | validation: maxItems 100
           - name: giftCardCode | type: string | description: Gift card redemption code.  | validation: minLength 8, maxLength 20
           - name: amount | type: Price | description: Amount to charge from the gift card.  
           - name: currencyConversionInfo | type: CurrencyConversionInfo | description: Details of the conversion from the gift card's currency to the order's currency.  Required if the order's currency differs from the gift card's currency.  When provided, the gift card is redeemed with `originalAmount`, otherwise with `amount`.  
              - name: originalCurrency | type: string | description: Currency the amount was converted from, as a three-letter currency code in @ISO-4217 alphabetic format.  | validation: format CURRENCY
              - name: originalAmount | type: string | description: Amount before conversion, in `originalCurrency`.  | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","lte":"1000000000000000","maxScale":4}
              - name: conversionRate | type: string | description: Rate used to convert `originalAmount` to the order's currency. For example, `"1.08"`.  | validation: format DECIMAL_VALUE, decimalValue {"gt":"0","lte":"1000000000000000"}
        - name: memberships | type: array<MembershipCharge> | description: Membership charges to apply to the order.  | validation: maxItems 100
           - name: lineItemId | type: string | description:   | validation: format GUID
           - name: membershipIdentifier | type: MembershipIdentifier | description:   
              - ONE-OF: 
                 - name: existingMembership | type: ExistingMembershipIdentifier | description: An existing, already-provisioned membership.  
                    - name: appId | type: string | description: GUID of the app providing this membership payment option (e.g., Pricing Plans).  | validation: format GUID
                    - name: membershipId | type: string | description: GUID of existing membership.  | validation: minLength 1, maxLength 200
                 - name: futureMembership | type: FutureMembershipIdentifier | description: A future membership - no membership GUID yet; identified by the paying plan line item + selected benefit.  
                    - name: lineItemId | type: string | description: GUID of the Plan line item that is used to pay for the booking item.  | validation: format GUID
                    - name: benefitId | type: string | description: The selected unit within the Plan that will be redeemed.  | validation: maxLength 200
        - name: idempotencyKey | type: string | description: Idempotency key to prevent duplicate charges, for example: checkoutId  | validation: format GUID
        - name: merchantInitiated | type: boolean | description: Specifies whether payment collection is initiated by Merchant or User of User  Default: `false`  
   param name: orderId | type: string | description: Order GUID to charge payments for. | required: true | validation: format GUID
 Return type: PROMISE<ChargeOrderResponse>
  - name: payments | type: array<Payment> | description: Payments created.  | validation: maxItems 100
     - ONE-OF: 
        - name: regularPaymentDetails | type: RegularPaymentDetails | description: Regular payment details.  
           - ONE-OF: 
              - name: creditCardDetails | type: CreditCardPaymentMethodDetails | description: Credit card details.  
                 - name: lastFourDigits | type: string | description: The last 4 digits of the card number.  | validation: maxLength 4
                 - name: brand | type: string | description: Card issuer's brand.  | validation: maxLength 100
           - name: paymentOrderId | type: string | description: Wix Payments order GUID.  | validation: maxLength 100
           - name: gatewayTransactionId | type: string | description: Payment gateway's transaction GUID. This field is only returned when the value of `offline_payment` is `false`.  | validation: maxLength 100
           - name: providerTransactionId | type: string | description: Transaction GUID in the payment provider's system. For example, at PayPal, Square, Stripe, etc. Not returned for offline payments.  | validation: maxLength 100
           - name: offlinePayment | type: boolean | description: Whether the payment was made offline. For example, when using cash or when marked as paid in the Business Manager.  
           - name: savedPaymentMethod | type: boolean | description: Whether there is a payment agreement that allows for future charges.  
           - name: authorizationDetails | type: AuthorizationDetails | description: Authorization details.  
              - name: delayedCapture | type: boolean | description: Whether the authorized payment is of a delayed capture.  | read-only: true 
              - name: authorizedDate | type: Date | description: Date and time the payment was authorized in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  
              - name: captures | type: array<AuthorizationCapture> | description: List of captures associated with payment In case of failed it can be replaced with new one with PENDING or SUCCESS statuses  | validation: maxItems 1
                 - name: _id | type: string | description: Capture GUID.  | read-only: true | validation: format GUID
                 - name: status | type: AuthorizationCaptureStatus | description: Status of this capture action  
                         - enum:
                         -     PENDING: Capture operation still in progress.
                         -     SUCCEEDED: Capture operation succeeded.
                         -     FAILED: Capture operation failed.
                 - name: amount | type: Price | description: Amount of this capture  | validation: immutable
                    - name: amount | type: string | description: Amount.  | validation: decimalValue {"gte":"0","lte":"1000000000000000"}
                    - name: formattedAmount | type: string | description: Amount formatted with currency symbol.  | read-only: true 
                 - name: _createdDate | type: Date | description: Date and time the capture was initiated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  
                 - name: failureDetails | type: AuthorizationActionFailureDetails | description: In case of status is FAILED may contain failure details  
                    - name: failureCode | type: string | description:   | validation: maxLength 100
              - name: void | type: AuthorizationVoid | description: Void associated with payment  
                 - name: status | type: AuthorizationVoidStatus | description: Status of this void action  
                         - enum:
                         -     PENDING: Void operation still in progress.
                         -     SUCCEEDED: Void operation succeeded.
                         -     FAILED: Void operation failed.
                 - name: voidedDate | type: Date | description: Date and time the void was initiated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  
                 - name: failureDetails | type: AuthorizationActionFailureDetails | description: In case of status is FAILED may contain failure details  
                 - name: reason | type: Reason | description: Reason of void action  
                         - enum:
                         -     MANUAL: Authorization was voided by user.
                         -     SCHEDULED: Authorization passed execution date.
              - name: scheduledAction | type: ScheduledAction | description: Scheduled action for this transaction  
                 - name: actionType | type: ActionType | description: Type of the action.  
                         - enum: VOID, CAPTURE
                 - name: executionDate | type: Date | description: The date and time of the action.  
           - name: chargebacks | type: array<Chargeback> | description: Record of chargebacks made by the buyer.  | validation: maxItems 6
              - name: _id | type: string | description: Chargeback GUID.  | read-only: true | validation: format GUID, immutable
              - name: _createdDate | type: Date | description: Date and time the chargeback was created in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | read-only: true | validation: immutable
              - name: _updatedDate | type: Date | description: Date and time the chargeback was updated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | read-only: true 
              - name: amount | type: Price | description: Amount.  | read-only: true | validation: immutable
              - name: reversalAmount | type: Price | description: Reversal amount. Present only when status is REVERSED.  | read-only: true 
              - name: status | type: ChargebackStatus | description: Status.  Default: `"APPROVED"`.  
                     - enum:
                     -     APPROVED: Chargeback was approved.
                     -     REVERSED: Chargeback was reversed.
              - name: externalId | type: string | description: External chargeback GUID.  | read-only: true | validation: format GUID, immutable
           - name: platformFee | type: Price | description: Platform fee amount associated with this payment.  
           - name: paymentMethodName | type: PaymentMethodName | description: Payment method with buyer and optional owner translations. Non-exhaustive list of supported values: + `CreditCard`, `Alipay`, `AstropayCash`, `AstropayDBT`, `AstropayMBT`, `Bitcoin`, `BitPay`, `Cash`, `ConvenienceStore`, `EPay`, `Fake`, `Giropay`, `IDeal`, `InPerson`, `Klarna`, `MercadoPago`, `Netpay`, `NordeaSolo`, `Offline`, `PagSeguro`, `PayEasy`, `PayPal`, `Paysafecard`, `Paysafecash`, `PointOfSale`, `Poli`, `Privat24`, `Przelewy24`, `RapidTransfer`, `Sepa`, `Skrill`, `Sofort`, `Trustly`, `Neteller`, `Unionpay`, `UniPay`, `Yandex`  
              - name: buyerLanguageName | type: string | description: Translated payment method name in buyer language.  | validation: maxLength 150
              - name: siteLanguageName | type: string | description: Translated payment method name in site owner language.  | validation: maxLength 150
              - name: userDefinedName | type: UserDefinedPaymentMethodName | description: User-provided payment method name.  When set, takes precedence over `buyerLanguageName` and `siteLanguageName`.  
                 - ONE-OF: 
                    - name: predefined | type: PredefinedPaymentMethod | description: Predefined payment method.  
                             - enum:
                             -     CASH: Cash payment.
                             -     BANK_TRANSFER: Bank transfer.
                             -     CHECK: Payment by check.
                    - name: custom | type: string | description: Custom payment method name provided by user.  For example, `"Wire transfer"`, `"Money order"`, `"Venmo"` or any other custom name.  | validation: minLength 1, maxLength 150
        - name: giftcardPaymentDetails | type: GiftCardPaymentDetails | description: Gift card payment details.  
           - name: giftCardPaymentId | type: string | description: Gift card payment GUID.  | validation: maxLength 100
           - name: appId | type: string | description: GUID of the app that created the gift card.  | validation: format GUID
           - name: obfuscatedCode | type: string | description: Gift card code with all but the last four characters masked. For example, `************QXY1`.  | validation: maxLength 30, immutable
        - name: membershipPaymentDetails | type: MembershipPaymentDetails | description: Membership payment details.  
           - name: membershipId | type: string | description: Membership GUID.  | validation: maxLength 200
           - name: lineItemId | type: string | description: GUID of the line item this membership applies to.  | validation: minLength 1, maxLength 100
           - name: name | type: MembershipName | description: Membership name.  
              - name: original | type: string | description: Membership name.  | validation: maxLength 100
              - name: translated | type: string | description: Translated membership name. Defaults to `original` when not provided.  | validation: maxLength 100
           - name: externalTransactionId | type: string | description: The transaction GUID in the membership system. Can be used to void the transaction.  | validation: minLength 1, maxLength 100
           - name: providerAppId | type: string | description: GUID of the application providing this payment option.  | validation: format GUID
           - name: futureMembership | type: FutureMembershipDetails | description: Details of a membership that does not yet exist, allowing the payment to be held before the membership is created.  
              - name: lineItemId | type: string | description: GUID of the plan line item in the order from which the membership will be created.  | validation: format GUID
              - name: benefitId | type: string | description: GUID of the benefit the future membership will grant.  | validation: maxLength 200
     - name: _id | type: string | description: Payment GUID.  | read-only: true | validation: format GUID
     - name: _createdDate | type: Date | description: Date and time the payment was created in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  
     - name: _updatedDate | type: Date | description: Date and time the payment was last updated in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format.  | read-only: true 
     - name: amount | type: Price | description: Payment amount.  
     - name: refundDisabled | type: boolean | description: Whether refunds for this payment are disabled. + `true`: This payment is not refundable. + `false`: This payment may be refunded. However, this ultimately depends on the payment provider.  
     - name: supportReceiptGeneration | type: boolean | description: Whether receipt generation is allowed for this payment. + `true`: This payment supports receipt generation. + `false`: This payment doesn't support receipt generation, or a receipt was already generated.  | read-only: true 
     - name: cashRounding | type: CashRoundingDetails | description: Details about cash rounding applied to this payment, when relevant.  
        - name: unroundedAmount | type: Price | description: Payment amount before cash rounding was applied. When provided, balance and status calculations use this value instead of `amount` to prevent false overpayment or underpayment due to rounding.  
        - name: roundingAdjustment | type: CashRounding | description: The difference between 'amount' and 'unroundedAmount' (amount minus unroundedAmount). A positive value indicates the price was rounded up; a negative value indicates a round-down.  | read-only: true 
           - name: amount | type: string | description: Amount, can be negative or positive.  | validation: decimalValue {"gte":"-1000000000000000","lte":"1000000000000000"}
           - name: formattedAmount | type: string | description: Amount formatted with currency symbol.  | read-only: true 
     - name: status | type: PaymentStatus | description: Overall payment status.  Gift card and membership payments support only `APPROVED`, `PENDING`, `CANCELED`, `DECLINED`, and `VOIDED`. The remaining values apply to regular payments.  
         - enum:
         -     APPROVED: Payment was charged successfully.
         -     PENDING: Payment is being processed and hasn't been confirmed yet.
         -     PENDING_MERCHANT: Payment is awaiting confirmation. For an offline payment, the merchant must confirm they received it. For an online payment, the payment provider hasn't confirmed it, which typically means the merchant's provider account setup isn't complete.
         -     CANCELED: Payment was canceled before it was charged.
         -     DECLINED: Payment was declined by the payment provider.
         -     REFUNDED: Payment was fully refunded.
         -     PARTIALLY_REFUNDED: Part of the payment amount was refunded.
         -     AUTHORIZED: Funds are held on the buyer's payment method but haven't been captured. Capture them with [Capture Authorized Payments](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/capture-authorized-payments.md) or release them with [Void Authorized Payments](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/void-authorized-payments.md). An authorized payment can't be refunded until it's captured.
         -     VOIDED: Payment was voided, releasing whatever it held or consumed: an authorization on the buyer's payment method, a gift card balance, or membership credits.  Gift card and membership payments don't support partial refunds, so a full refund of one is reported as `VOIDED` rather than `REFUNDED`.
     - name: chargeCorrelationId | type: string | description: GUID linking this payment to the charge request that created it. Matches the `idempotencyKey` sent in the Charge Order request.  | validation: format GUID
  - name: orderTransactions | type: OrderTransactions | description: Updated order transaction history reflecting all payments statuses  
     - name: orderId | type: string | description: Order GUID.  | validation: format GUID
     - name: payments | type: array<Payment> | description: Record of payments made to the merchant.  | validation: maxItems 100
     - name: refunds | type: array<Refund> | description: Record of refunds made to the buyer.  | validation: maxItems 300
        - name: _id | type: string | description: Refund GUID.  | read-only: true | validation: format GUID
        - name: transactions | type: array<RefundTransaction> | description: List of transactions.  | validation: minItems 0, maxItems 50
           - name: paymentId | type: string | description: GUID of the payment associated with this refund.  | validation: format GUID, immutable
           - name: amount | type: Price | description: Refund amount.  | validation: immutable
           - name: refundStatus | type: RefundStatus | description: Refund status.  
                 - enum:
                 -     PENDING: Refund was initiated on payment provider side. PENDING status was assigned by provider.
                 -     SUCCEEDED: Refund transaction succeeded.
                 -     FAILED: Refund transaction failed.
                 -     SCHEDULED: Refund request acknowledged, and will be executed soon.
                 -     STARTED: Refund was initiated on payment provider side.
           - name: refundStatusInfo | type: RefundStatusInfo | description: Optional details of current refund status.  
              - name: paymentGatewayReasonCode | type: string | description: Reason code for the refund's current status.  Learn more about [reason codes](https://dev.wix.com/docs/rest/business-management/payments/service-plugins/payment-service-provider-service-plugin/reason-codes.md).  | validation: minLength 1, maxLength 10
              - name: description | type: string | description: Free text explanation of current refund status.  | validation: minLength 1, maxLength 1000
           - name: gatewayRefundId | type: string | description: Payment gateway's refund GUID. This field is only returned when the value of `external_refund` is `false`.  | validation: format GUID
           - name: providerRefundId | type: string | description: GUID of the refund in the payment provider's system. For example, at PayPal, Square, Stripe, etc. Not returned for external refunds.  
           - name: externalRefund | type: boolean | description: Whether refund was made externally and manually on the payment provider's side.  | validation: immutable
        - name: details | type: RefundDetails | description: Refund business details.  
           - name: items | type: array<RefundItem> | description: Order line item GUIDs and quantities that were refunded.  | validation: minItems 0, maxItems 300
              - name: lineItemId | type: string | description: Line item GUID the refunded line item.  | validation: format GUID
              - name: quantity | type: integer | description: Line item quantity refunded.  | validation: minimum 1, maximum 100000
           - name: shippingIncluded | type: boolean | description: Whether the shipping fee was also refunded.  
           - name: reason | type: string | description: Reason for the refund, provided by customer (optional).  | validation: maxLength 200
           - name: lineItems | type: array<LineItemRefund> | description: Line items that were refunded.  | validation: minItems 0, maxItems 300
              - name: lineItemId | type: string | description: Line item GUID.  | validation: format GUID, immutable
              - name: quantity | type: integer | description: Refund quantity.  | validation: minimum 1, maximum 100000, immutable
           - name: additionalFees | type: array<AdditionalFeeRefund> | description: Additional fees that were refunded.  | validation: minItems 0, maxItems 100
              - name: additionalFeeId | type: string | description: Additional fee GUID.  | validation: format GUID, immutable
              - name: amount | type: Price | description: Refund amount.  | validation: immutable
           - name: shipping | type: ShippingRefund | description: Shipping amount that was refunded.  
              - name: amount | type: Price | description: Refund amount.  | validation: immutable
        - name: _createdDate | type: Date | description: Date and time the refund was created in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. Defaults to current time when not provided.  | read-only: true | validation: immutable
        - name: summary | type: AggregatedRefundSummary | description: Aggregated refund summary.  | read-only: true 
           - name: requestedRefund | type: Price | description: Total amount requested for refund.  
           - name: pendingRefund | type: Price | description: Pending refund amount - the portion of `requestedRefund` that is still pending.  
           - name: refunded | type: Price | description: Refunded amount - the portion of `requestedRefund` that refunded successfully.  
           - name: failedRefundAmount | type: Price | description: Failed refund amount - the portion of `requestedRefund` that failed.  
           - name: pending | type: boolean | description: Whether at least one refund transaction is still in `"PENDING"` status.  
           - name: breakdown | type: RefundItemsBreakdown | description: Breakdown of refunded items. Available only after refund is complete.  
              - name: lineItems | type: array<LineItemRefundSummary> | description: Refunded line items and the amount refunded for each.  | validation: minItems 0, maxItems 300
                 - name: lineItemId | type: string | description: GUID of the refunded line item.  | validation: format GUID
                 - name: totalRefundedAmount | type: Price | description: Total refunded amount for the line item.  
        - name: requestingServiceAppId | type: string | description: GUID of the app that initiated this refund.  | read-only: true | validation: format GUID, immutable
  - name: regularChargeResponseToken | type: string | description: (Optional) Charge response token (for regular charge) from payment gateway. Present when non-delayed charge is requested.  | validation: minLength 1, maxLength 300

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PAYMENT_INTENT_ID_REQUIRED | Description: Payment intent GUID is required for regular charges. payment intent is required only when delayedCharge is false
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_AMOUNT | Description: Charge amount is invalid.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: GIFT_CARD_NOT_FOUND | Description: Couldn't find the gift card.
   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: LINE_ITEM_PAID | Description: Requested line item is already paid with membership.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: ALREADY_REDEEMED | Description: Gift card was already redeemed.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: GIFT_CARD_ALREADY_APPLIED | Description: Gift card was already applied to the order.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_ALREADY_IN_PROGRESS | Description: A payment for this order is already in progress. Wait for it to reach a final status before charging again.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_ALREADY_APPROVED | Description: The payment was already approved. Unlike `ORDER_PAID`, the order isn't necessarily fully paid. Retrieve the order's payments instead of charging again.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_METHOD_UNAVAILABLE | Description: Payment method is unavailable. It's either disabled or not connected to the site.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PAYMENT_ATTEMPT_EXPIRED | Description: The payment attempt expired before it could be charged. Collect the payment details again and retry the charge.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MEMBERSHIP_NOT_ELIGIBLE | Description: Membership eligibility check failed.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_GIFT_CARD_CURRENCY | Description: Gift card currency is different from order currency.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_FUNDS | Description: Gift card has insufficient funds.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: GIFT_CARD_DISABLED | Description: Gift card is disabled.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: GIFT_CARD_EXPIRED | Description: Gift card is expired.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_HAS_CHARGEBACKS | Description: Order has chargebacks and can't be charged.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_PAID | Description: Order was already paid.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORDER_CANCELED | Description: Order was already canceled.


```

### Examples

### Charge Order
Charge an order using a credit card, a membership, and a gift card.

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

async function chargeOrder() {
  const response = await orderBilling.chargeOrder(
    "c8be6e35-227e-4c9e-89a9-936b5f568d81",
    {
      regularCharge: {
        amount: { amount: "9.99" },
        paymentIntentId: "5dd3717a-1030-4508-a86a-663d2f316e53",
        redirectUrls: {
          cancelUrl: "https://www.cancel.com",
          errorUrl: "https://www.error.com",
          pendingUrl: "https://www.pending.com",
          successUrl: "https://www.success.com",
        },
        savePaymentMethod: false,
      },
      memberships: [
        {
          lineItemId: "00000000-0000-0000-0000-000000000002",
          membershipIdentifier: {
            existingMembership: {
              appId: "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3",
              membershipId: "E7aAmgntEU1i8EynJ7KVoTdWmx84CF9vnpn5LNeiMHBGQJWp3XFK2bdG6NYklX8v3gtWo33WswnN1qYfjR5XSFZ4ffKU2ryTsVi",
            },
          },
        },
      ],
      giftCards: [
        {
          amount: { amount: "10.0" },
          giftCardCode: "TESTGIFTCARD0001",
        },
      ],
      idempotencyKey: "ca6baead-b619-4c4a-811d-e12a4e4dda72",
      memberId: "aab64a42-4a04-4e6a-bb60-346acc5a3d47",
      merchantInitiated: false,
    },
  );
  return response;
}

/* Promise resolves to:
 * {
 *   "payments": [
 *     {
 *       "regularPaymentDetails": {
 *         "gatewayTransactionId": "296fa780-ec09-40d1-957f-9604eb2c7d1f",
 *         "offlinePayment": false,
 *         "status": "APPROVED",
 *         "savedPaymentMethod": false,
 *         "chargebacks": []
 *       },
 *       "amount": { "amount": "9.99", "formattedAmount": "$9.99" },
 *       "refundDisabled": false,
 *       "status": "APPROVED",
 *       "chargeCorrelationId": "ca6baead-b619-4c4a-811d-e12a4e4dda72"
 *     },
 *     {
 *       "membershipPaymentDetails": {
 *         "membershipId": "E7aAmgntEU1i8EynJ7KVoTdWmx84CF9vnpn5LNeiMHBGQJWp3XFK2bdG6NYklX8v3gtWo33WswnN1qYfjR5XSFZ4ffKU2ryTsVi",
 *         "lineItemId": "00000000-0000-0000-0000-000000000002",
 *         "status": "CHARGE_PENDING",
 *         "name": { "original": "Silver Membership" },
 *         "voided": true,
 *         "providerAppId": "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3"
 *       },
 *       "refundDisabled": false,
 *       "status": "PENDING",
 *       "chargeCorrelationId": "ca6baead-b619-4c4a-811d-e12a4e4dda72"
 *     },
 *     {
 *       "giftcardPaymentDetails": {
 *         "appId": "d80111c5-a0f4-47a8-b63a-65b54d774a27",
 *         "voided": true,
 *         "obfuscatedCode": "************0001"
 *       },
 *       "amount": { "amount": "10.0", "formattedAmount": "$10.00" },
 *       "refundDisabled": false,
 *       "status": "PENDING",
 *       "chargeCorrelationId": "ca6baead-b619-4c4a-811d-e12a4e4dda72"
 *     }
 *   ],
 *   "orderTransactions": {
 *     "orderId": "c8be6e35-227e-4c9e-89a9-936b5f568d81"
 *   },
 *   "regularChargeResponseToken": "eyJjaGFyZ2VJZCI6IjI5NmZhNzgwLWVjMDktNDBkMS05NTdmLTk2MDRlYjJjN2QxZiIsInRyYW5zYWN0aW9uU3RhdHVzIjoiQVBQUk9WRUQiLCJyZWRpcmVjdFVybCI6Imh0dHBzOi8vd3d3LnN1Y2Nlc3MuY29tIiwiYW1vdW50Ijo5Ljk5LCJjdXJyZW5jeSI6IlVTRCIsInBheW1lbnRNZXRob2QiOiJDcmVkaXQvRGViaXQgQ2FyZHMifQ=="
 * }
 */

```

### chargeOrder (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 chargeOrder(orderId,options) {
  const response = await myWixClient.orderBilling.chargeOrder(orderId,options);
};
```

---