> 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

# ApplyCoupon

# Package: onlinePrograms

# Namespace: JoinApplicationsService

# Method link: https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/apply-coupon.md

## Permission Scopes:
Manage Online Programs: SCOPE.CHALLENGES.MANAGE
Manage Online Programs: SCOPE.CHALLENGES.MANAGE

## Introduction

Applies a coupon to a join application's payment order to reduce the payment amount.

`paymentStatus` must be `PAYMENT_IN_PROGRESS`, `PAYMENT_FAILED`, or `PAYMENT_CANCELED`. The last two let a member apply or change a coupon when retrying after a failed or canceled payment.

Returns the order totals with the discount applied. An order supports a single coupon, so remove the current coupon before applying a different one.

To remove the coupon, call [Remove Coupon](https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/remove-coupon.md). If the coupon covers the full amount, call [Complete Free Coupon Payment](https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/complete-free-coupon-payment.md) to finish without a paid checkout.

---

## REST API

### Schema

```
 Method: applyCoupon
 Description: Applies a coupon to a join application's payment order to reduce the payment amount.  `paymentStatus` must be `PAYMENT_IN_PROGRESS`, `PAYMENT_FAILED`, or `PAYMENT_CANCELED`. The last two let a member apply or change a coupon when retrying after a failed or canceled payment.  Returns the order totals with the discount applied. An order supports a single coupon, so remove the current coupon before applying a different one.  To remove the coupon, call [Remove Coupon](https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/remove-coupon.md). If the coupon covers the full amount, call [Complete Free Coupon Payment](https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/complete-free-coupon-payment.md) to finish without a paid checkout.
 URL: https://www.wixapis.com/online-programs/participants/v3/join-applications/{joinApplicationId}/apply-coupon
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  couponCode
 Method parameters: 
   param name: couponCode | type: couponCode | description: Coupon code to apply. | required: true | validation: maxLength 100
 Return type: ApplyCouponResponse
  - name: couponId | type: string | description: GUID of the applied coupon.  | validation: format GUID
  - name: subTotal | type: string | description: Order subtotal before the discount, formatted using the precision of the site currency configured in Site Properties. The value doesn't include the currency.  | validation: maxLength 50
  - name: discount | type: string | description: Discount applied to the order, formatted using the precision of the site currency configured in Site Properties. The value doesn't include the currency.  | validation: maxLength 50
  - name: total | type: string | description: Order total after the discount, formatted using the precision of the site currency configured in Site Properties. The value doesn't include the currency.  | validation: maxLength 50

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_PAYMENT_STATUS | Description: The join application's `paymentStatus` doesn't permit applying a coupon. Allowed from `PAYMENT_IN_PROGRESS`, `PAYMENT_FAILED`, and `PAYMENT_CANCELED`.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: COUPON_DOES_NOT_EXIST | Description: No coupon matches the specified coupon code.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: COUPON_IS_ALREADY_APPLIED | Description: A coupon is already applied to the payment order.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MISSING_PAYMENT_ORDER | Description: No payment order exists for the join application. Call Prepare Payment first.


```

### Examples

### Apply coupon to join application
Applies a discount coupon to the payment order for a join application

```curl
curl -X POST \
'https://www.wixapis.com/online-programs/participants/v3/join-applications/4f87b2e3-2a0d-4b9f-9a1c-2d8e71b7e5c4/apply-coupon' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "couponCode": "MINUS10"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.onlinePrograms.joinApplications.applyCoupon(joinApplicationId, couponCode)
 Description: Applies a coupon to a join application's payment order to reduce the payment amount.  `paymentStatus` must be `PAYMENT_IN_PROGRESS`, `PAYMENT_FAILED`, or `PAYMENT_CANCELED`. The last two let a member apply or change a coupon when retrying after a failed or canceled payment.  Returns the order totals with the discount applied. An order supports a single coupon, so remove the current coupon before applying a different one.  To remove the coupon, call [Remove Coupon](https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/remove-coupon.md). If the coupon covers the full amount, call [Complete Free Coupon Payment](https://dev.wix.com/docs/api-reference/business-management/online-programs/join-applications/complete-free-coupon-payment.md) to finish without a paid checkout.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  joinApplicationId, couponCode
 Method parameters: 
   param name: couponCode | type: string | description: Coupon code to apply. | required: true | validation: maxLength 100
   param name: joinApplicationId | type: string | description: GUID of the join application to apply the coupon to. | required: true | validation: format GUID
 Return type: PROMISE<ApplyCouponResponse>
  - name: couponId | type: string | description: GUID of the applied coupon.  | validation: format GUID
  - name: subTotal | type: string | description: Order subtotal before the discount, formatted using the precision of the site currency configured in Site Properties. The value doesn't include the currency.  | validation: maxLength 50
  - name: discount | type: string | description: Discount applied to the order, formatted using the precision of the site currency configured in Site Properties. The value doesn't include the currency.  | validation: maxLength 50
  - name: total | type: string | description: Order total after the discount, formatted using the precision of the site currency configured in Site Properties. The value doesn't include the currency.  | validation: maxLength 50

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVALID_PAYMENT_STATUS | Description: The join application's `paymentStatus` doesn't permit applying a coupon. Allowed from `PAYMENT_IN_PROGRESS`, `PAYMENT_FAILED`, and `PAYMENT_CANCELED`.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: COUPON_DOES_NOT_EXIST | Description: No coupon matches the specified coupon code.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: COUPON_IS_ALREADY_APPLIED | Description: A coupon is already applied to the payment order.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MISSING_PAYMENT_ORDER | Description: No payment order exists for the join application. Call Prepare Payment first.


```

### Examples

### Apply a coupon to a join application
Applies a discount coupon to the payment order for a join application

```javascript
import { joinApplications } from "@wix/online-programs";

async function applyCoupon() {
  const response = await joinApplications.applyCoupon(
    "4f87b2e3-2a0d-4b9f-9a1c-2d8e71b7e5c4",
    "MINUS10",
  );
}

/* Promise resolves to:
 * {
 *   "couponId": "748c7a79-7b13-4b0d-9c25-e1d090bd11f6",
 *   "subTotal": "25.00",
 *   "discount": "10.00",
 *   "total": "15.00"
 * }
 */

```

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

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


async function applyCoupon(joinApplicationId,couponCode) {
  const response = await myWixClient.joinApplications.applyCoupon(joinApplicationId,couponCode);
};
```

---