所以...我已经在本地安装了作曲家和Stripe库并将其推送到我的服务器usig FTP,然后我将其删除并通过SSH将作曲家和Stripe库直接安装到我的服务器上...但是我无法获得Stripe上班!!!!

我没有使用自定义编码...我只需要Stripe的基本Checkout .

我的表格:(使用正确的php require_once(' . / config.php');在php标签的页面顶部)

<form action="charge.php" method="POST">
   <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
      data-key="<?php echo $stripe['publishable_key']; ?>"
      data-amount="2298"
      data-name="Company Name"
      data-description="Ohio orders will be charged sales tax"
      data-image="icon/apple-icon-76x76.png"
      data-locale="auto"
      data-billing-address="true"
      data-shipping-address="true"
      data-allow-remember-me="false">
   </script>
</form>

我的config.php:

<?php
   require_once('vendor/autoload.php');

   $stripe = array(
      "secret_key"      => "sk_test_COPIED_DIRECTLY_FROM_STRIPE",
      "publishable_key" => "pk_test_COPIED_DIRECTLY_FROM_STRIPE"
   );

   \Stripe\Stripe::setApiKey($stripe['secret_key']);
?>

我的charge.php:

<?php
   require_once('./config.php');

   $token  = $_POST['stripeToken'];
   $email  = $_POST['stripeEmail'];

   $customer = \Stripe\Customer::create(array(
      'email' => $email,
      'source'  => $token
   ));

   $charge = \Stripe\Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 2298,
      'currency' => 'usd',
      'description' => 'Example description'
   ));

  echo '<h1>Successfully charged $22.98!</h1>';
?>

使用上述所有代码,我可以查看发送到Stripe仪表板的所有内容;但是,我得到以下402错误“致命错误:未捕获的条纹\错误\卡:无法向没有活动卡的客户收费....”

Stripe Dashboard告诉我:

{
   "error": {
   "message": "Cannot charge a customer that has no active card",
   "type": "card_error",
   "param": "card",
   "code": "missing"
   }
}

如果我尝试在POST参数之后立即更改我的charge.php页面以回显$ token而不是$ charge任何东西,我得到一个完全空白的charge.php页面,没有$ token echo'ed ....?

我没有从Stripe获得$令牌吗?