private void payWithExistingCard(PayPalCard card) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setCancelable(false);
    dialog.setTitle("Processing");
    dialog.setMessage("One moment");
    dialog.show();

    card.chargeCard(
        paypalEnvironment,
        printOrder.getCost(printOrder.getCurrencyCode()),
        getPayPalCurrency(printOrder.getCurrencyCode()),
        "",
        new PayPalCardChargeListener() {
          @Override
          public void onChargeSuccess(PayPalCard card, String proofOfPayment) {
            dialog.dismiss();
            submitOrderForPrinting(proofOfPayment);
            card.saveAsLastUsedCard(PaymentActivity.this);
          }

          @Override
          public void onError(PayPalCard card, Exception ex) {
            dialog.dismiss();
            showErrorDialog(ex.getMessage());
          }
        });
  }
  private void updateViewsBasedOnPromoCodeChange() {
    Button applyButton = (Button) findViewById(R.id.button_apply_promo);
    EditText promoText = (EditText) findViewById(R.id.edit_text_promo_code);
    if (printOrder.getPromoCode() != null) {
      promoText.setText(printOrder.getPromoCode());
      promoText.setEnabled(false);
      applyButton.setText("Clear");
    } else {
      promoText.setText("");
      promoText.setEnabled(true);
      applyButton.setText("Apply");
    }

    Button payWithCreditCardButton = (Button) findViewById(R.id.button_pay_with_credit_card);
    if (printOrder.getCost(printOrder.getCurrencyCode()).compareTo(BigDecimal.ZERO) <= 0) {
      findViewById(R.id.button_pay_with_paypal).setVisibility(View.GONE);
      payWithCreditCardButton.setText("Checkout for Free!");
      payWithCreditCardButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              submitOrderForPrinting(null);
            }
          });

    } else {
      findViewById(R.id.button_pay_with_paypal).setVisibility(View.VISIBLE);
      payWithCreditCardButton.setText("Pay with Credit Card");
    }
  }
 public void onButtonPayWithPayPalClicked(View view) {
   PayPalPayment payment =
       new PayPalPayment(
           printOrder.getCost(printOrder.getCurrencyCode()),
           printOrder.getCurrencyCode(),
           "Product");
   Intent intent = new Intent(this, com.paypal.android.sdk.payments.PaymentActivity.class);
   intent.putExtra(
       com.paypal.android.sdk.payments.PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT,
       printEnvironment.getPayPalEnvironment());
   intent.putExtra(
       com.paypal.android.sdk.payments.PaymentActivity.EXTRA_CLIENT_ID,
       printEnvironment.getPayPalClientId());
   intent.putExtra(
       com.paypal.android.sdk.payments.PaymentActivity.EXTRA_PAYER_ID,
       "<*****@*****.**>");
   intent.putExtra(
       com.paypal.android.sdk.payments.PaymentActivity.EXTRA_RECEIVER_EMAIL,
       printEnvironment.getPayPalReceiverEmail());
   intent.putExtra(com.paypal.android.sdk.payments.PaymentActivity.EXTRA_PAYMENT, payment);
   intent.putExtra(com.paypal.android.sdk.payments.PaymentActivity.EXTRA_SKIP_CREDIT_CARD, true);
   startActivityForResult(intent, REQUEST_CODE_PAYPAL);
 }