我们已使用PHP使用条带支付。它可在本地计算机上运行,​​但在实时服务器上无法正常运行。我们共享了所使用的代码,并附带了错误的屏幕截图。不知道我们在哪里犯了错误,您可以指导我们吗?

条码:

require_once('Stripe.php');

Stripe::setApiKey('secret key');

echo '<form action="" method="post">
  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="publish key"
          data-description="Access for a year"
          data-amount="5000"
          data-locale="auto"></script>
</form>';

if($_POST) {
 $token  = $_POST['stripeToken'];

  $customer = Stripe_Customer::create(array(
      'email' => 'customer@example.com',
      'source'  => $token
  ));

  $charge = Stripe_Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 5000,
      'currency' => 'usd'
  ));

  echo '<h1>Successfully charged $50.00!</h1>';

}


本地机器



实时服务器

最佳答案

1)看起来您可能没有将带区php绑定附带的data文件夹复制到服务器上---其中包含ca-certificates.crt错误中引用的failed loading cafile文件。确保服务器上存在此文件夹,然后查看是否可以解决问题!

2)如果您仍然遇到问题,则可能是服务器无法通过TLS 1.2与Stripe通信。从语法上看,您似乎正在使用Stripe的PHP库的旧版本,因此您想在此处将第二个示例用于test that

如果curl首先可以建立TLS 1.2连接,则还可以运行测试脚本like this来帮助确定libcurl和openssl版本。如果您需要升级curl和openssl,则一些有用的建议是here。您也可以在此问题上与系统管理员或网络主机聊天。

09-18 11:13