Skip to content

[BUG] [P1] UnionPay Test Card marked as invalid on iOS #4989

@alentvinsent

Description

@alentvinsent

Summary

UnionPay Test Card marked as invalid on iOS

What is blocked by this issue?

Saving a card

Code to reproduce

import Foundation
import Stripe

struct StripeValidator : CreditCardValidator, CardBrandInformationProvider {
    func validationState(forCardNumber number: String, shouldValidateBrand: Bool) -> ValidationState {



        let stripeState = STPCardValidator.validationState(forNumber: number, validatingCardBrand: shouldValidateBrand) 
        // MARK:- the above stripeState variable is returning .invalid ; 
        //MARK:-when entering UnionPay (19-digit card)    6205 5000 0000 0000 004



   


       return convert(stripeState: stripeState)
   }

    func maxCVCLength(forCardBrand brand: CardBrand) -> Int {
       return Int(STPCardValidator.maxCVCLength(for: convert(brand: brand)))
   }

   func brand(forNumber number: String) -> CardBrand {
      return CardBrand(stripeBrand: STPCardValidator.brand(forNumber: number))
  }

    func lengths(forCardBrand brand: CardBrand) -> Set<Int> {
        return Set(STPCardValidator.lengths(for: convert(brand: brand)).compactMap(Int.init))
    }

    private func convert(stripeState: STPCardValidationState) -> ValidationState {
       switch stripeState {
          case .incomplete:
              return .incomplete
           case .invalid:
              return .invalid
           case .valid:
               return .valid
            }
       }

    private func convert(brand: CardBrand) -> STPCardBrand {
           switch brand {
              case .amex: return .amex
              case .dinersClub: return .dinersClub
              case .discover: return .discover
              case .jcb: return .JCB
              case .mastercard: return .mastercard
              case .unionPay: return .unionPay
              case .unknown: return .unknown
              case .visa: return .visa
           }
    }
}

iOS version

iOS 18.1 (IPhone 16 Pro Simulator).

Installation method

Using Swift Package Manager from Xcode (Note:- Not used any Podfile)

SDK version

23.32.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1kind:bugtriagedIssue has been reviewed by Stripe and is being tracked internally

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions