简体   繁体   English

在 iOS 中免费验证/授权 Stripe 的 cvv 编号

[英]Validate/Authorise cvv number from Stripe without charge in iOS

Anyone please confirm how to validate/authorise cvv number of your credit/debit card from Stripe without charging the card?任何人请确认如何从 Stripe 验证/授权您的信用卡/借记卡的 cvv 号码而不向卡收费? I am using Stripe to create card token but that did not validate cvv.我正在使用 Stripe 创建卡令牌,但未验证 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.我正在构建一个自定义 UI 来添加我的付款详细信息,但我需要在不收费的情况下验证卡详细信息(cvv 号码)是否正确。 Below is the function I am using but that did not worked.下面是我正在使用的 function,但没有奏效。

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:) .如果您只想检查 CVV 长度是否与卡片品牌匹配,您可以简单地使用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.要在不实际向用户收费的情况下检查 CVV 是否有效,则需要使用 SetupIntent 保存客户的卡。 You can do so in two main ways:您可以通过两种主要方式做到这一点:

Note that Stripe cannot guarantee that the CVV check will be available as explained here .请注意,Stripe 不能保证 CVV 检查将可用,如此处所述

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

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