Skip to content

Commit 76abacb

Browse files
committed
complete merge (bolaware-staging-label)
2 parents bfe9400 + 125e69d commit 76abacb

File tree

7 files changed

+98
-48
lines changed

7 files changed

+98
-48
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Set the public key, encryption key and other required parameters. The `RavePayMa
7070
.isPreAuth(boolean)
7171
.setSubAccounts(List<SubAccount>)
7272
.shouldDisplayFee(boolean)
73+
.showStagingLabel(boolean)
7374
.initialize();
7475

7576
| function | parameter | type | required |
@@ -97,6 +98,7 @@ Set the public key, encryption key and other required parameters. The `RavePayMa
9798
| withTheme(styleId) | Sets the theme of the UI. | `int` | Not Required
9899
| setPaymentPlan(payment_plan) | If you want to do recurrent payment, this is the payment plan ID to use for the recurring payment, you can see how to create payment plans [here](https://flutterwavedevelopers.readme.io/v2.0/reference#create-payment-plan) and [here](https://flutterwavedevelopers.readme.io/docs/recurring-billing). This is only available for card payments | `String` | Not Required
99100
| shouldDisplayFee(boolean) | Set to `false` to not display a dialog for confirming total amount(including charge fee) that Rave will charge. By default this is set to `true` | `boolean` | Not Required
101+
| showStagingLabel(boolean) | Set to `false` to not display a staging label when in staging environment. By default this is set to `true` | `boolean` | Not Required
100102
| initialize() | Launch the Rave Payment UI | N/A | Required
101103

102104
### 2. Handle the response

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class MainActivity extends AppCompatActivity {
5050
SwitchCompat accountAchSwitch;
5151
SwitchCompat addSubAccountsSwitch;
5252
SwitchCompat isPreAuthSwitch;
53+
SwitchCompat shouldShowStagingLabelSwitch;
5354
List<Meta> meta = new ArrayList<>();
5455
List<SubAccount> subAccounts = new ArrayList<>();
5556
LinearLayout addSubaccountsLayout;
@@ -80,6 +81,7 @@ protected void onCreate(Bundle savedInstanceState) {
8081
ugMobileMoneySwitch = findViewById(R.id.accountUgMobileMoneySwitch);
8182
isLiveSwitch = findViewById(R.id.isLiveSwitch);
8283
addSubAccountsSwitch = findViewById(R.id.addSubAccountsSwitch);
84+
shouldShowStagingLabelSwitch = findViewById(R.id.shouldShowStagingLabelSwitch);
8385
addVendorBtn = findViewById(R.id.addVendorBtn);
8486
clearVendorBtn = findViewById(R.id.clearVendorsBtn);
8587
vendorListTXT = findViewById(R.id.refIdsTV);
@@ -202,6 +204,7 @@ private void validateEntries() {
202204
.onStagingEnv(!isLiveSwitch.isChecked())
203205
.setSubAccounts(subAccounts)
204206
.isPreAuth(isPreAuthSwitch.isChecked())
207+
.showStagingLabel(shouldShowStagingLabelSwitch.isChecked())
205208
// .setMeta(meta)
206209
// .withTheme(R.style.TestNewTheme)
207210
.initialize();

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
android:id="@+id/isDisplayFeeSwitch"
5858
/>
5959

60+
<android.support.v7.widget.SwitchCompat
61+
android:layout_width="match_parent"
62+
android:layout_height="wrap_content"
63+
android:layout_marginBottom="10dp"
64+
android:text="Show Staging Label"
65+
android:checked="true"
66+
android:id="@+id/shouldShowStagingLabelSwitch"
67+
/>
68+
69+
6070
<android.support.v7.widget.SwitchCompat
6171
android:layout_width="match_parent"
6272
android:layout_height="wrap_content"

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ protected void onCreate(Bundle savedInstanceState) {
7979

8080
if (ravePayInitializer.isStaging()) {
8181
BASE_URL = RaveConstants.STAGING_URL;
82+
if(ravePayInitializer.getShowStagingLabel()){
83+
findViewById(R.id.stagingModeBannerLay).setVisibility(View.VISIBLE);
84+
}
8285
}
8386
else {
8487
BASE_URL = RaveConstants.LIVE_URL;

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class RavePayInitializer {
3333
boolean staging = true;
3434
boolean isPreAuth = false;
3535
boolean displayFee = true;
36+
boolean showStagingLabel;
3637

3738
public RavePayInitializer(String email, double amount, String publicKey,
3839
String encryptionKey, String txRef, String narration,
@@ -41,7 +42,8 @@ public RavePayInitializer(String email, double amount, String publicKey,
4142
boolean withAccount, boolean withMpesa, boolean withGHMobileMoney,
4243
boolean withUgMobileMoney,
4344
boolean withAch, int theme,
44-
boolean staging, String meta, String subAccounts, String payment_plan, boolean isPreAuth) {
45+
boolean staging, String meta, String subAccounts, String payment_plan, boolean isPreAuth,
46+
boolean showStagingLabel) {
4547
this.email = email;
4648
this.amount = amount;
4749
this.publicKey = publicKey;
@@ -64,11 +66,20 @@ public RavePayInitializer(String email, double amount, String publicKey,
6466
this.subAccounts = subAccounts;
6567
this.payment_plan = payment_plan;
6668
this.isPreAuth = isPreAuth;
69+
this.showStagingLabel = showStagingLabel;
6770
}
6871

6972
public RavePayInitializer() {
7073
}
7174

75+
public boolean getShowStagingLabel() {
76+
return showStagingLabel;
77+
}
78+
79+
public void showStagingLabel(boolean showStagingLabel) {
80+
this.showStagingLabel = showStagingLabel;
81+
}
82+
7283
public boolean isWithMpesa() {
7384
return withMpesa;
7485
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class RavePayManager {
3939
boolean staging = true;
4040
boolean allowSaveCard = true;
4141
boolean isPreAuth = false;
42+
boolean showStagingLabel = true;
4243

4344
public RavePayManager allowSaveCardFeature(boolean allowSaveCard) {
4445
this.allowSaveCard = allowSaveCard;
@@ -104,6 +105,11 @@ public RavePayManager setSubAccounts(List<SubAccount> subAccounts){
104105
return this;
105106
}
106107

108+
public RavePayManager showStagingLabel(Boolean showStagingLabel){
109+
this.showStagingLabel = showStagingLabel;
110+
return this;
111+
}
112+
107113

108114
public RavePayManager setEmail(String email) {
109115
this.email = email;
@@ -179,6 +185,6 @@ public RavePayInitializer createRavePayInitializer() {
179185
currency, country, fName, lName, withCard, withAccount, withMpesa,
180186
withGHMobileMoney, withUgMobileMoney, withAch, theme, staging, meta, subAccounts,
181187
payment_plan,
182-
isPreAuth);
188+
isPreAuth, showStagingLabel);
183189
}
184190
}
Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,65 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:tools="http://schemas.android.com/tools"
5-
android:layout_width="match_parent"
6-
android:layout_height="match_parent"
7-
tools:context="com.flutterwave.raveandroid.RavePayActivity">
8-
9-
<include
10-
android:id="@+id/main_content"
11-
layout="@layout/content_rave_pay" />
12-
13-
<RelativeLayout
2+
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
144
android:layout_width="match_parent"
15-
android:gravity="center"
16-
android:clickable="true"
17-
android:background="#fff"
18-
android:id="@+id/rave_permission_required_layout"
19-
android:visibility="gone"
20-
android:padding="30dp"
21-
android:layout_height="match_parent">
22-
23-
24-
<TextView
25-
android:layout_width="wrap_content"
26-
android:layout_height="wrap_content"
27-
android:id="@+id/textView"
28-
android:layout_centerHorizontal="true"
29-
android:textSize="14sp"
30-
android:gravity="center_horizontal"
31-
android:layout_marginBottom="7dp"
32-
android:text="@string/permissions_are_required_to_complete_payment"
33-
/>
34-
35-
<Button
36-
android:layout_width="wrap_content"
37-
android:layout_height="wrap_content"
38-
style="@style/Base.Widget.AppCompat.Button.Borderless"
39-
android:textSize="12sp"
40-
android:layout_below="@id/textView"
41-
android:textColor="#009688"
42-
android:textStyle="bold"
43-
android:layout_centerHorizontal="true"
44-
android:id="@+id/requestPermsBtn"
45-
android:text="@string/grant_permission"
46-
/>
47-
48-
</RelativeLayout>
5+
android:layout_height="match_parent"
6+
tools:context="com.flutterwave.raveandroid.RavePayActivity">
7+
8+
<include
9+
android:id="@+id/main_content"
10+
layout="@layout/content_rave_pay" />
11+
12+
<RelativeLayout
13+
android:id="@+id/rave_permission_required_layout"
14+
android:layout_width="match_parent"
15+
android:layout_height="match_parent"
16+
android:background="#fff"
17+
android:clickable="true"
18+
android:gravity="center"
19+
android:padding="30dp"
20+
android:visibility="gone">
21+
22+
23+
<TextView
24+
android:id="@+id/textView"
25+
android:layout_width="wrap_content"
26+
android:layout_height="wrap_content"
27+
android:layout_centerHorizontal="true"
28+
android:layout_marginBottom="7dp"
29+
android:gravity="center_horizontal"
30+
android:text="@string/permissions_are_required_to_complete_payment"
31+
android:textSize="14sp" />
32+
33+
<Button
34+
android:id="@+id/requestPermsBtn"
35+
style="@style/Base.Widget.AppCompat.Button.Borderless"
36+
android:layout_width="wrap_content"
37+
android:layout_height="wrap_content"
38+
android:layout_below="@id/textView"
39+
android:layout_centerHorizontal="true"
40+
android:text="@string/grant_permission"
41+
android:textColor="#009688"
42+
android:textSize="12sp"
43+
android:textStyle="bold" />
44+
45+
</RelativeLayout>
46+
47+
<RelativeLayout
48+
android:id="@+id/stagingModeBannerLay"
49+
android:layout_width="match_parent"
50+
android:layout_height="match_parent"
51+
android:visibility="gone"
52+
android:gravity="bottom">
53+
54+
<TextView
55+
android:layout_width="match_parent"
56+
android:layout_height="wrap_content"
57+
android:layout_centerInParent="true"
58+
android:background="@android:color/holo_red_dark"
59+
android:gravity="center"
60+
android:text="You are currently on staging mode"
61+
android:textColor="@android:color/white" />
62+
63+
</RelativeLayout>
4964

5065
</android.support.design.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)