简体   繁体   English

在贝宝集成中禁用信用卡付款选项

[英]Disable credit card payment option in paypal integration

I want to disable/hide a button with option for "credit card payment" in paypal integration to android application.我想在与 Android 应用程序的贝宝集成中禁用/隐藏带有“信用卡付款”选项的按钮。 Is there any way to do this?有没有办法做到这一点?

In latest SDK below is the solution : (taken from another answer to keep this answer upto date)在下面的最新 SDK 中是解决方案:(取自另一个答案以使此答案保持最新)

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

intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, object);

For older SDK :对于旧版 SDK:

Set below extra to an Intent that starts PaymentActivity .将下面额外设置为启动PaymentActivityIntent This will hide "Pay with credit card" button.这将隐藏“使用信用卡付款”按钮。

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

you must put "PaymentActivity.EXTRA_SKIP_CREDIT_CARD" in onBuyPressed function...您必须将“PaymentActivity.EXTRA_SKIP_CREDIT_CARD”放在 onBuyPressed 函数中...

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);
}

=) =)

Try This试试这个

In my case EXTRA_SKIP_CREDIT_CARD is not working在我的情况下 EXTRA_SKIP_CREDIT_CARD 不起作用

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);

Just use acceptCreditCards(false) as false to disable Credit Card.只需使用 acceptCreditCards(false) 作为 false 来禁用信用卡。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM