# ApplicationCharge

        <p>The ApplicationCharge resource facilitates one-time charges. This type of charge is recommended for apps that
        aren’t billed on a recurring basis. You can create an application charge by sending a request with the name the charge should
        appear under, the price your app is charging, and a return URL where Shopify redirects the merchant
        after the charge is accepted. After you've created the charge, redirect the merchant to the confirmation URL returned by Shopify.
        If the charge is declined, then Shopify redirects the merchant and provides a notification message that the app charge was declined.</p>

        <div class="note">
          <h4>Note</h4>
          <p>For testing purposes you can include <code>"test": true</code> when creating the charge. This prevents the credit card from being charged.
          Test shops and demo shops can't be charged.</p>
        </div>

## Resource Properties

### ApplicationCharge

* confirmation_url: The URL where the merchant accepts or declines the application charge.
  * Type: x-string
  * Example: "https://jsmith.myshopify.com/admin/charges/confirm_application_charge?id=1012637313&amp;signature=BAhpBIGeWzw%3D--17779c1efb4688e9cfa653a3245f923b4f1eb140"
* created_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format) when the application charge was created.
  * Type: x-string
  * Example: "2013-06-27T08:48:27-04:00"
* id: The ID of the application charge.
  * Type: x-string
  * Example: 675931192
* name: The application charge name.
  * Type: x-string
  * Example: "Super Duper Expensive action"
* price: The price of the application charge. The minimum price is 0.50, and maximum price is 10,000.
  * Type: x-string
  * Example: "100.00"
* return_url: The URL where the merchant is redirected after accepting a charge.
  * Type: x-string
  * Example: "http://super-duper.shopifyapps.com"
* status:         <p>The status of the application charge. Valid values:</p>
        <ul>
          <li><strong>pending</strong>: The application charge is pending approval by the merchant.</li>
          <li><strong>accepted</strong>: <strong>Removed in version 2021-01</strong>. The application charge has been accepted by the merchant and is ready to be activated by the app. At this point it will appear on the merchant's invoice. As of API version 2021-01, when a merchant accepts a charge, the charge immediately transitions from <code>pending</code> to <code>active</code>.</li>
          <li><strong>active</strong>: The application charge has been activated by the app and will be paid out to the Partner.</li>
          <li><strong>declined</strong>: The application charge was declined by the merchant.</li>
          <li><strong>expired</strong>: The application charge was not accepted within 2 days of being created.</li>
        </ul>

  * Type: x-string
  * Example: "accepted"
* test: Whether the application charge is a test transaction. Valid values:<code>true</code>,<code>null</code>.
  * Type: x-string
  * Example: nil
* updated_at: The date and time (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> format) when the charge was last updated.
  * Type: x-string
  * Example: "2013-06-27T08:48:27-04:00"
* currency: The currency of the price of the application charge.
  * Type: x-string
  * Example: "USD"
## Creates an application charge

Creates an application charge

### Endpoint
/admin/api/#{api_version}/application_charges.json (POST)

### Parameters
* api_version (required): 

### Responses
#### 201
Creates an application charge

Examples:
##### Create a test charge that will not cause a credit card to be charged
Request:
```
POST /admin/api/unstable/application_charges.json
{"application_charge":{"name":"Super Duper Expensive action","price":100.0,"return_url":"http://super-duper.shopifyapps.com","test":true}}
```

Response:
```
HTTP/1.1 201 Created
{"application_charge":{"id":1017262359,"name":"Super Duper Expensive action","api_client_id":755357713,"price":"100.00","status":"pending","return_url":"http://super-duper.shopifyapps.com/","test":true,"created_at":"2025-01-02T11:21:36-05:00","updated_at":"2025-01-02T11:21:36-05:00","currency":"USD","charge_type":null,"decorated_return_url":"http://super-duper.shopifyapps.com/?charge_id=1017262359","confirmation_url":"https://jsmith.myshopify.com/admin/charges/755357713/1017262359/ApplicationCharge/confirm_application_charge?signature=BAh7BzoHaWRpBBcxojw6EmF1dG9fYWN0aXZhdGVU--53cb494fedf6f420ff06e85ed207a3442ea4447e"}}
```
##### Create an application charge
Request:
```
POST /admin/api/unstable/application_charges.json
{"application_charge":{"name":"Super Duper Expensive action","price":100.0,"return_url":"http://super-duper.shopifyapps.com"}}
```

Response:
```
HTTP/1.1 201 Created
{"application_charge":{"id":1017262360,"name":"Super Duper Expensive action","api_client_id":755357713,"price":"100.00","status":"pending","return_url":"http://super-duper.shopifyapps.com/","test":null,"created_at":"2025-01-02T11:21:38-05:00","updated_at":"2025-01-02T11:21:38-05:00","currency":"USD","charge_type":null,"decorated_return_url":"http://super-duper.shopifyapps.com/?charge_id=1017262360","confirmation_url":"https://jsmith.myshopify.com/admin/charges/755357713/1017262360/ApplicationCharge/confirm_application_charge?signature=BAh7BzoHaWRpBBgxojw6EmF1dG9fYWN0aXZhdGVU--258ee22d3cebf17a9fbc35be9bc959c04aac0b06"}}
```
#### 422
Creates an application charge

Examples:
##### Trying to create a charge with a price less than 0.50 will return an error
Request:
```
POST /admin/api/unstable/application_charges.json
{"application_charge":{"name":"Super Duper Expensive action","price":0.4,"return_url":"http://super-duper.shopifyapps.com"}}
```

Response:
```
HTTP/1.1 422 Unprocessable Entity
{"errors":{"price":["must be greater than or equal to the equivalent of $0.50 USD"]}}
```
##### Trying to create a charge without a price or name will return an error
Request:
```
POST /admin/api/unstable/application_charges.json
{"application_charge":{"name":""}}
```

Response:
```
HTTP/1.1 422 Unprocessable Entity
{"errors":{"name":["can't be blank"],"price":["must be greater than or equal to the equivalent of $0.50 USD"]}}
```
## Retrieves a list of application charges

Retrieves a list of application charges

### Endpoint
/admin/api/#{api_version}/application_charges.json (GET)

### Parameters
* api_version (required): 
* fields: A comma-separated list of fields to include in the response.
* since_id: Restrict results to after the specified ID.

### Responses
#### 200
Retrieves a list of application charges

Examples:
##### Retrieve all application charges
Request:
```
GET /admin/api/unstable/application_charges.json
```

Response:
```
HTTP/1.1 200 OK
{"application_charges":[{"id":556467234,"name":"Green theme","api_client_id":755357713,"price":"120.00","status":"accepted","return_url":"http://google.com","test":null,"external_id":null,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","currency":"USD","charge_type":"theme","decorated_return_url":"http://google.com?charge_id=556467234"},{"id":675931192,"name":"iPod Cleaning","api_client_id":755357713,"price":"5.00","status":"accepted","return_url":"http://google.com","test":null,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","currency":"USD","charge_type":null,"decorated_return_url":"http://google.com?charge_id=675931192"},{"id":1017262346,"name":"Create me a logo","api_client_id":755357713,"price":"123.00","status":"accepted","return_url":"http://google.com","test":null,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","currency":"USD","charge_type":"brokered_service","decorated_return_url":"http://google.com?charge_id=1017262346"}]}
```
##### Retrieve all application charges since a specified ID
Request:
```
GET /admin/api/unstable/application_charges.json
```

Response:
```
HTTP/1.1 200 OK
{"application_charges":[{"id":675931192,"name":"iPod Cleaning","api_client_id":755357713,"price":"5.00","status":"accepted","return_url":"http://google.com","test":null,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","currency":"USD","charge_type":null,"decorated_return_url":"http://google.com?charge_id=675931192"},{"id":1017262346,"name":"Create me a logo","api_client_id":755357713,"price":"123.00","status":"accepted","return_url":"http://google.com","test":null,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","currency":"USD","charge_type":"brokered_service","decorated_return_url":"http://google.com?charge_id=1017262346"}]}
```
## Retrieves an application charge

Retrieves an application charge

### Endpoint
/admin/api/#{api_version}/application_charges/{application_charge_id}.json (GET)

### Parameters
* api_version (required): 
* application_charge_id (required): 
* fields: A comma-separated list of fields to include in the response.

### Responses
#### 200
Retrieves an application charge

Examples:
##### Retrieve an application charge
Request:
```
GET /admin/api/unstable/application_charges/675931192.json
```

Response:
```
HTTP/1.1 200 OK
{"application_charge":{"id":675931192,"name":"iPod Cleaning","api_client_id":755357713,"price":"5.00","status":"accepted","return_url":"http://google.com","test":null,"created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","currency":"USD","charge_type":null,"decorated_return_url":"http://google.com?charge_id=675931192"}}
```