Skip to content

Commit

Permalink
-Add Query Function
Browse files Browse the repository at this point in the history
- Add PaymentSDKQueryConfiguration.dart
  • Loading branch information
KhaledAlramam committed Dec 21, 2022
1 parent 659e401 commit af361b1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/PaymentSDKQueryConfiguration.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'flutter_paytabs_bridge.dart';

class PaymentSDKQueryConfiguration {
String? serverKey;
String? clientKey;
String? merchantCountryCode;
String? profileID;
String? transactionReference;

PaymentSDKQueryConfiguration(
String serverKey,
String clientKey,
String merchantCountryCode,
String profileID,
String transactionReference) {
this.clientKey = clientKey;
this.merchantCountryCode = merchantCountryCode;
this.profileID = profileID;
this.serverKey = serverKey;
this.transactionReference = transactionReference;
}
}

extension PaymentSDKQueryConfigurationExtension on PaymentSDKQueryConfiguration {
Map<String, dynamic> get map {
return {
pt_client_key: this.clientKey,
pt_server_key: this.serverKey,
pt_merchant_country_code: this.merchantCountryCode,
pt_profile_id: this.profileID,
pt_transaction_reference: this.transactionReference,
};
}
}
20 changes: 20 additions & 0 deletions lib/flutter_paytabs_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:path_provider/path_provider.dart';

import 'PaymentSDKQueryConfiguration.dart';
import 'PaymentSDKSavedCardInfo.dart';
import 'PaymentSdkConfigurationDetails.dart';

Expand Down Expand Up @@ -159,6 +160,25 @@ class FlutterPaytabsBridge {
'startPaymentWithSavedCards', argsMap);
}

static Future<dynamic> queryTransaction(
PaymentSdkConfigurationDetails arg,
PaymentSDKQueryConfiguration paymentSDKQueryConfiguration,
void eventsCallBack(dynamic)) async {
arg.samsungPayToken = null;
MethodChannel localChannel = MethodChannel('flutter_paytabs_bridge');
EventChannel localStream =
const EventChannel('flutter_paytabs_bridge_stream');
localStream.receiveBroadcastStream().listen(eventsCallBack);
var logoImage = arg.iOSThemeConfigurations?.logoImage ?? "";
if (logoImage != "") {
arg.iOSThemeConfigurations?.logoImage = await handleImagePath(logoImage);
}
var argsMap = arg.map;
argsMap["paymentSDKQueryConfiguration"] = paymentSDKQueryConfiguration.map;
return await localChannel.invokeMethod(
'queryTransaction', argsMap);
}

static Future<String> handleImagePath(String path) async {
var bytes = await rootBundle.load(path);
String dir = (await getApplicationDocumentsDirectory()).path;
Expand Down

0 comments on commit af361b1

Please sign in to comment.