2015-02-10 96 views

回答

0

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

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

Here is a list of the variables you can expect从预先批准的配置文件获取创建。你会注意到“sender_email”参数,这是你要找的。

下面是我在处理Preapproval请求后在沙箱中获得的实际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] => [email protected] 
    [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 
) 
0

Ichathan,你要利用MSDK的Profile Sharing功能来获取客户的属性和范围内,在未来的支付范围传递给也为那些获得同意。您可以用于配置文件共享的可用范围列在iOS SDK的PayPalOAuthScopes.h文件中。

0

这个answer是正确的,但不详细。

Profile Sharing Mobile Integration允许用户同意未来付款以及在一个登录流程中获取电子邮件和其他信息。下面是我们使用的片段:

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() 
    } 
} 

编辑:移动控制器,为您提供了对档案信息的权限的身份验证令牌,但你必须从您的服务器端代码信息的另一个呼叫:

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

0

这就是我做到的。 配置文件共享Paypal Profile Sharing给我们的身份验证令牌 这种特殊的委托函数被调用

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

}

的authToken之后,我们需要打一些服务器端API。我们也可以通过应用程序来实现这一点。我已经从客户端打到服务器端apis

第一步是做一个基本的认证请求,它会返回一个刷新以及访问令牌。 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

。访问令牌是由基本身份认证令牌生成

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) 
       } 
      }) 

     } 
    } 
} 

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

免责声明:本项目仅是为一个POC,所以我不确定我们是否通过从客户端点击服务器端API来违反PCI合规性