Create an order and charge a customer's card purely through the REST API?

RareArtifact
Tourist
13 0 2

Hey guys, hoping someone has a definitive answer on this and where I should start.

We have a couple of stand-alone landing pages for individual products that are completely detached from our Shopify Plus account. These are "single page checkout" sites; the user enters their credit card information right from the main page, there is no "cart" or checkout. The primary use for these are single-product campaigns and for our call center employees to place orders from customer who called in by phone.

Currently we handle the transaction with a Stripe account: The user completes the form and posts to a script on our server. Our server charges the card through Stripe's REST API, then pushes the order into Shopify as a prepaid order through the REST API. This is all working fine, but I'd like to eliminate Stripe and just have Shopify charge the card so everything stays in one platform.

Is this possible? My goal is to create a single script that uses only the REST API, no client-side code, no directing the user to a checkout page, etc.

  1. Create an unpaid order in Shopify and get the Order ID.
  2. Add the customer's card information and charge the card for the order total. (transaction?)
  3. Update the payment status to paid if approved, or delete the whole order if declined.

 

Replies 2 (2)
RareArtifact
Tourist
13 0 2

To clarify, I basically just want to do this -- which you can do through the Admin interface -- via the API. Create an order (or draft order), then pay for it by putting card number/exp/etc. into the API. Card is charged, order becomes paid.

RareArtifact_0-1634761208147.png

 

GrahamS
Shopify Staff
156 25 32

Hey @RareArtifact ,

With just orders API or transactions API alone, you wouldn't be able to do that. The act of creating an order or a transaction only creates the digital record of those events. The actual payment processing can only happen if your app has specific configurations in place, otherwise we just create a record of a transaction that never actually happened. As far as strictly imitating the draft order payment collection process via API goes - that's not possible at this time.

A more involved breakdown of the process would be here in THIS DOC

Graham S | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog