Shopify API交易 - “找不到可捕获的交易”

时间:2016-06-07 16:47:23

标签: php api transactions shopify payment

我遇到了一个我自己无法处理的问题。我想通过App更改Shopfiy中订单的paymnent状态。 Shopify API文档清楚地描述了如何将现有交易标记为“付费”:https://help.shopify.com/api/reference/transaction#create

我写了所有内容,但是我收到了一条错误消息: “找不到可捕获的交易”

奇怪的是,完全相同的代码曾用于我们之前创建的另一个应用程序。

$shopify = shopify\client($stores[$order['storeID']]['shop'], SHOPIFY_APP_API_KEY, $stores[$order['storeID']]['oauth_token']);
try
{
    # Making an API request can throw an exception
    $transactions = $shopify('POST /admin/orders/'.$order['order_id'].'/transactions.json', array(), array
    (
        'transaction' => array
        (
            "amount" => $order['cod_amount_received'],
            "kind" => "capture"
        )
    ));

    print_r($transactions);
}
catch (shopify\ApiException $e)
{
    # HTTP status code was >= 400 or response contained the key 'errors'
    echo $e;
    print_r($e->getRequest());
    print_r($e->getResponse());
}
catch (shopify\CurlException $e)
{
    # cURL error
    echo $e;
    print_r($e->getRequest());
    print_r($e->getResponse());
}

我收到的回复:

  

phpish \ shopify \ ApiException:[422] / chroot /中无法处理的实体(https://proda-hu.myshopify.com/admin/orders/3264737735/transactions.json)数组('base'=>数组(0 =>'找不到可捕捉的交易',)) 98Array上的home / onlinema / webshippy.com / html / app / syncback_shopify.php([method] => POST [uri] => https://proda-hu.myshopify.com/admin/orders/3264737735/transactions.json [query] => Array()[headers] = >数组([X-Shopify-Access-Token] => 37c97637d737cf7ac8d8784d3d8ba7fd [content-type] => application / json; charset = utf-8)[payload] =>数组([transaction] =>数组([amount] => 5980.00 [kind] => capture)))数组([errors] =>数组([base] =>数组([0] =>未找到可捕获的交易)))

API中的任何内容都可能已更改?有人可以帮忙吗?谢谢,安德鲁

1 个答案:

答案 0 :(得分:2)

尝试创建交易作为订单数组的一部分。

$orders['order']['transactions'][]  =   array(
                            'amount'    =>  $tran->amount,
                            'kind'      =>  $tran->kind,
                            'status'    =>  $tran->status,
                            'source_name'=> 'other'
                        );

为我工作。