【问题标题】:laravel-shopify-API-wrapper: Pass charge to shopifylaravel-shopify-API-wrapper:将费用传递给shopify
【发布时间】:2016-08-03 15:30:10
【问题描述】:

我正在使用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 的方式。没有关于如何传递收费数据的文档我可以看到。

【问题讨论】:

    标签: php laravel shopify


    【解决方案1】:

    我只是想回想一下我在一个旧项目上做了什么,这是我的处理方式,我正在为这个 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')
            ]]);
    

    不知道这对你有没有帮助...

    【讨论】:

    • 刚刚尝试了收费部分的数据结构,但不幸的是没有运气。好主意,不过还是谢谢。
    【解决方案2】:

    必须传递完整的 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 ) )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-15
      • 1970-01-01
      • 1970-01-01
      • 2017-09-04
      • 1970-01-01
      相关资源
      最近更新 更多