stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.11k stars 975 forks source link

validateCardReturningError() is deprecated, using STPCardValidator instead: Syntax question in Swift 2.1 #322

Closed daisyramos317 closed 8 years ago

daisyramos317 commented 8 years ago

So I was using an older version of Stripe, v5.1.4 until recently hence the numerous deprecation warnings I've received :) Anyhow I am using STPCardValidator and wanted to know if my syntax is correct when calling the .validationState() methods.

Here is what I have. Note: I am using a regex function to validate the card type

if (self.validateCardType(creditCardField.text!) == "Visa") { STPCardValidator.validationStateForCVC(self.securityField.text!, cardBrand: STPCardBrand.Visa) STPCardValidator.validationStateForNumber(self.creditCardField.text!, validatingCardBrand: true) }

jflinter commented 8 years ago

Hey there @daisyramos317, Sorry for the slow reply on our end. That syntax isn't correct - you'll actually need to check the validation state returned by those functions. I'd recommend you do something like:

let cardParams = STPCardParams()
cardParams.number = ...
cardParams.expMonth = ...
cardParams.expYear = ...
cardParams.cvc = ...
if STPCardValidator.validationStateForCard(cardParams) == .Valid {
  // the card is valid.
}
daisyramos317 commented 8 years ago

thank you! @jflinter

phungnet commented 7 years ago

thanks

hemraj-shaqawal commented 7 years ago

thanks

Abdulazizalghwly commented 1 year ago

ممكن صديق تدفع علي

Abdulazizalghwly commented 1 year ago

Abdulaziz Mohammed alghwly

Abdulazizalghwly commented 1 year ago

Yemen Sana'a

Abdulazizalghwly commented 1 year ago

لذلك كنت أستخدم إصدارًا قديمًا من Stripe ، v5.1.4 حتى وقت قريب ، ومن هنا جاءت تحذيرات الإهمال العديدة التي تلقيتها :) على أي حال ، فأنا أستخدم STPCardValidator وأردت معرفة ما إذا كان بناء الجملة الخاص بي صحيحًا عند استدعاء طرق .validationState ().

هذا ما لدي. ملاحظة: أنا أستخدم دالة regex للتحقق من نوع البطاقة

if (self.validateCardType(creditCardField.text!) == "Visa") { STPCardValidator.validationStateForCVC(self.securityField.text!, cardBrand: STPCardBrand.Visa) STPCardValidator.validationStateForNumber(self.creditCardField.text!, validatingCardBrand: true) }