Skip to content

Commit 92c731d

Browse files
committed
Merge branch 'mobileMoneyHotFix'
2 parents 1724586 + a1e1def commit 92c731d

31 files changed

+131
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Set the public key, encryption key and other required parameters. The `RavePayMa
8888
| 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
8989
| 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
9090
| 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
91-
| setPhoneNumber(phoneNumber) | This is the customer's phone number. | `String` | Not Required
91+
| setPhoneNumber(phoneNumber) | This sets the customer's phone number. This functions is also overloaded to allow you specify whether the customer can edit their phone number as such: `setPhoneNumber(phoneNumber,false)`. When set to false, the user will not be able to change the number you set here.| `String`<br/><br/>Optional overloads:<br/>`String`, `boolean` | Not Required
9292
| acceptAccountPayments(boolean) | Set to `true` if you want to accept payments via bank accounts, else set to `false`. | `boolean` | Not Required
9393
| acceptCardPayments(boolean) | Set to `true` if you want to accept payments via cards, else set to `false` | `boolean` | Not Required |
9494
| acceptMpesaPayments(boolean) | Set to `true` if you want to accept Mpesa payments, else set to `false` . For this option to work, you should set your country to `KE` and your currency to `KES` | `boolean` | Not Required |

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@Parcel
1212
public class RavePayInitializer {
1313
private final ArrayList<Integer> orderedPaymentTypesList = new ArrayList<>();
14+
private boolean isPhoneEditable = true;
1415
String phoneNumber = "";
1516
private boolean saveCardFeatureAllowed = true;
1617
String email;
@@ -38,7 +39,7 @@ public class RavePayInitializer {
3839
public RavePayInitializer(String email, double amount, String publicKey,
3940
String encryptionKey, String txRef, String narration,
4041
String currency, String country, String fName,
41-
String lName, int theme, String phoneNumber, boolean saveCardFeatureAllowed,
42+
String lName, int theme, String phoneNumber, boolean isPhoneEditable, boolean saveCardFeatureAllowed,
4243
boolean isPermanent, int duration, int frequency,
4344
boolean staging, String meta, String subAccounts, String payment_plan, boolean isPreAuth,
4445
boolean showStagingLabel, boolean displayFee, ArrayList<Integer> orderedPaymentTypesList) {
@@ -62,6 +63,7 @@ public RavePayInitializer(String email, double amount, String publicKey,
6263
this.payment_plan = payment_plan;
6364
this.isPreAuth = isPreAuth;
6465
this.phoneNumber = phoneNumber;
66+
this.isPhoneEditable = isPhoneEditable;
6567
this.saveCardFeatureAllowed = saveCardFeatureAllowed;
6668
this.showStagingLabel = showStagingLabel;
6769
this.displayFee = displayFee;
@@ -221,6 +223,10 @@ public boolean getIsDisplayFee() {
221223
return displayFee;
222224
}
223225

226+
public boolean getIsPhoneEditable() {
227+
return isPhoneEditable;
228+
}
229+
224230
public void setIsDisplayFee(boolean displayFee) {
225231
this.displayFee = displayFee;
226232
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class RavePayManager {
5858
boolean staging = true;
5959
boolean isPreAuth = false;
6060
private String phoneNumber = "";
61+
private Boolean allowEditPhone = true;
6162
boolean showStagingLabel = true;
6263
boolean displayFee = true;
6364
private boolean isPermanent = false;
@@ -274,6 +275,12 @@ public RavePayManager setPhoneNumber(String phoneNumber) {
274275
return this;
275276
}
276277

278+
public RavePayManager setPhoneNumber(String phoneNumber, Boolean isEditable) {
279+
this.phoneNumber = phoneNumber;
280+
this.allowEditPhone = isEditable;
281+
return this;
282+
}
283+
277284
public RavePayManager setPaymentPlan(String payment_plan) {
278285
this.payment_plan = payment_plan;
279286
return this;
@@ -329,6 +336,7 @@ public RavePayInitializer createRavePayInitializer() {
329336
lName,
330337
theme,
331338
phoneNumber,
339+
allowEditPhone,
332340
allowSaveCard,
333341
isPermanent,
334342
duration,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ interface View {
4646

4747
void onRequerySuccessful(RequeryResponse response, String responseAsJSONString);
4848

49+
void onPhoneValidated(String phoneToSet, boolean isEditable);
50+
4951
void onValidationSuccessful(HashMap<String, ViewObject> dataHashMap);
5052

5153
void showFieldError(int viewID, String message, Class<?> viewtype);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ public void onAmountValidated(String amountToSet, int visibility) {
238238
amountEt.setText(amountToSet);
239239
}
240240

241+
@Override
242+
public void onPhoneValidated(String phoneToSet, boolean isEditable) {
243+
phoneEt.setText(phoneToSet);
244+
phoneEt.setEnabled(isEditable);
245+
}
246+
241247
@Override
242248
public void onValidationSuccessful(HashMap<String, ViewObject> dataHashMap) {
243249
presenter.processTransaction(dataHashMap, ravePayInitializer);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ public void init(RavePayInitializer ravePayInitializer) {
489489
} else {
490490
mView.onAmountValidated("", View.VISIBLE);
491491
}
492+
if (phoneValidator.isPhoneValid(ravePayInitializer.getPhoneNumber())) {
493+
mView.onPhoneValidated(String.valueOf(ravePayInitializer.getPhoneNumber()), ravePayInitializer.getIsPhoneEditable());
494+
}
492495
}
493496
}
494497

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public void onRequerySuccessful(RequeryResponse response, String responseAsJSONS
8989

9090
}
9191

92+
@Override
93+
public void onPhoneValidated(String phoneToSet, boolean isEditable) {
94+
95+
}
96+
9297
@Override
9398
public void onValidationSuccessful(HashMap<String, ViewObject> dataHashMap) {
9499

raveandroid/src/main/java/com/flutterwave/raveandroid/francMobileMoney/FrancMobileMoneyContract.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ interface View {
2222

2323
void showPollingIndicator(boolean active);
2424

25+
void onPhoneValidated(String phoneToSet, boolean isEditable);
26+
2527
void showProgressIndicator(boolean active);
2628

2729
void onAmountValidationSuccessful(String amountToPay);

raveandroid/src/main/java/com/flutterwave/raveandroid/francMobileMoney/FrancMobileMoneyFragment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ public void onAmountValidationSuccessful(String amountToPay) {
159159
amountEt.setText(amountToPay);
160160
}
161161

162+
@Override
163+
public void onPhoneValidated(String phoneToSet, boolean isEditable) {
164+
phoneEt.setText(phoneToSet);
165+
phoneEt.setEnabled(isEditable);
166+
}
167+
162168
@Override
163169
public void showProgressIndicator(boolean active) {
164170

raveandroid/src/main/java/com/flutterwave/raveandroid/francMobileMoney/FrancMobileMoneyPresenter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ public void init(RavePayInitializer ravePayInitializer) {
273273
if (isAmountValid) {
274274
mView.onAmountValidationSuccessful(String.valueOf(ravePayInitializer.getAmount()));
275275
}
276+
if (phoneValidator.isPhoneValid(ravePayInitializer.getPhoneNumber())) {
277+
mView.onPhoneValidated(String.valueOf(ravePayInitializer.getPhoneNumber()), ravePayInitializer.getIsPhoneEditable());
278+
}
276279
}
277280
}
278281

0 commit comments

Comments
 (0)