RecurringApplicationCharge

The RecurringApplicationCharge resource facilitates a fixed-value, 30-day recurring charge. 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 cannot be charged.

Updating

Each shop can have only one recurring charge per app. When a new recurring application charge is activated for a shop that already has one, the existing recurring charge is canceled and replaced by the new charge. The new recurring charge is then activated.

What you can do with RecurringApplicationCharge

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

RecurringApplicationCharge properties

activated_on
"activated_on": null

The date and time (ISO 8601 format) when the customer activated the recurring application charge.
Note: The recurring application charge must be activated or the returned value is null.

billing_on
"billing_on": null

The date and time (ISO 8601 format) when the customer is billed.
Note: The recurring application charge must be accepted or the returned value is null.

cancelled_on
"cancelled_on": null

The date and time (ISO 8601 format) when the merchant canceled their recurring application charge.
Note: Returns null when the recurring application charge is not canceled.

capped_amount
"capped_amount": "100"

The limit a customer can be charged for usage based billing. The maximum is 10,000. If this property is provided, then you must also provide the terms property. See usage charges for more information.

confirmation_url
"confirmation_url": "https://apple.myshopify.com/admin/charges/confirm_recurring_application_charge?id=654381177&signature=BAhpBHkQASc%3D--374c02da2ea0371b23f40781b8a6d5f4a520e77b"

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

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

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

id
"id": 675931192

The ID of the recurring application charge.

name
"name": "Super Duper Expensive action"

The name of the recurring application charge.

price
"price": "100.00"

The price of the recurring application charge. The 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 the charge.

status
"status": "accepted"

The status of the recurring charge. Valid values:

  • pending: The recurring charge is pending.
  • accepted: The recurring charge has been accepted.
  • active: The recurring charge is activated. This is the only status that actually causes a merchant to be charged. An accepted charge is transitioned to active using the activate endpoint.
  • declined: The recurring charge has been declined.
  • expired: The recurring charge was not accepted within 2 days of being created.
  • frozen: The recurring charge is on hold due to a shop subscription non-payment. The charge will re-activate once subscription payments resume.
  • cancelled: The developer cancelled the charge.

terms
"terms": "$1 for 1000 emails"

The terms and conditions of usage based billing charges. Must be present in order to create usage charges, for example when the capped_amount property is provided. Presented to the merchant when they approve an app's usage charges.

test
"test": null

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

trial_days
"trial_days": 0

The number of days that the customer is eligible for a free trial.

trial_ends_on
"trial_ends_on": null

The date and time (ISO 8601 format) when the free trial ends.

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

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

Endpoints

POST /admin/recurring_application_charges.json
Creates a recurring application charge

Create a recurring application charge

POST /admin/recurring_application_charges.json
{
  "recurring_application_charge": {
    "name": "Super Duper Plan",
    "price": 10.0,
    "return_url": "http://super-duper.shopifyapps.com"
  }
}
View Response
HTTP/1.1 201 Created
{
  "recurring_application_charge": {
    "id": 1029266948,
    "name": "Super Duper Plan",
    "api_client_id": 755357713,
    "price": "10.00",
    "status": "pending",
    "return_url": "http://super-duper.shopifyapps.com/",
    "billing_on": null,
    "created_at": "2018-05-07T15:47:10-04:00",
    "updated_at": "2018-05-07T15:47:10-04:00",
    "test": null,
    "activated_on": null,
    "trial_ends_on": null,
    "cancelled_on": null,
    "trial_days": 0,
    "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1029266948",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/1029266948/confirm_recurring_application_charge?signature=BAhpBAReWT0%3D--b51a6db06a3792c4439783fcf0f2e89bf1c9df68"
  }
}

Create a new charge with terms and a capped amount

POST /admin/recurring_application_charges.json
{
  "recurring_application_charge": {
    "name": "Super Duper Plan",
    "price": 10.0,
    "return_url": "http://super-duper.shopifyapps.com",
    "capped_amount": 100,
    "terms": "$1 for 1000 emails"
  }
}
View Response
HTTP/1.1 201 Created
{
  "recurring_application_charge": {
    "id": 1029266949,
    "name": "Super Duper Plan",
    "api_client_id": 755357713,
    "price": "10.00",
    "status": "pending",
    "return_url": "http://super-duper.shopifyapps.com/",
    "billing_on": null,
    "created_at": "2018-05-07T15:47:10-04:00",
    "updated_at": "2018-05-07T15:47:10-04:00",
    "test": null,
    "activated_on": null,
    "trial_ends_on": null,
    "cancelled_on": null,
    "trial_days": 0,
    "capped_amount": "100.00",
    "balance_used": 0.0,
    "balance_remaining": 100.0,
    "risk_level": 0.0,
    "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1029266949",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/1029266949/confirm_recurring_application_charge?signature=BAhpBAVeWT0%3D--63cd58df5045f8e2fb9b35690d5cdc9751270575"
  }
}

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

POST /admin/recurring_application_charges.json
{
  "recurring_application_charge": {
    "name": "Super Duper Plan",
    "price": 10.0,
    "return_url": "http://super-duper.shopifyapps.com",
    "test": true
  }
}
View Response
HTTP/1.1 201 Created
{
  "recurring_application_charge": {
    "id": 1029266950,
    "name": "Super Duper Plan",
    "api_client_id": 755357713,
    "price": "10.00",
    "status": "pending",
    "return_url": "http://super-duper.shopifyapps.com/",
    "billing_on": null,
    "created_at": "2018-05-07T15:47:11-04:00",
    "updated_at": "2018-05-07T15:47:11-04:00",
    "test": true,
    "activated_on": null,
    "trial_ends_on": null,
    "cancelled_on": null,
    "trial_days": 0,
    "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1029266950",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/1029266950/confirm_recurring_application_charge?signature=BAhpBAZeWT0%3D--d4f2cab5f28f7c9180e0f27526cdbd505a10591c"
  }
}

Create a new charge with a trial period. The trial period will go into effect at the time the recurring charge is activated.

POST /admin/recurring_application_charges.json
{
  "recurring_application_charge": {
    "name": "Super Duper Plan",
    "price": 10.0,
    "return_url": "http://super-duper.shopifyapps.com",
    "trial_days": 5
  }
}
View Response
HTTP/1.1 201 Created
{
  "recurring_application_charge": {
    "id": 1029266951,
    "name": "Super Duper Plan",
    "api_client_id": 755357713,
    "price": "10.00",
    "status": "pending",
    "return_url": "http://super-duper.shopifyapps.com/",
    "billing_on": null,
    "created_at": "2018-05-07T15:47:11-04:00",
    "updated_at": "2018-05-07T15:47:11-04:00",
    "test": null,
    "activated_on": null,
    "trial_ends_on": null,
    "cancelled_on": null,
    "trial_days": 5,
    "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1029266951",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/1029266951/confirm_recurring_application_charge?signature=BAhpBAdeWT0%3D--2fde0d208f2e31c05d1b4e4ec469d05f1ad03d40"
  }
}

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

POST /admin/recurring_application_charges.json
{
  "recurring_application_charge": {
    "name": ""
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "name": [
      "can't be blank"
    ],
    "price": [
      "must be greater than zero"
    ]
  }
}
GET /admin/recurring_application_charges/455696195.json
Retrieves a single charge
fields

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

Retrieve a single charge

GET /admin/recurring_application_charges/#{recurring_application_charge_id}.json
View Response
HTTP/1.1 200 OK
{
  "recurring_application_charge": {
    "id": 455696195,
    "name": "Super Mega Plan",
    "api_client_id": 755357713,
    "price": "15.00",
    "status": "pending",
    "return_url": "http://yourapp.com",
    "billing_on": "2018-05-07",
    "created_at": "2018-05-07T15:33:38-04:00",
    "updated_at": "2018-05-07T15:33:38-04:00",
    "test": null,
    "activated_on": null,
    "trial_ends_on": null,
    "cancelled_on": null,
    "trial_days": 0,
    "decorated_return_url": "http://yourapp.com?charge_id=455696195",
    "confirmation_url": "https://apple.myshopify.com/admin/charges/455696195/confirm_recurring_application_charge?signature=BAhpBENfKRs%3D--a911ece9470850c96f6c7735c684b8a3f6869594"
  }
}
GET /admin/recurring_application_charges.json
Retrieves a list of recurring 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 recurring application charges

GET /admin/recurring_application_charges.json
View Response
HTTP/1.1 200 OK
{
  "recurring_application_charges": [
    {
      "id": 455696195,
      "name": "Super Mega Plan",
      "api_client_id": 755357713,
      "price": "15.00",
      "status": "accepted",
      "return_url": "http://yourapp.com",
      "billing_on": "2018-05-07",
      "created_at": "2018-05-07T15:33:38-04:00",
      "updated_at": "2018-05-07T15:47:12-04:00",
      "test": null,
      "activated_on": null,
      "trial_ends_on": null,
      "cancelled_on": null,
      "trial_days": 0,
      "decorated_return_url": "http://yourapp.com?charge_id=455696195"
    }
  ]
}

