1
votes

(I'm a first time poster, so please forgive my lack of proper formatting, and if this question has already been answered in some form or fashion)

Issue: Shopify API - Partial Refund On Order Through Creation of A New Transaction(opposed to simply cancelling the order)

Reason: Give customer partial refund without cancelling the order

Problem: The Query Crashes at the point of sending the 'Create Transaction' into the shopify api, no errors, try and catch are not initiated, and the code after the query to shopify is ignored as well.

Shopify Developer API XML/JSON for Transactions: http://api.shopify.com/transactions.html

Currently using Sandeepsheety's PHP API Code: https://github.com/sandeepshetty/shopify.php/blob/master/README.md

<?php
//-------------------------------------------------------------------------------
//PHP Code Begins
//NOTE: [Does return correct values for the Order through GET through id=135264996 and,
// transaction GET data is verified as well - Test Order Total = $94.50 and,
// tested a few other orders ids with the same result.]
//-------------------------------------------------------------------------------

       //Does connect and I have verified with a few GETS and even a couple cancellations
        $shopify = shopify_api_client($SHOPIFY_STORE_URL, NULL, $SHOPIFY_API_KEY, $SHOPIFY_TOKEN, true);

       //Based on Create Transactions: (POST /admin/orders/#{id}/transactions.json)
        $jsonURL= "/admin/orders/135264996/transactions.json";

        $query = $shopify('POST', $jsonURL, array('kind'='refund', 'amount'=10));
       //NOTHING HAPPENS and Code Stops HERE

        echo "Passed";  //IGNORED
?>
1
Could you clarify what you mean by "try and catch are not initiated"? shopify.php throws an exception if the response code is >=400. You need a try/catch block around the POST request which seems to be missing in the code snippet above. - Sandeep Shetty

1 Answers

4
votes

The Transaction API only supports 'capture' as the kind. The server is returning a 403 Forbidden, with text "Only capturing is currently supported".

shopify.php must not be handling that error properly but that is the issue you're running into.