Skip to content

Commit 1fac608

Browse files
committed
Update Francophone mobile money flow
1 parent a85ef48 commit 1fac608

File tree

11 files changed

+87
-49
lines changed

11 files changed

+87
-49
lines changed

app/src/main/java/com/flutterwave/rave_android/MainActivity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
162162
}
163163
});
164164

165+
francMobileMoneySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
166+
@Override
167+
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
168+
if (b) {
169+
countryEt.setVisibility(View.VISIBLE);
170+
} else {
171+
countryEt.setVisibility(View.GONE);
172+
}
173+
}
174+
});
175+
165176
cardSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
166177
@Override
167178
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
@@ -321,7 +332,7 @@ private void validateEntries() {
321332
.acceptRwfMobileMoneyPayments(rwfMobileMoneySwitch.isChecked())
322333
.acceptUkPayments(ukbankSwitch.isChecked())
323334
.acceptSaBankPayments(saBankSwitch.isChecked())
324-
.acceptFrancMobileMoneyPayments(francMobileMoneySwitch.isChecked())
335+
.acceptFrancMobileMoneyPayments(francMobileMoneySwitch.isChecked(), countryEt.getText().toString())
325336
.acceptBankTransferPayments(bankTransferSwitch.isChecked())
326337
.acceptUssdPayments(ussdSwitch.isChecked())
327338
.acceptBarterPayments(barterSwitch.isChecked())

app/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@
149149
android:checked="false"
150150
android:text="@string/francophone" />
151151

152+
<EditText
153+
android:id="@+id/countryEt"
154+
android:layout_width="match_parent"
155+
android:layout_height="wrap_content"
156+
android:layout_marginBottom="10dp"
157+
android:hint="@string/country_code_e_g_ng"
158+
android:textSize="14sp"
159+
android:visibility="gone" />
160+
152161
<androidx.appcompat.widget.SwitchCompat
153162
android:id="@+id/accountGHMobileMoneySwitch"
154163
android:layout_width="match_parent"
@@ -361,15 +370,6 @@
361370
android:hint="@string/currency_code_e_g_ngn"
362371
android:textSize="14sp" />
363372

364-
<EditText
365-
android:id="@+id/countryEt"
366-
android:layout_width="match_parent"
367-
android:layout_height="wrap_content"
368-
android:layout_marginBottom="10dp"
369-
android:hint="@string/country_code_e_g_ng"
370-
android:textSize="14sp"
371-
android:visibility="gone" />
372-
373373

374374
<EditText
375375
android:id="@+id/fNameEt"

rave_android/src/main/java/com/flutterwave/raveandroid/RaveUiManager.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,24 @@ public RaveUiManager setNarration(String narration) {
108108

109109
public RaveUiManager setCurrency(String currency) {
110110
this.currency = currency;
111-
switch (currency) {
112-
case "KES":
113-
country = "KE";
114-
break;
115-
case "GHS":
116-
country = "GH";
117-
break;
118-
case "ZAR":
119-
country = "ZA";
120-
break;
121-
case "TZS":
122-
country = "TZ";
123-
break;
124-
default:
125-
country = "NG";
126-
break;
111+
if (country==null || country.isEmpty()) { // Set the country based on Rave defaults if the country is not already set
112+
switch (currency) {
113+
case "KES":
114+
country = "KE";
115+
break;
116+
case "GHS":
117+
country = "GH";
118+
break;
119+
case "ZAR":
120+
country = "ZA";
121+
break;
122+
case "TZS":
123+
country = "TZ";
124+
break;
125+
default:
126+
country = "NG";
127+
break;
128+
}
127129
}
128130
return this;
129131
}
@@ -260,9 +262,10 @@ public RaveUiManager acceptSaBankPayments(boolean withSaBankAccount) {
260262
return this;
261263
}
262264

263-
public RaveUiManager acceptFrancMobileMoneyPayments(boolean withFrancMobileMoney) {
265+
public RaveUiManager acceptFrancMobileMoneyPayments(boolean withFrancMobileMoney, String country) {
264266
if (!orderedPaymentTypesList.contains(PAYMENT_TYPE_FRANCO_MOBILE_MONEY) && withFrancMobileMoney)
265267
orderedPaymentTypesList.add(PAYMENT_TYPE_FRANCO_MOBILE_MONEY);
268+
this.country = country;
266269
return this;
267270
}
268271

rave_android/src/main/java/com/flutterwave/raveandroid/francMobileMoney/FrancMobileMoneyFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public void showWebPage(String authenticationUrl, String flwRef) {
213213

214214
this.flwRef = flwRef;
215215
new RaveVerificationUtils(this, ravePayInitializer.isStaging(), ravePayInitializer.getPublicKey(), ravePayInitializer.getTheme())
216-
.showWebpageVerificationScreen(authenticationUrl);
216+
.showWebpageVerificationScreen(authenticationUrl,flwRef);
217217
}
218218

219219

rave_android/src/test/java/com/flutterwave/raveandroid/RaveUiManagerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void ravePayManagerSetup_PaymentTypesNotAddedMoreThanOnce() {
3232
.acceptAchPayments(true)
3333
.acceptBankTransferPayments(true)
3434
.acceptCardPayments(true)
35-
.acceptFrancMobileMoneyPayments(true)
35+
.acceptFrancMobileMoneyPayments(true,"NG")
3636
.acceptGHMobileMoneyPayments(true)
3737
.acceptMpesaPayments(true)
3838
.acceptRwfMobileMoneyPayments(true)
@@ -44,7 +44,7 @@ public void ravePayManagerSetup_PaymentTypesNotAddedMoreThanOnce() {
4444
.acceptAchPayments(true)
4545
.acceptBankTransferPayments(true)
4646
.acceptCardPayments(true)
47-
.acceptFrancMobileMoneyPayments(true)
47+
.acceptFrancMobileMoneyPayments(true,"NG")
4848
.acceptGHMobileMoneyPayments(true)
4949
.acceptMpesaPayments(true)
5050
.acceptRwfMobileMoneyPayments(true)
@@ -56,7 +56,7 @@ public void ravePayManagerSetup_PaymentTypesNotAddedMoreThanOnce() {
5656
.acceptAchPayments(true)
5757
.acceptBankTransferPayments(true)
5858
.acceptCardPayments(true)
59-
.acceptFrancMobileMoneyPayments(true)
59+
.acceptFrancMobileMoneyPayments(true,"NG")
6060
.acceptGHMobileMoneyPayments(true)
6161
.acceptUkPayments(true)
6262
.acceptMpesaPayments(true)
@@ -86,7 +86,7 @@ public void ravePayManagerSetup_AllPaymentTypesAddedAreInPaymentTypesList() {
8686
.acceptAccountPayments(true)
8787
.acceptAchPayments(true)
8888
.acceptBankTransferPayments(true)
89-
.acceptFrancMobileMoneyPayments(true)
89+
.acceptFrancMobileMoneyPayments(true,"")
9090
.acceptGHMobileMoneyPayments(true)
9191
.acceptMpesaPayments(true)
9292
.acceptRwfMobileMoneyPayments(true)

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/francmobilemoney/FrancMobileMoneyHandler.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.flutterwave.raveandroid.rave_presentation.francmobilemoney;
22

3+
import android.os.Handler;
34
import android.util.Log;
45

56
import com.flutterwave.raveandroid.rave_java_commons.Payload;
@@ -38,7 +39,8 @@ public class FrancMobileMoneyHandler implements FrancMobileMoneyContract.Handler
3839
RemoteRepository networkRequest;
3940
@Inject
4041
PayloadEncryptor payloadEncryptor;
41-
private FrancMobileMoneyContract.Interactor mInteractor;
42+
private final FrancMobileMoneyContract.Interactor mInteractor;
43+
private final Handler pollingHandler = new Handler();
4244

4345
@Inject
4446
public FrancMobileMoneyHandler(FrancMobileMoneyContract.Interactor mInteractor) {
@@ -142,8 +144,13 @@ public void onSuccess(RequeryResponse response, String responseAsJSONString) {
142144
} else if (response.getData().getStatus().contains("fail")) {
143145
mInteractor.showProgressIndicator(false);
144146
mInteractor.onPaymentFailed(response.getData().getStatus(), responseAsJSONString);
145-
} else if (response.getData().getChargeResponseCode().equals("02")) {
146-
requeryTx(flwRef, publicKey);
147+
} else if (response.getData().getChargeResponseCode().equals("02")||response.getData().getChargeResponseCode().equals("01")) {
148+
pollingHandler.postDelayed(new Runnable() {
149+
@Override
150+
public void run() {
151+
requeryTx(flwRef, publicKey);
152+
}
153+
},2000);
147154
} else if (response.getData().getChargeResponseCode().equals("00")) {
148155
mInteractor.showPollingIndicator(false);
149156
mInteractor.onPaymentSuccessful(flwRef, responseAsJSONString);

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/francmobilemoney/FrancophoneMobileMoneyPaymentManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
public class FrancophoneMobileMoneyPaymentManager {
1313

1414
private final RaveNonUIManager manager;
15+
private final String country;
1516
@Inject
1617
public FrancMobileMoneyHandler paymentHandler;
1718
FrancMobileMoneyInteractorImpl interactor;
1819

19-
public FrancophoneMobileMoneyPaymentManager(RaveNonUIManager manager, FrancophoneMobileMoneyPaymentCallback callback) {
20+
public FrancophoneMobileMoneyPaymentManager(RaveNonUIManager manager, String country, FrancophoneMobileMoneyPaymentCallback callback) {
2021
this.manager = manager;
22+
this.country = country;
2123

2224
injectFields(manager.getRaveComponent(), callback);
2325

@@ -32,7 +34,7 @@ public void charge() {
3234
private Payload createPayload() {
3335
PayloadBuilder builder = new PayloadBuilder();
3436
builder.setAmount(String.valueOf(manager.getAmount()))
35-
.setCountry(manager.getCountry())
37+
.setCountry(country)
3638
.setCurrency(manager.getCurrency())
3739
.setEmail(manager.getEmail())
3840
.setFirstname(manager.getfName())

rave_utils/src/main/java/com/flutterwave/raveutils/verification/RaveVerificationUtils.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.content.Intent;
66

7+
import androidx.annotation.Nullable;
78
import androidx.fragment.app.Fragment;
89

910
import com.flutterwave.raveutils.R;
@@ -82,9 +83,14 @@ private void showOtpScreen(String validateInstruction, boolean forSavedCards) {
8283
else fragment.startActivityForResult(intent, OTP_REQUEST_CODE);
8384
}
8485

85-
public void showWebpageVerificationScreen(String authurl) {
86+
public void showWebpageVerificationScreen(String authUrl) {
87+
showWebpageVerificationScreen(authUrl, null);
88+
}
89+
90+
public void showWebpageVerificationScreen(String authUrl, @Nullable String flwRef) {
8691
Intent intent = new Intent(context, VerificationActivity.class);
87-
intent.putExtra(WebFragment.EXTRA_AUTH_URL, authurl);
92+
intent.putExtra(WebFragment.EXTRA_AUTH_URL, authUrl);
93+
intent.putExtra(WebFragment.EXTRA_FLW_REF, flwRef);
8894
intent.putExtra(VerificationActivity.ACTIVITY_MOTIVE, "web");
8995
intent.putExtra(EXTRA_IS_STAGING, isStaging);
9096
intent.putExtra(VerificationActivity.PUBLIC_KEY_EXTRA, publicKey);

rave_utils/src/main/java/com/flutterwave/raveutils/verification/web/WebContract.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ interface View {
1818
interface UserActionsListener {
1919

2020

21-
void init(String flwRef, String publicKey);
21+
void init(String flwRef, String publicKey, Boolean isBarter);
2222

23-
void requeryTx(String flwRef, String publicKey);
23+
void requeryTx(String flwRef, String publicKey, Boolean isBarter);
2424

2525
void onAttachView(View view);
2626

rave_utils/src/main/java/com/flutterwave/raveutils/verification/web/WebFragment.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import javax.inject.Inject;
3131

32+
import static com.flutterwave.raveandroid.rave_java_commons.RaveConstants.BARTER_CHECKOUT;
3233
import static com.flutterwave.raveandroid.rave_java_commons.RaveConstants.RESULT_ERROR;
3334
import static com.flutterwave.raveandroid.rave_java_commons.RaveConstants.RESULT_SUCCESS;
3435
import static com.flutterwave.raveutils.verification.VerificationActivity.PUBLIC_KEY_EXTRA;
@@ -44,6 +45,7 @@ public class WebFragment extends Fragment implements WebContract.View {
4445
String authurl;
4546
String flwRef = "";
4647
String publicKey = "";
48+
String motive = "";
4749
WebView webView;
4850
ProgressDialog progressDialog;
4951
@Inject
@@ -70,6 +72,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
7072
try {
7173
flwRef = getArguments().getString(EXTRA_FLW_REF);
7274
publicKey = getArguments().getString(EXTRA_PUBLIC_KEY);
75+
motive = getArguments().getString(VerificationActivity.ACTIVITY_MOTIVE);
7376
} catch (Exception e) {
7477
e.printStackTrace();
7578
}
@@ -81,9 +84,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
8184
}
8285

8386
private void initPresenter() {
84-
if (flwRef != null && publicKey != null)
85-
if (!flwRef.isEmpty() && !publicKey.isEmpty())
86-
presenter.init(flwRef, publicKey);
87+
if (flwRef != null && publicKey != null && motive!=null)
88+
if (!flwRef.isEmpty() && !publicKey.isEmpty()){
89+
presenter.init(flwRef, publicKey, motive.equals(BARTER_CHECKOUT));
90+
}
8791
}
8892

8993
private void logEvent(Event event) {
@@ -218,7 +222,7 @@ public void onPageFinished(WebView view, String url) {
218222

219223
@Override
220224
public void onPollingRoundComplete(String flwRef, String publicKey) {
221-
presenter.requeryTx(flwRef, publicKey);
225+
presenter.requeryTx(flwRef, publicKey, motive.equals(BARTER_CHECKOUT));
222226
}
223227

224228
@Override

0 commit comments

Comments
 (0)