Skip to content

Commit 14dd1db

Browse files
committed
Map country codes to currencies internally
1 parent 831cdac commit 14dd1db

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ but if you are not interested in our default UI and you want to use yours and on
5050
Set the public key, encryption key and other required parameters. The `RaveUiManager` accepts a mandatory instance of the calling `Activity` (or a `Fragment` that has a parent activity).
5151

5252
new RaveUiManager(activity).setAmount(amount)
53-
.setCountry(country)
5453
.setCurrency(currency)
5554
.setEmail(email)
5655
.setfName(fName)
@@ -140,7 +139,6 @@ First specify the theme in your `styles.xml` file. In this theme, you can edit t
140139
Then in your RavePayManager setup, add `.withTheme(<Reference to your style>)` anywhere before calling the `initialize()` function. e.g.
141140
```java
142141
new RavePayManager(activity).setAmount(amount)
143-
.setCountry(country)
144142
//...
145143
//...
146144
.withTheme(R.Style.MyCustomTheme)
@@ -154,7 +152,6 @@ Set the public key, encryption key and other required parameters.
154152
RaveNonUIManager raveNonUIManager =
155153
new RaveNonUIManager()
156154
.setAmount(amount)
157-
.setCountry(country)
158155
.setCurrency(currency)
159156
.setEmail(email)
160157
.setfName(fName)
@@ -193,7 +190,6 @@ For example to charge cards, use the `CardPaymentManager`
193190
| function | parameter | type | required |
194191
| ------------- |:-------------:| -----:| -----:|
195192
| setAmount(amount) | This is the amount to be charged from card/account | `double` | Required
196-
| setCountry(country) | This is the route country for the transaction with respect to the currency. You can find a list of supported countries and currencies [here](https://flutterwavedevelopers.readme.io/docs/multicurrency-payments) | `String` | Required
197193
| setCurrency(currency) | This is the specified currency to charge the card in | `String` | Required
198194
| setfName(fName) | This is the first name of the card holder or the customer | `String` | Required
199195
| setlName(lName) | This is the last name of the card holder or the customer | `String` | Required

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ private void validateEntries() {
242242
String txRef = txRefEt.getText().toString();
243243
String narration = narrationEt.getText().toString();
244244
String currency = currencyEt.getText().toString();
245-
String country = countryEt.getText().toString();
246245
String fName = fNameEt.getText().toString();
247246
String lName = lNameEt.getText().toString();
248247
String phoneNumber = phoneNumberEt.getText().toString();
@@ -281,11 +280,6 @@ private void validateEntries() {
281280
currencyEt.setError("A valid currency code is required");
282281
}
283282

284-
if (country.length() < 1) {
285-
valid = false;
286-
countryEt.setError("A valid country code is required");
287-
}
288-
289283
if (setExpirySwitch.isChecked()) {
290284
if (accountDuration.isEmpty()) {
291285
valid = false;
@@ -322,7 +316,6 @@ private void validateEntries() {
322316
// .withTheme(R.style.TestNewTheme)
323317
.showStagingLabel(shouldShowStagingLabelSwitch.isChecked())
324318
.setAmount(Double.parseDouble(amount))
325-
.setCountry(country)
326319
.setCurrency(currency)
327320
.setEmail(email)
328321
.setfName(fName)
@@ -358,7 +351,6 @@ private void validateEntries() {
358351

359352
} else {
360353
raveManager = new RaveNonUIManager().setAmount(Double.parseDouble(amount))
361-
.setCountry(country)
362354
.setCurrency(currency)
363355
.setEmail(email)
364356
.setfName(fName)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@
356356
android:id="@+id/countryEt"
357357
android:layout_width="match_parent"
358358
android:layout_height="wrap_content"
359+
android:visibility="gone"
359360
android:layout_marginBottom="10dp"
360361
android:hint="@string/country_code_e_g_ng"
361362
android:textSize="14sp" />

rave_android/src/main/java/com/flutterwave/raveandroid/RaveUiManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,27 @@ public RaveUiManager setNarration(String narration) {
107107

108108
public RaveUiManager setCurrency(String currency) {
109109
this.currency = currency;
110+
switch (currency) {
111+
case "KES":
112+
country = "KE";
113+
break;
114+
case "GHS":
115+
country = "GH";
116+
break;
117+
case "ZAR":
118+
country = "ZA";
119+
break;
120+
case "TZS":
121+
country = "TZ";
122+
break;
123+
default:
124+
country = "NG";
125+
break;
126+
}
110127
return this;
111128
}
112129

130+
@Deprecated
113131
public RaveUiManager setCountry(String country) {
114132
this.country = country;
115133
return this;

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/RaveNonUIManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,27 @@ public RaveNonUIManager setNarration(String narration) {
7171

7272
public RaveNonUIManager setCurrency(String currency) {
7373
this.currency = currency;
74+
switch (currency) {
75+
case "KES":
76+
country = "KE";
77+
break;
78+
case "GHS":
79+
country = "GH";
80+
break;
81+
case "ZAR":
82+
country = "ZA";
83+
break;
84+
case "TZS":
85+
country = "TZ";
86+
break;
87+
default:
88+
country = "NG";
89+
break;
90+
}
7491
return this;
7592
}
7693

94+
@Deprecated
7795
public RaveNonUIManager setCountry(String country) {
7896
this.country = country;
7997
return this;

0 commit comments

Comments
 (0)