我希望做到以下几点:
到目前为止,这就是我所取得的成就:
重要的是,我能够检查是否客户有足够的余额之前,他们收费,因为这是糟糕的用户体验,如果我必须回到他们,并再次要求他们的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";
}重要的是,只有当客户有足够的资金时,我才会尝试收费
发布于 2015-04-22 12:53:59
Stripe.js不验证银行提供的卡的有效性。它只需确保字段是正确的(有意义的过期日期、传递Luhn算法的卡号等)。
在您的情况下,最好的解决方案是在服务器上创建电荷并检查它是否成功。如果失败,您将向您的客户返回一个错误,就像您现在所做的那样。
不幸的是,在创建卡片令牌时无法事先知道。即使是条形检查也只能通过运行$0/1授权来确保卡是有效的,而不是授权全部金额。
https://stackoverflow.com/questions/29795606
复制相似问题