我想在paypal集成到Android应用程序中禁用/隐藏带有“信用卡支付”选项的按钮。有没有办法做到这一点?
答案 0 :(得分:13)
以下最新的SDK是解决方案:(取自另一个答案,以使此答案保持最新状态)
PayPalConfiguration() object = new PayPalConfiguration();
object = object.acceptCreditCards(false);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, object);
适用于较旧的SDK:
将以下内容设置为以Intent
开头的PaymentActivity
。这将隐藏“使用信用卡付款”按钮。
// Set extra to skip credit card payment.
intent.putExtra(PaymentActivity.EXTRA_SKIP_CREDIT_CARD, true);
答案 1 :(得分:2)
你必须在onBuyPressed函数中加上“PaymentActivity.EXTRA_SKIP_CREDIT_CARD”...
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);
}
=)
答案 2 :(得分:0)
在我的情况下,EXTRA_SKIP_CREDIT_CARD无效
所以我尝试了这段代码,这对我来说最终是
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);
答案 3 :(得分:0)
只需将acceptCreditCards(false)设置为false即可禁用信用卡。
private static PayPalConfiguration config = new PayPalConfiguration()
.acceptCreditCards(false)//disable credit card from PayPal