【问题标题】:iOS Stripe - Get card token without ephemeral key?iOS Stripe - 获取没有临时密钥的卡令牌?
【发布时间】:2018-11-26 11:47:00
【问题描述】:

Android 中实现 Stripe 时,CardInputWidget 会为您提供一个 Card 对象,然后您会使用该卡从 Stripe API 中获得一个 token,然后最后,您将该令牌发送到您的服务器,这会产生费用。

iOS 中实现 Stripe 时,我可以看到工作流程完全不同。服务器需要有一个 API 端点来提供 Stripe ephemeral key。有没有办法像在 Android 工作流程中那样做 - 没有ephemeral key

【问题讨论】:

  • 您好,您是如何在 Android 中获取 Token 的?你有任何参考链接或代码块吗?

标签: android ios stripe-payments


【解决方案1】:
let stripeCard = STPCardParams() /// Declare Stripe Payment Function
stripeCard.name = "Card Name" // you can enter Card Owner name which is displayed in card
stripeCard.number = "Card number" //You can enter card Number which is displayed in Card
stripeCard.expMonth = "ExpireMonth" // enter expire Month which is displayed in Card
stripeCard.expYear = "ExpireYear" // enter expire year which is displayed in Card
stripeCard.cvc = "CVV" // enter CVV which is displayed in Card
//after check card valid or not from below method
if STPCardValidator.validationState(forCard: self.stripeCard) == .valid 
{
// the card is valid.
print("Valid card")
STPAPIClient.shared().createToken(withCard: self.stripeCard, completion: { (token, error) -> Void in
    if error != nil {
    print(error ?? "")
    return
    }

    print(token!) 
    // call your php Api Pass token id which is given bellow link PHP API link
    APICallResponse.shared.getStripePayment(arrUserLoginDetails:          self.arrStripePayement,vc:self, completion: {data in
      self.SkripePayment = data 
    })
}
}

您可以从给定的链接中参考 PHP API

Stripe payment with php

【讨论】:

    【解决方案2】:

    是的,绝对可以,您可以使用 Stripe 的 iOS SDK 进行开发,而无需使用其预构建的 UI 或临时密钥方法。

    您可以使用自己的表单或STPPaymentCardTextField 类,创建一个STPCardParams 实例,然后从该实例创建一个STPToken,您可以将其发送到您的后端。

    STPCardParams *cardParams = [[STPCardParams alloc] init];
    cardParams.number = @"4242424242424242";
    cardParams.expMonth = 10;
    cardParams.expYear = 2020;
    cardParams.cvc = @"345";
    
    [[STPAPIClient sharedClient] createTokenWithCard:cardParams completion:^(STPToken *token, NSError *error) {
      ...
    }
    }];
    

    请参阅https://stripe.com/docs/mobile/ios/custom#stpapiclient--stpcardparams 了解更多信息。

    【讨论】:

      猜你喜欢
      • 2018-07-12
      • 1970-01-01
      • 2020-02-29
      • 2014-09-02
      • 2019-06-29
      • 2014-09-12
      • 2016-11-13
      • 2023-01-14
      • 2018-12-12
      相关资源
      最近更新 更多