简体   繁体   English

当其余的表单对Stripe无效时,填充信用卡和cvc字段

[英]Populate credit card and cvc field when rest of form is invalid with Stripe

I have been reading thru the Stripe documentation and I was unable to find the answer. 我一直在阅读Stripe文档,但找不到答案。

I have a form that has the following fields: first name, last name, address, credit card number, cvc, card expiration. 我有一个包含以下字段的表格:名字,姓氏,地址,信用卡号,信用卡,信用卡过期。

I know the credit card and cvc fields will not have have a name so it does not get posted to the server. 我知道信用卡和cvc字段将没有名称,因此不会被发布到服务器。

If the user forgets to fill out the entire form (server side validation for the name and address fields), it displays an error and reloads the page with the fields populated with the data the user entered before submitting. 如果用户忘记填写整个表单(名称和地址字段的服务器端验证),它将显示错误,并使用在提交前用户输入的数据填充的字段重新加载页面。

This may not be possible but wanted to ask, is it possible to repopulate the cvc and credit card fields? 这可能无法实现,但想问一问,是否可以重新填充cvc和信用卡字段? I obviously could accomplish this if I gave those two fields a name, but that is insecure and not a option. 如果我给这两个字段起一个名字,我显然可以做到这一点,但这是不安全的,不是一种选择。

There is no way to achieve that, because if you want to repopulate those fields, you have to store that data somewhere, and that's very dangerous. 无法实现这一点,因为如果您想重新填充这些字段,则必须将数据存储在某个地方,这非常危险。 The only way I can think right know would be using cookies, but those are sent to the server too. 我认为正确的唯一方法就是使用Cookie,但这些Cookie也会发送到服务器。

What you could do is, if the server displays an error, it could send a page with a simple script window.history.back() . 您可以做的是,如果服务器显示错误,则可以发送带有简单脚本window.history.back() As said on the comment, Chrome and most browsers will repopulate them for you. 如评论所述,Chrome和大多数浏览器将为您重新填充它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM