簡體   English   中英

iOS Stripe-獲取沒有臨時密鑰的卡令牌?

[英]iOS Stripe - Get card token without ephemeral key?

Android中實現Stripe時 ,有CardInputWidget可以為您提供Card對象,然后您可以使用該卡從Stripe API中獲取token ,最后將令牌發送至服務器,以進行收費。

iOS中實現Stripe時 ,我可以看到工作流程完全不同。 服務器需要具有API端點才能提供Stripe ephemeral key 有沒有辦法像Android工作流程中那樣-沒有ephemeral key

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

用PHP條帶化支付

是的,絕對可以,使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM