我正在使用Stripe作为支付网关。我可以在Stripe调用它时成功获取一张卡片的“标记”,这里解释如下:https://stripe.com/docs/checkout#api 不错。我成功地在我的条纹仪表板中接收了该令牌。现在我需要做的是实际收取卡(令牌)。以下是他们如何说的:“你已经得到了用户的信用卡信息,现在是什么?现在你向他们收取钱,这发生在你的服务器上,最快的方法是使用我们的客户端库。”那么,他们提供正确的网页上所需要的PHP:我使用这个PHP代码错了吗? (使用Stripe)
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://manage.stripe.com/account
Stripe::setApiKey("sk_test_68YYnDTKPzcxxRZbkxEJtOVq");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = Stripe_Charge::create(array(
"amount" => 1000, // amount in cents, again
"currency" => "usd",
"card" => $token,
"description" => "[email protected]")
);
} catch(Stripe_CardError $e) {
// The card has been declined
}
你可以清楚地看到他们是如何在这里解释一下:https://stripe.com/docs/tutorials/charges
这里是哪里出了问题。 1)本代码中的哪个位置实际上确定要收取什么卡?我在我的私人仪表板中拥有该卡的令牌ID号。我现在需要收费,但是这个代码并没有说明卡片的任何内容。我看到的唯一现货是:
$token = $_POST['stripeToken'];
'stripeToken'我在这张卡的身份证号码?
2)我创建了一个简单的网页与运行此:
<div id="payment">
<form action="charge-cards.php">
<?php require 'Stripe.php';?>
<input type="submit">
</form>
</div><!--end payment-->
“充cards.php”是由条纹提供顶级的代码。当我点击提交,我得到了如下错误:
Fatal error: Class 'Stripe' not found in /home/preemin/public_html/fun.dit /testing/charge-cards.php on line 5
谁能明白我?!“在做错误的感谢
可能是您缺少一些“包含”! –
你有红色的https://stripe.com/docs/checkout/guides/php吗?他们在那里说“让我们创建一个名为config.php的文件,我们将在其中设置一些初始配置。”你有没有下载“条纹PHP库” –
谢谢你的回复!是的,我已经将Stripe.php上传到我的服务器,并在上面的表单中包含:“<?php require'Stripe.php';?> –