laravel-shopify-API-wrapper:将费用传递给 shopify
laravel-shopify-API-wrapper: Pass charge to shopify
我正在使用 this shopify api code。我已经成功安装了我的应用程序,但现在当我尝试在拨打电话时为我的应用程序设置费用时,我收到此错误:
Exception in api.php line 512:
ERROR #3: <url> malformed
这是我的代码:
$charge_params = array (
'recurring_application_charge' => array (
'name' => 'Name Of Charge',
'price' => 10,
'return_url' => 'https://dev.shopify.com/show_products/', // also tried escaping the url so https:\/\/dev.shopify.com\/show_products\/
'test' => true
)
);
$charge = $sh->call(['URL' => '/admin/recurring_application_charges.json', 'METHOD' => 'GET', 'DATA' => ['charge_params' => $charge_params]], false);
谁能看出我做错了什么?我怀疑这可能是 $charge_params
的传递方式。我没有看到关于如何传递收费数据的文档。
我只是想回忆一下我在一个旧项目上做了什么,这是我处理它的方式,为此我使用了以下包 https://github.com/phpish/shopify:
$connection = shopify\client($shop, Config::get('shopify.app_api_key'), $token);
$billing = $connection('POST /admin/recurring_application_charges.json', [
'recurring_application_charge' => [
'name' => 'Standard',
'price' => '5.0',
'return_url' => Config::get('app.url') . '/shopify/billing',
'test' => Config::get('shopify.test_mode')
]]);
不确定这是否对您有帮助...
必须通过完整的 URL 并以稍微不同的方式通过电荷阵列。还将方法更改为"POST"。
这段代码成功了:
$charge = $sh->call([
'URL' => 'https://mystore.myshopify.com/admin/recurring_application_charges.json',
'METHOD' => 'POST',
'DATA' => array (
'recurring_application_charge' => array (
'name' => 'Name Of Charge',
'price' => 10,
'return_url' => 'https://dev.shopify.com/show_products/',
'test' => true
)
)
], false);
print_r($charge);
exit;
这返回了以下内容:
stdClass Object ( [recurring_application_charge] => stdClass Object ( [id] => 2655692 [name] => Name Of Charge [api_client_id] => 1182423 [price] => 10.00 [status] => pending [return_url] => https://dev.shopify.com/show_products/ [billing_on] => [created_at] => 2016-08-03T13:50:11-04:00 [updated_at] => 2016-08-03T13:50:11-04:00 [test] => 1 [activated_on] => [trial_ends_on] => [cancelled_on] => [trial_days] => 0 [decorated_return_url] => https://dev.shopify.com/show_products/?charge_id=2655692 [confirmation_url] => https://mystore.myshopify.com/admin/charges/2655692/confirm_recurring_application_charge?signature=BAhpA8yFKA%3D%3D--8f87b4bd0d3cb9a588dfcb1566572731c0118776 ) )
我正在使用 this shopify api code。我已经成功安装了我的应用程序,但现在当我尝试在拨打电话时为我的应用程序设置费用时,我收到此错误:
Exception in api.php line 512:
ERROR #3: <url> malformed
这是我的代码:
$charge_params = array (
'recurring_application_charge' => array (
'name' => 'Name Of Charge',
'price' => 10,
'return_url' => 'https://dev.shopify.com/show_products/', // also tried escaping the url so https:\/\/dev.shopify.com\/show_products\/
'test' => true
)
);
$charge = $sh->call(['URL' => '/admin/recurring_application_charges.json', 'METHOD' => 'GET', 'DATA' => ['charge_params' => $charge_params]], false);
谁能看出我做错了什么?我怀疑这可能是 $charge_params
的传递方式。我没有看到关于如何传递收费数据的文档。
我只是想回忆一下我在一个旧项目上做了什么,这是我处理它的方式,为此我使用了以下包 https://github.com/phpish/shopify:
$connection = shopify\client($shop, Config::get('shopify.app_api_key'), $token);
$billing = $connection('POST /admin/recurring_application_charges.json', [
'recurring_application_charge' => [
'name' => 'Standard',
'price' => '5.0',
'return_url' => Config::get('app.url') . '/shopify/billing',
'test' => Config::get('shopify.test_mode')
]]);
不确定这是否对您有帮助...
必须通过完整的 URL 并以稍微不同的方式通过电荷阵列。还将方法更改为"POST"。
这段代码成功了:
$charge = $sh->call([
'URL' => 'https://mystore.myshopify.com/admin/recurring_application_charges.json',
'METHOD' => 'POST',
'DATA' => array (
'recurring_application_charge' => array (
'name' => 'Name Of Charge',
'price' => 10,
'return_url' => 'https://dev.shopify.com/show_products/',
'test' => true
)
)
], false);
print_r($charge);
exit;
这返回了以下内容:
stdClass Object ( [recurring_application_charge] => stdClass Object ( [id] => 2655692 [name] => Name Of Charge [api_client_id] => 1182423 [price] => 10.00 [status] => pending [return_url] => https://dev.shopify.com/show_products/ [billing_on] => [created_at] => 2016-08-03T13:50:11-04:00 [updated_at] => 2016-08-03T13:50:11-04:00 [test] => 1 [activated_on] => [trial_ends_on] => [cancelled_on] => [trial_days] => 0 [decorated_return_url] => https://dev.shopify.com/show_products/?charge_id=2655692 [confirmation_url] => https://mystore.myshopify.com/admin/charges/2655692/confirm_recurring_application_charge?signature=BAhpA8yFKA%3D%3D--8f87b4bd0d3cb9a588dfcb1566572731c0118776 ) )