已批准未来付款的用户的PayPal电子邮件ID

时间:2015-02-10 06:19:08

标签: ios objective-c paypal

我们在IOS应用中使用PayPal未来付款。我们需要知道已授权未来付款的帐户的电子邮件ID。我们如何获取已授权未来付款的用户的电子邮件ID。当前用于批准的API操作仅返回授权令牌。

4 个答案:

答案 0 :(得分:0)

我假设未来付款"您指的是预先批准的付款.. ??

设置IPN解决方案,并确保Preapproval API请求中的IPNNotificationURL。 IPN将包括有关交易的更多详细信息,包括付款人电子邮件地址。

来自预批准配置文件的

Here is a list of the variables you can expect已创建。您会注意到" sender_email"参数,这是你正在寻找的。

这是我在处理预批准请求后在沙盒中获得的实际IPN的示例。

Array
(
    [max_number_of_payments] => 100
    [starting_date] => 2015-03-01T00:00:21.000-08:00
    [pin_type] => NOT_REQUIRED
    [max_amount_per_payment] => 20.00
    [currency_code] => USD
    [sender_email] => guy.louzon-buyer@gmail.com
    [verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31AiHQSQchSGUInXdtl6zomfkZ7H4C
    [test_ipn] => 1
    [date_of_month] => 0
    [current_number_of_payments] => 0
    [preapproval_key] => PA-2M0807730Y425554F
    [ending_date] => 2015-12-31T23:59:21.000-08:00
    [approved] => true
    [transaction_type] => Adaptive Payment PREAPPROVAL
    [day_of_week] => NO_DAY_SPECIFIED
    [status] => ACTIVE
    [current_total_amount_of_all_payments] => 0.00
    [current_period_attempts] => 0
    [charset] => windows-1252
    [payment_period] => 0
    [notify_version] => UNVERSIONED
    [max_total_amount_of_all_payments] => 2000.00
)

答案 1 :(得分:0)

Ichathan,您希望利用mSDK的Profile Sharing功能获取客户属性,并在其中传递未来付款范围,以获得对这些属性的同意。您可以用于配置文件共享的可用范围列在iOS SDK的PayPalOAuthScopes.h文件中。

答案 2 :(得分:0)

This answer is correct but not detailed.

The Profile Sharing Mobile Integration allows the user to consent to future payments as well as gets email and other information in one login flow. Here's the snippet we 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:

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

答案 3 :(得分:0)

这就是我做的。 配置文件共享Paypal Profile Sharing为我们提供了验证令牌 这个特定的委托函数被称为

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

}

在authToken之后,我们需要点击一些服务器端API。我们也可以通过app方面实现这一目标。我从客户端点击服务器端apis

第一步是制作一个基本的Auth请求,它将返回一个Refresh和Access Token。 Get Access Token

    func generateAccessToken(authCode : String ,block : completionHandler){
    let parameters = ["grant_type" : "authorization_code", "response_type" :"token","redirect_uri" : "urn:ietf:wg:oauth:2.0:oob","code":authCode]
    let username = AppConstants().kPayPalUserName  //APP_ID
    let password = AppConstants().kPayPalSecret

    let credentialData = "\(username):\(password)".data(using: String.Encoding.utf8)!
    let base64Credentials = credentialData.base64EncodedString(options: [])
    let headers = ["Authorization": "Basic \(base64Credentials)"]
    let customerURL = AppConstants().kPayPalUrl
    Alamofire.request(customerURL,
                      method: .post,
                      parameters: parameters,
                      encoding: URLEncoding.default,
                      headers:headers)
        .validate()
        .responseJSON { response in
            switch response.result {
            case .success(let value):
                KVNProgress.dismiss(completion: {
                    block?(true, value as! Dictionary<String, Any>)  // get the accessToken
                })

            //   BasicFunctions.displayAlert("Success", needDismiss: false, title: "Task Created Successfully")
            case .failure(let responseError):


                KVNProgress.dismiss(completion: {
                    if (responseError != nil) {
                        BasicFunctions.displayAlert(SERVER_ERROR)
                        //                                                    let json = JSONSerialization
                        //   block!(false,responseError as! Dictionary<String, Any>)
                    }else{
                        BasicFunctions.displayAlert(SERVER_ERROR)
                    }
                })

            }
    }
}

使用访问令牌,我们需要点击另一个CURL请求,它将为我们提供所有用户信息Get User Profile Information

现在使用此请求我们可以获得完整的用户信息。访问令牌是从Basic Auth Token生成的

func getUserProfileInfo(accessToken : String,block : completionHandler){

    KVNProgress.show()
    let parameters = ["":""]


    let headers = ["Authorization": "Bearer " + accessToken]

    let customerURL = "https://api.sandbox.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid"


    Alamofire.request(customerURL, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { (response) in
        switch response.result {
        case .success(let value):
            KVNProgress.dismiss(completion: {
                block?(true, value as! Dictionary<String, Any>)
            })

        //   BasicFunctions.displayAlert("Success", needDismiss: false, title: "Task Created Successfully")
        case .failure(let responseError):


            KVNProgress.dismiss(completion: {
                if (responseError != nil) {
                    BasicFunctions.displayAlert(SERVER_ERROR)
                    //                                                    let json = JSONSerialization
                    //   block!(false,responseError as! Dictionary<String, Any>)
                }else{
                    BasicFunctions.displayAlert(SERVER_ERROR)
                }
            })

        }
    }
}

注意:确保在Paypal中的应用设置中您已允许访问电子邮件或其他用户信息

免责声明:此项目仅适用于POC,因此我不确定是否通过从客户端点击服务器端API来违反PCI合规性