prolificinteractive / Caishen

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

CardIO + NumberInputTextField #126

Closed teodorciuraru closed 6 years ago

teodorciuraru commented 6 years ago

How can I combine the last example in this repo (multiple TextFields) with an accessory button that will open CardIO?

DannyVancura commented 6 years ago

Hey, this should do the trick:

    func userDidProvide(_ cardInfo: CardIOCreditCardInfo!, in paymentViewController: CardIOPaymentViewController!) {
        let numberFormatter = NumberFormatter()
        numberFormatter.minimumIntegerDigits = 2
        numberFormatter.maximumIntegerDigits = 2
        cardNumberTextField.prefill(cardInfo.cardNumber)
        monthInputTextField.prefill(numberFormatter.string(from: cardInfo.expiryMonth as NSNumber) ?? "")
        yearInputTextField.prefill(numberFormatter.string(from: cardInfo.expiryYear as NSNumber) ?? "")
        cvcInputTextField.prefill(cardInfo.cvv)

        paymentViewController.dismiss(animated: true, completion: nil)
    }