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 or declined. After you've created the charge, redirect the merchant to the confirmation URL returned by Shopify. You'll also need to activate the charge to get paid. For step-by-step guidance that walks through this flow using examples, see our implementation guide.

Note

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.

What you can do with ApplicationCharge

The Shopify API lets you do the following with the ApplicationCharge resource. More detailed versions of these general actions may be available:

ApplicationCharge properties

confirmation_url
"confirmation_url": "https://apple.myshopify.com/admin/charges/confirm_application_charge?id=1012637313&signature=BAhpBIGeWzw%3D--17779c1efb4688e9cfa653a3245f923b4f1eb140"

The URL where the merchant accepts or declines the application charge.

created_at
"created_at": "2013-06-27T08:48:27-04:00"

The date and time (ISO 8601 format) when the application charge was created.

id
"id": 675931192

The ID of the application charge.

name
"name": "Super Duper Expensive action"

The application charge name.

price
"price": "100.00"

The price of the application charge. The minimum price is 0.50, and maximum price is 10,000.

return_url
"return_url": "http://super-duper.shopifyapps.com"

The URL where the merchant is redirected after accepting or declining a charge.

status
"status": "accepted"

The status of the application charge. Valid values:

  • pending: The application charge is pending approval by the merchant.
  • accepted: The application charge has been accepted by the merchant and is ready to be activated by the app.
  • active: The application charge has been activated by the app and appears on the merchant's invoice.
  • declined: The application charge was declined by the merchant.
  • expired: The application charge was not accepted within 2 days of being created.

test
"test": null

Whether the application charge is a test transaction. Valid values:true,null.

updated_at
"updated_at": "2013-06-27T08:48:27-04:00"

The date and time (ISO 8601 format) when the charge was last updated.

Endpoints

POST /admin/application_charges.json
Creates an application charge

Create an application charge

POST /admin/application_charges.json
{
  "application_charge": {
    "name": "Super Duper Expensive action",
    "price": 100.0,
    "return_url": "http://super-duper.shopifyapps.com"
  }
}
View Response
HTTP/1.1 201 Created
{
  "application_charge": {
    "id": 1017262355,
    "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": "2018-09-14T10:52:26-04:00",
    "updated_at": "2018-09-14T10:52:26-04:00",
    "charge_type": null,
    "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1017262355",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/1017262355/confirm_application_charge?signature=BAhpBBMxojw%3D--80d7001455c12e4284b7282db1d756c16dfc5497"
  }
}

Create a test charge that will not cause a credit card to be charged

POST /admin/application_charges.json
{
  "application_charge": {
    "name": "Super Duper Expensive action",
    "price": 100.0,
    "return_url": "http://super-duper.shopifyapps.com",
    "test": true
  }
}
View Response
HTTP/1.1 201 Created
{
  "application_charge": {
    "id": 1017262356,
    "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": "2018-09-14T10:52:28-04:00",
    "updated_at": "2018-09-14T10:52:28-04:00",
    "charge_type": null,
    "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1017262356",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/1017262356/confirm_application_charge?signature=BAhpBBQxojw%3D--b08a77da822cc700ebeae43c74af1857e4405766"
  }
}

Trying to create a charge without a price or name will return an error

POST /admin/application_charges.json
{
  "application_charge": {
    "name": ""
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "name": [
      "can't be blank"
    ],
    "price": [
      "must be greater than or equal to 0.5"
    ]
  }
}

Trying to create a charge with a price less than 0.50 will return an error

POST /admin/application_charges.json
{
  "application_charge": {
    "name": "Super Duper Expensive action",
    "price": 0.4,
    "return_url": "http://super-duper.shopifyapps.com"
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "price": [
      "must be greater than or equal to 0.5"
    ]
  }
}
GET /admin/application_charges/675931192.json
Retrieves an application charge
fields

A comma-separated list of fields to include in the response.

Retrieve an application charge

GET /admin/application_charges/#{application_charge_id}.json
View 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": "2018-09-14T10:00:39-04:00",
    "updated_at": "2018-09-14T10:00:39-04:00",
    "charge_type": null,
    "decorated_return_url": "http://google.com?charge_id=675931192"
  }
}
GET /admin/application_charges.json
Retrieves a list of application charges
since_id

Restrict results to after the specified ID.

fields

A comma-separated list of fields to include in the response.

Retrieve all application charges

GET /admin/application_charges.json
View Response
HTTP/1.1 200 OK
{
  "application_charges": [
    {
      "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": "2018-09-14T10:00:39-04:00",
      "updated_at": "2018-09-14T10:00:39-04:00",
      "charge_type": "brokered_service",
      "decorated_return_url": "http://google.com?charge_id=1017262346"
    },
    {
      "id": 556467234,
      "name": "Green theme",
      "api_client_id": 755357713,
      "price": "120.00",
      "status": "accepted",
      "return_url": "http://google.com",
      "test": null,
      "created_at": "2018-09-14T10:00:39-04:00",
      "updated_at": "2018-09-14T10:00:39-04:00",
      "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": "2018-09-14T10:00:39-04:00",
      "updated_at": "2018-09-14T10:00:39-04:00",
      "charge_type": null,
      "decorated_return_url": "http://google.com?charge_id=675931192"
    }
  ]
}

Retrieve all application charges since a specified ID

GET /admin/application_charges.json?since_id=556467234
View 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": "2018-09-14T10:00:39-04:00",
      "updated_at": "2018-09-14T10:00:39-04:00",
      "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": "2018-09-14T10:00:39-04:00",
      "updated_at": "2018-09-14T10:00:39-04:00",
      "charge_type": "brokered_service",
      "decorated_return_url": "http://google.com?charge_id=1017262346"
    }
  ]
}
POST /admin/application_charges/675931192/activate.json
Activates an accepted application charge

Activate an application charge

POST /admin/application_charges/#{application_charge_id}/activate.json
{
  "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": "2018-09-14T10:00:39-04:00",
    "updated_at": "2018-09-14T10:00:39-04:00",
    "charge_type": null,
    "decorated_return_url": "http://google.com?charge_id=675931192"
  }
}
View Response
HTTP/1.1 200 OK
{
  "application_charge": {
    "id": 675931192,
    "name": "iPod Cleaning",
    "api_client_id": 755357713,
    "price": "5.00",
    "status": "active",
    "return_url": "http://google.com/",
    "test": null,
    "created_at": "2018-09-14T10:00:39-04:00",
    "updated_at": "2018-09-14T10:52:36-04:00",
    "charge_type": null,
    "decorated_return_url": "http://google.com/?charge_id=675931192"
  }
}

Sign up for a Partner account to get started.

Sign up