我正在使用Shopify CakePHP库,当我想创建定期付款时,我不断收到错误"无法处理的实体"。
两个类似的库发生相同的错误:第一个、第二个
以下部分中出现错误:
// Create a new recurring charge
$charge = array
(
"recurring_application_charge"=>array
(
"price"=>1.0,
"name"=>"Super Duper Plan",
"return_url"=>"http://super-duper.shopifyapps.com",
"test"=>true
)
);
try
{
$recurring_application_charge = $sc->call('POST', '/admin/recurring_application_charges.json', $charge);
// API call limit helpers
echo $sc->callsMade(); // 2
echo $sc->callsLeft(); // 498
echo $sc->callLimit(); // 500
}
catch (ShopifyApiException $e)
{
debug($e->getMessage()); // Error
}
我收到的错误是第 422 号,它有以下描述:请求格式正确,但由于语义错误而无法遵循。这意味着数组中的某些内容是错误的。你能告诉我这里可能有什么问题吗?
注意:$charge
部分是从 Shopify 账单 API 文档中复制/粘贴的
谢谢!
如果您使用的是 https://github.com/isaacbowen/shopify-cakephp 为什么要手动构造和执行请求?您应该能够使用它创建的帮助程序,我在代码中看到一个 ShopifyRecurringApplicationCharge 类。我绝对不是 php 专家,但我不确定您的请求是否会将您的有效负载正确编码为 json,是吗?