Skip to content

Commit

Permalink
feat : complete purchase process
Browse files Browse the repository at this point in the history
  • Loading branch information
cho4u4o committed Oct 15, 2024
1 parent 9c552d0 commit 39e337b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
16 changes: 14 additions & 2 deletions lib/screens/purchase/payment_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class Payment extends StatelessWidget {
callback: (Map<String, String> 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(),
Expand All @@ -79,6 +79,12 @@ class Payment extends StatelessWidget {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('결제 실패: $errorMsg')),
);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => const PurchaseFail(),
),
);
}
},
);
Expand Down Expand Up @@ -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(
Expand Down
11 changes: 10 additions & 1 deletion lib/screens/purchase/purchase_fail.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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)
],
),
Expand Down
11 changes: 10 additions & 1 deletion lib/screens/purchase/purchase_success.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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)
],
),
Expand Down

0 comments on commit 39e337b

Please sign in to comment.