Skip to content

Commit f0daea7

Browse files
authored
Merge pull request #1 from Flutterwave/master
Update with master
2 parents d5adbf1 + dec38c3 commit f0daea7

File tree

10 files changed

+56
-17
lines changed

10 files changed

+56
-17
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The minimum supported SDK version is 15
2828
**Step 2.** Add the dependency
2929

3030
dependencies {
31-
implementation 'com.github.Flutterwave:rave-android:1.0.32'
31+
implementation 'com.github.Flutterwave:rave-android:1.0.33'
3232
}
3333

3434
**Step 3.** Add the required permission
@@ -69,6 +69,7 @@ Set the public key, encryption key and other required parameters. The `RavePayMa
6969
.withTheme(styleId)
7070
.isPreAuth(boolean)
7171
.setSubAccounts(List<SubAccount>)
72+
.shouldDisplayFee(boolean)
7273
.initialize();
7374

7475
| function | parameter | type | required |
@@ -80,8 +81,8 @@ Set the public key, encryption key and other required parameters. The `RavePayMa
8081
| setlName(lName) | This is the last name of the card holder or the customer | `String` | Required
8182
| setEmail(email) | This is the email address of the customer | `String` | Required
8283
| setNarration(narration) | This is a custom description added by the merchant | `String` | Not Required
83-
| setPublicKey(publicKey) | Merchant's public key. | `String` | Required
84-
| setEncryptionKey(encryptionKey) | Merchant's encryption key | `String` | Required
84+
| setPublicKey(publicKey) | Merchant's public key. Get your merchant keys here for [ staging](https://flutterwavedevelopers.readme.io/blog/how-to-get-your-staging-keys-from-the-rave-sandbox-environment) and [live](https://flutterwavedevelopers.readme.io/blog/how-to-get-your-live-keys-from-the-rave-dashboard)| `String` | Required
85+
| setEncryptionKey(encryptionKey) | Merchant's encryption key. Get your merchant keys here for [ staging](https://flutterwavedevelopers.readme.io/blog/how-to-get-your-staging-keys-from-the-rave-sandbox-environment) and [live](https://flutterwavedevelopers.readme.io/blog/how-to-get-your-live-keys-from-the-rave-dashboard) | `String` | Required
8586
| setTxRef(txRef) | This is the unique reference, unique to the particular transaction being carried out. It is generated by the merchant for every transaction | `String` | Required
8687
| acceptAccountPayments(boolean) | Set to `true` if you want to accept payments via cards, else set to `false`. | `boolean` | Not Required
8788
| acceptCardPayments(boolean) | Set to `true` if you want to accept payments via bank accounts, else set to `false` | `boolean` | Not Required |
@@ -95,6 +96,7 @@ Set the public key, encryption key and other required parameters. The `RavePayMa
9596
| setIsPreAuth(boolean) | Set to `true` to preauthorise the transaction amount. [Learn more about preauthourization](https://developer.flutterwave.com/v2.0/reference#introduction-1). | `int` | Not Required
9697
| withTheme(styleId) | Sets the theme of the UI. | `int` | Not Required
9798
| 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
99+
| 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
98100
| initialize() | Launch the Rave Payment UI | N/A | Required
99101

100102
### 2. Handle the response

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@
4848
android:id="@+id/accountMpesaSwitch"
4949
/>
5050

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="Should Display Fee"
56+
android:checked="true"
57+
android:id="@+id/isDisplayFeeSwitch"
58+
/>
59+
5160
<android.support.v7.widget.SwitchCompat
5261
android:layout_width="match_parent"
5362
android:layout_height="wrap_content"

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class RavePayInitializer {
3232
int theme;
3333
boolean staging = true;
3434
boolean isPreAuth = false;
35+
boolean displayFee = true;
3536

3637
public RavePayInitializer(String email, double amount, String publicKey,
3738
String encryptionKey, String txRef, String narration,
@@ -53,7 +54,6 @@ public RavePayInitializer(String email, double amount, String publicKey,
5354
this.lName = lName;
5455
this.withAccount = withAccount;
5556
this.withGHMobileMoney = withGHMobileMoney;
56-
this.withUgMobileMoney = withUgMobileMoney;
5757
this.withMpesa = withMpesa;
5858
this.withCard = withCard;
5959
this.withAch = withAch;
@@ -229,4 +229,11 @@ public void setPayment_plan(String payment_plan) {
229229
public void setPreAuth( Boolean isPreAuth){ this.isPreAuth = isPreAuth; }
230230

231231
public boolean getIsPreAuth() { return isPreAuth; }
232+
233+
public boolean getIsDisplayFee() {
234+
return displayFee;
235+
}
236+
public void setIsDisplayFee() {
237+
this.displayFee = displayFee;
238+
}
232239
}

raveandroid/src/main/java/com/flutterwave/raveandroid/account/AccountFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ private void validateDetails() {
269269
showGTBankAmountIssue();
270270
}
271271
else {
272-
presenter.fetchFee(body, selectedBank.isInternetbanking());
272+
if(ravePayInitializer.getIsDisplayFee()){
273+
presenter.fetchFee(body, selectedBank.isInternetbanking());
274+
} else {
275+
presenter.chargeAccount(body, ravePayInitializer.getEncryptionKey(), selectedBank.isInternetbanking());
276+
}
273277
}
274278

275279
}

raveandroid/src/main/java/com/flutterwave/raveandroid/ach/AchContract.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface UserActionsListener {
3333

3434
void onPayButtonClicked(RavePayInitializer ravePayInitializer, String amount);
3535

36-
void chargeAccount(Payload payload, String encryptionKey);
36+
void chargeAccount(Payload payload, String encryptionKey, boolean isDisplayFee);
3737

3838
void verifyRequeryResponse(RequeryResponse response, String responseAsJSONString, RavePayInitializer ravePayInitializer, String flwRef);
3939

raveandroid/src/main/java/com/flutterwave/raveandroid/ach/AchPresenter.java

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

55
import com.flutterwave.raveandroid.Payload;
66
import com.flutterwave.raveandroid.PayloadBuilder;
7-
import com.flutterwave.raveandroid.RaveConstants;
87
import com.flutterwave.raveandroid.RavePayInitializer;
98
import com.flutterwave.raveandroid.Utils;
109
import com.flutterwave.raveandroid.card.ChargeRequestBody;
@@ -15,8 +14,6 @@
1514
import com.flutterwave.raveandroid.responses.ChargeResponse;
1615
import com.flutterwave.raveandroid.responses.RequeryResponse;
1716

18-
import static com.flutterwave.raveandroid.RaveConstants.AVS_VBVSECURECODE;
19-
2017

2118
public class AchPresenter implements AchContract.UserActionsListener {
2219

@@ -112,11 +109,11 @@ private void initiatePayment(RavePayInitializer ravePayInitializer) {
112109

113110
Payload body = builder.createBankPayload();
114111

115-
chargeAccount(body, ravePayInitializer.getEncryptionKey());
112+
chargeAccount(body, ravePayInitializer.getEncryptionKey(), ravePayInitializer.getIsDisplayFee());
116113
}
117114

118115
@Override
119-
public void chargeAccount(Payload payload, String encryptionKey) {
116+
public void chargeAccount(Payload payload, String encryptionKey, final boolean isDisplayFee) {
120117

121118
String requestBodyAsString = Utils.convertChargeRequestPayloadToJson(payload);
122119
String accountRequestBody = Utils.getEncryptedData(requestBodyAsString, encryptionKey);
@@ -143,8 +140,12 @@ public void onSuccess(ChargeResponse response, String responseAsJSONString) {
143140
String currency = response.getData().getCurrency();
144141
sharedMgr.saveFlwRef(flwRef);
145142

146-
mView.showFee(authUrl, flwRef, chargedAmount, currency);
147-
// mView.showWebView(authUrl, flwRef);
143+
if (isDisplayFee) {
144+
mView.showFee(authUrl, flwRef, chargedAmount, currency);
145+
}
146+
else {
147+
mView.showWebView(authUrl, flwRef);
148+
}
148149
}
149150
else {
150151
mView.onPaymentError("No authUrl was returned");

raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ private void validateDetails() {
309309

310310
Payload body = builder.createPayload();
311311

312-
presenter.fetchFee(body, RaveConstants.MANUAL_CARD_CHARGE);
312+
if(ravePayInitializer.getIsDisplayFee()){
313+
presenter.fetchFee(body, RaveConstants.MANUAL_CARD_CHARGE);
314+
} else {
315+
presenter.chargeCard(body, ravePayInitializer.getEncryptionKey());
316+
}
313317

314318
}
315319
}

raveandroid/src/main/java/com/flutterwave/raveandroid/ghmobilemoney/GhMobileMoneyFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ private void validate() {
225225

226226
Payload body = builder.createGhMobileMoneyPayload();
227227

228-
presenter.fetchFee(body);
228+
if(ravePayInitializer.getIsDisplayFee()){
229+
presenter.fetchFee(body);
230+
} else {
231+
presenter.chargeGhMobileMoney(body, ravePayInitializer.getEncryptionKey());
232+
}
229233
}
230234

231235
}

raveandroid/src/main/java/com/flutterwave/raveandroid/mpesa/MpesaFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ private void validate() {
180180

181181
Payload body = builder.createMpesaPayload();
182182

183-
presenter.fetchFee(body);
183+
if(ravePayInitializer.getIsDisplayFee()){
184+
presenter.fetchFee(body);
185+
} else {
186+
presenter.chargeMpesa(body, ravePayInitializer.getEncryptionKey());
187+
}
184188
}
185189

186190
}

raveandroid/src/main/java/com/flutterwave/raveandroid/ugmobilemoney/UgMobileMoneyFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ private void validate() {
164164

165165
Payload body = builder.createUgMobileMoneyPayload();
166166

167-
presenter.fetchFee(body);
167+
if(ravePayInitializer.getIsDisplayFee()){
168+
presenter.fetchFee(body);
169+
} else {
170+
presenter.chargeUgMobileMoney(body, ravePayInitializer.getEncryptionKey());
171+
}
168172
}
169173

170174
}

0 commit comments

Comments
 (0)