You can provide your own button that starts the PayPal Order flow.
Swift
var braintreeClient: BTAPIClient!
override func viewDidLoad() {
super.viewDidLoad();
self.braintreeClient = BTAPIClient(authorization: "<#CLIENT_AUTHORIZATION#>");
let customPayPalButton = UIButton(frame: CGRect(x: 0, y: 0, width: 60, height: 120));
customPayPalButton.addTarget(self, action: #selector(customPayPalButtonTapped(button:)), for: UIControlEvents.touchUpInside);
self.view.addSubview(customPayPalButton);
}
func customPayPalButtonTapped(button: UIButton) {
let payPalDriver = BTPayPalDriver(apiClient: self.braintreeClient);
// Start the Checkout flow
let payPalRequest = BTPayPalCheckoutRequest(amount: "1.00");
payPalRequest.currencyCode = "USD"; // Optional; see BTPayPalCheckoutRequest.h for more options
// Specify the intent on the request object
payPalRequest.intent = .order;
payPalDriver.tokenizePayPalAccount(with: payPalRequest) { (tokenizedPayPalAccount, error) -> Void in
// ...
};
}
After the customer completes the consent flow and the PayPal pop-up closes, successful tokenization
will return a nonce. Send the nonce to your server and use a Braintree server SDK call to associate
it to a customer's payment method. See the
server-side section
for various options for doing so.
Kui küpsistega nõustute, kasutame neid teie kasutajakogemuse täiustamiseks ja kohandamiseks ning võimaldame oma partneritel teile isikupärastatud PayPali reklaame näidata, kui teisi veebisaite külastate. Küpsiste haldamine ja lisateave