Skip to content

Commit

Permalink
payway v2
Browse files Browse the repository at this point in the history
  • Loading branch information
kechankrisna committed Aug 9, 2023
1 parent 73f2412 commit 28d71e5
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 113 deletions.
18 changes: 9 additions & 9 deletions .flutter-plugins
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This is a generated file; do not edit or check into version control.
flutter_inappwebview=/Users/whitehat/.pub-cache/hosted/pub.dev/flutter_inappwebview-6.0.0-beta.22/
fluttertoast=/Users/whitehat/.pub-cache/hosted/pub.dev/fluttertoast-8.1.3/
url_launcher=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher-6.1.9/
url_launcher_android=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_android-6.0.23/
url_launcher_ios=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.0/
url_launcher_linux=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.2/
url_launcher_macos=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.2/
url_launcher_web=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.14/
url_launcher_windows=/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.3/
flutter_inappwebview=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\flutter_inappwebview-6.0.0-beta.24+1\\
fluttertoast=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\fluttertoast-8.2.2\\
url_launcher=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher-6.1.12\\
url_launcher_android=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher_android-6.0.23\\
url_launcher_ios=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher_ios-6.1.0\\
url_launcher_linux=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher_linux-3.0.2\\
url_launcher_macos=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher_macos-3.0.2\\
url_launcher_web=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher_web-2.0.14\\
url_launcher_windows=C:\\Users\\ML\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\url_launcher_windows-3.0.3\\
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_inappwebview","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/flutter_inappwebview-6.0.0-beta.22/","native_build":true,"dependencies":[]},{"name":"fluttertoast","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/fluttertoast-8.1.3/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_ios-6.1.0/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_inappwebview","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/flutter_inappwebview-6.0.0-beta.22/","native_build":true,"dependencies":[]},{"name":"fluttertoast","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/fluttertoast-8.1.3/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_android-6.0.23/","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_inappwebview","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/flutter_inappwebview-6.0.0-beta.22/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_macos-3.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.2/","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.3/","native_build":true,"dependencies":[]}],"web":[{"name":"flutter_inappwebview","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/flutter_inappwebview-6.0.0-beta.22/","dependencies":[]},{"name":"fluttertoast","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/fluttertoast-8.1.3/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/whitehat/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.14/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_inappwebview","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2023-02-14 18:29:49.294792","version":"3.7.0"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_inappwebview","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_inappwebview-6.0.0-beta.24+1\\\\","native_build":true,"dependencies":[]},{"name":"fluttertoast","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\fluttertoast-8.2.2\\\\","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\url_launcher_ios-6.1.0\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_inappwebview","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_inappwebview-6.0.0-beta.24+1\\\\","native_build":true,"dependencies":[]},{"name":"fluttertoast","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\fluttertoast-8.2.2\\\\","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\url_launcher_android-6.0.23\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_inappwebview","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_inappwebview-6.0.0-beta.24+1\\\\","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\url_launcher_macos-3.0.2\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"url_launcher_linux","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\url_launcher_linux-3.0.2\\\\","native_build":true,"dependencies":[]}],"windows":[{"name":"url_launcher_windows","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\url_launcher_windows-3.0.3\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"flutter_inappwebview","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_inappwebview-6.0.0-beta.24+1\\\\","dependencies":[]},{"name":"fluttertoast","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\fluttertoast-8.2.2\\\\","dependencies":[]},{"name":"url_launcher_web","path":"C:\\\\Users\\\\ML\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\url_launcher_web-2.0.14\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_inappwebview","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2023-08-09 11:56:29.560463","version":"3.10.6"}
2 changes: 1 addition & 1 deletion example/.env_sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ABA_PAYWAY_API_URL="yout backend api url"
ABA_PAYWAY_API_URL="https://checkout-sandbox.payway.com.kh/api/payment-gateway/v1/payments"
ABA_PAYWAY_API_KEY="key from support"
ABA_PAYWAY_MERCHANT_ID="MERCHANT_ID from support"
ABA_PAYWAY_MERCHANT_NAME="MERCHANT_NAME from support"
64 changes: 32 additions & 32 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ packages:
dependency: transitive
description:
name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -28,10 +28,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.3.0"
clock:
dependency: transitive
description:
Expand All @@ -44,18 +44,18 @@ packages:
dependency: transitive
description:
name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev"
source: hosted
version: "1.17.0"
version: "1.17.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.2"
version: "3.0.3"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -68,10 +68,10 @@ packages:
dependency: transitive
description:
name: dio
sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8"
sha256: ce75a1b40947fea0a0e16ce73337122a86762e38b982e1ccb909daa3b9bc4197
url: "https://pub.dev"
source: hosted
version: "4.0.6"
version: "5.3.2"
easy_logger:
dependency: transitive
description:
Expand All @@ -97,10 +97,10 @@ packages:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: d9283d92059a22e9834bc0a31336658ffba77089fb6f3cc36751f1fc7c6661a3
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "5.1.0"
flutter_easyloading:
dependency: "direct main"
description:
Expand All @@ -113,10 +113,10 @@ packages:
dependency: transitive
description:
name: flutter_inappwebview
sha256: "6d6c741ddba1dba5229d63ba75767064791a7ce845196b45e31105e93d67c949"
sha256: fad1f2740ff4b5b7da378a639f54beeb9d787b6339c89a9de00494d92372c0bb
url: "https://pub.dev"
source: hosted
version: "6.0.0-beta.22"
version: "6.0.0-beta.24+1"
flutter_inappwebview_internal_annotations:
dependency: transitive
description:
Expand Down Expand Up @@ -147,10 +147,10 @@ packages:
dependency: transitive
description:
name: fluttertoast
sha256: "774fa28b07f3a82c93596bc137be33189fec578ed3447a93a5a11c93435de394"
sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c"
url: "https://pub.dev"
source: hosted
version: "8.1.3"
version: "8.2.2"
http_parser:
dependency: transitive
description:
Expand All @@ -163,26 +163,26 @@ packages:
dependency: transitive
description:
name: intl
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev"
source: hosted
version: "0.17.0"
version: "0.18.1"
js:
dependency: transitive
description:
name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.5"
version: "0.6.7"
matcher:
dependency: transitive
description:
name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.13"
version: "0.12.15"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -195,18 +195,18 @@ packages:
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.9.1"
path:
dependency: transitive
description:
name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.2"
version: "1.8.3"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -264,10 +264,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.4.16"
version: "0.5.1"
typed_data:
dependency: transitive
description:
Expand All @@ -280,10 +280,10 @@ packages:
dependency: transitive
description:
name: url_launcher
sha256: e8f2efc804810c0f2f5b485f49e7942179f56eabcfe81dce3387fec4bb55876b
sha256: "781bd58a1eb16069412365c98597726cd8810ae27435f04b3b4d3a470bacd61e"
url: "https://pub.dev"
source: hosted
version: "6.1.9"
version: "6.1.12"
url_launcher_android:
dependency: transitive
description:
Expand Down Expand Up @@ -349,5 +349,5 @@ packages:
source: hosted
version: "2.1.4"
sdks:
dart: ">=2.18.0 <4.0.0"
flutter: ">=3.3.0"
dart: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Demonstrates how to use the aba_payment plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

