Anyone please confirm how to validate/authorise cvv number of your credit/debit card from Stripe without charging the card? I am using Stripe to create card token but that did not validate cvv. I am building a custom UI to add my payment details but I need to validate whether card details (cvv number) are correct or not without charging it. Below is the function I am using but that did not worked.
func isValidCard(cardNumber: String?, month: UInt, year: UInt, cvv: String?) -> Bool {
let params = STPCardParams()
params.number = cardNumber
params.expMonth = month
params.expYear = year
params.cvc = cvv
if STPCardValidator.validationState(forCard: params) == .valid {
return true
} else {
return false
}
}
Any help will be appreciated. Thanks
If you only want to check that the CVV length match the card brand, you could simply use validationState(forCVC:cardBrand:)
.
To check that the CVV is valid without actually charging the user, then you need to save the customer's card with a SetupIntent. You can do so in two main ways:
STPSetupIntentConfirmParams
while passing the card detailsNote that Stripe cannot guarantee that the CVV check will be available as explained here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.