Shopify API – ApplicationCharge

top

Create a new one-time application charge

Request to charge a shop a one-time fee by issuing this call with the name the charge should appear under (on the shop owner’s invoice), the price your application is charging, and a return_url to where Shopify will redirect the shop owner to after they have accepted or declined the charge.

Setting the test flag to true will set the ApplicationCharge to not actually charge the credit card it otherwise would.

After this request returns, an ApplicationCharge has been created, but is held in a pending state until the shop owner has accepted or declined it.

Proceed by redirecting the shop owner to the confirmation_url set in the response where they may accept or decline the charge.

After the charge has been accepted or declined, Shopify redirects the shop owner to the return_url set in the request. At this point the shop is either in an accepted or declined state. In order to actually receive payment for this charge it must be activated by your application.

Note

Test or demo shops may not be charged.

POST /admin/application_charges.xml

Create a one-time charge called 'Super Duper Expensive action' for $100.00 USD

Request

           
<?xml version="1.0" encoding="UTF-8"?>
<application-charge>
  <name>Super Duper Expensive action</name>
  <price type="float">100.0</price>
  <return-url>http://super-duper.shopifyapps.com</return-url>
</application-charge>      

Response

           
HTTP/1.1 201 Created
<?xml version="1.0" encoding="UTF-8"?>
<application-charge>
  <created-at type="datetime">2010-02-10T14:04:14-05:00</created-at>
  <id type="integer">1007331636</id>
  <name>Super Duper Expensive action</name>
  <price type="decimal">100.00</price>
  <return-url>http://super-duper.shopifyapps.com?charge_id=1007331636&amp;signature=45483281f81360af8c79324cf3629c78</return-url>
  <status>pending</status>
  <test type="boolean" nil="true"></test>
  <updated-at type="datetime">2010-02-10T14:04:14-05:00</updated-at>
  <confirmation-url>http://apple.myshopify.com/admin/subscriptions/confirm_application_charge/1007331636?signature=BAhpBDSpCjw%3D--d1b5560d78c7fe2345b25dd27f6fc9019a5b7495</confirmation-url>
</application-charge>
POST /admin/application_charges.xml

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

Request

           
<?xml version="1.0" encoding="UTF-8"?>
<application-charge>
  <name>Super Duper Expensive action</name>
  <price type="float">100.0</price>
  <return-url>http://super-duper.shopifyapps.com</return-url>
  <test type="boolean">true</test>
</application-charge>      

Response

           
HTTP/1.1 201 Created
<?xml version="1.0" encoding="UTF-8"?>
<application-charge>
  <created-at type="datetime">2010-02-10T14:04:14-05:00</created-at>
  <id type="integer">1007331637</id>
  <name>Super Duper Expensive action</name>
  <price type="decimal">100.00</price>
  <return-url>http://super-duper.shopifyapps.com?charge_id=1007331637&amp;signature=738fcbb654f850bc94dc2b5ce96b00b2</return-url>
  <status>pending</status>
  <test type="boolean">true</test>
  <updated-at type="datetime">2010-02-10T14:04:14-05:00</updated-at>
  <confirmation-url>http://apple.myshopify.com/admin/subscriptions/confirm_application_charge/1007331637?signature=BAhpBDWpCjw%3D--66f97716b91c5ed07ed8176751f20a799be0bac5</confirmation-url>
</application-charge>
top

Retrieve all one-time application charges

All charges that have been requested are retrieved by this request.

GET /admin/application_charges.xml

Retrieving all one-time charges

Response

           
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<application-charges type="array">
  <application-charge>
    <created-at type="datetime">2010-02-10T14:04:12-05:00</created-at>
    <id type="integer">675931192</id>
    <name>iPod Cleaning</name>
    <price type="decimal">5.00</price>
    <return-url>http://google.com?charge_id=675931192&amp;signature=a35f19e224d4a45f17bb1e316f5fd632</return-url>
    <status>accepted</status>
    <test type="boolean" nil="true"></test>
    <updated-at type="datetime">2010-02-10T14:04:12-05:00</updated-at>
  </application-charge>
</application-charges>
top

Activate a one-time application charge

Activate a previously accepted one-time application charge.

POST /admin/application_charges/#{id}/activate.xml

Activate a one-time charge

Request

           
<?xml version="1.0" encoding="UTF-8"?>
<application-charge>
  <name>iPod Cleaning</name>
  <price type="decimal">5.0</price>
  <created-at type="datetime">2010-02-10T19:04:12Z</created-at>
  <return-url>http://google.com?charge_id=675931192&amp;signature=a35f19e224d4a45f17bb1e316f5fd632</return-url>
  <updated-at type="datetime">2010-02-10T19:04:12Z</updated-at>
  <id type="integer">675931192</id>
  <test nil="true"></test>
  <status>accepted</status>
</application-charge>      

Response

           
HTTP/1.1 200 OK
Last updated at Feb 2010 Feb:02 PM.