I am making an e-commerce android app for a client using firebase. I need to integrate paypal so that the payment deducts from the customer's paypal and received to merchant's(i-e my client) paypal account. For paypal integration i saw tutorials and made two sandbox accounts on my clients paypal. I tested the app and payment is deducted from sandbox(buyer account) of my client successfully.

But now i am confused about one thing: As this will be a e-commerce app , the customer will be random anywhere in the world and he will pay an amount from his paypal account, which will be transfered in the paypal merchant's account of my client. I will set the client id of my client in the Main Activity ,which is given to him by paypal in his paypal business account , but what would the coding for the customer to login from his paypal account and pay the shopping bill? Is there any need to separately write some code for customer to pay his paypal account or this will done automatically?

For example i have two sandbox accounts: 1-) Saboorsiddiuque880-buyer@gmail.com 2-) Saboorsiddique880-facilitator@gmail.com

I have $10000 in my buyer account and $100 in my facilitator account.

I want that when I do shopping e.g for $5 from my buyer account, then $5 dollars should be deducted from my buyer account and should be added to merchant account resulting in merchant's balance $105. The problem is that money is deducted from buyer account successfully but it does not added to merchant account. Is anything i am doing wrong?

Below is my code:

    // this config variable is declared and defined in class scope

     private static PayPalConfiguration config = new 

        .clientId("My sandbox client ID");

    // this code is in onCreateView Method of my fragment to start the paypal 

    Intent intent = new Intent(getActivity(), PayPalService.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);

     // this code is for the checkout button
     PayPalPayment payment = new PayPalPayment(new BigDecimal("1.75"), "USD", 
    "hipster jeans",PayPalPayment.PAYMENT_INTENT_SALE);

            Intent intent = new Intent(getActivity(), 

            // send the same configuration for restart resiliency

            intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);

            startActivityForResult(intent, 0);

    // this code is in OnActivityResult Method

    if (resultCode == Activity.RESULT_OK) {
        PaymentConfirmation confirm = 
        if (confirm != null) {
            try {
                Log.i("paymentExample", confirm.toJSONObject().toString(4));

               } catch (JSONException e) {
                Log.e("paymentExample", "an extremely unlikely failure 
             occurred: ", e);

    else if (resultCode == Activity.RESULT_CANCELED) {
        Log.i("paymentExample", "The user canceled.");
        Toast.makeText(getActivity(),"The user 

    else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
        Log.i("paymentExample", "An invalid Payment or PayPalConfiguration 
        was submitted. Please see the docs.");


Paypal does not pay the seller immediately so this may translate into the demo system. I'd get into the documentation to see how they simulate the escrow delay.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.