2016-08-03 78 views
0

我正在使用this shopify api code。我設法讓我的應用程序安裝,但現在當我嘗試建立一個收費我的應用程序時,我打這個電話我得到這個錯誤:laravel-shopify-API-wrapper:通過收費購物

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被傳入的方式。沒有關於如何通過我可以看到的收費數據傳遞的文檔。

回答

0

必須通過完整的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)) 
0

我只是想回憶什麼,我做了一箇舊的項目,這是我如何處理它,我現在用的是以下軟件包這一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') 
     ]]); 

不知道這是任何幫助你...

+0

只是想你的數據結構爲充一部分,但沒有運氣很遺憾。好主意,但無論如何感謝。 – user1532669