Skip to content

Commit d301086

Browse files
committed
complete merge
2 parents baebb98 + 08eeb6a commit d301086

29 files changed

+1489
-27
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies {
2424
exclude group: 'com.android.support', module: 'support-annotations'
2525
})
2626
compile 'com.android.support:appcompat-v7:27.0.2'
27-
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
27+
compile 'com.android.support.constraint:constraint-layout:1.1.2'
2828
testCompile 'junit:junit:4.12'
2929
compile project(':raveandroid')
3030
}

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,32 @@ public class MainActivity extends AppCompatActivity {
3535
Button startPayBtn;
3636
SwitchCompat cardSwitch;
3737
SwitchCompat accountSwitch;
38+
SwitchCompat ghMobileMoneySwitch;
3839
SwitchCompat isLiveSwitch;
40+
SwitchCompat isMpesaSwitch;
3941
List<Meta> meta = new ArrayList<>();
4042

4143
@Override
4244
protected void onCreate(Bundle savedInstanceState) {
4345
super.onCreate(savedInstanceState);
4446
setContentView(R.layout.activity_main);
4547

46-
emailEt = (EditText) findViewById(R.id.emailEt);
47-
amountEt = (EditText) findViewById(R.id.amountEt);
48-
publicKeyEt = (EditText) findViewById(R.id.publicKeyEt);
49-
secretKeyEt = (EditText) findViewById(R.id.secretKeyEt);
50-
txRefEt = (EditText) findViewById(R.id.txRefEt);
51-
narrationEt = (EditText) findViewById(R.id.narrationTV);
52-
currencyEt = (EditText) findViewById(R.id.currencyEt);
53-
countryEt = (EditText) findViewById(R.id.countryEt);
54-
fNameEt = (EditText) findViewById(R.id.fNameEt);
55-
lNameEt = (EditText) findViewById(R.id.lnameEt);
56-
startPayBtn = (Button) findViewById(R.id.startPaymentBtn);
57-
cardSwitch = (SwitchCompat) findViewById(R.id.cardPaymentSwitch);
58-
accountSwitch = (SwitchCompat) findViewById(R.id.accountPaymentSwitch);
59-
isLiveSwitch = (SwitchCompat) findViewById(R.id.isLiveSwitch);
48+
emailEt = findViewById(R.id.emailEt);
49+
amountEt = findViewById(R.id.amountEt);
50+
publicKeyEt = findViewById(R.id.publicKeyEt);
51+
secretKeyEt = findViewById(R.id.secretKeyEt);
52+
txRefEt = findViewById(R.id.txRefEt);
53+
narrationEt = findViewById(R.id.narrationTV);
54+
currencyEt = findViewById(R.id.currencyEt);
55+
countryEt = findViewById(R.id.countryEt);
56+
fNameEt = findViewById(R.id.fNameEt);
57+
lNameEt = findViewById(R.id.lnameEt);
58+
startPayBtn = findViewById(R.id.startPaymentBtn);
59+
cardSwitch = findViewById(R.id.cardPaymentSwitch);
60+
accountSwitch = findViewById(R.id.accountPaymentSwitch);
61+
isMpesaSwitch = findViewById(R.id.accountMpesaSwitch);
62+
ghMobileMoneySwitch = findViewById(R.id.accountGHMobileMoneySwitch);
63+
isLiveSwitch = findViewById(R.id.isLiveSwitch);
6064

6165
publicKeyEt.setText(RaveConstants.PUBLIC_KEY);
6266
secretKeyEt.setText(RaveConstants.PRIVATE_KEY);
@@ -135,10 +139,12 @@ private void validateEntries() {
135139
.setPublicKey(publicKey)
136140
.setSecretKey(secretKey)
137141
.setTxRef(txRef)
142+
.acceptMpesaPayments(isMpesaSwitch.isChecked())
138143
.acceptAccountPayments(accountSwitch.isChecked())
139144
.acceptCardPayments(cardSwitch.isChecked())
145+
.acceptGHMobileMoneyPayments(ghMobileMoneySwitch.isChecked())
140146
.onStagingEnv(!isLiveSwitch.isChecked())
141-
.setMeta(meta)
147+
// .setMeta(meta)
142148
// .withTheme(R.style.TestNewTheme)
143149
.initialize();
144150

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@
3838
android:id="@+id/accountPaymentSwitch"
3939
/>
4040

41+
42+
<android.support.v7.widget.SwitchCompat
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:layout_marginBottom="10dp"
46+
android:text="Accept Mpesa payments"
47+
android:checked="true"
48+
android:id="@+id/accountMpesaSwitch"
49+
/>
50+
51+
<android.support.v7.widget.SwitchCompat
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"
54+
android:layout_marginBottom="10dp"
55+
android:text="Accept GH Mobile money payments"
56+
android:checked="false"
57+
android:id="@+id/accountGHMobileMoneySwitch"
58+
/>
59+
4160
<android.support.v7.widget.SwitchCompat
4261
android:layout_width="match_parent"
4362
android:layout_height="wrap_content"

raveandroid/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ dependencies {
2828
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2929
exclude group: 'com.android.support', module: 'support-annotations'
3030
})
31-
compile 'com.android.support:appcompat-v7:25.3.1'
32-
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'
33-
compile 'com.android.support:design:25.3.1'
34-
compile 'com.android.support:support-v4:25.3.1'
31+
compile 'com.android.support:appcompat-v7:25.4.0'
32+
compile 'com.android.support:design:25.4.0'
33+
compile 'com.android.support:support-v4:25.4.0'
3534
compile 'com.squareup.picasso:picasso:2.5.2'
36-
compile 'com.squareup.retrofit2:retrofit:2.3.0'
35+
compile 'com.squareup.retrofit2:retrofit:2.4.0'
3736
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
3837
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
3938
compile 'org.parceler:parceler-api:1.1.9'
4039
annotationProcessor 'org.parceler:parceler:1.1.9'
4140
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
4241
compile 'com.scottyab:aescrypt:0.0.1'
4342
testCompile 'junit:junit:4.12'
43+
compile 'com.android.support.constraint:constraint-layout:1.1.2'
4444
}

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

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,31 @@ public String getCardBIN() {
1919

2020
private String payment_plan;
2121

22+
public String getIs_mpesa() {
23+
return is_mpesa;
24+
}
25+
26+
public void setIs_mpesa(String is_mpesa) {
27+
this.is_mpesa = is_mpesa;
28+
}
29+
30+
public String getIs_mpesa_lipa() {
31+
return is_mpesa_lipa;
32+
}
33+
34+
public void setIs_mpesa_lipa(String is_mpesa_lipa) {
35+
this.is_mpesa_lipa = is_mpesa_lipa;
36+
}
37+
38+
private String is_mpesa;
39+
40+
private String is_mpesa_lipa;
41+
2242
public Payload(List<Meta> meta, String narration,
2343
String expirymonth, String PBFPubKey, String IP, String lastname,
2444
String firstname, String currency, String country, String amount,
2545
String email, String expiryyear, String cvv, String device_fingerprint,
2646
String cardno, String txRef) {
27-
this.meta = meta;
2847
this.narration = narration;
2948
this.expirymonth = expirymonth;
3049
this.PBFPubKey = PBFPubKey;
@@ -46,6 +65,8 @@ public Payload(List<Meta> meta, String narration,
4665
}
4766

4867
meta.add(new Meta("sdk", "android"));
68+
this.meta = meta;
69+
4970
}
5071

5172

@@ -90,7 +111,6 @@ public Payload(List<Meta> meta, String narration, String IP, String accountnumbe
90111
String lastname, String firstname, String currency, String country, String amount,
91112
String email, String device_fingerprint, String txRef, String PBFPubKey,
92113
String billingaddress, String billingcity, String billingstate, String billingzip, String billingcountry) {
93-
this.meta = meta;
94114
this.narration = narration;
95115
this.IP = IP;
96116
this.accountnumber = accountnumber;
@@ -115,8 +135,45 @@ public Payload(List<Meta> meta, String narration, String IP, String accountnumbe
115135
}
116136

117137
meta.add(new Meta("sdk", "android"));
138+
this.meta = meta;
139+
118140
}
119141

142+
public Payload(String phonenumber,
143+
List<Meta> meta,
144+
String narration,
145+
String IP,
146+
String lastname,
147+
String firstname,
148+
String currency,
149+
String country,
150+
String amount,
151+
String email,
152+
String device_fingerprint,
153+
String txRef,
154+
String PBFPubKey) {
155+
this.meta = meta;
156+
this.narration = narration;
157+
this.IP = IP;
158+
this.phonenumber = phonenumber;
159+
this.lastname = lastname;
160+
this.firstname = firstname;
161+
this.currency = currency;
162+
this.country = country;
163+
this.amount = amount;
164+
this.email = email;
165+
this.device_fingerprint = device_fingerprint;
166+
this.txRef = txRef;
167+
this.PBFPubKey = PBFPubKey;
168+
169+
if (meta == null) {
170+
meta = new ArrayList<>();
171+
}
172+
173+
meta.add(new Meta("sdk", "android"));
174+
this.meta = meta;
175+
176+
}
120177

121178
public Payload(List<Meta> meta, String narration, String IP, String accountnumber, String accountbank,
122179
String lastname, String firstname, String currency, String country, String amount,
@@ -141,6 +198,8 @@ public Payload(List<Meta> meta, String narration, String IP, String accountnumbe
141198
}
142199

143200
meta.add(new Meta("sdk", "android"));
201+
this.meta = meta;
202+
144203
}
145204

146205
public String getToken() {
@@ -455,5 +514,19 @@ public String toString()
455514
public void setCardBIN(String cardBIN) {
456515
this.cardBIN = cardBIN;
457516
}
517+
518+
public String is_mobile_money_gh;
519+
520+
public void setNetwork(String network) {
521+
this.network = network;
522+
}
523+
524+
public String network;
525+
526+
527+
528+
public void setIs_mobile_money_gh(String is_mobile_money_gh) {
529+
this.is_mobile_money_gh = is_mobile_money_gh;
530+
}
458531
}
459532

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ public class PayloadBuilder {
1717
private String device_fingerprint;
1818
private String cardno;
1919
private String payment_plan;
20+
private String network;
21+
22+
public PayloadBuilder setIs_mobile_money_gh(String is_mobile_money_gh) {
23+
this.is_mobile_money_gh = is_mobile_money_gh;
24+
return this;
25+
}
26+
27+
private String is_mobile_money_gh;
28+
29+
private String phonenumber;
2030

2131
private String txRef;
2232
private String meta = "";
@@ -77,6 +87,11 @@ public PayloadBuilder setCurrency(String currency) {
7787
return this;
7888
}
7989

90+
public PayloadBuilder setPhonenumber(String phonenumber) {
91+
this.phonenumber = phonenumber;
92+
return this;
93+
}
94+
8095
public PayloadBuilder setCountry(String country) {
8196
this.country = country;
8297
return this;
@@ -148,6 +163,26 @@ public Payload createBankPayload() {
148163
return payload;
149164
}
150165

166+
public Payload createMpesaPayload() {
167+
List<Meta> metaObj = Utils.pojofyMetaString(meta);
168+
Payload payload = new Payload(phonenumber, metaObj, narration, ip, lastname,
169+
firstname, currency, country, amount, email, device_fingerprint, txRef, pbfPubKey);
170+
payload.setPayment_type("mpesa");
171+
payload.setIs_mpesa("1");
172+
payload.setIs_mpesa_lipa("1");
173+
return payload;
174+
}
175+
176+
public Payload createGhMobileMoneyPayload() {
177+
List<Meta> metaObj = Utils.pojofyMetaString(meta);
178+
Payload payload = new Payload(phonenumber, metaObj, narration, ip, lastname,
179+
firstname, currency, country, amount, email, device_fingerprint, txRef, pbfPubKey);
180+
payload.setIs_mobile_money_gh("1");
181+
payload.setPayment_type("mobilemoneygh");
182+
payload.setNetwork(network);
183+
return payload;
184+
}
185+
151186
public PayloadBuilder setMeta(String meta) {
152187
this.meta = meta;
153188
return this;
@@ -158,4 +193,8 @@ public PayloadBuilder setNarration(String narration) {
158193
return this;
159194
}
160195

196+
public PayloadBuilder setNetwork(String network) {
197+
this.network = network;
198+
return this;
199+
}
161200
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import com.flutterwave.raveandroid.account.AccountFragment;
2323
import com.flutterwave.raveandroid.card.CardFragment;
24+
import com.flutterwave.raveandroid.ghmobilemoney.GhMobileMoneyFragment;
25+
import com.flutterwave.raveandroid.mpesa.MpesaFragment;
2426

2527
import org.parceler.Parcels;
2628

@@ -98,6 +100,14 @@ protected void onCreate(Bundle savedInstanceState) {
98100
raveFragments.add(new RaveFragment(new AccountFragment(), "Account"));
99101
}
100102

103+
if (ravePayInitializer.isWithMpesa()) {
104+
raveFragments.add(new RaveFragment(new MpesaFragment(), "Mpesa"));
105+
}
106+
107+
if (ravePayInitializer.isWithGHMobileMoney()) {
108+
raveFragments.add(new RaveFragment(new GhMobileMoneyFragment(), "MOBILE MONEY"));
109+
}
110+
101111
mainPagerAdapter.setFragments(raveFragments);
102112
pager.setAdapter(mainPagerAdapter);
103113

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public class RavePayInitializer {
2222
String lName;
2323
String meta;
2424
String payment_plan;
25+
boolean withMpesa = false;
2526
boolean withCard = true;
2627
boolean withAccount = true;
28+
boolean withGHMobileMoney = false;
2729
int theme;
2830
boolean allowSaveCard;
2931
boolean staging = true;
@@ -32,7 +34,7 @@ public RavePayInitializer(String email, double amount, String publicKey,
3234
String secretKey, String txRef, String narration,
3335
String currency, String country, String fName,
3436
String lName, boolean withCard,
35-
boolean withAccount, int theme,
37+
boolean withAccount, boolean withMpesa, boolean withGHMobileMoney, int theme,
3638
boolean staging, boolean allowSaveCard, String meta, String payment_plan) {
3739
this.email = email;
3840
this.amount = amount;
@@ -45,6 +47,8 @@ public RavePayInitializer(String email, double amount, String publicKey,
4547
this.fName = fName;
4648
this.lName = lName;
4749
this.withAccount = withAccount;
50+
this.withGHMobileMoney = withGHMobileMoney;
51+
this.withMpesa = withMpesa;
4852
this.withCard = withCard;
4953
this.theme = theme;
5054
this.staging = staging;
@@ -56,6 +60,14 @@ public RavePayInitializer(String email, double amount, String publicKey,
5660
public RavePayInitializer() {
5761
}
5862

63+
public boolean isWithMpesa() {
64+
return withMpesa;
65+
}
66+
67+
public void setWithMpesa(boolean withMpesa) {
68+
this.withMpesa = withMpesa;
69+
}
70+
5971
public String getMeta() {
6072
return meta;
6173
}
@@ -96,6 +108,14 @@ public void setWithAccount(boolean withAccount) {
96108
this.withAccount = withAccount;
97109
}
98110

111+
public boolean isWithGHMobileMoney() {
112+
return withGHMobileMoney;
113+
}
114+
115+
public void setWithGHMobileMoney(boolean withGHMobileMoney) {
116+
this.withGHMobileMoney = withGHMobileMoney;
117+
}
118+
99119
public boolean isWithCard() {
100120
return withCard;
101121
}

0 commit comments

Comments
 (0)