简体   繁体   English

对信用卡使用Stripe SDK

[英]Using Stripe SDK for creditcards

I'm trying to use Stripe and it's working. 我正在尝试使用Stripe,它正在工作。 There's just one problem. 只有一个问题。 I've got a STPPaymentCardTextField and I send the cardParams to the their backend like so: 我有一个STPPaymentCardTextField,我将cardParams发送到其后端,如下所示:

STPAPIClient.sharedClient().createTokenWithCard(paymentTextField.cardParams) { (token, error) -> Void in
            if let error = error  {
                HUD.flash(.Error, delay:1.0, completion: {(done) in
                })
                print(error)
            }
            else if let token = token {

            }
        }

I however need to know the cardtype (Visa, Amex, Mastercard etc.) as well. 但是,我还需要了解卡类型(签证,美国运通卡,万事达卡等)。 This can only be retrieved by using the STPCard object. 这只能通过使用STPCard对象来检索。 I do not know how to cast my STPCardParams object into a STPCard object to get this data. 我不知道如何将我的STPCardParams对象转换为STPCard对象以获取此数据。

Thanks to Paulw11's comment I found this to be what I'm looking for: 感谢Paulw11的评论,我发现这就是我想要的:

STPAPIClient.sharedClient().createTokenWithCard(paymentTextField.cardParams) { (token, error) -> Void in
            if let error = error  {
                HUD.flash(.Error, delay:1.0, completion: {(done) in
                })
                print(error)
            }
            else if let token = token {

            let brandTypeID = STPCardValidator.brandForNumber(self.paymentTextField.cardNumber!).rawValue

            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM