Skip to content

Commit d6a47bd

Browse files
committed
implement new gtb_otp auth model
1 parent f90c4c5 commit d6a47bd

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class RaveConstants {
1414
public static String STAGING_URL = "http://flw-pms-dev.eu-west-1.elasticbeanstalk.com";
1515
public static String LIVE_URL = "https://rave-api.herokuapp.com";
1616
public static String VBV = "VBVSECURECODE";
17+
public static String GTB_OTP = "GTB_OTP";
1718
public static String PIN = "PIN";
1819
public static String AVS_VBVSECURECODE = "AVS_VBVSECURECODE";
1920
public static String RAVEPAY = "ravepay";

raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardContract.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface View {
2323

2424
void showToast(String message);
2525

26-
void showOTPLayout(String flwRef);
26+
void showOTPLayout(String flwRef, String chargeResponseMessage);
2727

2828
void onValidateSuccessful(String message, String responseAsString);
2929

raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public class CardFragment extends Fragment implements View.OnClickListener, Card
9494
View v;
9595
Button savedCardBtn;
9696
String cardFirst6;
97+
TextView otpInstructionsTv;
9798
String cardLast4;
9899
boolean shouldISaveThisCard = false;
99100

@@ -126,6 +127,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
126127
webView = (WebView) v.findViewById(R.id.rave_webview);
127128
pcidss_tv = (TextView) v.findViewById(R.id.rave_pcidss_compliant_tv);
128129
progressContainer = (FrameLayout) v.findViewById(R.id.rave_progressContainer);
130+
otpInstructionsTv = (TextView) v.findViewById(R.id.otp_instructions_tv);
129131

130132
ravePayInitializer = ((RavePayActivity) getActivity()).getRavePayInitializer();
131133

@@ -456,11 +458,13 @@ private void dismissDialog() {
456458
/**
457459
* If an OTP is required, this method shows the dialog that receives it
458460
* @param flwRef
461+
* @param chargeResponseMessage
459462
*/
460463
@Override
461-
public void showOTPLayout(String flwRef) {
464+
public void showOTPLayout(String flwRef, String chargeResponseMessage) {
462465
this.flwRef = flwRef;
463466
dismissDialog();
467+
otpInstructionsTv.setText(chargeResponseMessage);
464468
bottomSheetBehaviorOTP.setState(BottomSheetBehavior.STATE_EXPANDED);
465469
}
466470

raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardPresenter.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,20 @@ else if (suggested_auth.equals(AVS_VBVSECURECODE)) {
7878
else {
7979
String authModelUsed = response.getData().getAuthModelUsed();
8080

81-
if (authModelUsed.equalsIgnoreCase(RaveConstants.VBV)) {
82-
String authUrlCrude = response.getData().getAuthurl();
83-
String flwRef = response.getData().getFlwRef();
84-
85-
mView.onVBVAuthModelUsed(authUrlCrude, flwRef);
86-
81+
if (authModelUsed != null) {
82+
83+
if (authModelUsed.equalsIgnoreCase(RaveConstants.VBV)) {
84+
String authUrlCrude = response.getData().getAuthurl();
85+
String flwRef = response.getData().getFlwRef();
86+
87+
mView.onVBVAuthModelUsed(authUrlCrude, flwRef);
88+
}
89+
else if (authModelUsed.equalsIgnoreCase(RaveConstants.GTB_OTP)) {
90+
String flwRef = response.getData().getFlwRef();
91+
String chargeResponseMessage = response.getData().getChargeResponseMessage();
92+
chargeResponseMessage = chargeResponseMessage == null ? "Enter your one time password (OTP)" : chargeResponseMessage;
93+
mView.showOTPLayout(flwRef, chargeResponseMessage);
94+
}
8795
}
8896
}
8997
}
@@ -142,7 +150,10 @@ public void onSuccess(ChargeResponse response, String responseAsJSONString) {
142150
else if (chargeResponseCode.equalsIgnoreCase("02")) {
143151
String authModelUsed = response.getData().getAuthModelUsed();
144152
if (authModelUsed.equalsIgnoreCase(RaveConstants.PIN)) {
145-
mView.showOTPLayout(response.getData().getFlwRef());
153+
String flwRef = response.getData().getFlwRef();
154+
String chargeResponseMessage = response.getData().getChargeResponseMessage();
155+
chargeResponseMessage = (chargeResponseMessage == null || chargeResponseMessage.length() == 0) ? "Enter your one time password (OTP)" : chargeResponseMessage;
156+
mView.showOTPLayout(flwRef, chargeResponseMessage);
146157
}
147158
else if (authModelUsed.equalsIgnoreCase(RaveConstants.AVS_VBVSECURECODE)){
148159
String flwRef = response.getData().getFlwRef();

raveandroid/src/main/java/com/flutterwave/raveandroid/card/NullCardView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void showToast(String message) {
4242
}
4343

4444
@Override
45-
public void showOTPLayout(String flwRef) {
45+
public void showOTPLayout(String flwRef, String chargeResponseMessage) {
4646

4747
}
4848

raveandroid/src/main/res/layout/fragment_card.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
android:layout_marginRight="30dp"
233233
android:layout_marginBottom="30dp"
234234
android:layout_marginLeft="30dp"
235+
android:id="@+id/otp_instructions_tv"
235236
android:text="@string/enter_your_one_ntime_password_otp"
236237
android:gravity="center_vertical|center_horizontal"
237238
/>

0 commit comments

Comments
 (0)