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 onButtonApplyClicked(View view) {
    if (printOrder.getPromoCode() != null) {
      // Clear promo code
      printOrder.clearPromoCode();
      updateViewsBasedOnPromoCodeChange();
    } else {
      // Apply promo code
      final ProgressDialog dialog = new ProgressDialog(this);
      dialog.setCancelable(false);
      dialog.setTitle("Processing");
      dialog.setMessage("Checking Code...");
      dialog.show();

      String promoCode = ((EditText) findViewById(R.id.edit_text_promo_code)).getText().toString();
      printOrder.applyPromoCode(
          promoCode,
          new ApplyPromoCodeListener() {
            @Override
            public void onPromoCodeApplied(PrintOrder order, BigDecimal discount) {
              dialog.dismiss();
              Toast.makeText(PaymentActivity.this, "Discount applied!", Toast.LENGTH_LONG).show();
              updateViewsBasedOnPromoCodeChange();
            }

            @Override
            public void onError(PrintOrder order, Exception ex) {
              dialog.dismiss();
              showErrorDialog(ex.getMessage());
            }
          });
    }
  }