prolificinteractive / Caishen

A Payment Card UI & Validator for iOS
MIT License
766 stars 119 forks source link

Manual installation #77

Closed ElectrumDevelopment closed 7 years ago

ElectrumDevelopment commented 8 years ago

I installed it, how do I get the individual pieces as string so I can set it to user defaults

ElectrumDevelopment commented 8 years ago

func cardTextField(cardTextField: CardTextField, didEnterCardInformation information: Card, withValidationResult validationResult: CardValidationResult) { if validationResult == .Valid { defaults.setObject(Card.Number, forKey: "cardNumber") defaults.setObject(Card.expiryDate, forKey: "expDate") defaults.setObject(Card.cardVerificationCode, forKey: "cvc")

    }
}

Thats how I have it and it doesn't work

DannyVancura commented 8 years ago

Hey, I think saving the pieces to user defaults should look more like this:

defaults.setObject(information.bankCardNumber.rawValue, forKey: "number")
defaults.setObject(information.expiryDate.rawValue, forKey: "expiry")
defaults.setObject(information.cardVerificationCode.rawValue, forKey: "cvc")

Depending on your use case I'd probably not save the CVC or even the data all together. At least the PCI security standards council advises to store data only if necessary and not to store the CVC at all.

Also I'd recommend to encrypt the data. NSUserDefaults is basically stored as a plain plist file, potentially exposing the user's credit card information. I would use Keychain Services for this use case.

ElectrumDevelopment commented 8 years ago

Thanks for the suggestions! Encryption will definitely be my first priority

ElectrumDevelopment commented 8 years ago

Also, any way to capture the date as a string instead of a NSDate?

DannyVancura commented 8 years ago

To get a date in any form you want, you should use an NSDateFormatter, possibly in the language that the device user uses and with the date and time format that you need (like Jan 1, 2016, 1/1/2016, etc.).