private void submitOrderForPrinting(String proofOfPayment) {
    if (proofOfPayment != null) {
      printOrder.setProofOfPayment(proofOfPayment);
    }
    printOrder.saveToHistory(this);

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setCancelable(false);
    dialog.setIndeterminate(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setTitle("Processing");
    dialog.setMessage("One moment...");
    dialog.setMax(100);
    dialog.show();

    printOrder.submitForPrinting(
        this,
        new PrintOrderSubmissionListener() {
          @Override
          public void onProgress(
              PrintOrder printOrder,
              int totalAssetsUploaded,
              int totalAssetsToUpload,
              long totalAssetBytesWritten,
              long totalAssetBytesExpectedToWrite,
              long totalBytesWritten,
              long totalBytesExpectedToWrite) {
            if (Looper.myLooper() != Looper.getMainLooper())
              throw new AssertionError("Should be calling back on the main thread");
            final float step = (1.0f / totalAssetsToUpload);
            float progress =
                totalAssetsUploaded * step
                    + (totalAssetBytesWritten / (float) totalAssetBytesExpectedToWrite) * step;
            dialog.setProgress((int) (totalAssetsUploaded * step * 100));
            dialog.setSecondaryProgress((int) (progress * 100));
            dialog.setMessage("Uploading images");
          }

          @Override
          public void onSubmissionComplete(PrintOrder printOrder, String orderIdReceipt) {
            if (Looper.myLooper() != Looper.getMainLooper())
              throw new AssertionError("Should be calling back on the main thread");
            printOrder.saveToHistory(PaymentActivity.this);
            dialog.dismiss();
            Intent i = new Intent(PaymentActivity.this, OrderReceiptActivity.class);
            i.putExtra(OrderReceiptActivity.EXTRA_PRINT_ORDER, (Parcelable) printOrder);
            startActivityForResult(i, REQUEST_CODE_RECEIPT);
          }

          @Override
          public void onError(PrintOrder printOrder, Exception error) {
            if (Looper.myLooper() != Looper.getMainLooper())
              throw new AssertionError("Should be calling back on the main thread");
            printOrder.saveToHistory(PaymentActivity.this);
            dialog.dismiss();
            // showErrorDialog(error.getMessage());

            Intent i = new Intent(PaymentActivity.this, OrderReceiptActivity.class);
            i.putExtra(OrderReceiptActivity.EXTRA_PRINT_ORDER, (Parcelable) printOrder);
            startActivityForResult(i, REQUEST_CODE_RECEIPT);
          }
        });
  }