Code : Widget: PaymentWidgetExamplePage( user: user!, inventryId: widget.inventryId, quantity: widget.quantity, product: widget.product, orderId: orderId!, ) Class: class PaymentWidgetExamplePage extends StatefulWidget { final User user; final ProductProduct product; final int quantity; final String inventryId; String orderId; PaymentWidgetExamplePage({ Key? key, required this.user, required this.product, required this.quantity, required this.inventryId, required this.orderId, }) : super(key: key); @override State createState() => _PaymentWidgetExamplePageState(); } class _PaymentWidgetExamplePageState extends State { late PaymentWidget _paymentWidget; PaymentMethodWidgetControl? _paymentMethodWidgetControl; AgreementWidgetControl? _agreementWidgetControl; bool loading = false; @override void initState() { super.initState(); double total = widget.product.price * widget.quantity.toDouble(); double discountPercent = widget.product.productTax.toDouble(); num finalAmount = total * (1 - discountPercent / 100); _paymentWidget = PaymentWidget( clientKey: "TOSS_PAYMENT_KEY", customerKey: widget.user.id, ); _paymentWidget .renderPaymentMethods( selector: 'methods', amount: Amount( value: finalAmount.round(),currency: Currency.KRW, country: "KR", ), options: RenderPaymentMethodsOptions( variantKey: "gec", ), ) .then((control) { _paymentMethodWidgetControl = control; }).catchError((e) { debugPrint("Payment methods render error: $e"); }); _paymentWidget.renderAgreement(selector: 'agreement').then((control) { _agreementWidgetControl = control; }).catchError((e) { debugPrint("Agreement render error: $e"); }); } @override Widget build(BuildContext context) { return Column( children: [ Container( height: 300, child: PaymentMethodWidget( paymentWidget: _paymentWidget, selector: 'methods', ), ), Container( height: 100, child: AgreementWidget( paymentWidget: _paymentWidget, selector: 'agreement', ), ), MyElevatedButton( onPressed: loading ? null : _handlePayment, child: Text(loading ? "pleasewait_loading".tr() : "order".tr()), ), ], ); } Future _handlePayment() async { if (widget.user.shipping.address.line1.isEmpty) { showSnackBar( context: context, content: "enter_shipping_warning".tr(), ); return; } setState(() { loading = true; }); try { Result paymentResult = await _paymentWidget.requestPayment( paymentInfo: PaymentInfo( customerName: widget.user.name, orderId: widget.orderId, orderName: widget.product.name, customerMobilePhone: widget.user.contact.phone, showCustomerMobilePhone: true, ), ); if (paymentResult.success != null) { var confirm = await UserRepository().confirmPayment( paymentResult.success!.amount, paymentResult.success!.paymentKey, paymentResult.success!.orderId, ); if (confirm['status'] == true) { statuscheck(confirm['data']['orderId']); } else { showSnackBar(context: context, content: confirm['data'].toString()); setState(() => loading = false); Navigator.pop(context); } } else if (paymentResult.fail != null) { showSnackBar( context: context, content: paymentResult.fail!.errorMessage.toString(), ); setState(() => loading = false); } } catch (e) { setState(() => loading = false); showSnackBar(context: context, content: e.toString()); } } void statuscheck(String paymentId) async { try { var res = await UserRepository().getUser(); double total = widget.product.price * widget.quantity.toDouble(); double discountPercent = widget.product.productTax.toDouble(); num finalAmount = total * (1 - discountPercent / 100); UserModel user = UserModel.fromJson(res['data']); var submitRes = await UserRepository().submitOrder( tabledata: [ { "created_by": "653b481026c8b2e7afcc2dd2", "business": widget.product.business, "product": widget.product.id, "item_no": 1, "inventory": widget.inventryId, "inventory_id": widget.inventryId, "unit": widget.product.unitOfMeasurement, "price": widget.product.price, "quantity": widget.quantity, "tax": widget.product.productTax, "total": finalAmount, "sku": widget.product.sku, "item_name": widget.product.name, } ], paymentId: paymentId, customerId: user.user.id, podate: DateTime.now(), deliverydate: DateTime.now(), total: (widget.product.price * widget.quantity), tax: widget.product.productTax, assets: [ {"url": widget.product.assets.first.url, "type": "image"} ], name: widget.product.name, ); if (submitRes['status'] == true) { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => OrderSuccess( quantity: widget.quantity, product: widget.product, order: submitRes['data'], ), ), ); } else { showSnackBar(context: context, content: submitRes['message']); setState(() { loading = false; Navigator.pop(context); }); } } catch (e) { setState(() { loading = false; Navigator.pop(context); }); } } } Confirm Payment Code: Future> confirmPayment( num amount, String paymentKey, String orderId) async { try { const String secretKey = 'TOSS_PAYMENT_KEY'; const String apiUrl = 'https://api.tosspayments.com/v1/payments/confirm'; final headers = { 'Authorization': 'Basic ${base64Encode(utf8.encode('$secretKey:'))}', 'Content-Type': 'application/json', }; final body = { "paymentKey": paymentKey, "orderId": orderId, "amount": amount.round(), // ✅ ensure integer for KRW }; debugPrint("Confirm Request: $body"); final response = await http.post( Uri.parse(apiUrl), headers: headers, body: jsonEncode(body), ); debugPrint("Confirm Response: ${response.body}"); if (response.statusCode == 200) { final responseData = jsonDecode(response.body); return {'status': true, 'data': responseData}; } else { final responseData = jsonDecode(response.body); return { 'status': false, 'data': { 'code': responseData['code'], 'message': responseData['message'], } }; } } catch (e) { return {'status': false, 'data': e.toString()}; } }