environment:
sdk: '>=2.14.0 <3.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
flutter:
Expand Down
2 changes: 0 additions & 2 deletions lib/models/aba_transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import 'package:intl/intl.dart';
import 'package:aba_payment/enumeration.dart';
import 'package:aba_payment/models/models.dart';
import 'package:aba_payment/services/services.dart';
import 'aba_transaction_item.dart';
import 'aba_server_response.dart';

class ABATransaction {
late ABAMerchant? merchant;
Expand Down
2 changes: 0 additions & 2 deletions lib/models/reponses/payway_check_transaction_response.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:convert';

import 'package:flutter/foundation.dart';

import 'package:aba_payment/enumeration.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PaywayCreateTransactionResponse {
};

String get message =>
PaywayCreateTransactionResponseMessage.of(status!).message;
PaywayCreateTransactionResponseMessage.of(status).message;

PaywayCreateTransactionResponse copyWith({
int? status,
Expand Down
37 changes: 23 additions & 14 deletions lib/services/aba_client_service.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:convert';

import 'package:crypto/crypto.dart' as crypto;
import 'package:aba_payment/models/models.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
// import 'package:flutter/material.dart';
import '/services/http_client_adapter/http_client_adapter.dart';

class ABAClientService {
final ABAMerchant? merchant;
Expand All @@ -20,8 +21,10 @@ class ABAClientService {
Dio get client {
Dio dio = Dio();
dio.options.baseUrl = merchant!.baseApiUrl!;
dio.options.connectTimeout = 60 * 1000; //60 seconds
dio.options.receiveTimeout = 60 * 1000; //60 seconds
dio.options.connectTimeout = const Duration(seconds: 60);
dio.options.receiveTimeout = const Duration(seconds: 60);

dio.httpClientAdapter = PlatformHttpClientAdapter().clientAdapter();

/// [add interceptors]
dio.interceptors
Expand All @@ -36,7 +39,7 @@ class ABAClientService {
return handler.next(response); // continue
// If you want to reject the request with a error message,
// you can reject a `DioError` object eg: return `dio.reject(dioError)`
}, onError: (DioError e, handler) {
}, onError: (DioException e, handler) {
// Do something with response error
return handler.next(e); //continue
// If you want to resolve the request with some custom data,
Expand Down Expand Up @@ -104,7 +107,7 @@ class ABAClientService {
"$reqTime ${merchant!.merchantID} $tranId $amount $items $shipping $ctid $pwt $firstName $lastName $email $phone $type $paymentOption $returnUrl $cancelUrl $continueSuccessUrl $returnDeeplink $currency $customFields $returnParams";
var str =
"$reqTime${merchant!.merchantID}$tranId$amount$items$shipping$ctid$pwt$firstName$lastName$email$phone$type$paymentOption$returnUrl$cancelUrl$continueSuccessUrl$returnDeeplink$currency$customFields$returnParams";

var bytes = utf8.encode(str);
var digest = crypto.Hmac(crypto.sha512, key).convert(bytes);
var hash = base64Encode(digest.bytes);
Expand Down Expand Up @@ -161,29 +164,35 @@ class ABAClientService {

static String handleResponseError(dynamic error) {
String errorDescription = "";
if (error is DioError) {
DioError dioError = error;
if (error is DioException) {
DioException dioError = error;
switch (dioError.type) {
case DioErrorType.connectTimeout:
case DioExceptionType.connectionTimeout:
errorDescription = "Connection timeout with API server";
break;
case DioErrorType.sendTimeout:
case DioExceptionType.sendTimeout:
errorDescription = "Send timeout in connection with API server";
break;
case DioErrorType.receiveTimeout:
case DioExceptionType.receiveTimeout:
errorDescription = "Receive timeout in connection with API server";
break;
case DioErrorType.response:
case DioExceptionType.badResponse:
errorDescription =
"Received invalid status code: ${dioError.response!.statusCode}";
break;
case DioErrorType.cancel:
case DioExceptionType.cancel:
errorDescription = "Request to API server was cancelled";
break;
case DioErrorType.other:
case DioExceptionType.unknown:
errorDescription =
"Connection to API server failed due to internet connection";
break;
case DioExceptionType.badCertificate:
errorDescription = "Bad Certificate Error";
break;
case DioExceptionType.connectionError:
errorDescription = "Connection Error";
break;
}
} else {
errorDescription = "Unexpected error occured";
Expand Down Expand Up @@ -214,7 +223,7 @@ final dioLoggerInterceptor =
"└------------------------------------------------------------------------------");
handler.next(response);
// return response; // continue
}, onError: (DioError error, handler) async {
}, onError: (DioException error, handler) async {
debugPrint("| [DIO] Error: ${error.error}: ${error.response.toString()}");
debugPrint(
"└------------------------------------------------------------------------------");
Expand Down
4 changes: 4 additions & 0 deletions lib/services/http_client_adapter/http_client_adapter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export "http_client_adapter_none.dart"
if (dart.library.io) "http_client_adapter_io.dart"
if (dart.library.html) "http_client_adapter_web.dart";

Loading

0 comments on commit 28d71e5

Please sign in to comment.