我有一個頁面,用戶輸入cc並獲得收費。如何將卡添加到用戶並使用Stripe對其進行充電?
我創建使用JS
Stripe.card.createToken(ccData, function stripeResponseHandler(status, response) {
var token = response.id;
// add the cc info to the user using
// charge the cc for an amount
});
添加我使用PHP
$stripeResp = Stripe_Customer::retrieve($stripeUserId);
$stripeResp->sources->create(['source' => $cardToken]);
充電,並抄送我使用PHP以及
$stripeCharge = Stripe_Charge::create([
'source' => $token,
'amount' => $amount
]);
的CC卡令牌
做所有這一切,我得到You cannot use a Stripe token more than once
。
任何想法如何將cc保存到此用戶$stripeUserId
並收取費用。
PHP是受歡迎的,但js也很棒。
謝謝,我想我剛剛在某個時候感到困惑 – Patrioticcow