build method
Builds the TossPayments widget and initializes the payment process.
Implementation
@override
Widget build(BuildContext context) {
return TosspaymentsWebview(executeJS: (WebViewController controller) {
controller.evaluateJavascript('''
var clientKey = '$clientKey';
var tossPayments = TossPayments(clientKey);
tossPayments.requestPayment('${data.paymentMethod}', ${jsonEncode(data.toJson())});
''');
}, didSuccess: (String url) {
final Success? result = successFromUrl(url);
if (result != null) {
success(result);
return true;
}
return false;
}, didFail: (String url) {
final Fail? result = failFromUrl(url);
if (result != null) {
fail(result);
return true;
}
return false;
});
}