简体   繁体   English

Paypal iOS SDK从未来的付款同意中获取用户个人资料信息

[英]Paypal iOS SDK get user profile information from the future payment consent

I have been wondering how I can get the user's consent to give information (name, email, etc) from the future payment consent dialog once they have logged in using the mobile sdk. 我一直在想,一旦用户使用移动SDK登录后,如何才能从用户的未来付款同意对话框中获得信息(姓名,电子邮件等)的同意。 Right now when I implement the future payment consent, it does not ask the user to share their information and does not return anything related to the user. 现在,当我实施未来的付款同意书时,它不会要求用户共享他们的信息,并且不会返回与用户相关的任何内容。 I have however noticed in apps like Munchery, the consent UI after the user logs in asks the user both for future payment consent and to share their name and email. 但是,我在诸如Munchery之类的应用中注意到,用户登录后的同意UI要求用户既要获得未来的付款同意,又要分享其姓名和电子邮件。 All of this is done on one form with wording different than what seems to be available in the current SDK. 所有这些操作都以一种形式完成,措辞与当前SDK中可用的措辞不同。

A similar question was asked here but using the profile sharing view controller displays an entirely separate login and consent form which ends up requiring two log ins in a row. 在这里提出类似的问题,但是使用配置文件共享视图控制器会显示一个完全独立的登录和同意表单,最终需要连续两次登录。 Is it still possible in the version 2.0 SDK to get future payment and profile information consent at the same exact time from a user? 在2.0版SDK中是否仍然可以在同一确切时间获得用户的未来付款和资料信息同意? Thanks. 谢谢。

This answer is correct but is just not very helpful so here's how we did it. 这个答案是正确的,但不是很有帮助,因此我们来做一下。

The Profile Sharing Mobile Integration feature of Paypal does exactly what you want - authorize future payments and return user information in the same call. 贝宝的配置文件共享移动集成功能完全可以满足您的需求-在以后的通话中授权未来的付款并返回用户信息。 You can do it all in one login flow. 您可以在一个登录流程中完成全部操作。 The user does see an additional screen that displays the scopes requested by the app, but does not have to go through a second login. 用户确实会看到一个附加屏幕,该屏幕显示了应用程序请求的范围,但不必再次登录。

Here is the code snippet we've used: 这是我们使用的代码片段:

func profileController() -> PayPalProfileSharingViewController {
    PayPalMobile.preconnectWithEnvironment(PayPalEnvironmentSandbox)//PayPalEnvironmentNoNetwork)
    let scope: Set<String> = Set([kPayPalOAuth2ScopeEmail, kPayPalOAuth2ScopeFuturePayments])
    let controller = PayPalProfileSharingViewController(scopeValues: scope, configuration: self.paypalConfiguration!, delegate: self)
    return controller!
}

func payPalProfileSharingViewController(profileSharingViewController: PayPalProfileSharingViewController, userDidLogInWithAuthorization profileSharingAuthorization: [NSObject : AnyObject]) {
    self.processAuthorization(profileSharingAuthorization)
}

func userDidCancelPayPalProfileSharingViewController(profileSharingViewController: PayPalProfileSharingViewController) {
    self.delegate?.didFailPayPalConsent()
}

func processAuthorization(authorization: [NSObject: AnyObject]) {
    if let authCode = authorization["response"]?["code"] as? String {
        self.delegate?.didSucceedPayPalConsent(authCode)
    }
    else {
        self.delegate?.didFailPayPalConsent()
    }
}

Edit: The mobile controller gives you the auth token that has permissions for profile information, but you have to make another call from your server side code for that information: 编辑:移动控制器为您提供了具有配置文件信息权限的auth令牌,但是您必须从服务器端代码中再次调用该信息:

https://developer.paypal.com/docs/api/#get-user-information https://developer.paypal.com/docs/api/#get-user-information

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

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