캔 충전 - 결제수단 카카오페이 추가

This commit is contained in:
Yu Sung
2024-08-30 17:00:05 +09:00
parent f5445a3c48
commit ca9dee5574
6 changed files with 84 additions and 35 deletions

View File

@@ -107,7 +107,7 @@ struct CanPgPaymentView: View {
Text("카드")
.font(.custom( viewModel.paymentMethod == .card ? Font.bold.rawValue : Font.medium.rawValue, size: 16.7))
.foregroundColor(viewModel.paymentMethod == .card ? Color.button : Color.grayee)
.frame(width: (screenSize().width - 40) / 2)
.frame(maxWidth: .infinity)
.padding(.vertical, 16.7)
.background(
viewModel.paymentMethod == .card ?
@@ -130,7 +130,7 @@ struct CanPgPaymentView: View {
Text("계좌이체")
.font(.custom( viewModel.paymentMethod == .bank ? Font.bold.rawValue : Font.medium.rawValue, size: 16.7))
.foregroundColor(viewModel.paymentMethod == .bank ? Color.button : Color.grayee)
.frame(width: (screenSize().width - 40) / 2)
.frame(maxWidth: .infinity)
.padding(.vertical, 16.7)
.background(
viewModel.paymentMethod == .bank ?
@@ -156,7 +156,7 @@ struct CanPgPaymentView: View {
Text("휴대폰 결제")
.font(.custom( viewModel.paymentMethod == .phone ? Font.bold.rawValue : Font.medium.rawValue, size: 16.7))
.foregroundColor(viewModel.paymentMethod == .phone ? Color.button : Color.grayee)
.frame(width: (screenSize().width - 40) / 2)
.frame(maxWidth: .infinity)
.padding(.vertical, 16.7)
.background(
viewModel.paymentMethod == .phone ?
@@ -175,7 +175,26 @@ struct CanPgPaymentView: View {
}
}
Spacer()
Image("ic_kakaopay")
.foregroundColor(viewModel.paymentMethod == .kakaopay ? Color.button : Color.grayee)
.frame(maxWidth: .infinity)
.padding(.vertical, 8.3)
.background(
viewModel.paymentMethod == .kakaopay ?
Color.button.opacity(0.3) :
Color.gray23
)
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(lineWidth: 1)
.foregroundColor(viewModel.paymentMethod == .kakaopay ? Color.button : Color.gray77)
)
.onTapGesture {
if viewModel.paymentMethod != .kakaopay {
viewModel.paymentMethod = .kakaopay
}
}
}
.frame(width: screenSize().width - 26.7)
.padding(.top, 16.7)

View File

@@ -14,6 +14,7 @@ enum PaymentMethod: String {
case card = "카드"
case bank = "계좌이체"
case phone = "휴대폰"
case kakaopay = "카카오페이"
}
final class CanPgPaymentViewModel: ObservableObject {
@@ -51,22 +52,24 @@ final class CanPgPaymentViewModel: ObservableObject {
if let data = decoded.data, decoded.success {
payload.applicationId = BOOTPAY_APP_HECTO_ID
payload.pg = "세틀뱅크"
payload.pg = paymentMethod == .kakaopay ? "카카오" : "세틀뱅크"
payload.orderId = "\(data.chargeId)"
payload.method = paymentMethod!.rawValue
var username = UserDefaults.string(forKey: .nickname)
if username.count > 10 {
username = "\(username.prefix(6))..."
if paymentMethod != .kakaopay {
var username = UserDefaults.string(forKey: .nickname)
if username.count > 10 {
username = "\(username.prefix(6))..."
}
let bootUser = BootUser()
bootUser.userId = "\(UserDefaults.int(forKey: .userId))"
bootUser.username = UserDefaults.string(forKey: .nickname)
payload.user = bootUser
}
let bootUser = BootUser()
bootUser.userId = "\(UserDefaults.int(forKey: .userId))"
bootUser.username = UserDefaults.string(forKey: .nickname)
payload.user = bootUser
onSuccess()
} else {
if let message = decoded.message {