diff --git a/android/src/main/java/com/razorpay/rn/RazorpayModule.java b/android/src/main/java/com/razorpay/rn/RazorpayModule.java index c918e0b8e..e9e90f80b 100644 --- a/android/src/main/java/com/razorpay/rn/RazorpayModule.java +++ b/android/src/main/java/com/razorpay/rn/RazorpayModule.java @@ -85,28 +85,24 @@ private void sendEvent(String eventName, WritableMap params) { @Override public void onPaymentSuccess(String razorpayPaymentId, PaymentData paymentData) { - WritableMap successParams = Arguments.createMap(); - successParams.putString(MAP_KEY_PAYMENT_ID, razorpayPaymentId); - successParams.putMap(MAP_KEY_PAYMENT_DETAILS, Utils.jsonToWritableMap(paymentData.getData())); - sendEvent("Razorpay::PAYMENT_SUCCESS", successParams); + sendEvent("Razorpay::PAYMENT_SUCCESS", Utils.jsonToWritableMap(paymentData.getData())); } @Override public void onPaymentError(int code, String description, PaymentData paymentData) { WritableMap errorParams = Arguments.createMap(); - errorParams.putInt(MAP_KEY_ERROR_CODE, code); - errorParams.putString(MAP_KEY_ERROR_DESC, description); - errorParams.putMap(MAP_KEY_PAYMENT_DETAILS, Utils.jsonToWritableMap(paymentData.getData())); - sendEvent("Razorpay::PAYMENT_ERROR", errorParams); + JSONObject paymentDataJson = paymentData.getData(); + try{ + paymentDataJson.put(MAP_KEY_ERROR_CODE, code); + paymentDataJson.put(MAP_KEY_ERROR_DESC, description); + } catch(Exception e){ + } + sendEvent("Razorpay::PAYMENT_ERROR", Utils.jsonToWritableMap(paymentDataJson)); } @Override public void onExternalWalletSelected(String walletName, PaymentData paymentData){ - WritableMap params = Arguments.createMap(); - params.putString(MAP_KEY_WALLET_NAME, walletName); - params.putMap(MAP_KEY_PAYMENT_DETAILS, Utils.jsonToWritableMap(paymentData.getData())); - sendEvent("Razorpay::EXTERNAL_WALLET_SELECTED", params); - + sendEvent("Razorpay::EXTERNAL_WALLET_SELECTED", Utils.jsonToWritableMap(paymentData.getData())); } }