【发布时间】:2021-01-06 15:51:29
【问题描述】:
在提交付款并重定向用户后,我无法尝试捕捉资金不足错误。现在,如果用户资金不足,网站会给出 500 错误。
在 PHP 中,错误日志是:
PHP 致命错误:未捕获的 Stripe\Error\InvalidRequest:必须提供来源或客户。在 /home/betheexe/public_html/_www/legalrideshare.com/stripe-php/lib/ApiRequestor.php:210 来自 API 请求“req_o4ePJL1WVn611Y”
这是我接受付款的代码:
结帐页面:
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_live_XXXXXXXXXXXXXXXXXXX"
data-amount="2499"
data-name="LR"
data-description="Deactivation"
data-email="<?php echo $_SESSION["email"]; ?>"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto">
</script>
提交后:
\Stripe\Stripe::setApiKey("sk_live_XXXXXXXXXXXXXX");
// Token is created using Checkout or Elements!
// Get the payment token ID submitted by the form:
$token = $_POST['stripeToken'];
$charge = \Stripe\Charge::create([
'amount' => '2499',
'currency' => 'usd',
'description' => 'Deactivation Letter',
'source' => $token,
]);
我只想捕捉发生的任何错误,以免页面失败。我也一定缺少来源吗?
【问题讨论】:
-
IT GIVE A 500 Error 它是条带服务器或您的服务器
-
错误提示
Must provide source or customer.,我没有看到你在哪里告诉 Stripe WHO 给 Bill,最好先解决这个问题吗? -
对不起....我的服务器。
标签: php stripe-payments