stripe / stripe-apps

Stripe Apps lets you embed custom user experiences directly in the Stripe Dashboard and orchestrate the Stripe API.
https://stripe.com/docs/stripe-apps
MIT License
148 stars 73 forks source link

How can I create a token with just the last 4 of a card? #963

Closed lukeirvin closed 7 months ago

lukeirvin commented 7 months ago

I need to get a STPToken but I can only get the last 4 of a card & I get an invalid card number error.

I'm using STPAddCardViewController

    private func getToken(paymentMethod: STPPaymentMethod) {
            let cardParams = STPCardParams()            
            cardParams.number = paymentMethod.card?.last4
            cardParams.expMonth = UInt(paymentMethod.card?.expMonth ?? 0)
            cardParams.expYear = UInt(paymentMethod.card?.expYear ?? 0)            

            STPAPIClient.shared.createToken(withCard: cardParams) { (token: STPToken?, error: Error?) in
                guard let token = token, error == nil else {
                    // Present error to user...
                    return
                }

                print(token)
            }
        }
remi-stripe commented 7 months ago

@lukeirvin I think you're in the wrong repo so I'm going to close this issue. It looks like you have an integration support question better directed at our support team though so I recommend you reach out to them instead: https://support.stripe.com/contact

To unblock you, it's impossible to create a Token with just the card last 4 digits. But our support team can guide you better once you explain what you are really trying to achieve!