我一直在尝试按照条带文档中提供的说明将Stripe集成到我的网站中。但是,运行时会出现以下错误。
注意:未定义的索引:stripeToken
致命错误:未捕获的异常' Stripe \ Error \ InvalidRequest'有消息'必须提供来源或客户。'
require_once('vendor/autoload.php');
\Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxx");
$token = $_POST['stripeToken'];
// Charge the user's card:
$charge = \Stripe\Charge::create(array(
"amount" => 1000,
"currency" => "usd",
"description" => "Example charge",
"source" => $token,
));
<form action="shop.php" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_xxxxxxxxxxxxx"
data-amount="1000"
data-name="Example"
data-description="Widget"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto">
</script>
</form>
密钥已更改。谢谢你的帮助。