【问题标题】:Invalid hash - Stripe (Creating Source)无效的哈希 - 条纹(创建源)
【发布时间】:2018-03-25 12:18:01
【问题描述】:

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

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

只有当我尝试在下面的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】:

    这里的问题是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  
      )
    ));
    

    【讨论】:

    • 嘿@koopajah,这是有道理的!所以我尝试了它,它的工作原理谢谢队友! :)
    猜你喜欢
    • 1970-01-01
    • 2013-12-20
    • 2015-11-08
    • 2016-09-21
    • 2015-10-06
    • 2021-06-24
    • 2011-09-20
    • 2011-04-20
    • 2020-04-09
    相关资源
    最近更新 更多