shopify中的POST交易

时间:2014-08-18 11:40:05

标签: shopify

我也在创建交易,下面是我的代码

$dataem  = array('transactions'=>array('kind'=>'sale','status'=>'success'));
$urls = 'https://'.'xxxxxxxxxxxxxxxxx'.':'.'xxxxxxxxxxxxxxxxxxxxx'.'@storeName.myshopify.com/admin/orders/xxxxxxxid/transactions.json';

$data_string = json_encode($dataem);

$headers = array(
"Content-Type: application/json",
"Accept: application/json",
"Content-Length:" . strlen($data_string));

$handler = curl_init($urls);
curl_setopt($handler, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($handler, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, $headers);
$responses = curl_exec($handler);
echo "<pre>";
print_r($responses);

并显示结果{“errors”:{“transaction”:“必需参数缺失或无效”}}

1 个答案:

答案 0 :(得分:1)

请参阅creating a transaction here的Shopify API文档:

POST /admin/orders/#{id}/transactions.json
{   
    "transaction": {
        "kind": "capture"
    }
}

你有'交易'而不是'交易'。此外,响应中返回status,您不应在请求中指定它。