From ce6d76a9bc8591a440f3c1366994e03cac82e6f3 Mon Sep 17 00:00:00 2001 From: Dongmin Yu Date: Wed, 28 Aug 2024 11:17:11 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=8E=A8=20=EC=BB=A8=EB=B2=A4?= =?UTF-8?q?=EC=85=98=20=EB=A7=9E=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=AA=85=EC=9D=98=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Iamport_certification.dart | 76 ---------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 lib/Iamport_certification.dart diff --git a/lib/Iamport_certification.dart b/lib/Iamport_certification.dart deleted file mode 100644 index 44894bf..0000000 --- a/lib/Iamport_certification.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'dart:convert'; -import 'dart:core'; - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:iamport_flutter/model/certification_data.dart'; -import 'package:iamport_flutter/model/iamport_validation.dart'; -import 'package:iamport_flutter/model/url_data.dart'; -import 'package:iamport_flutter/widget/iamport_error.dart'; -import 'package:iamport_flutter/widget/iamport_webview.dart'; -import 'package:iamport_webview_flutter/iamport_webview_flutter.dart'; - -class IamportCertification extends StatelessWidget { - final PreferredSizeWidget? appBar; - final Widget? initialChild; - final String userCode; - final CertificationData data; - final callback; - final Set>? gestureRecognizers; - final String? customUserAgent; - - IamportCertification({ - Key? key, - this.appBar, - this.initialChild, - required this.userCode, - required this.data, - required this.callback, - this.gestureRecognizers, - this.customUserAgent, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - var redirectUrl = UrlData.redirectUrl; - if (this.data.mRedirectUrl != null && this.data.mRedirectUrl!.isNotEmpty) { - redirectUrl = this.data.mRedirectUrl!; - } - - IamportValidation validation = - IamportValidation.fromCertificationData(userCode, data, callback); - if (validation.getIsValid()) { - return IamportWebView( - type: ActionType.auth, - appBar: this.appBar, - initialChild: this.initialChild, - gestureRecognizers: this.gestureRecognizers, - customUserAgent: this.customUserAgent, - executeJS: (WebViewController controller) { - controller.evaluateJavascript(''' - IMP.init("${this.userCode}"); - IMP.certification(${jsonEncode(this.data.toJson())}, function(response) { - const query = []; - Object.keys(response).forEach(function(key) { - query.push(key + "=" + response[key]); - }); - location.href = "$redirectUrl" + "?" + query.join("&"); - }); - '''); - }, - useQueryData: (Map data) { - this.callback(data); - }, - isPaymentOver: (String url) { - return url.startsWith(redirectUrl); - }, - // 인증에는 customPGAction 수행할 필요 없음 - customPGAction: (WebViewController controller) {}, - ); - } else { - return IamportError(ActionType.auth, validation.getErrorMessage()); - } - } -} From e49720c9a91e2568530458b9bf62f7f11f6fc983 Mon Sep 17 00:00:00 2001 From: Dongmin Yu Date: Wed, 28 Aug 2024 12:02:37 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20`lib/iamport=5Fcertification.dart`?= =?UTF-8?q?=20=EB=8B=A4=EC=8B=9C=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/iamport_certification.dart | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 lib/iamport_certification.dart diff --git a/lib/iamport_certification.dart b/lib/iamport_certification.dart new file mode 100644 index 0000000..031cb83 --- /dev/null +++ b/lib/iamport_certification.dart @@ -0,0 +1,74 @@ +import 'dart:convert'; +import 'dart:core'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:iamport_flutter/model/certification_data.dart'; +import 'package:iamport_flutter/model/iamport_validation.dart'; +import 'package:iamport_flutter/model/url_data.dart'; +import 'package:iamport_flutter/widget/iamport_error.dart'; +import 'package:iamport_flutter/widget/iamport_webview.dart'; +import 'package:iamport_webview_flutter/iamport_webview_flutter.dart'; + +class IamportCertification extends StatelessWidget { + + const IamportCertification({ + super.key, + this.appBar, + this.initialChild, + required this.userCode, + required this.data, + required this.callback, + this.gestureRecognizers, + this.customUserAgent, + }); + final PreferredSizeWidget? appBar; + final Widget? initialChild; + final String userCode; + final CertificationData data; + final ValueSetter> callback; + final Set>? gestureRecognizers; + final String? customUserAgent; + + @override + Widget build(BuildContext context) { + var redirectUrl = UrlData.redirectUrl; + if (data.mRedirectUrl != null && data.mRedirectUrl!.isNotEmpty) { + redirectUrl = data.mRedirectUrl!; + } + + final validation = + IamportValidation.fromCertificationData(userCode, data, callback); + if (validation.getIsValid()) { + return IamportWebView( + type: ActionType.auth, + appBar: appBar, + initialChild: initialChild, + gestureRecognizers: gestureRecognizers, + customUserAgent: customUserAgent, + executeJS: (WebViewController controller) async { + await controller.evaluateJavascript(''' + IMP.init("$userCode"); + IMP.certification(${jsonEncode(data.toJson())}, function(response) { + const query = []; + Object.keys(response).forEach(function(key) { + query.push(key + "=" + response[key]); + }); + location.href = "$redirectUrl" + "?" + query.join("&"); + }); + '''); + }, + useQueryData: callback, + isPaymentOver: (String url) { + return url.startsWith(redirectUrl); + }, + // 인증에는 customPGAction 수행할 필요 없음 + customPGAction: (WebViewController controller) {}, + ); + } else { + return IamportError(ActionType.auth, validation.getErrorMessage()); + } + } +}