我有一個困境,相當大的一個。使用付款
我工作條紋作爲我的支付網關,它工作在2方式的過程。其生成的令牌
問題客戶
- 收集帳單信息是令牌只能使用一次,並在第1步,我無法驗證,如果客戶有足夠的資金,所以如果它沒有,那麼卡被拒絕,問題是我不能重複使用令牌,所以我不能回到客戶,並再次要求他們的細節。所以我的問題是如何在不向客戶收費的情況下驗證他們在生成令牌時有足夠的資金。下面
是一個快速瀏覽一下如何產生的代碼:
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); }
更新:
// This identifies your website in the createToken call below Stripe.setPublishableKey('CODE'); var appendedStripeToken = false; var stripeResponseHandler = function(status, response) { var $form = $('#payment-form'); if (response.error) { // Show the errors on the form $form.find('.payment-errors').text(response.error.message); $form.find('button').prop('disabled', false); } else { // token contains id, last4, and card type var token = response.id; handleCall(token); } }; 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); } function phpCall() { if(appendedStripeToken === true){ $.ajax({ type: "POST", data: {run: true, priceFinal: $('#priceFinal').val(), courseProvider: $('#courseProvider').val(), userEmail: $('#userEmail').val(), courseDelivery: $('#courseDelivery').val(), courseTitle: $('#courseTitle').val(), courseDate: $('#courseDate').val(), courseToken: $('#courseToken').val(), cardname: $('#billingcardName').val(), finalCoupon: $('#finalCoupon').val(), couponDiscount: $('#couponDiscount').val() }, url: 'functions/paymentEmail.php', success: function (response) {//response is value returned from php (for your example it's "bye bye" $('#payment-form').prop('disabled', true); // TODO: give your html-submit-input-tag an "id" attribute window.location = response; } }); } }
不能收取用戶,如果他/她沒有足夠的平衡,所以,付款將是要麼是成功或失敗,如果失敗,有重新啓動事務新的令牌。 –
但我如何驗證他們是否有足夠的餘額而不收取費用?它很尷尬詢問客戶他們的信用卡細節 – John