Disable credit card payment option in paypal integration

3.5k Views Asked by At

I want to disable/hide a button with option for "credit card payment" in paypal integration to android application. Is there any way to do this?

4

There are 4 best solutions below

1
On BEST ANSWER

In latest SDK below is the solution : (taken from another answer to keep this answer upto date)

PayPalConfiguration() object = new PayPalConfiguration();
object = object.acceptCreditCards(false);

intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, object);

For older SDK :

Set below extra to an Intent that starts PaymentActivity. This will hide "Pay with credit card" button.

// Set extra to skip credit card payment.
intent.putExtra(PaymentActivity.EXTRA_SKIP_CREDIT_CARD, true);
0
On

you must put "PaymentActivity.EXTRA_SKIP_CREDIT_CARD" in onBuyPressed function...

public void onBuyPressed(View pressed) {
    PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("1.75"), "USD", "hipster jeans");

    Intent intent = new Intent(this, PaymentActivity.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

    // It's important to repeat the clientId here so that the SDK has it if Android restarts your 
    // app midway through the payment UI flow.
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "credential-from-developer.paypal.com");
    intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "your-customer-id-in-your-system");
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

    /******************************************************************/
    //HERE disable/hide a button with option for "credit card payment"
    /******************************************************************/
    intent.putExtra(PaymentActivity.EXTRA_SKIP_CREDIT_CARD, true);

    startActivityForResult(intent, 0);
}

=)

0
On

Just use acceptCreditCards(false) as false to disable Credit Card.

private static PayPalConfiguration config = new PayPalConfiguration()
        .acceptCreditCards(false)//disable credit card from PayPal
0
On

Try This

In my case EXTRA_SKIP_CREDIT_CARD is not working

So i tried this code this is working for me finally

    PayPalConfiguration config = new PayPalConfiguration().environment(PayPalConfiguration.ENVIRONMENT_SANDBOX).clientId(Constants.PAYPAL_CLIENT_ID);
    PayPalPayment payment = new PayPalPayment(new BigDecimal("10"), "USD", "Credited Amount", PayPalPayment.PAYMENT_INTENT_SALE);
    Intent intent = new Intent(this, PaymentActivity.class);
    config.acceptCreditCards(false);//this will disable your card option
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
    startActivityForResult(intent, 123);