我正在使用以下功能来请求 Paypal 计费协议:
private func fetchNounceForPayPal(type : String, token : String, viewControllerPresentingDelegate : UIViewController?, appSwitchDelegate : UIViewController? ) {
self.braintreeClient = BTAPIClient(authorization: token)
if let client = self.braintreeClient {
self.payPalDriver = BTPayPalDriver(apiClient: client)
let req = BTPayPalRequest.init()
if type == PaymentMethods.paypalCredit.getRawValue() {
req.offerCredit = true
}
if let driver = self.payPalDriver {
driver.viewControllerPresentingDelegate = viewControllerPresentingDelegate as? BTViewControllerPresentingDelegate
driver.appSwitchDelegate = appSwitchDelegate as? BTAppSwitchDelegate
driver.requestBillingAgreement(req) { (tokenizedPayPalAccount, error) in
printLog("requestBillingAgreement \(String(describing: tokenizedPayPalAccount)) , \(String(describing: error)) , \(String(describing: self.brainTreePayPalDelegate)) ")
}
}
}
}