Skip to content

Commit 903731b

Browse files
committed
Add Uganda Mobile Money
1 parent 27d705e commit 903731b

File tree

12 files changed

+603
-3
lines changed

12 files changed

+603
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class MainActivity extends AppCompatActivity {
4444
SwitchCompat cardSwitch;
4545
SwitchCompat accountSwitch;
4646
SwitchCompat ghMobileMoneySwitch;
47+
SwitchCompat ugMobileMoneySwitch;
4748
SwitchCompat isLiveSwitch;
4849
SwitchCompat isMpesaSwitch;
4950
SwitchCompat accountAchSwitch;
@@ -76,6 +77,7 @@ protected void onCreate(Bundle savedInstanceState) {
7677
isMpesaSwitch = findViewById(R.id.accountMpesaSwitch);
7778
isPreAuthSwitch = findViewById(R.id.isPreAuthSwitch);
7879
ghMobileMoneySwitch = findViewById(R.id.accountGHMobileMoneySwitch);
80+
ugMobileMoneySwitch = findViewById(R.id.accountUgMobileMoneySwitch);
7981
isLiveSwitch = findViewById(R.id.isLiveSwitch);
8082
addSubAccountsSwitch = findViewById(R.id.addSubAccountsSwitch);
8183
addVendorBtn = findViewById(R.id.addVendorBtn);
@@ -196,6 +198,7 @@ private void validateEntries() {
196198
.acceptCardPayments(cardSwitch.isChecked())
197199
.acceptAchPayments(accountAchSwitch.isChecked())
198200
.acceptGHMobileMoneyPayments(ghMobileMoneySwitch.isChecked())
201+
.acceptUgMobileMoneyPayments(ugMobileMoneySwitch.isChecked())
199202
.onStagingEnv(!isLiveSwitch.isChecked())
200203
.setSubAccounts(subAccounts)
201204
.isPreAuth(isPreAuthSwitch.isChecked())

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@
6666
android:id="@+id/accountGHMobileMoneySwitch"
6767
/>
6868

69+
<android.support.v7.widget.SwitchCompat
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content"
72+
android:layout_marginBottom="10dp"
73+
android:text="Accept UG Mobile money payments"
74+
android:checked="false"
75+
android:id="@+id/accountUgMobileMoneySwitch"
76+
/>
77+
6978
<android.support.v7.widget.SwitchCompat
7079
android:layout_width="match_parent"
7180
android:layout_height="wrap_content"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ public void setCardBIN(String cardBIN) {
579579

580580
public String is_mobile_money_gh;
581581

582+
public String is_mobile_money_ug;
583+
582584
public void setNetwork(String network) {
583585
this.network = network;
584586
}
@@ -595,6 +597,10 @@ public void setIs_mobile_money_gh(String is_mobile_money_gh) {
595597
this.is_mobile_money_gh = is_mobile_money_gh;
596598
}
597599

600+
public void setIs_mobile_money_ug(String is_mobile_money_ug) {
601+
this.is_mobile_money_ug = is_mobile_money_ug;
602+
}
603+
598604
public boolean isIs_us_bank_charge() {
599605
return is_us_bank_charge;
600606
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ public PayloadBuilder setIs_mobile_money_gh(String is_mobile_money_gh) {
3030
return this;
3131
}
3232

33+
public PayloadBuilder setIs_mobile_money_ug(String is_mobile_money_ug) {
34+
this.is_mobile_money_ug = is_mobile_money_ug;
35+
return this;
36+
}
37+
3338
private String is_mobile_money_gh;
39+
private String is_mobile_money_ug;
3440

3541
private String phonenumber;
3642

@@ -219,6 +225,17 @@ public Payload createGhMobileMoneyPayload() {
219225
return payload;
220226
}
221227

228+
public Payload createUgMobileMoneyPayload() {
229+
List<Meta> metaObj = Utils.pojofyMetaString(meta);
230+
List<SubAccount> subaccountsObj = Utils.pojofySubaccountString(subAccounts);
231+
Payload payload = new Payload(phonenumber, metaObj, subaccountsObj, narration, ip, lastname,
232+
firstname, currency, country, amount, email, device_fingerprint, txRef, pbfPubKey);
233+
payload.setIs_mobile_money_ug("1");
234+
payload.setPayment_type("mobilemoneyuganda");
235+
payload.setNetwork(network);
236+
return payload;
237+
}
238+
222239
public PayloadBuilder setMeta(String meta) {
223240
this.meta = meta;
224241
return this;

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.flutterwave.raveandroid.card.CardFragment;
2525
import com.flutterwave.raveandroid.ghmobilemoney.GhMobileMoneyFragment;
2626
import com.flutterwave.raveandroid.mpesa.MpesaFragment;
27+
import com.flutterwave.raveandroid.ugmobilemoney.UgMobileMoneyFragment;
2728

2829
import org.parceler.Parcels;
2930

@@ -110,7 +111,11 @@ else if (ravePayInitializer.getCountry().equalsIgnoreCase("ng") && ravePayInitia
110111
}
111112

112113
if (ravePayInitializer.isWithGHMobileMoney()) {
113-
raveFragments.add(new RaveFragment(new GhMobileMoneyFragment(), "MOBILE MONEY"));
114+
raveFragments.add(new RaveFragment(new GhMobileMoneyFragment(), "GHANA MOBILE MONEY"));
115+
}
116+
117+
if (ravePayInitializer.isWithUgMobileMoney()) {
118+
raveFragments.add(new RaveFragment(new UgMobileMoneyFragment(), "UGANDA MOBILE MONEY"));
114119
}
115120

116121
mainPagerAdapter.setFragments(raveFragments);

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class RavePayInitializer {
2828
boolean withCard = true;
2929
boolean withAccount = true;
3030
boolean withGHMobileMoney = false;
31+
boolean withUgMobileMoney = false;
3132
int theme;
3233
boolean staging = true;
3334
boolean isPreAuth = false;
@@ -36,7 +37,9 @@ public RavePayInitializer(String email, double amount, String publicKey,
3637
String encryptionKey, String txRef, String narration,
3738
String currency, String country, String fName,
3839
String lName, boolean withCard,
39-
boolean withAccount, boolean withMpesa, boolean withGHMobileMoney, boolean withAch, int theme,
40+
boolean withAccount, boolean withMpesa, boolean withGHMobileMoney,
41+
boolean withUgMobileMoney,
42+
boolean withAch, int theme,
4043
boolean staging, String meta, String subAccounts, String payment_plan, boolean isPreAuth) {
4144
this.email = email;
4245
this.amount = amount;
@@ -50,6 +53,7 @@ public RavePayInitializer(String email, double amount, String publicKey,
5053
this.lName = lName;
5154
this.withAccount = withAccount;
5255
this.withGHMobileMoney = withGHMobileMoney;
56+
this.withUgMobileMoney = withUgMobileMoney;
5357
this.withMpesa = withMpesa;
5458
this.withCard = withCard;
5559
this.withAch = withAch;
@@ -112,6 +116,10 @@ public boolean isWithGHMobileMoney() {
112116
return withGHMobileMoney;
113117
}
114118

119+
public boolean isWithUgMobileMoney() {
120+
return withUgMobileMoney;
121+
}
122+
115123
public void setWithGHMobileMoney(boolean withGHMobileMoney) {
116124
this.withGHMobileMoney = withGHMobileMoney;
117125
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class RavePayManager {
3434
boolean withAch = false;
3535
boolean withMpesa = false;
3636
boolean withGHMobileMoney = false;
37+
boolean withUgMobileMoney = false;
3738
private int theme = R.style.DefaultTheme;
3839
boolean staging = true;
3940
boolean allowSaveCard = true;
@@ -83,6 +84,11 @@ public RavePayManager acceptGHMobileMoneyPayments(boolean withGHMobileMoney) {
8384
return this;
8485
}
8586

87+
public RavePayManager acceptUgMobileMoneyPayments(boolean withUgMobileMoney) {
88+
this.withUgMobileMoney = withUgMobileMoney;
89+
return this;
90+
}
91+
8692
public RavePayManager isPreAuth(boolean isPreAuth){
8793
this.isPreAuth = isPreAuth;
8894
return this;
@@ -169,6 +175,10 @@ public void initialize() {
169175
}
170176

171177
public RavePayInitializer createRavePayInitializer() {
172-
return new RavePayInitializer(email, amount, publicKey, encryptionKey, txRef, narration, currency, country, fName, lName, withCard, withAccount, withMpesa, withGHMobileMoney, withAch, theme, staging, meta, subAccounts, payment_plan, isPreAuth);
178+
return new RavePayInitializer(email, amount, publicKey, encryptionKey, txRef, narration,
179+
currency, country, fName, lName, withCard, withAccount, withMpesa,
180+
withGHMobileMoney, withUgMobileMoney, withAch, theme, staging, meta, subAccounts,
181+
payment_plan,
182+
isPreAuth);
173183
}
174184
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.flutterwave.raveandroid.ugmobilemoney;
2+
3+
import com.flutterwave.raveandroid.Payload;
4+
5+
/**
6+
* Created by Jeremiah on 28/06/2018.
7+
*/
8+
9+
public interface UgMobileMoneyContract {
10+
11+
interface View {
12+
void showProgressIndicator(boolean active);
13+
void showPollingIndicator(boolean active);
14+
void onPollingRoundComplete(String flwRef, String txRef, String publicKey);
15+
void onPaymentError(String message);
16+
void showToast(String message);
17+
void onPaymentSuccessful(String status, String flwRef, String responseAsString);
18+
void displayFee(String charge_amount, Payload payload);
19+
void showFetchFeeFailed(String s);
20+
void onPaymentFailed(String message, String responseAsJSONString);
21+
}
22+
23+
interface UserActionsListener {
24+
void fetchFee(Payload payload);
25+
void chargeUgMobileMoney(Payload payload, String encryptionKey);
26+
void requeryTx(String flwRef, String txRef, String publicKey);
27+
}
28+
}

0 commit comments

Comments
 (0)