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

cam*_*dev 1 php stripe-payments

大家好,我在使用带库的付款方式IDEAL在Stripe上创建了一个源,我偶然发现了这个异常错误。

致命错误:/home/ubuntu/workspace/ideal/stripe-php-4.13.0/lib/ApiRequestor.php:110中来自API请求“ req_S1FAI6czFIggdC”的消息“ Invalid hash”未捕获的异常“ Stripe \ Error \ InvalidRequest” /home/ubuntu/workspace/ideal/stripe-php-4.13.0/lib/ApiRequestor.php在第110行

仅当我尝试将以下代码行添加到下面的owner对象下时,才会出现该错误(请参阅下面的实际代码),这甚至会在正确的位置添加该错误。

 "address" => "Test Adress"
Run Code Online (Sandbox Code Playgroud)

实际代码:

\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  
  )
));
Run Code Online (Sandbox Code Playgroud)

koo*_*jah 7

这里的问题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  
  )
));
Run Code Online (Sandbox Code Playgroud)