Skip to content

Commit 2ba98d1

Browse files
committed
Add Pay with Bank Transfer
1 parent 5a7c9db commit 2ba98d1

23 files changed

+1002
-22
lines changed

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ android {
1414
release {
1515
minifyEnabled false
1616
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
// proguardFiles "$rootProject.rootDir.absolutePath/raveandroid/proguard-rules.pro"
18+
19+
1720
}
1821
}
1922
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class MainActivity extends AppCompatActivity {
4545
SwitchCompat accountSwitch;
4646
SwitchCompat ghMobileMoneySwitch;
4747
SwitchCompat ugMobileMoneySwitch;
48+
SwitchCompat bankTransferSwitch;
4849
SwitchCompat isLiveSwitch;
4950
SwitchCompat isMpesaSwitch;
5051
SwitchCompat accountAchSwitch;
@@ -81,6 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
8182
shouldDisplayFeeSwitch = findViewById(R.id.isDisplayFeeSwitch);
8283
ghMobileMoneySwitch = findViewById(R.id.accountGHMobileMoneySwitch);
8384
ugMobileMoneySwitch = findViewById(R.id.accountUgMobileMoneySwitch);
85+
bankTransferSwitch = findViewById(R.id.bankTransferSwitch);
8486
isLiveSwitch = findViewById(R.id.isLiveSwitch);
8587
addSubAccountsSwitch = findViewById(R.id.addSubAccountsSwitch);
8688
shouldShowStagingLabelSwitch = findViewById(R.id.shouldShowStagingLabelSwitch);
@@ -127,6 +129,7 @@ public void onClick(View view) {
127129
clear();
128130
}
129131
});
132+
130133
}
131134

