Skip to content

Commit 4cbede9

Browse files
committed
Merge branch 'ghMomoFlowUpdate'
2 parents 6c2bc63 + ab274eb commit 4cbede9

File tree

10 files changed

+97
-10
lines changed

10 files changed

+97
-10
lines changed

rave_android/src/main/java/com/flutterwave/raveandroid/ghmobilemoney/GhMobileMoneyFragment.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.flutterwave.raveandroid.rave_java_commons.RaveConstants;
3434
import com.flutterwave.raveandroid.rave_logger.events.StartTypingEvent;
3535
import com.flutterwave.raveandroid.rave_presentation.data.events.ErrorEvent;
36+
import com.flutterwave.raveutils.verification.RaveVerificationUtils;
3637
import com.google.android.material.textfield.TextInputEditText;
3738
import com.google.android.material.textfield.TextInputLayout;
3839

@@ -41,6 +42,7 @@
4142
import javax.inject.Inject;
4243

4344
import static android.view.View.GONE;
45+
import static com.flutterwave.raveandroid.rave_java_commons.RaveConstants.WEB_VERIFICATION_REQUEST_CODE;
4446

4547
/**
4648
* A simple {@link Fragment} subclass.
@@ -224,6 +226,30 @@ public void onPhoneValidated(String phoneToSet, boolean isEditable) {
224226
phoneEt.setEnabled(isEditable);
225227
}
226228

229+
@Override
230+
public void showWebPage(String authenticationUrl
231+
// , String flwRef
232+
) {
233+
234+
// this.flwRef = flwRef;
235+
new RaveVerificationUtils(this, ravePayInitializer.isStaging(), ravePayInitializer.getPublicKey(), ravePayInitializer.getTheme())
236+
.showWebpageVerificationScreen(authenticationUrl);
237+
}
238+
239+
240+
@Override
241+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
242+
if (resultCode == RavePayActivity.RESULT_SUCCESS) {
243+
//just to be sure this v sent the receiving intent
244+
if (requestCode == WEB_VERIFICATION_REQUEST_CODE) {
245+
presenter.requeryTx(ravePayInitializer.getPublicKey());
246+
}
247+
} else {
248+
super.onActivityResult(requestCode, resultCode, data);
249+
}
250+
}
251+
252+
227253
private void showInstructionsAndVoucher(boolean show) {
228254

229255
if (show) {

rave_android/src/main/java/com/flutterwave/raveandroid/ghmobilemoney/NullGhMobileMoneyView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ public void onValidationSuccessful(HashMap<String, ViewObject> dataHashMap) {
6666
public void onPaymentSuccessful(String status, String flwRef, String responseAsString) {
6767

6868
}
69+
70+
@Override
71+
public void showWebPage(String captchaLink) {
72+
73+
}
6974
}

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/ghmobilemoney/GhMobileMoneyContract.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface Interactor {
1616
void onPaymentFailed(String message, String responseAsJSONString);
1717
void onPaymentSuccessful(String status, String flwRef, String responseAsString);
1818

19+
void showWebPage(String captchaLink);
1920
}
2021

2122
interface Handler {
@@ -25,5 +26,7 @@ interface Handler {
2526
void logEvent(Event event, String publicKey);
2627

2728
void cancelPolling();
29+
30+
void requeryTx(String publicKey);
2831
}
2932
}

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/ghmobilemoney/GhMobileMoneyHandler.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class GhMobileMoneyHandler implements GhMobileMoneyContract.Handler {
3838
PayloadEncryptor payloadEncryptor;
3939
private GhMobileMoneyContract.Interactor mInteractor;
4040
private boolean pollingCancelled = false;
41+
private String txRef = null;
4142

4243
@Inject
4344
public GhMobileMoneyHandler(GhMobileMoneyContract.Interactor mInteractor) {
@@ -78,6 +79,7 @@ public void onError(String message) {
7879

7980
@Override
8081
public void chargeGhMobileMoney(final Payload payload, final String encryptionKey) {
82+
txRef = payload.getTxRef();
8183
String cardRequestBodyAsString = Utils.convertChargeRequestPayloadToJson(payload);
8284
String encryptedCardRequestBody = payloadEncryptor.getEncryptedData(cardRequestBodyAsString, encryptionKey).trim().replaceAll("\\n", "");
8385

@@ -96,11 +98,16 @@ public void chargeGhMobileMoney(final Payload payload, final String encryptionKe
9698
public void onSuccess(MobileMoneyChargeResponse response) {
9799

98100
mInteractor.showProgressIndicator(false);
99-
100-
if (response.getData() != null) {
101-
String flwRef = response.getData().getFlwRef();
102-
String txRef = response.getData().getTx_ref();
103-
requeryTx(flwRef, txRef, payload.getPBFPubKey());
101+
MobileMoneyChargeResponse.Data data = response.getData();
102+
if (data != null) {
103+
if (data.getCode() != null && data.getCode().equals("02")
104+
&& data.getCaptchaLink() != null) {
105+
mInteractor.showWebPage(data.getCaptchaLink());
106+
} else {
107+
String flwRef = data.getFlwRef();
108+
String txRef = data.getTx_ref();
109+
requeryTx(flwRef, txRef, payload.getPBFPubKey());
110+
}
104111
} else {
105112
mInteractor.onPaymentError(noResponse);
106113
}
@@ -115,11 +122,17 @@ public void onError(String message) {
115122
});
116123
}
117124

125+
@Override
126+
public void requeryTx(final String publicKey) {
127+
requeryTx(null, txRef, publicKey);
128+
}
129+
118130
@Override
119131
public void requeryTx(final String flwRef, final String txRef, final String publicKey) {
120132

121133
RequeryRequestBody body = new RequeryRequestBody();
122134
body.setFlw_ref(flwRef);
135+
body.setTx_ref(txRef);
123136
body.setPBFPubKey(publicKey);
124137

125138
mInteractor.showPollingIndicator(true);

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/ghmobilemoney/GhMobileMoneyInteractorImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public void onPaymentSuccessful(String status, String flwRef, String responseAsS
5050
callback.onSuccessful(flwRef);
5151
}
5252

53+
@Override
54+
public void showWebPage(String captchaLink) {
55+
callback.showAuthenticationWebPage(captchaLink);
56+
}
57+
5358
@Override
5459
public void showFetchFeeFailed(String errorMessage) {
5560
feeCheckListener.onFetchFeeError(errorMessage);

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/ghmobilemoney/GhanaMobileMoneyPaymentCallback.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ public interface GhanaMobileMoneyPaymentCallback {
88
void onError(String errorMessage, @Nullable String flwRef);
99

1010
void onSuccessful(String flwRef);
11+
12+
void showAuthenticationWebPage(String url);
1113
}

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/ghmobilemoney/GhanaMobileMoneyPaymentManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public void chargeVodafone(String voucher) {
3939
charge(vodafone, voucher);
4040
}
4141

42+
public void onWebpageAuthenticationComplete() {
43+
paymentHandler.requeryTx(manager.getPublicKey());
44+
}
45+
4246
private void charge(String network, String voucher) {
4347
Payload payload = createPayload(network, voucher);
4448

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/ghmobilemoney/NullGhMobileMoneyPaymentCallback.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public void onSuccessful(String flwRef) {
1919

2020
}
2121

22+
@Override
23+
public void showAuthenticationWebPage(String url) {
24+
25+
}
26+
2227
}

rave_remote/src/main/java/com/flutterwave/raveandroid/rave_remote/requests/RequeryRequestBody.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ public class RequeryRequestBody {
88

99
private String order_ref;
1010

11+
private String tx_ref;
12+
13+
public void setTx_ref(String tx_ref) {
14+
this.tx_ref = tx_ref;
15+
}
16+
1117
public String getPBFPubKey() {
1218
return PBFPubKey;
1319
}

rave_remote/src/main/java/com/flutterwave/raveandroid/rave_remote/responses/MobileMoneyChargeResponse.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.flutterwave.raveandroid.rave_remote.responses;
22

3+
import com.google.gson.annotations.SerializedName;
4+
35
/**
46
* Created by hamzafetuga on 18/07/2017.
57
*/
@@ -38,6 +40,14 @@ public static class Data {
3840
String chargeResponseCode;
3941
String authModelUsed;
4042
String flwRef;
43+
String txRef;
44+
String chargeResponseMessage;
45+
String authurl;
46+
String redirectUrl;
47+
@SerializedName("link")
48+
String captchaLink;
49+
String code;
50+
4151

4252
public void setFlwRef(String flwRef) {
4353
this.flwRef = flwRef;
@@ -55,10 +65,6 @@ public void setTx_ref(String txRef) {
5565
this.txRef = txRef;
5666
}
5767

58-
String txRef;
59-
String chargeResponseMessage;
60-
String authurl;
61-
6268
public String getRedirectUrl() {
6369
return redirectUrl;
6470
}
@@ -67,7 +73,6 @@ public void setChargeResponseCode(String chargeResponseCode) {
6773
this.chargeResponseCode = chargeResponseCode;
6874
}
6975

70-
String redirectUrl;
7176

7277
public String getAuthurl() {
7378
return authurl;
@@ -94,5 +99,18 @@ public String getSuggested_auth() {
9499
return suggested_auth;
95100
}
96101

102+
103+
public String getTxRef() {
104+
return txRef;
105+
}
106+
107+
public String getCaptchaLink() {
108+
return captchaLink;
109+
}
110+
111+
public String getCode() {
112+
return code;
113+
}
114+
97115
}
98116
}

0 commit comments

Comments
 (0)