From 41b7247a44342c7cc6cd9ada54e62ac460954a48 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Sat, 4 Nov 2023 21:13:21 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BA=94=20=EC=B6=A9=EC=A0=84=20=ED=9B=84=20?= =?UTF-8?q?=EB=A1=9C=EC=BB=AC=EC=97=90=20=EC=A0=80=EC=9E=A5=EB=90=9C=20?= =?UTF-8?q?=EC=BA=94=20=EC=88=98=EA=B0=80=20=EB=B3=80=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detail/LiveRoomDonationDialogView.swift | 2 +- .../MyPage/Can/Payment/CanPgPaymentView.swift | 27 ++++++++++--------- .../Can/Payment/CanPgPaymentViewModel.swift | 5 +++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/SodaLive/Sources/Content/Detail/LiveRoomDonationDialogView.swift b/SodaLive/Sources/Content/Detail/LiveRoomDonationDialogView.swift index 11db963..04892b1 100644 --- a/SodaLive/Sources/Content/Detail/LiveRoomDonationDialogView.swift +++ b/SodaLive/Sources/Content/Detail/LiveRoomDonationDialogView.swift @@ -60,7 +60,7 @@ struct LiveRoomDonationDialogView: View { Image("ic_forward") } .onTapGesture { - AppState.shared.setAppStep(step: .canCharge(refresh: {})) + AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true)) self.isShowing = false } } diff --git a/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentView.swift b/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentView.swift index f72d9cf..af2bc35 100644 --- a/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentView.swift +++ b/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentView.swift @@ -27,7 +27,7 @@ struct CanPgPaymentView: View { ZStack { Color.black.ignoresSafeArea() - if viewModel.isShowPamentView { + if viewModel.isShowPaymentView { BootpayUI(payload: viewModel.payload, requestType: BootpayRequest.TYPE_PAYMENT) .onConfirm { DEBUG_LOG("onConfirm: \($0)") @@ -38,28 +38,31 @@ struct CanPgPaymentView: View { } .onError { DEBUG_LOG("onError: \($0)") - viewModel.isShowPamentView = false + viewModel.isShowPaymentView = false viewModel.errorMessage = "결제 중 오류가 발생했습니다." viewModel.isShowPopup = true } .onDone { DEBUG_LOG("onDone: \($0)") viewModel.verifyPayment($0) { - self.refresh() - - if afterCompletionToGoBack { - AppState.shared.back() - } else { - AppState.shared.setAppStep(step: .canStatus(refresh: refresh)) - } - let can = UserDefaults.int(forKey: .can) UserDefaults.set(can + canResponse.can + canResponse.rewardCan, forKey: .can) + + self.refresh() + + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + if afterCompletionToGoBack { + AppState.shared.back() + AppState.shared.back() + } else { + AppState.shared.setAppStep(step: .canStatus(refresh: refresh)) + } + } } } .onClose { DEBUG_LOG("onClose") - viewModel.isShowPamentView = false + viewModel.isShowPaymentView = false } } else { GeometryReader { proxy in @@ -279,7 +282,7 @@ struct CanPgPaymentView: View { viewModel.payload.price = Double(canResponse.price) viewModel.payload.taxFree = 0 - viewModel.isShowPamentView = true + viewModel.isShowPaymentView = true } } } diff --git a/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentViewModel.swift b/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentViewModel.swift index 0e64b65..910e1c4 100644 --- a/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentViewModel.swift +++ b/SodaLive/Sources/MyPage/Can/Payment/CanPgPaymentViewModel.swift @@ -26,7 +26,7 @@ final class CanPgPaymentViewModel: ObservableObject { @Published var isShowPopup = false @Published var isLoading = false - @Published var isShowPamentView = false + @Published var isShowPaymentView = false @Published var paymentMethod: PaymentMethod? = nil let payload = Payload() @@ -99,6 +99,9 @@ final class CanPgPaymentViewModel: ObservableObject { let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) if decoded.success { + self.errorMessage = "캔이 충전되었습니다" + self.isShowPopup = true + onSuccess() } else { if let message = decoded.message {