title: below calculation work in API?
body: <p>i created checkoutpage then it contain total,payment due and payment balance. If give total it show the payment due amount &amp; payment balance amount in mobile app. But it doesn't update  the browser? </p>
  
  <pre><code>public class FinalCheckOutActivity extends Activity implements View.OnClickListener {
      private AQuery mAQuery;
      private TransparentProgressDialog mTransparentProgressDialog;
      private String mStrCheckOut = "", mStrGEtData = "", mStrAddressData = "", mStrPaypAl = "";
      private Spinner mSpnDefualtAddress, mSpnShipAddress;
      private Button mBtnPlaceOrder;
      private CheckBox mChBxSameAddres, mChkBxDiffAddress, mChkBoxAccept;
      private RadioButton mRdoPayPal, mRdoCash;
      private RadioGroup mRdoGroupPay;
      private ImageView mIvBack;
      private TextView mTvAddAddress, mTvSubTot, mTvDiscount, mTVGrandTot, mTvPendingAmt, mTvPayNow, mIvAddAddress;
      private ArrayList&lt;SpinnerData&gt; mArrayListAddres;
      private LinearLayout mLinearLayoutShiipingMethod, mLinearLayoutPayMethod, mLinearLayoutOrderDetails;
      private RadioGroup mRbnOptionshippingmethods;
      private ArrayList&lt;UserAddressData&gt; mArrayListshippingMethod;
      private ArrayList&lt;UserAddressData&gt; mArrayListPaymentMethods;
      private String shippingMethodId;
      private RadioGroup mRbnOptionPaymentMethods;
      private String shippingPaymentID;
      private View viewOrderData;
      private JSONObject mJsonObject, jsonObjectData;
      private LinearLayout mLinearLayoutTabShiping;
      private RadioButton newRadioButton;
      private ArrayList&lt;SpinnerData&gt; mArrayListBilign;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_final_check_out);
  
  
          //setUI();
      }
  
      private void setUI() {
          mAQuery = new AQuery(this);
          mTransparentProgressDialog = new TransparentProgressDialog(this, R.drawable.ic_loader_image);
          mSpnDefualtAddress = (Spinner) findViewById(R.id.spn_default_address);
          mSpnShipAddress = (Spinner) findViewById(R.id.spn_ship_address);
  
          mBtnPlaceOrder = (Button) findViewById(R.id.btn_place_order);
  
          mRdoGroupPay = (RadioGroup) findViewById(R.id.rdo_payment);
          mRdoCash = (RadioButton) findViewById(R.id.rdo_cash);
          mRdoPayPal = (RadioButton) findViewById(R.id.rdo_paypal);
  
          mLinearLayoutTabShiping = (LinearLayout) findViewById(R.id.layout_shiping);
  
          mChBxSameAddres = (CheckBox) findViewById(R.id.chk_ship_to_same_address);
          mChkBxDiffAddress = (CheckBox) findViewById(R.id.chk_diff_ship_address);
          mChkBoxAccept = (CheckBox) findViewById(R.id.chk_acceept);
          mLinearLayoutShiipingMethod = (LinearLayout) findViewById(R.id.layout_shipping_method);
          mLinearLayoutPayMethod = (LinearLayout) findViewById(R.id.layout_payment_method);
          mLinearLayoutOrderDetails = (LinearLayout) findViewById(R.id.lv_shipping_order_view);
          mIvAddAddress = (TextView) findViewById(R.id.img_add_address);
          mTvSubTot = (TextView) findViewById(R.id.tv_subtotal);
          mTvDiscount = (TextView) findViewById(R.id.tv_discount);
          mTVGrandTot = (TextView) findViewById(R.id.tv_grand_tot);
          mTvPendingAmt = (TextView) findViewById(R.id.tv_pending_pay);
          mTvPayNow = (TextView) findViewById(R.id.tv_payable_now);
          mIvBack = (ImageView) findViewById(R.id.img_back_one_page);
          mArrayListAddres = new ArrayList&lt;&gt;();
          mArrayListshippingMethod = new ArrayList&lt;&gt;();
          mArrayListPaymentMethods = new ArrayList&lt;&gt;();
          mArrayListBilign = new ArrayList&lt;&gt;();
          mBtnPlaceOrder.setOnClickListener(this);
          mIvAddAddress.setOnClickListener(this);
  //        mTvAddAddress.setOnClickListener(this);
          mIvBack.setOnClickListener(this);
  
  
  
          ajaxCallback.setTimeout(Integer.parseInt(getString(R.string.ajax_timeout)));
          mChBxSameAddres.setChecked(true);
          mLinearLayoutTabShiping.setVisibility(View.GONE);
          mChBxSameAddres.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                  if (isChecked) {
  
                      mLinearLayoutTabShiping.setVisibility(View.GONE);
                      //mSpnShipAddress.setVisibility(View.GONE);
  
                      // perform logic
                  }
  
              }
          });
  
          mChkBxDiffAddress.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                  if (isChecked) {
                      mChBxSameAddres.setChecked(false);
                      mLinearLayoutTabShiping.setVisibility(View.VISIBLE);
                  }
              }
          });
  
          SpinnerData data = new SpinnerData();
          data.setmStrName("Select Address");
          mArrayListAddres.add(data);
          mSpnDefualtAddress.setAdapter(new SpinnerAdapter(this, mArrayListAddres));
          getFinalCheckOutData();
  
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          setUI();
          //getAddressData();
      }
  
      /**
       * get user address web service call
       **/
      private void getAddressData() {
          mStrAddressData = getString(R.string.WS_HOST) + getString(R.string.WS_GET_MULTIPLE_ADDRESS);
          HashMap&lt;String, Object&gt; hashMap = new HashMap&lt;&gt;();
          hashMap.put("customer_id", SessionClass.getUserId(this));
          Log.e("Hash map final data", "Hash map-&gt;" + hashMap.toString());
          if (AvailableNetwork.isConnectingToInternet(this)) {
              mAQuery.progress(mTransparentProgressDialog).ajax(mStrAddressData, hashMap, JSONObject.class, ajaxCallback);
          } else {
             // showAlert(getString(R.string.no_internt_connection), -1);
              Snackbar snackbar = Snackbar
                      .make(MainActivity.coordinatorLayout, R.string.no_internt_connection, Snackbar.LENGTH_LONG)
                      .setAction("RETRY", new View.OnClickListener() {
                          @Override
                          public void onClick(View view) {
                              //setUI(view);
                          }
                      });
  
              // Changing message text color
              snackbar.setActionTextColor(Color.RED);
              // Changing action button text color
              View sbView = snackbar.getView();
              CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) sbView.getLayoutParams();
              params.gravity = Gravity.TOP;
              sbView.setLayoutParams(params);
              TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
              textView.setTextColor(Color.YELLOW);
              snackbar.show();
          }
  
  
      }
  
      /**
       * get user address web service call
       **/
      private void getPaypalData() {
          mStrPaypAl = getString(R.string.WS_HOST) + getString(R.string.WS_PAYPAL);
          HashMap&lt;String, Object&gt; hashMap = new HashMap&lt;&gt;();
          hashMap.put("order_increment_id", orderID);
          Log.e("Hash map final data", "Hash map-&gt;" + hashMap.toString());
          if (AvailableNetwork.isConnectingToInternet(this)) {
              mAQuery.progress(mTransparentProgressDialog).ajax(mStrPaypAl, hashMap, JSONObject.class, ajaxCallback);
          } else {
             // showAlert(getString(R.string.no_internt_connection), -1);
              Snackbar snackbar = Snackbar
                      .make(MainActivity.coordinatorLayout, R.string.no_internt_connection, Snackbar.LENGTH_LONG)
                      .setAction("RETRY", new View.OnClickListener() {
                          @Override
                          public void onClick(View view) {
                              //setUI(view);
                          }
                      });
  
              // Changing message text color
              snackbar.setActionTextColor(Color.RED);
              // Changing action button text color
              View sbView = snackbar.getView();
              CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) sbView.getLayoutParams();
              params.gravity = Gravity.TOP;
              sbView.setLayoutParams(params);
              TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
              textView.setTextColor(Color.YELLOW);
              snackbar.show();
          }
  
  
      }
  
      /**
       * Get final checkout data
       **/
      private void getFinalCheckOutData() {
          mStrGEtData = getString(R.string.WS_HOST) + getString(R.string.WS_FINAL_CHECKOUT_DETAIls);
          HashMap&lt;String, Object&gt; hashMap = new HashMap&lt;&gt;();
          hashMap.put("cart_id", IntermediateCheckoutActivity.cartId);
          Log.e("Hash map final data", "Hash map-&gt;" + hashMap.toString());
          if (AvailableNetwork.isConnectingToInternet(this)) {
              mAQuery.progress(mTransparentProgressDialog).ajax(mStrGEtData, hashMap, JSONObject.class, ajaxCallback);
          } else {
             // showAlert(getString(R.string.no_internt_connection), -1);
              Snackbar snackbar = Snackbar
                      .make(MainActivity.coordinatorLayout, R.string.no_internt_connection, Snackbar.LENGTH_LONG)
                      .setAction("RETRY", new View.OnClickListener() {
                          @Override
                          public void onClick(View view) {
                              //setUI(view);
                          }
                      });
  
              // Changing message text color
              snackbar.setActionTextColor(Color.RED);
              // Changing action button text color
              View sbView = snackbar.getView();
              CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) sbView.getLayoutParams();
              params.gravity = Gravity.TOP;
              sbView.setLayoutParams(params);
              TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
              textView.setTextColor(Color.YELLOW);
              snackbar.show();
          }
  
      }
  
      /**
       * Place order web service call
       **/
  
      private void placeOrder() {
          mStrCheckOut = getString(R.string.WS_HOST) + getString(R.string.WS_PLACE_ORDER);
          HashMap&lt;String, Object&gt; hashMap = new HashMap&lt;&gt;();
          hashMap.put("cart_id", IntermediateCheckoutActivity.cartId);
          hashMap.put("checkoutdetails", jsonObjectData.toString());
          Log.e("Place order", "hash map--&gt;" + hashMap.toString());
          if (AvailableNetwork.isConnectingToInternet(this)) {
              mAQuery.progress(mTransparentProgressDialog).ajax(mStrCheckOut, hashMap, JSONObject.class, ajaxCallback);
          } else {
              //showAlert(getString(R.string.no_internt_connection), -1);
              Snackbar snackbar = Snackbar
                      .make(MainActivity.coordinatorLayout, R.string.no_internt_connection, Snackbar.LENGTH_LONG)
                      .setAction("RETRY", new View.OnClickListener() {
                          @Override
                          public void onClick(View view) {
                              //setUI(view);
                          }
                      });
  
              // Changing message text color
              snackbar.setActionTextColor(Color.RED);
              // Changing action button text color
              View sbView = snackbar.getView();
              CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) sbView.getLayoutParams();
              params.gravity = Gravity.TOP;
              sbView.setLayoutParams(params);
              TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
              textView.setTextColor(Color.YELLOW);
              snackbar.show();
          }
      }
  
      private boolean checkValidationn() {
          if (mSpnDefualtAddress.getSelectedItemPosition() == 0) {
              showAlert("Please select billing address first.", -1);
              mSpnDefualtAddress.requestFocus();
              return false;
          } else if (mRbnOptionshippingmethods.getCheckedRadioButtonId() == -1) {
              showAlert("Please select shipping method first.", -1);
              mRbnOptionshippingmethods.requestFocus();
              return false;
          } else if (mRdoGroupPay.getCheckedRadioButtonId() == -1) {
              showAlert("Please select payment method first.", -1);
              mRdoGroupPay.requestFocus();
              return false;
          } else if (!mChkBoxAccept.isChecked()) {
              showAlert("Please select terms and conditions first.", -1);
              mChkBoxAccept.requestFocus();
              return false;
          }
          return true;
      }
  
      private void showAlert(String message, final int flg) {
          AlertDialog.Builder aBuilder = new AlertDialog.Builder(this);
          aBuilder.setCancelable(false);
          aBuilder.setMessage(message);
          aBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                  setNxtFlg(flg);
              }
          });
          aBuilder.create();
          aBuilder.show();
      }
  
      private void setNxtFlg(int flg) {
  
          switch (flg) {
              case 3:
                  Intent intent = new Intent(FinalCheckOutActivity.this, PayPalPaymentActivity.class);
                  intent.putExtra("key", urlMain);
                  intent.putExtra("order_id", orderID);
                  overridePendingTransition(R.anim.anim_left_in, R.anim.anim_left_out);
                  startActivity(intent);
                  break;
              case 1:
                  Intent intent1 = new Intent(FinalCheckOutActivity.this, MainActivity.class);
                  intent1.putExtra("key", "4");
                  startActivity(intent1);
                  overridePendingTransition(R.anim.anim_left_in, R.anim.anim_left_out);
                  break;
          }
      }
  
      @Override
      public void onClick(View v) {
          Intent intent;
          switch (v.getId()) {
              case R.id.btn_place_order:
                  getCheckOutData();
                  if (checkValidationn()) {
                      placeOrder();
                  }
                  break;
              case R.id.img_back_one_page:
                  onBackPressed();
                  //finish();
                  overridePendingTransition(R.anim.anim_left_in, R.anim.anim_left_out);
                  break;
              case R.id.img_add_address:
                  intent = new Intent(FinalCheckOutActivity.this, CheckoutActivity.class);
                  startActivity(intent);
                  overridePendingTransition(R.anim.anim_left_in, R.anim.anim_left_out);
                  break;
              /*case R.id.txt_add_address:
                  intent = new Intent(FinalCheckOutActivity.this, AddUserAddressActivity.class);
                  startActivity(intent);
                  overridePendingTransition(R.anim.anim_left_in, R.anim.anim_left_out);
                  //finish();
                  break;*/
          }
      }
  
      private void getCheckOutData() {
          mJsonObject = new JSONObject();
          jsonObjectData = new JSONObject();
          try {
  
              if (mChBxSameAddres.isChecked()) {
                  jsonObjectData.put("billing_id", mArrayListAddres.get(mSpnDefualtAddress.getSelectedItemPosition()).getmStrId());
                  jsonObjectData.put("shipping_id", mArrayListAddres.get(mSpnDefualtAddress.getSelectedItemPosition()).getmStrId());
              } else {
                  // jsonObjectData.put("shipping_id", mArrayListAddres.get(mSpnShipAddress.getSelectedItemPosition()).getmStrId());
              }
  
              if (mChkBxDiffAddress.isChecked()) {
                  jsonObjectData.put("billing_id", mArrayListAddres.get(mSpnDefualtAddress.getSelectedItemPosition()).getmStrId());
                  jsonObjectData.put("shipping_id", mArrayListAddres.get(mSpnShipAddress.getSelectedItemPosition()).getmStrId());
              } else {
                  jsonObjectData.put("shipping_id", mArrayListAddres.get(mSpnDefualtAddress.getSelectedItemPosition()).getmStrId());
              }
              JSONObject mJsonObjectPay = new JSONObject();
              if (mRdoCash.isChecked()) {
                  shippingPaymentID = "checkmo";
                  mJsonObjectPay.put("method", shippingPaymentID);
              } else if (mRdoPayPal.isChecked()) {
                  shippingPaymentID = "paypaladaptive";
                  mJsonObjectPay.put("method", shippingPaymentID);
              }
  
              jsonObjectData.put("payment", mJsonObjectPay);
              jsonObjectData.put("shipping_method", shippingMethodId);
              jsonObjectData.put("checkout_method", "customer");
              jsonObjectData.put("onestepcheckout_feedback_freetext", "");
              jsonObjectData.put("accept_terms", 1);
              jsonObjectData.put("customer_id", SessionClass.getUserId(FinalCheckOutActivity.this));
              mJsonObject.put("checkoutdetails", jsonObjectData);
              //showAlert("place order array" + jsonObjectData.toString(), -1);
              //Log.e("Place order", "Data--&gt;" + jsonObjectData.toString());
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  
      private String orderID;
      private String urlMain;
      /**
       * web service responce
       **/
      AjaxCallback&lt;JSONObject&gt; ajaxCallback = new AjaxCallback&lt;JSONObject&gt;() {
          @Override
          public void callback(String url, JSONObject object, AjaxStatus status) {
              super.callback(url, object, status);
              Log.e("Check out", "Url--&gt;" + url);
              Log.e("Check out", "Responce--&gt;" + object);
              if (object != null) {
                  if (status.getCode() == 200) {
                      if (mTransparentProgressDialog.isShowing()) {
                          mTransparentProgressDialog.dismiss();
                      }
                      if (url.equalsIgnoreCase(mStrAddressData)) {
                          try {
                              if (object.getString("errorcode").equalsIgnoreCase("0")) {
                                  setAddressData(object.getJSONArray("data"));
                                  //getFinalCheckOutData();
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
                      } else if (url.equalsIgnoreCase(mStrGEtData)) {
                          try {
                              String now = getIntent().getExtras().getString("pay_now");
                              String due = getIntent().getExtras().getString("pay_due");
  
                              if (object.getString("errorcode").equalsIgnoreCase("0")) {
                                  JSONObject mJsonObject = object.getJSONObject("data");
                                  setShippingMethods(mJsonObject.getJSONArray("shippingmethods"));
                                  setPaymentMethods(mJsonObject.getJSONArray("paymentmethods"));
                                  if (!mJsonObject.isNull("items")) {
                                      setOrderView(mJsonObject.getJSONArray("items"));
                                  }
                                  mTvSubTot.setText(mJsonObject.getString("subtotal"));
                                  mTvDiscount.setText(mJsonObject.getString("discount"));
                                  mTVGrandTot.setText(mJsonObject.getString("grandtotal"));
                                 // mTvPendingAmt.setText(mJsonObject.getString("pendingpayment"));
  
                                 // mTvPayNow.setText(mJsonObject.getString("payablenow"));
                                  mTvPendingAmt.setText(now);
                                  mTvPayNow.setText(due);
                                  getAddressData();
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
                      } else if (url.equalsIgnoreCase(mStrCheckOut)) {
                          try {
                              if (object.getString("errorcode").equalsIgnoreCase("0")) {
                                  //showAlert("Your order placed successfully.", -1);
  
                                  if (shippingPaymentID.equalsIgnoreCase("paypaladaptive")) {
  
                                      JSONObject mJsonObject = object.getJSONObject("data");
  
                                      orderID = mJsonObject.getString("order_increment_id");
                                      getPaypalData();
                                  } else {
                                      showAlert("Your order placed successfully.", 1);
                                  }
                                  //SessionClass.logout(FinalCheckOutActivity.this);
                                  SessionClass.setUrerCartId(FinalCheckOutActivity.this, "");
                              } else if (object.getString("errorcode").equalsIgnoreCase("1")) {
                                  showAlert("There is error in order creation.", -1);
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
                      } else if (url.equalsIgnoreCase(mStrPaypAl)) {
                          try {
                              if (object.getString("errorcode").equalsIgnoreCase("0")) {
  
                                  JSONObject mJsonObject = object.getJSONObject("data");
                                  urlMain = mJsonObject.getString("url").replace("/\\/", "");
                                  Log.e("Final url", "Url--&gt;" + urlMain);
                                  showAlert("Click on ok to continue.", 3);
  
                              } else if (object.getString("errorcode").equalsIgnoreCase("2")) {
                                  showAlert("Paypal API call failed. Account not found. Unilateral receiver not allowed in chained payment is restricted.", -1);
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
                      }
  
                  } else {
                     // showAlert(getString(R.string.no_connection_server), -1);
                      Snackbar snackbar = Snackbar
                              .make(MainActivity.coordinatorLayout, R.string.no_connection_server, Snackbar.LENGTH_LONG)
                              .setAction("RETRY", new View.OnClickListener() {
                                  @Override
                                  public void onClick(View view) {
                                      //setUI(view);
                                  }
                              });
  
                      // Changing message text color
                      snackbar.setActionTextColor(Color.RED);
                      // Changing action button text color
                      View sbView = snackbar.getView();
                      CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) sbView.getLayoutParams();
                      params.gravity = Gravity.TOP;
                      sbView.setLayoutParams(params);
                      TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                      textView.setTextColor(Color.YELLOW);
                      snackbar.show();
                  }
              }
          }
      };
  
      /**
       * Set order view data from web servicie responce
       **/
      private void setOrderView(JSONArray items) {
          try {
              mLinearLayoutOrderDetails.removeAllViews();
              //mArrayListMethod.clear();
              for (int i = 0; i &lt; items.length(); i++) {
                  JSONObject mJsonObject = items.getJSONObject(i);
                  viewOrderData = getLayoutInflater().inflate(R.layout.single_chkout_order_listing, null);
                  TextView mTvName = (TextView) viewOrderData.findViewById(R.id.tv_order_name);
                  TextView mTvPrice = (TextView) viewOrderData.findViewById(R.id.tv_order_price);
                  TextView mTvQuan = (TextView) viewOrderData.findViewById(R.id.tv_order_quantity);
                  TextView mTvSubTot = (TextView) viewOrderData.findViewById(R.id.tv_order_sub_total);
  
                  mTvName.setText(mJsonObject.getString("name"));
                  mTvPrice.setText(mJsonObject.getString("price"));
                  mTvQuan.setText(mJsonObject.getString("quantity"));
                  mTvSubTot.setText(mJsonObject.getString("rowtotal"));
                  mLinearLayoutOrderDetails.addView(viewOrderData);
              }
  
  
          } catch (Exception e) {
              e.printStackTrace();
          }
  
  
      }
  </code></pre>