Set up PayPal payments

DOCS

Last updated: Aug 15th, 6:03am

Complete the steps to check out using PayPal.

Know before you code

The PayPal authorization flow includes PayPal One Touch, which buyers use to trigger an app switch that brings up the PayPal login and authorization webview, then reverts back to the app to complete the purchase.

Step 1: Display a PayPal button during checkout

Contact your account manager or a PayPal solutions engineer to get a list of approved PayPal Button assets to render the PayPal button.

Step 2: Check out with PayPal

  1. Implement the CheckoutListener interface on your app's Activity class.
  2. Implement onResume override to handle the PayPal checkout web re-direct back into your native app.
  3. Use the CheckoutClient to call payWithPayPal with a valid PayPal orderID and the CheckoutListener activity.
  4. Inspect the checkout result in the onCheckoutComplete callback to handle checkout errors or to complete the transaction.
    1public class MyActivity extends Activity implements CheckoutListener {
    2 ...
    3
    4 protected void onResume() {
    5 super.onResume();
    6 checkoutClient.onResume(this);
    7 }
    8
    9 private void initiatePayPalCheckout() {
    10 // re-directs to browser
    11 checkoutClient.payWithPayPal(orderId, this);
    12 }
    13
    14 public void onCheckoutComplete(Exception error, CheckoutResult result) {
    15 if (error == null) {
    16 // handle checkout error
    17 } else if (result instanceof PayPalCheckoutResult) {
    18 String orderId = result.getOrderId();
    19
    20 if (orderId != null) {
    21 // Send orderID to your server to process the payment
    22 // Capture or authorize the orderID
    23 }
    24 }
    25 }
    26}

    Calling payWithPayPal redirects your buyer to a Web Browser or Chrome Custom Tab depending on the Android API level. This allows a user to log in with their PayPal account to complete the checkout.

    Next step

    Process the order