无效的哈希 - 条带(创建源)

问题描述 投票:1回答:1

大家好,所以我正在使用他们的库使用支付方法IDEAL创建条带源,我偶然发现了这个不寻常的错误。

致命错误:来自API请求'req_S1FAI6czFIggdC'的/home/ubuntu/workspace/ideal/stripe-php-4.13.0/lib/ApiRequestor.php:110中未捕获的异常'Stripe \ Error \ InvalidRequest'和消息'无效散列'第110行/home/ubuntu/workspace/ideal/stripe-php-4.13.0/lib/ApiRequestor.php

只有在我尝试在下面的owner对象下添加这行代码时才会出现该错误(请参阅下面的实际代码),这会导致错误甚至在正确的地方添加。

 "address" => "Test Adress"

实际代码:

\Stripe\Stripe::setApiKey("test_key_here");

$source = \Stripe\Source::create(array(
  "type" => $type,
  "currency" => $currency,
  "amount" => $amount,
  "statement_descriptor" => $product,
  "owner" => array(
    "phone" => $phone,
    "email" => $email,
    "name" => $name,
    "address" => "Test Adress" //this causes the error
  ),
  "redirect" => array (
    "return_url" =>  $returnUrl 
  ),
  "ideal" => array(
    "bank" => $bank  
  )
));
php stripe-payments
1个回答
6
投票

这里的问题是address不是街道地址,它是一个散列,需要多个子参数(第1行和第2行,城市等),如下所示:https://stripe.com/docs/api#create_source-owner-address

代码应该是这样的:

$source = \Stripe\Source::create(array(
  "type" => $type,
  "currency" => $currency,
  "amount" => $amount,
  "statement_descriptor" => $product,
  "owner" => array(
    "phone" => $phone,
    "email" => $email,
    "name" => $name,
    "address" => array(
      "line1" => "Test line1",
      "city" => "My City",
      "postal_code" => "90210",
      "state" => "CA",
  ),
  "redirect" => array (
    "return_url" =>  $returnUrl 
  ),
  "ideal" => array(
    "bank" => $bank  
  )
));
© www.soinside.com 2019 - 2024. All rights reserved.