【问题标题】:Create Stripe Customer: Received unknown parameter: true创建条纹客户:收到未知参数:true
【发布时间】:2015-05-25 06:08:37
【问题描述】:

每当我尝试创建 Stripe 客户以保存客户以供以后收费时,我都会收到一个奇怪的错误。好像在网上找不到任何其他实例,我可以得到一些帮助吗?错误是:Received unknown parameter: true

我的表单代码如下:

    <form action="customer.php" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js"
    class="stripe-button"
    data-key="***KEY***"
    data-image="img.jpg"
    data-name="Form"
    data-label="Save Card"
    data-allow-remember-me="false"
    data-panel-label="Save Card"
    data-email="<?php echo $email;?>"
    >
  </script>
</form>

而我的 customer.php 的 PHP 是:

<?php
require_once('vendor/stripe-php-2.1.1/init.php');
require_once('vendor/autoload.php');
require_once('connect.php');



\Stripe\Stripe::setApiKey("***KEY***");

// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
try {
// Create a Customer
$customer = \Stripe\Customer::create(array(
  "source" => $token,
  "description" => "Example customer",
  "email" => 'Mathexl@gmail.com'

  )
);
} catch (Stripe_CardError $e) {
    // Since it's a decline, Stripe_CardError will be caught
    $body = $e->getJsonBody();
    $err  = $body['error'];

    echo 'Status is:' . $e->getHttpStatus() . "\n";
    echo 'Type is:' . $err['type'] . "\n";
    echo 'Code is:' . $err['code'] . "\n";
    // param is '' in this case
    echo 'Param is:' . $err['param'] . "\n";
    echo 'Message is:' . $err['message'] . "\n";
} catch (Exception $e) {
    echo $e->getMessage();
} catch (ErrorException $e) {
    echo $e->getMessage();
}

// Save the customer ID in your database so you can use it later
echo $customer;
?>

【问题讨论】:

    标签: php parameters stripe-payments


    【解决方案1】:

    解决了!事实证明,我在代码中没有错误——只是我所涉及的 API 版本有问题。更新它就可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      • 2017-12-03
      • 2020-01-16
      • 2018-12-27
      • 1970-01-01
      相关资源
      最近更新 更多