diff --git a/lib/screens/purchase/payment_page.dart b/lib/screens/purchase/payment_page.dart index 21f7594..6125bfc 100644 --- a/lib/screens/purchase/payment_page.dart +++ b/lib/screens/purchase/payment_page.dart @@ -63,11 +63,11 @@ class Payment extends StatelessWidget { callback: (Map result) async { print('결제 결과: $result'); - if (result['success'] == 'true') { + if (result['error_msg'] == null) { String? impUid = result['imp_uid']; String? merchantUid = result['merchant_uid']; await verifyIamport(product.id, impUid, merchantUid, context); - Navigator.push( + Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => const PurchaseSuccess(), @@ -79,6 +79,12 @@ class Payment extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('결제 실패: $errorMsg')), ); + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => const PurchaseFail(), + ), + ); } }, ); @@ -167,6 +173,12 @@ class Payment extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('결제 검증 성공')), ); + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => const PurchaseSuccess(), + ), + ); } else { // 실패 처리 ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/screens/purchase/purchase_fail.dart b/lib/screens/purchase/purchase_fail.dart index 3da4a9d..a7cca28 100644 --- a/lib/screens/purchase/purchase_fail.dart +++ b/lib/screens/purchase/purchase_fail.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:saphy/screens/main/main_screen.dart'; import 'package:saphy/utils/colors.dart'; import 'package:saphy/widgets/normal_button.dart'; @@ -18,7 +19,15 @@ class PurchaseFail extends StatelessWidget { title: "홈으로 돌아가기", bgColor: black, txtColor: white, - onTap: () {}, + onTap: () { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute( + builder: (context) => const MainScreen(), + ), + (route) => false, + ); + }, flag: true) ], ), diff --git a/lib/screens/purchase/purchase_success.dart b/lib/screens/purchase/purchase_success.dart index bdbad1a..45d2deb 100644 --- a/lib/screens/purchase/purchase_success.dart +++ b/lib/screens/purchase/purchase_success.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:saphy/screens/main/main_screen.dart'; import 'package:saphy/utils/colors.dart'; import 'package:saphy/widgets/normal_button.dart'; @@ -31,7 +32,15 @@ class PurchaseSuccess extends StatelessWidget { title: "홈으로 돌아가기", bgColor: black, txtColor: white, - onTap: () {}, + onTap: () { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute( + builder: (context) => const MainScreen(), + ), + (route) => false, + ); + }, flag: true) ], ),