orazz / CreditCardForm-iOS

CreditCardForm is iOS framework that allows developers to create the UI which replicates an actual Credit Card.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Credit Card Holder Name

cesarmtz93 opened this issue · comments

is there a way i could add the option of capturing the card holders name?

commented

Demo 2

creditCardView.cardHolderString = "Name"

i meant it to be in the capturing form, is that possible?

commented

@cesarmtz93 What do you mean by capturing?

img_3165

Like this

commented

You can use your own textfield and set text manually.

How to get cardName from card number ?

You can use this code to create the card holder's field:

func createCardHolderTextField() {
    let y = paymentTextField.frame.origin.y + 99
    let cardHolderTextField = UITextField()
    cardHolderTextField.frame = CGRect(x: 15, y: y, width: self.view.frame.size.width - 30, height: 44)
    cardHolderTextField.delegate = self
    paymentTextField.translatesAutoresizingMaskIntoConstraints = false
    paymentTextField.borderWidth = 0
    
    let border = CALayer()
    let width = CGFloat(1.0)
    border.borderColor = UIColor.darkGray.cgColor
    border.frame = CGRect(x: 0, y: paymentTextField.frame.size.height - width, width:  paymentTextField.frame.size.width, height: paymentTextField.frame.size.height)
    border.borderWidth = width
    cardHolderTextField.layer.addSublayer(border)
    cardHolderTextField.layer.masksToBounds = true
    view.addSubview(cardHolderTextField)
    
    NSLayoutConstraint.activate([
        cardHolderTextField.topAnchor.constraint(equalTo: paymentTextField.bottomAnchor, constant: 20),
        cardHolderTextField.centerXAnchor.constraint(equalTo: view.centerXAnchor),
        cardHolderTextField.widthAnchor.constraint(equalToConstant: self.view.frame.size.width-20),
        cardHolderTextField.heightAnchor.constraint(equalToConstant: 44)
        ])
    
    cardHolderTextField.placeholder = "CARD HOLDER"
    
}

Dont forget to use the delegate methods in the viewController class

creditCardView.cardHolderString = textField.text

for card Holder Name capture (User can enter Name in textField get Value in cardHolderString