Re: Shopify APIs - creating order without receiving payment from end-user

Shopify APIs - creating order without receiving payment from end-user

Lux83
Visitor
3 0 2

So we're building a buy-now-pay-later store module in our web-app that will be integrated into Shopify (via Shopify's Storefront APIs).

 

Our users should be able to make orders through our web app (without payment), and then someone on our end will be able to fulfill the order.

 

The user would then able to make their payment after the fact (via a custom payment implementation handled on our side), and then a webhook would just update the payment status from 'Pending Payment' to 'Complete' on shopify.

 

Is this possible via Shopify's APIs? We're trying to find a way to directly create an order without requiring payment, but our devs aren't having that much luck.

 

Summary

- We have a buy-now pay-later module on our web application that uses Shopify as the backend for storing products and creating orders. 

- We want clients to be able to create orders without payment, which may initially show as having "Pending Payment" status, but otherwise this would be considered a full order (i.e. not a draft order) which someone from our side could fulfil.

- Afterwards, when the client makes their payment, we should be able to update the status accordingly.

Replies 3 (3)

garyrgilbert
Shopify Partner
425 41 178

Hi Lux83,

 

This was possible, it is no longer possible to simply update the payment status. You will need to use the transactions API.

 

When an order is created using a manual/custom payment method a pending financial transaction is automatically created for the order.  When the customer then pays the order and your service wants to mark that order as paid in shopify, you need to query the /order/[id]/transactions.json endpoint and find the pending transaction. You then create a new transaction with kind:"capture" with the id of the pending transaction as the parent_id in the transaction you create.

 

e.g.

{
"transaction":
    {
        "parent_id" : [associated transaction_id],
        "currency": "[order currency]",
        "amount": "[amount being paid]",
        "kind": "capture"
    }
}

 

Then depending on what the amount paid is shopify will either mark the order as paid, or partially paid.

 

Hope this helps,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Lux83
Visitor
3 0 2

Hi Gary, 

 

Thanks a lot for the heads up on the updating the payment status. We'll keep this in mind!!

 

But our main hurdle atm is just the simple fact of creating the order itself, but creating it such that the payment status is specifically something like "Pending Payment", such that it's still created as a complete order for all intents and purposes when it comes to order fulfilment and whatnot.

garyrgilbert
Shopify Partner
425 41 178

Hi Lux,

 

Shouldnt be a problem. In that case you would add a transaction "object" to your post body that specifies the transaction type as "authorization", then later when the customer has paid the order your app would reference the authorization transaction when capturing it.

 

take a look here: https://shopify.dev/api/admin-rest/2022-10/resources/order#post-orders

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution