Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/iamport_certification.dart 파일 이름변경 #139

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions lib/Iamport_certification.dart → lib/iamport_certification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,45 @@ 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<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers;
final String? customUserAgent;

IamportCertification({
Key? key,
const IamportCertification({
super.key,
this.appBar,
this.initialChild,
required this.userCode,
required this.data,
required this.callback,
this.gestureRecognizers,
this.customUserAgent,
}) : super(key: key);
});
final PreferredSizeWidget? appBar;
final Widget? initialChild;
final String userCode;
final CertificationData data;
final ValueSetter<Map<String, String>> callback;
final Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers;
final String? customUserAgent;

@override
Widget build(BuildContext context) {
var redirectUrl = UrlData.redirectUrl;
if (this.data.mRedirectUrl != null && this.data.mRedirectUrl!.isNotEmpty) {
redirectUrl = this.data.mRedirectUrl!;
if (data.mRedirectUrl != null && data.mRedirectUrl!.isNotEmpty) {
redirectUrl = data.mRedirectUrl!;
}

IamportValidation validation =
final 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) {
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]);
Expand All @@ -60,9 +60,7 @@ class IamportCertification extends StatelessWidget {
});
''');
},
useQueryData: (Map<String, String> data) {
this.callback(data);
},
useQueryData: callback,
isPaymentOver: (String url) {
return url.startsWith(redirectUrl);
},
Expand Down