我正在使用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';?> –