Skip to content

Commit

Permalink
Added support to use Rave v2 instead. fixes [#2]
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonweze committed May 31, 2021
1 parent f8f06be commit 74e6ef2
Show file tree
Hide file tree
Showing 25 changed files with 297 additions and 222 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@

* Update API Endpoints and parameters to v3
* Added example project
* More details to README.md
* More details to README.md

## 1.0.2

* Added support to use Rave v2 instead. fixes [#2](https://github.com/nelstein/nravepay/issues/2)
Binary file not shown.
Binary file not shown.
Binary file modified example/android/.gradle/6.7/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified example/android/.gradle/6.7/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified example/android/.gradle/6.7/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified example/android/.gradle/6.7/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified example/android/.gradle/6.7/javaCompile/taskHistory.bin
Binary file not shown.
Binary file not shown.
Binary file modified example/android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified example/android/.gradle/checksums/checksums.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions example/ios/Flutter/Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/admin/Downloads/flutter
FLUTTER_APPLICATION_PATH=/Users/admin/Documents/Projects/nravepay/example
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=lib/main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
EXCLUDED_ARCHS[sdk=iphonesimulator*]=arm64 i386
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=false
TREE_SHAKE_ICONS=false
Expand Down
1 change: 1 addition & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/admin/Downloads/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/admin/Documents/Projects/nravepay/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
Expand Down
46 changes: 22 additions & 24 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ void main() {
publicKey: PaymentKeys.publicKey,
encryptionKey: PaymentKeys.encryptionKey,
secKey: PaymentKeys.secretKey,
staging: true);
staging: true,
version: Version.v2);
runApp(MyApp());
}

Expand Down Expand Up @@ -37,15 +38,14 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
Future<void> _startPayment() async {
var initializer = PayInitializer(
amount: 450,
amount: 45,
email: 'email@email.com',
txRef: 'reference${DateTime.now().microsecondsSinceEpoch}',
txRef: 'TXREF-${DateTime.now().microsecondsSinceEpoch}',
narration: 'New payment',
country: 'Nigeria',
country: 'NG',
currency: 'NGN',
firstname: 'Nelson',
lastname: 'Eze',
useCard: true,
phoneNumber: '09092343432',
onComplete: (result) {
if (result.status == HttpStatus.success) {
Expand All @@ -60,25 +60,23 @@ class _MyHomePageState extends State<MyHomePage> {
}

List<BankCard> cards = [
BankCard.fromMap({
"id": '1234567',
"token": "flw-t1nf-5eab9b1fbfbab5806f676a88ef9630c2-m03k",
"last_4digits": "4246",
"expiry": "09/32",
"first_6digits": "418742",
"issuer": "Visa",
"type": "VISA"
}),
BankCard.fromMap({
"id": "1622103329220332_2643",
"token": "flw-t1nf-2c09dac5ab2da4c472c75da603da2e42-m03k",
"last_4digits": "2643",
"expiry": "09/32",
"country": "UNITED KINGDOM GB",
"first_6digits": "455605",
"issuer": "CREDIT",
"type": "VISA"
})
BankCard(
id: '1234567',
token: "flw-t1nf-5eab9b1fbfbab5806f676a88ef9630c2-m03k",
last4digits: "4246",
expiry: "09/32",
first6digits: "418742",
issuer: "Visa",
type: "VISA"),
BankCard(
id: "1622103329220332_2643",
token: "flw-t1nf-2c09dac5ab2da4c472c75da603da2e42-m03k",
last4digits: "2643",
expiry: "09/32",
country: "UNITED KINGDOM GB",
first6digits: "455605",
issuer: "CREDIT",
type: "VISA")
];

@override
Expand Down
1 change: 1 addition & 0 deletions example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/admin/Downloads/flutter
FLUTTER_APPLICATION_PATH=/Users/admin/Documents/Projects/nravepay/example
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/admin/Downloads/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/admin/Documents/Projects/nravepay/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.5.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -169,7 +169,7 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -204,7 +204,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.19"
version: "0.3.0"
tripledes:
dependency: transitive
description:
Expand Down
22 changes: 16 additions & 6 deletions lib/src/base/manager.base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class BaseTransactionManager {
final transactionBloc = TransactionBloc.instance;
final connectionBloc = ConnectionBloc.instance;
late Payload payload;
late String txRef;
String flwRef = '';
late int transactionId;
bool saveCard = true;
HttpResult? paymentResult;
Expand All @@ -30,7 +30,14 @@ abstract class BaseTransactionManager {
onComplete ??= this.onComplete;
setConnectionState(ConnectionState.waiting);
try {
var response = await service.reQuery(transactionId);
var response = await service.reQuery(
transactionId,
payload.version == Version.v2
? {
"txref": payload.txRef,
"SECKEY": payload.secKey,
}
: null);
onComplete(response);
Navigator.pop(context);
} on NRavePayException catch (e) {
Expand Down Expand Up @@ -62,10 +69,12 @@ abstract class BaseTransactionManager {
_validateCharge(otp) async {
try {
setConnectionState(ConnectionState.waiting);
var response = await service.validateCardCharge(ValidateChargeRequestBody(
transactionReference: txRef,
otp: otp,
pBFPubKey: payload.pbfPubKey!));
var response = await service.validateCardCharge(
ValidateChargeRequestBody(
transactionReference: flwRef,
otp: otp,
pBFPubKey: payload.pbfPubKey!),
payload.version);
transactionId = response.id;
setConnectionState(ConnectionState.done);
transactionId = response.id;
Expand All @@ -80,6 +89,7 @@ abstract class BaseTransactionManager {
));
}
} catch (e) {
print(e);
reQueryTransaction();
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/src/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class NRavePayException {
}
}

enum Version { v2, v3 }

class NRavePayRepository {
static NRavePayRepository get instance => ngetIt<NRavePayRepository>();
PayInitializer initializer;
Expand All @@ -109,7 +111,8 @@ class NRavePayRepository {
{required String publicKey,
required String encryptionKey,
required String secKey,
required bool staging}) async {
required bool staging,
required Version version}) async {
var initializer = PayInitializer(
publicKey: publicKey,
encryptionKey: encryptionKey,
Expand All @@ -118,7 +121,8 @@ class NRavePayRepository {
txRef: '',
email: '',
staging: staging,
onComplete: print);
onComplete: print,
version: version);
final httpService = HttpService(initializer);
var repository = NRavePayRepository._(initializer);
ngetIt.registerSingleton<NRavePayRepository>(repository);
Expand Down
Loading

0 comments on commit 74e6ef2

Please sign in to comment.