title: Razor Pay callback methods are not invoked in background
body: <p>I have implemented Razor Pay payment gateway in my Android application. Everything is working fine for debit/credit card.</p>
  
  <p>I am facing problem with UPI payment. Actually for UPI  payment user has to visit UPI app to make the payment. Everything is working for UPI as well but the only problem is callback methods are not invoked if payment is successful or not until and unless I visit the app again.</p>
  
  <p>This is big problem for me because sometime if user pay via UPI app and does not open the app again, it's been difficult for me to save the entries in the database for the payment.</p>
  
  <p>I am saving entries in the database every time success callback method is invoked. How do I call success method when app is in background but not closed.</p>
  
  <p>Here is the code snippet:</p>
  
  <p>To open the payment activity:</p>
  
  <pre><code>  Intent intent = new Intent(context, PaymentActivity.class);
          intent.putExtra("orderId", order_id);
          intent.putExtra("totalAmount", String.valueOf(totalPrice));
          intent.putExtra("email", email);
          intent.putExtra("phoneNo", phone_number);
          intent.putExtra("userId", user_id);
          startActivityForResult(intent, 2);
          overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
  </code></pre>
  
  <p>To call the Razor pay Activity:</p>
  
  <pre><code>final Activity activity = this;
      price = Double.parseDouble(total_price);
      double paisa_double = price * 100;
      int paisa_int = (int) paisa_double;
      final Checkout checkout = new Checkout();
      checkout.setKeyID(getResources().getString(R.string.razor_pay_key));
      try {
          JSONObject options = new JSONObject();
          options.put("name", "Razorpay Corp");
          options.put("description", "Order No: " + order_id);
          options.put("order_id", razor_id);
          //You can omit the image option to fetch the image from dashboard
          options.put("image", "https://s3.amazonaws.com/rzp-mobile/images/rzp.png");
          options.put("currency", "INR");
          options.put("amount", String.valueOf(paisa_int));
          //options.put("amount", "100");
          JSONObject preFill = new JSONObject();
          preFill.put("email", email);
          preFill.put("contact", phone_no);
          options.put("prefill", preFill);
          JSONObject notes = new JSONObject();
          notes.put("notes", order_id);
          options.put("notes", notes);
          checkout.open(activity, options);
      } catch (Exception e) {
          Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT)
                  .show();
          e.printStackTrace();
      }
  </code></pre>
  
  <p>And these are the callback methods:</p>
  
  <pre><code>  @Override
      public void onPaymentSuccess(String razorpayPaymentID, PaymentData paymentData) {
          try {
              //Toast.makeText(this, "Payment Successful: " + razorpayPaymentID, Toast.LENGTH_SHORT).show();
              Intent intent = new Intent();
              intent.putExtra("razorpayPaymentID", razorpayPaymentID);
              setResult(2, intent);
              finish();
  
          } catch (Exception e) {
              Log.e(TAG, "Exception in onPaymentSuccess", e);
          }
      }
  
      @Override
      public void onPaymentError(int code, String response, PaymentData paymentData) {
          try {
              Toast.makeText(this, "Payment failed: " + code + " " + response, Toast.LENGTH_SHORT).show();
          } catch (Exception e) {
              Log.e(TAG, "Exception in onPaymentError", e);
          }
      }
  </code></pre>