Skip to content

Commit

Permalink
Merge pull request #52 from razorpay/f/flaten_response
Browse files Browse the repository at this point in the history
Changed android wrapper to return flat response
  • Loading branch information
AbhinavArora95 authored Feb 22, 2018
2 parents 4eaf379 + c3d97a8 commit bf167a6
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions android/src/main/java/com/razorpay/rn/RazorpayModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

}

0 comments on commit bf167a6

Please sign in to comment.