Retrieve all recurring charges since a specified ID

GET /admin/recurring_application_charges.json?since_id=455696195
View Response
HTTP/1.1 200 OK
{
  "recurring_application_charges": [
    {
      "id": 1029266952,
      "name": "Super Duper Plan",
      "api_client_id": 755357713,
      "price": "10.00",
      "status": "pending",
      "return_url": "http://super-duper.shopifyapps.com/",
      "billing_on": null,
      "created_at": "2018-05-07T15:47:12-04:00",
      "updated_at": "2018-05-07T15:47:12-04:00",
      "test": null,
      "activated_on": null,
      "trial_ends_on": null,
      "cancelled_on": null,
      "trial_days": 0,
      "decorated_return_url": "http://super-duper.shopifyapps.com/?charge_id=1029266952",
      "confirmation_url": "https://apple.myshopify.com/admin/charges/1029266952/confirm_recurring_application_charge?signature=BAhpBAheWT0%3D--1bcda80152133fff010a3a1560e02eff95bf40b3"
    }
  ]
}
POST /admin/recurring_application_charges/455696195/activate.json
Activates a previously accepted recurring application charge

Activate a recurring application charge

POST /admin/recurring_application_charges/#{recurring_application_charge_id}/activate.json
{
  "recurring_application_charge": {
    "id": 455696195,
    "name": "Super Mega Plan",
    "api_client_id": 755357713,
    "price": "15.00",
    "status": "accepted",
    "return_url": "http://yourapp.com",
    "billing_on": "2018-05-07",
    "created_at": "2018-05-07T15:33:38-04:00",
    "updated_at": "2018-05-07T15:47:12-04:00",
    "test": null,
    "activated_on": null,
    "trial_ends_on": null,
    "cancelled_on": null,
    "trial_days": 0,
    "decorated_return_url": "http://yourapp.com?charge_id=455696195"
  }
}
View Response
HTTP/1.1 200 OK
{
  "recurring_application_charge": {
    "id": 455696195,
    "name": "Super Mega Plan",
    "api_client_id": 755357713,
    "price": "15.00",
    "status": "active",
    "return_url": "http://yourapp.com",
    "billing_on": "2018-06-06",
    "created_at": "2018-05-07T15:33:38-04:00",
    "updated_at": "2018-05-07T15:47:13-04:00",
    "test": null,
    "activated_on": "2018-05-07",
    "trial_ends_on": "2018-05-07",
    "cancelled_on": null,
    "trial_days": 0,
    "decorated_return_url": "http://yourapp.com?charge_id=455696195"
  }
}
DELETE /admin/recurring_application_charges/455696195.json
Cancels a recurring application charge

Cancel the current recurring charge for a shop

DELETE /admin/recurring_application_charges/#{recurring_application_charge_id}.json
View Response
HTTP/1.1 200 OK
PUT /admin/recurring_application_charges/455696195/customize.json
Updates the capped amount of an active recurring application charge

Increase the capped amount for a shop

PUT /admin/recurring_application_charges/#{recurring_application_charge_id}/customize.json?recurring_application_charge[capped_amount]=200
View Response
HTTP/1.1 200 OK
{
  "recurring_application_charge": {
    "id": 455696195,
    "name": "Super Mega Plan",
    "api_client_id": 755357713,
    "price": "15.00",
    "status": "active",
    "return_url": "http://yourapp.com",
    "billing_on": "2018-06-06",
    "created_at": "2018-05-07T15:33:38-04:00",
    "updated_at": "2018-05-07T15:47:15-04:00",
    "test": null,
    "activated_on": "2018-05-07",
    "trial_ends_on": "2018-05-07",
    "cancelled_on": null,
    "trial_days": 0,
    "capped_amount": "100.00",
    "balance_used": 0.0,
    "balance_remaining": 100.0,
    "risk_level": 0.075,
    "decorated_return_url": "http://yourapp.com?charge_id=455696195",
    "update_capped_amount_url": "https://apple.myshopify.com/admin/charges/455696195/confirm_update_capped_amount?signature=BAhpBENfKRs%3D--d67190fb954f6577ff6a66934f81613665766f0c"
  }
}