【问题标题】:Stripe confirm Card details for swiftStripe 确认卡的详细信息以方便快捷
【发布时间】:2018-10-13 01:31:45
【问题描述】:

我使用 CardIO 和 stripe 为应用程序设置快速付款。我正在浏览 Stripes 文档以了解如何在不设置完整帐户的情况下快速验证。

我的第一个问题是 textField.isValid 确认什么?是否有一些调用条带来确认卡或者是一个简单的内容检查?

func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
    // Toggle buy button state
    buyButton.enabled = textField.isValid
}

如果它确实确认卡是有效的,那么它与下面的代码之间的区别是什么?令牌是否仅在即将执行购买时使用?

func userDidProvideCreditCardInfo(cardInfo: CardIOCreditCardInfo!, inPaymentViewController paymentViewController: CardIOPaymentViewController!) {
        if let info = cardInfo {
            let str = NSString(format: "Received card info.\n Number: %@\n expiry: %02lu/%lu\n cvv: %@.", info.redactedCardNumber, info.expiryMonth, info.expiryYear, info.cvv)
            print(str)

            //dismiss scanning controller
            paymentViewController?.dismissViewControllerAnimated(true, completion: nil)

            //create Stripe card
            let card: STPCardParams = STPCardParams()
            card.number = info.cardNumber
            card.expMonth = info.expiryMonth
            card.expYear = info.expiryYear
            card.cvc = info.cvv

            //Send to Stripe
            getStripeToken(card)

        }
    }

编辑:我应该补充一点,我很好奇是否必须开始处理付款以确认卡,或者我可以提前这样做吗? (例如:您输入的到期日期不正确)。

【问题讨论】:

  • Stripe SDK 是开源的,因此您可以查看方法的源代码以了解它的作用,但不,它不会对 Stripe 进行任何调用,只是本地验证它可以代表有效卡。
  • @dan 这不是真的 - 令牌创建涉及使用您的 Publishable Key 对 Stripe 进行 API 调用。

标签: ios swift stripe-payments


【解决方案1】:

textField.isValid 在这种情况下validates that each of the STPPaymentCardTextField fields are valid;这不涉及对 Stripe 的任何 API 调用。

第二个示例确实对 Stripe 进行了“创建令牌”API 调用,尽管这实际上并没有验证卡;直到您将它用于create a Customerstore it on an existing Customercreate a Charge,它才会得到验证。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-08
    • 2018-05-21
    • 2020-11-30
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 2016-03-04
    • 1970-01-01
    相关资源
    最近更新 更多