【发布时间】:2012-07-18 16:47:41
【问题描述】:
(我是第一次发帖,所以请原谅我缺乏正确的格式,如果这个问题已经以某种形式或方式得到了回答)
问题: Shopify API - 通过创建新交易对订单进行部分退款(反对简单地取消订单)
原因:在不取消订单的情况下给予客户部分退款
问题: 将'Create Transaction'发送到shopify api时查询崩溃,没有错误,try和catch没有启动,查询到shopify后的代码被忽略也是。
用于交易的 Shopify Developer API XML/JSON: http://api.shopify.com/transactions.html
目前使用 Sandeepsheety 的 PHP API 代码: 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
?>
【问题讨论】:
-
您能否澄清“未启动尝试和捕获”的意思?如果响应代码 >=400,shopify.php 将引发异常。您需要围绕 POST 请求的 try/catch 块,上面的代码 sn-p 中似乎缺少该块。