简体   繁体   English

如何在iOS(Swift)中处理Stripe Payment身份验证?

[英]How to process Stripe payment authentication in iOS (Swift)?

I don't know if there's a lot of people people in here who are familiar with Stripe, but I hope someone can help me out. 我不知道这里是否有很多人熟悉Stripe,但我希望有人能帮助我。 I'm setting up iDEAL payment in my app using Sources, and I'm using the guide on the Stripe website to help me out. 我正在使用Sources在我的应用程序中设置iDEAL付款,并且正在使用Stripe网站上的指南来帮助我。 Everything was explained very clear about how to set up the source, but the problem I'm running into is that the guide is very unclear about how I should continue after the source has been created and the user has authenticated the payment. 关于如何设置源的所有解释都非常清楚,但是我遇到的问题是,该指南还不清楚如何在创建源并验证用户付款后如何继续。 It only describes how to continue when you're a web developer, but it's very unclear how to continue when you're an iOS developer. 它仅描述了当您是Web开发人员时如何继续,但是还不清楚当您是iOS开发人员时如何继续。 Basically what I want to do, is to get notified on whether the source object became chargeable (successful authentication) or failed. 基本上,我想做的是获取有关源对象是否收费(成功认证)或失败的通知。 It only says you can get notified about the authentication status through client-side polling, but it's poorly described how to set up client-side polling in iOS. 它只是说您可以通过客户端轮询获得有关身份验证状态的通知,但是对如何在iOS中设置客户端轮询的描述很少。 Can someone give me some directions on how I should continue after the authentication has been completed and the user returns back to the app? 有人可以给我一些指示,以指示在身份验证完成并且用户返回到应用程序后应如何继续? How can I get access to the new status of the source object after I return to the app? 返回应用程序后,如何访问源对象的新状态?

It's not possible to charge a given source or create a customer in your iOS application as those calls require your Secret API key. 由于这些调用需要您的Secret API密钥,因此无法在iOS应用中向给定的来源收费或创建客户。 You should never have the Secret API key in your iOS application otherwise an attacker could get his hands on it and then create charges, refunds or transfers on your behalf. 您切勿在iOS应用程序中拥有Secret API密钥,否则攻击者可能会亲手使用它,然后代您创建费用,退款或转移。

Once the source is created client-side, you need to send its id src_XXXX to your server. 在客户端创建源之后,您需要将其ID src_XXXX发送到您的服务器。 There, you will be able to call the Create Charge API to charge your source with your Secret API key. 在那里,您将能够调用Create Charge API来使用您的Secret API密钥向您的来源收费。

Since you plan to use iDeal, the source is not chargeable immediately. 由于您打算使用iDeal,因此无法立即向来源收费。 Instead, you need to either poll the source client-side until it's ready to be charged or you need to listen for the source.chargeable webhook event indicating that the source is ready to be charged. 取而代之的是,您需要轮询源客户端,直到可以对其进行充电为止,或者需要侦听表明已准备好对源进行充电的source.chargeable webhook事件。

Once it is ready, you will be able to charge the source on your server. 准备就绪后,您将可以为服务器上的源收费

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

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