Search code examples
iosswiftstripe-paymentscard.io

How can I display my scanned card details in my stripe STPCardFormView?


My Stripe UI I am using stripe for payments, also I need the feature for card scanning and display scanned card details in stripe view, for card scanning iam using Card.io, I am getting card details from card.io

and I am using STPCardFormView for stripe,

but I am unable to display scanned values in stripe ui

Here my code

    let cardForm = STPCardFormView(style: .borderless)
    //Card.io didComplete scan
    func userDidProvide(_ cardInfo: CardIOCreditCardInfo!, in paymentViewController:    CardIOPaymentViewController!) {
        if let info = cardInfo {
            
            
            let cardParams = STPPaymentMethodCardParams()
            cardParams.number = info.cardNumber
            cardParams.expMonth = NSNumber(value: info.expiryMonth)
            cardParams.expYear = NSNumber(value: info.expiryYear)
            cardParams.cvc = info.cvv
            
//
            cardForm.cardParams = cardParams
        }

I am getting an compile time error "Cannot assign to property: 'cardParams' setter is inaccessible " if setter is inaccessible, Then how can I display scanned details from card.io in srtipe ui


Solution

  • STPCardFormView does not allow pre-filling of card details. You should use the CardIO scanned card and just create a PaymentMethod off it using createPaymentMethod() and display the last4 and brand to your customer.

    STPCardFormView should be an alternative for users who don't want to scan their cards.