创建条带客户:收到未知参数:true

时间:2015-05-21 17:41:23

标签: php parameters stripe-payments

每当我尝试创建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>

我的PHP for customer.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;
?>

1 个答案:

答案 0 :(得分:0)

Solved! Turns out wasn't an error on my part in the code - just the version of the API i had involved was buggy. Updating it did the trick.