132135
private void clear(){
@@ -203,6 +206,7 @@ private void validateEntries() {
203206
.acceptAchPayments(accountAchSwitch.isChecked())
204207
.acceptGHMobileMoneyPayments(ghMobileMoneySwitch.isChecked())
205208
.acceptUgMobileMoneyPayments(ugMobileMoneySwitch.isChecked())
209+
.acceptBankTransferPayments(bankTransferSwitch.isChecked())
206210
.onStagingEnv(!isLiveSwitch.isChecked())
207211
.setSubAccounts(subAccounts)
208212
.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
@@ -94,6 +94,15 @@
9494
android:id="@+id/accountUgMobileMoneySwitch"
9595
/>
9696

97+
<android.support.v7.widget.SwitchCompat
98+
android:layout_width="match_parent"
99+
android:layout_height="wrap_content"
100+
android:layout_marginBottom="10dp"
101+
android:text="Accept Bank Transfer Payments"
102+
android:checked="false"
103+
android:id="@+id/bankTransferSwitch"
104+
/>
105+
97106
<android.support.v7.widget.SwitchCompat
98107
android:layout_width="match_parent"
99108
android:layout_height="wrap_content"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ public Payload(List<Meta> meta, List<SubAccount> subaccounts, String narration,
254254

255255
}
256256

257+
258+
257259
public String getToken() {
258260
return token;
259261
}
@@ -608,5 +610,11 @@ public boolean isIs_us_bank_charge() {
608610
public void setIs_us_bank_charge(boolean is_us_bank_charge) {
609611
this.is_us_bank_charge = is_us_bank_charge;
610612
}
613+
614+
public boolean is_bank_transfer;
615+
616+
public void setIs_bank_transfer(boolean is_bank_transfer) {
617+
this.is_bank_transfer = is_bank_transfer;
618+
}
611619
}
612620

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class PayloadBuilder {
2424
private String voucher;
2525
private boolean isPreAuth = false;
2626
private boolean is_us_bank_charge = false;
27+
private boolean is_bank_transfer= false;
2728

2829
public PayloadBuilder setIs_mobile_money_gh(String is_mobile_money_gh) {
2930
this.is_mobile_money_gh = is_mobile_money_gh;
@@ -35,6 +36,12 @@ public PayloadBuilder setIs_mobile_money_ug(String is_mobile_money_ug) {
3536
return this;
3637
}
3738

39+
public PayloadBuilder setIs_bank_transfer(boolean is_bank_transfer) {
40+
this.is_bank_transfer = is_bank_transfer;
41+
return this;
42+
}
43+
44+
3845
private String is_mobile_money_gh;
3946
private String is_mobile_money_ug;
4047

@@ -202,6 +209,17 @@ public Payload createBankPayload() {
202209
return payload;
203210
}
204211

212+
public Payload createBankTransferPayload() {
213+
List<Meta> metaObj = Utils.pojofyMetaString(meta);
214+
List<SubAccount> subaccountsObj = Utils.pojofySubaccountString(subAccounts);
215+
Payload payload = new Payload(phonenumber, metaObj, subaccountsObj, narration, ip, lastname,
216+
firstname, currency, country, amount, email, device_fingerprint, txRef, pbfPubKey);
217+
payload.setIs_bank_transfer(true);
218+
payload.setPayment_type("banktransfer");
219+
payload.setNetwork(network);
220+
return payload;
221+
}
222+
205223
public Payload createMpesaPayload() {
206224
List<Meta> metaObj = Utils.pojofyMetaString(meta);
207225
List<SubAccount> subaccountsObj = Utils.pojofySubaccountString(subAccounts);
@@ -236,6 +254,8 @@ public Payload createUgMobileMoneyPayload() {
236254
return payload;
237255
}
238256

257+
258+
239259
public PayloadBuilder setMeta(String meta) {
240260
this.meta = meta;
241261
return this;
@@ -255,4 +275,6 @@ public PayloadBuilder setNetwork(String network) {
255275
this.network = network;
256276
return this;
257277
}
278+
279+
258280
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ public class RaveConstants {
1212
public static String PUBLIC_KEY = "FLWPUBK-e634d14d9ded04eaf05d5b63a0a06d2f-X"; //test
1313
// public static String ENCRYPTION_KEY = "FLWSECK-bb971402072265fb156e90a3578fe5e6-X"; //test
1414
public static String ENCRYPTION_KEY = "bb9714020722eb4cf7a169f2";
15-
public static String STAGING_URL = "https://ravesandbox.azurewebsites.net";
16-
public static String LIVE_URL = "https://raveapi.azurewebsites.net";
15+
// public static String STAGING_URL = "https://ravesandbox.azurewebsites.net";
16+
// public static String LIVE_URL = "https://raveapi.azurewebsites.net";
17+
//Todo: change back BAse URL
18+
public static String STAGING_URL = "https://ravesandboxapi.flutterwave.com";
19+
public static String LIVE_URL = "https://api.ravepay.co";
1720
public static String VBV = "VBVSECURECODE";
1821
public static String GTB_OTP = "GTB_OTP";
1922
public static String ACCESS_OTP = "ACCESS_OTP";

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,19 @@
55
import android.content.Intent;
66
import android.content.pm.PackageManager;
77
import android.os.Build;
8-
import android.provider.SyncStateContract;
98
import android.support.annotation.NonNull;
10-
import android.support.design.widget.BottomSheetBehavior;
119
import android.support.design.widget.TabLayout;
1210
import android.support.v4.view.ViewPager;
1311
import android.support.v7.app.AppCompatActivity;
1412
import android.os.Bundle;
1513
import android.util.Log;
16-
import android.view.Menu;
17-
import android.view.MenuItem;
1814
import android.view.View;
1915
import android.widget.Button;
2016
import android.widget.RelativeLayout;
2117

2218
import com.flutterwave.raveandroid.account.AccountFragment;
2319
import com.flutterwave.raveandroid.ach.AchFragment;
20+
import com.flutterwave.raveandroid.banktransfer.BankTransferFragment;
2421
import com.flutterwave.raveandroid.card.CardFragment;
2522
import com.flutterwave.raveandroid.ghmobilemoney.GhMobileMoneyFragment;
2623
import com.flutterwave.raveandroid.mpesa.MpesaFragment;
@@ -121,6 +118,12 @@ else if (ravePayInitializer.getCountry().equalsIgnoreCase("ng") && ravePayInitia
121118
raveFragments.add(new RaveFragment(new UgMobileMoneyFragment(), "UGANDA MOBILE MONEY"));
122119
}
123120

121+
if (ravePayInitializer.isWithBankTransfer()) {
122+
if (ravePayInitializer.getCountry().equalsIgnoreCase("ng") && ravePayInitializer.getCurrency().equalsIgnoreCase("ngn")){
123+
raveFragments.add(new RaveFragment(new BankTransferFragment(), "Pay with Bank Transfer"));
124+
}
125+
}
126+
124127
mainPagerAdapter.setFragments(raveFragments);
125128
pager.setAdapter(mainPagerAdapter);
126129

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class RavePayInitializer {
2929
boolean withAccount = true;
3030
boolean withGHMobileMoney = false;
3131
boolean withUgMobileMoney = false;
32+
boolean withBankTransfer = false;
3233
int theme;
3334
boolean staging = true;
3435
boolean isPreAuth = false;
@@ -41,7 +42,7 @@ public RavePayInitializer(String email, double amount, String publicKey,
4142
String lName, boolean withCard,
4243
boolean withAccount, boolean withMpesa, boolean withGHMobileMoney,
4344
boolean withUgMobileMoney,
44-
boolean withAch, int theme,
45+
boolean withAch, boolean withBankTransfer, int theme,
4546
boolean staging, String meta, String subAccounts, String payment_plan, boolean isPreAuth,
4647
boolean showStagingLabel, boolean displayFee) {
4748
this.email = email;
@@ -57,6 +58,7 @@ public RavePayInitializer(String email, double amount, String publicKey,
5758
this.withAccount = withAccount;
5859
this.withGHMobileMoney = withGHMobileMoney;
5960
this.withUgMobileMoney = withUgMobileMoney;
61+
this.withBankTransfer = withBankTransfer;
6062
this.withMpesa = withMpesa;
6163
this.withCard = withCard;
6264
this.withAch = withAch;
@@ -133,6 +135,11 @@ public boolean isWithUgMobileMoney() {
133135
return withUgMobileMoney;
134136
}
135137

138+
139+
public boolean isWithBankTransfer() {
140+
return withBankTransfer;
141+
}
142+
136143
public void setWithGHMobileMoney(boolean withGHMobileMoney) {
137144
this.withGHMobileMoney = withGHMobileMoney;
138145
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class RavePayManager {
3535
boolean withMpesa = false;
3636
boolean withGHMobileMoney = false;
3737
boolean withUgMobileMoney = false;
38+
boolean withBankTransfer = false;
3839
private int theme = R.style.DefaultTheme;
3940
boolean staging = true;
4041
boolean allowSaveCard = true;
@@ -91,6 +92,11 @@ public RavePayManager acceptUgMobileMoneyPayments(boolean withUgMobileMoney) {
9192
return this;
9293
}
9394

95+
public RavePayManager acceptBankTransferPayments(boolean withBankTransfer) {
96+
this.withBankTransfer = withBankTransfer;
97+
return this;
98+
}
99+
94100
public RavePayManager isPreAuth(boolean isPreAuth){
95101
this.isPreAuth = isPreAuth;
96102
return this;
@@ -189,7 +195,7 @@ public RavePayManager shouldDisplayFee(Boolean displayFee){
189195
public RavePayInitializer createRavePayInitializer() {
190196
return new RavePayInitializer(email, amount, publicKey, encryptionKey, txRef, narration,
191197
currency, country, fName, lName, withCard, withAccount, withMpesa,
192-
withGHMobileMoney, withUgMobileMoney, withAch, theme, staging, meta, subAccounts,
198+
withGHMobileMoney, withUgMobileMoney, withAch, withBankTransfer, theme, staging, meta, subAccounts,
193199
payment_plan,
194200
isPreAuth, showStagingLabel,displayFee);
195201
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.flutterwave.raveandroid.banktransfer;
2+
3+
import com.flutterwave.raveandroid.Payload;
4+
import com.flutterwave.raveandroid.responses.ChargeResponse;
5+
6+
7+
public interface BankTransferContract {
8+
9+
interface View {
10+
void showProgressIndicator(boolean active);
11+
void showPollingIndicator(boolean active);
12+
void onPollingRoundComplete(String flwRef, String txRef, String encryptionKey);
13+
void onPaymentError(String message);
14+
void showToast(String message);
15+
void onPaymentSuccessful(String status, String flwRef, String responseAsString);
16+
void displayFee(String charge_amount, Payload payload);
17+
void showFetchFeeFailed(String s);
18+
void onPaymentFailed(String message, String responseAsJSONString);
19+
void onTransferDetailsReceived(ChargeResponse response);
20+
void onPollingTimeout(String flwRef, String txRef, String responseAsJSONString);
21+
}
22+
23+
interface UserActionsListener {
24+
void fetchFee(Payload payload);
25+
void requeryTx(String flwRef, String txRef, String publicKey);
26+
void payWithBankTransfer(Payload body, String encryptionKey);
27+
void setRequeryCountdownTime(long currentTimeMillis);
28+
}
29+
}

0 commit comments

Comments
 (0)