我希望做到以下几点:
到目前为止,这就是我所取得的成就:
重要的是,我能够检查是否客户有足够的余额之前,他们收费,因为这是糟糕的用户体验,如果我必须回到他们,并再次要求他们的cc信息,因为我无法确认他们是否有足够的资金事先。
因此,我也想核实一下,客户在生成令牌之前是否有足够的资金,例如,如果金额为5k,而客户只有3k而没有帐户,那么就会出现一个错误,以便客户能够输入适当的信息:
function handleCall(token) {
var $form = $('#payment-form');
if (!appendedStripeToken) {
// Insert the token into the form so it gets submitted to the server
$form.append($('<input type="hidden" id="courseToken" name="stripeToken" />').val(token));
appendedStripeToken = true;
phpCall();
}
}
function onSubmit() {
var $form = $('#payment-form'); // TODO: give your html-form-tag an "id" attribute and type this id in this line. IMPORTANT: Don't replace the '#'!
// Disable the submit button to prevent repeated clicks
// TODO: give your html-submit-input-tag an "id" attribute
Stripe.card.createToken($form, stripeResponseHandler);
}
我是如何产生标记的;
$stripChargeValid = true;
try {
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => $amount,
'currency' => 'cad',
'description'=> $courseTitle
));
} catch(\Stripe\Error\Card $e) {
// The card has been declined
$stripChargeValid = false;
echo "failed";
}
重要的是,只有当客户有足够的资金时,我才会尝试收费
https://stackoverflow.com/questions/29795606
复制