我一直想知道如何在用户使用移动sdk登录后,获得用户同意从未来的付款同意对话框中提供信息(姓名,电子邮件等)。现在,当我实施未来的付款同意时,它不会要求用户共享他们的信息,也不会返回与用户相关的任何内容。然而,我在Munchery这样的应用程序中注意到,用户登录后的同意UI会询问用户未来的付款同意并分享他们的姓名和电子邮件。所有这些都是在一个表单上完成的,其措辞与当前SDK中可用的措辞不同。
类似的问题被问到here但是使用配置文件共享视图控制器会显示一个完全独立的登录和同意表单,最终需要连续两个登录。在版本2.0 SDK中是否仍然可以在用户的同一时间获得未来的付款和个人资料信息同意?感谢。
答案 0 :(得分:0)
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: