2013-08-29 81 views

回答

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

工作對我來說這並不是新的PayPal SDK工作了。 – user1007522

+0

@ user1007522因此,如何在新的Paypal SDK中隱藏「使用信用卡進行遊戲」 – BaDo

2

你必須把 「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); 
} 

=)

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