Skip to content

Commit e090ca4

Browse files
author
Wilberforce Uwadiegwu
authored
Merge pull request #46 from wilburt/dev
Dev
2 parents b52183c + 147fdc8 commit e090ca4

File tree

7 files changed

+30
-17
lines changed

7 files changed

+30
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.3+1
2+
* Fixed issue with wrong plugin class in pubspec.yaml (#45)
3+
* Added spaces to initial string for card number field
4+
5+
16
## 1.0.3
27
* Fixed issue with using disposed context(#26)
38
* Removed hardcoded currency text in the checkout prompt (#30)

lib/src/api/service/base_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mixin BaseApiService {
1111
'X-Paystack-Build': PlatformInfo().paystackBuild,
1212
'X-PAYSTACK-USER-AGENT':
1313
jsonEncode({'lang': Platform.isIOS ? 'objective-c' : 'kotlin'}),
14-
'bindings_version': "1.3.0", // TODO: Update for every new versions
14+
'bindings_version': "1.3.0+1", // TODO: Update for every new versions
1515
'X-FLUTTER-USER-AGENT': jsonEncode({'version': '1.0.0'})
1616
};
1717
final String baseUrl = 'https://standard.paystack.co';

lib/src/common/card_utils.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class CardUtils {
7878
return year;
7979
}
8080

81+
/// Removes non numerical characters from the string
8182
static String getCleanedNumber(String text) {
8283
if (text == null) {
8384
return '';

lib/src/common/utils.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,17 @@ class Utils {
5151
throw new InvalidEmailException(charge.email);
5252
}
5353
}
54+
55+
/// Add double spaces after every 4th character
56+
static String addSpaces(String text) {
57+
var buffer = new StringBuffer();
58+
for (int i = 0; i < text.length; i++) {
59+
buffer.write(text[i]);
60+
var nonZeroIndex = i + 1;
61+
if (nonZeroIndex % 4 == 0 && nonZeroIndex != text.length) {
62+
buffer.write(' '); // Add double spaces.
63+
}
64+
}
65+
return buffer.toString();
66+
}
5467
}

lib/src/widgets/common/input_formatters.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3+
import 'package:flutter_paystack/src/common/utils.dart';
34

45
class CardMonthInputFormatter extends TextInputFormatter {
56
String previousText;
@@ -42,16 +43,7 @@ class CardNumberInputFormatter extends TextInputFormatter {
4243
return newValue;
4344
}
4445

45-
var buffer = new StringBuffer();
46-
for (int i = 0; i < text.length; i++) {
47-
buffer.write(text[i]);
48-
var nonZeroIndex = i + 1;
49-
if (nonZeroIndex % 4 == 0 && nonZeroIndex != text.length) {
50-
buffer.write(' '); // Add double spaces.
51-
}
52-
}
53-
54-
var string = buffer.toString();
46+
var string = Utils.addSpaces(text);
5547
return newValue.copyWith(
5648
text: string,
5749
selection: new TextSelection.collapsed(offset: string.length));

lib/src/widgets/input/card_input.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_paystack/src/common/card_utils.dart';
3+
import 'package:flutter_paystack/src/common/utils.dart';
34
import 'package:flutter_paystack/src/models/card.dart';
45
import 'package:flutter_paystack/src/widgets/buttons.dart';
56
import 'package:flutter_paystack/src/widgets/input/cvc_field.dart';
@@ -36,8 +37,9 @@ class _CardInputState extends State<CardInput> {
3637
super.initState();
3738
numberController = new TextEditingController();
3839
numberController.addListener(_getCardTypeFrmNumber);
39-
numberController.text =
40-
_card != null && _card.number != null ? _card.number : null;
40+
if (_card?.number != null) {
41+
numberController.text = Utils.addSpaces(_card.number);
42+
}
4143
}
4244

4345
@override

pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_paystack
22
description: A Flutter plugin for making payments via Paystack Payment Gateway. Completely supports Android and iOS.
3-
version: 1.0.3
3+
version: 1.0.3+1
44
author: Wilberforce Uwadiegwu <[email protected]>
55
homepage: https://github.com/wilburt/flutter_paystack
66

@@ -23,10 +23,10 @@ flutter:
2323
plugin:
2424
platforms:
2525
android:
26-
package: io.flutter.plugins.webviewflutter
27-
pluginClass: WebViewFlutterPlugin
26+
package: co.paystack.flutterpaystack
27+
pluginClass: FlutterPaystackPlugin
2828
ios:
29-
pluginClass: FLTWebViewFlutterPlugin
29+
pluginClass: FlutterPaystackPlugin
3030

3131
assets:
3232
- assets/images/

0 commit comments

Comments
 (0)