Discussing APIs and development related to customers, discounts, and order management.
Good Morning!
Hoping someone can shed some light on an issue we're facing. We are attempting to make partial captures on an order with a successful authorization, the first transaction/partial capture is successful, but subsequent ones fail.
Here are some details;
1. We first create the order through POST `api/2023-04/orders.json` with a single transaction that is authorized
2. A call to GET `api/2023-04/transactions.json` confirms there is a single, successful authorized transaction for this order.
GET /admin/api/2023-04/orders/6015472500898/transactions.json status: 200 body: {"transactions":[{"id":6966709223586,"order_id":6015472500898,"kind":"authorization","gateway":"PaypalCommercePlatform","status":"success","message":null,"created_at":"2023-12-19T17:59:27-06:00","test":false,"authorization":"","location_id":null,"user_id":null,"parent_id":null,"processed_at":"2023-12-19T17:59:27-06:00","device_id":null,"error_code":null,"source_name":"5021135","amount":"90.05","currency":"USD","payment_id":"#1152.1","total_unsettled_set":{"presentment_money":{"amount":"90.05","currency":"USD"},"shop_money":{"amount":"90.05","currency":"USD"}},"admin_graphql_api_id":"gid:\/\/shopify\/OrderTransaction\/6966709223586"}]}
2.1. We call POST `api/2023-04/transactions.json` to create the first partial capture transaction. It has amount less than the first transaction, its kind is `capture`, and the parent_id is the id of the authorization transaction. This request returns a 201.
POST /admin/api/2023-04/orders/6015472500898/transactions.json body: {"transaction":{"order_id":"6015472500898","amount":68.19,"kind":"capture","currency":"USD","parent_id":"6966709223586"}} status: 201 body: {"transaction":{"id":6966716629154,"order_id":6015472500898,"kind":"capture","gateway":"PaypalCommercePlatform","status":"success","message":"Marked the PaypalCommercePlatform payment as received","created_at":"2023-12-19T18:03:05-06:00","test":true,"authorization":null,"location_id":null,"user_id":null,"parent_id":6966709223586,"processed_at":"2023-12-19T18:03:05-06:00","device_id":null,"error_code":null,"source_name":"5021135","receipt":{},"amount":"68.19","currency":"USD","payment_id":"#1152.2","total_unsettled_set":{"presentment_money":{"amount":"0.0","currency":"USD"},"shop_money":{"amount":"0.0","currency":"USD"}},"admin_graphql_api_id":"gid:\/\/shopify\/OrderTransaction\/6966716629154"}}
2.2. Later, we POST `api/2023-04/transactions.json` again to do a second partial capture transaction for a different line item. The amount is the balance of the order, kind is `capture`, and the parent_id is the id of the first authorization created at order creation time. This request returns a 422.
POST https://bold-eric-dufault.myshopify.com/admin/api/2023-04/orders/6015472500898/transactions.json body: {"transaction":{"order_id":"6015472500898","amount":21.86,"kind":"capture","currency":"USD","parent_id":"6966709223586"}} status: 422 body: {"errors":{"base":["Can only capture successful authorizations"]}}
Should we be handling partial capture transactions differently? I can only guess that the first partial capture is closing out the original authorization transaction despite its amount being less than the full amount.
Thank you in advance!