# ApplicationCharge
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.
For testing purposes you can include "test": true
when creating the charge. This prevents the credit card from being charged.
Test shops and demo shops can't be charged.
The status of the application charge. Valid values:
pending
to active
.true
,null
.
* Type: x-string
* Example: nil
* updated_at: The date and time (ISO 8601 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":1017262350,"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":"2024-09-19T10:13:00-04:00","updated_at":"2024-09-19T10:13:00-04:00","currency":"USD","charge_type":null,"decorated_return_url":"http://super-duper.shopifyapps.com/?charge_id=1017262350","confirmation_url":"https://jsmith.myshopify.com/admin/charges/755357713/1017262350/ApplicationCharge/confirm_application_charge?signature=BAh7BzoHaWRpBA4xojw6EmF1dG9fYWN0aXZhdGVU--2464d6c107837471fc7e579542e7dfa197a95f6d"}}
```
##### 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":1017262348,"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":"2024-09-19T10:12:57-04:00","updated_at":"2024-09-19T10:12:57-04:00","currency":"USD","charge_type":null,"decorated_return_url":"http://super-duper.shopifyapps.com/?charge_id=1017262348","confirmation_url":"https://jsmith.myshopify.com/admin/charges/755357713/1017262348/ApplicationCharge/confirm_application_charge?signature=BAh7BzoHaWRpBAwxojw6EmF1dG9fYWN0aXZhdGVU--752f542dcbce9eae267922af3df2c9e59556197e"}}
```
#### 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":"2024-09-19T10:10:57-04:00","updated_at":"2024-09-19T10:10:57-04: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":"2024-09-19T10:10:57-04:00","updated_at":"2024-09-19T10:10:57-04: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":"2024-09-19T10:10:57-04:00","updated_at":"2024-09-19T10:10:57-04: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":"2024-09-19T10:10:57-04:00","updated_at":"2024-09-19T10:10:57-04: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":"2024-09-19T10:10:57-04:00","updated_at":"2024-09-19T10:10:57-04: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":"2024-09-19T10:10:57-04:00","updated_at":"2024-09-19T10:10:57-04:00","currency":"USD","charge_type":null,"decorated_return_url":"http://google.com?charge_id=675931192"}}
```