Skip to content

Commit ec63795

Browse files
committed
correct amount comparison function
1 parent 63345ad commit ec63795

File tree

1 file changed

+8
-1
lines changed
  • raveandroid/src/main/java/com/flutterwave/raveandroid

1 file changed

+8
-1
lines changed

raveandroid/src/main/java/com/flutterwave/raveandroid/Utils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static boolean wasTxSuccessful(RavePayInitializer ravePayInitializer, Str
5858

5959
if (chargeResponse.equalsIgnoreCase("00") &&
6060
status.contains("success") &&
61-
Double.parseDouble(amount) == Double.parseDouble(txAmount) &&
61+
areAmountsSame(amount, txAmount) &&
6262
currency.equalsIgnoreCase(txCurrency)) {
6363
Log.d("RAVE TX V", "true");
6464
return true;
@@ -73,6 +73,13 @@ public static boolean wasTxSuccessful(RavePayInitializer ravePayInitializer, Str
7373
return false;
7474
}
7575

76+
private static Boolean areAmountsSame(String amount1, String amount2) {
77+
Double number1 = Double.parseDouble(amount1);
78+
Double number2 = Double.parseDouble(amount2);
79+
80+
return Math.abs(number1 - number2) < 0.0001;
81+
}
82+
7683
public static String unNullify(String text) {
7784

7885
if (text == null) {

0 commit comments

Comments
 (0)