휴대폰 결제도 헥토파이낸셜로 수정
This commit is contained in:
parent
6884a060e4
commit
6d83869cae
|
@ -50,19 +50,23 @@ final class CanPgPaymentViewModel: ObservableObject {
|
||||||
let decoded = try jsonDecoder.decode(ApiResponse<CanChargeResponse>.self, from: responseData)
|
let decoded = try jsonDecoder.decode(ApiResponse<CanChargeResponse>.self, from: responseData)
|
||||||
|
|
||||||
if let data = decoded.data, decoded.success {
|
if let data = decoded.data, decoded.success {
|
||||||
payload.applicationId = paymentMethod == .phone ? BOOTPAY_APP_ID : BOOTPAY_APP_HECTO_ID
|
payload.applicationId = BOOTPAY_APP_HECTO_ID
|
||||||
payload.pg = paymentMethod == .phone ? "웰컴페이먼츠" : "세틀뱅크"
|
payload.pg = "세틀뱅크"
|
||||||
payload.orderId = "\(data.chargeId)"
|
payload.orderId = "\(data.chargeId)"
|
||||||
payload.method = paymentMethod!.rawValue
|
payload.method = paymentMethod!.rawValue
|
||||||
|
|
||||||
if paymentMethod != .phone {
|
var username = UserDefaults.string(forKey: .nickname)
|
||||||
let bootUser = BootUser()
|
|
||||||
bootUser.userId = "\(UserDefaults.int(forKey: .userId))"
|
if username.count > 10 {
|
||||||
bootUser.username = UserDefaults.string(forKey: .nickname)
|
username = "\(username.prefix(6))..."
|
||||||
|
|
||||||
payload.user = bootUser
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let bootUser = BootUser()
|
||||||
|
bootUser.userId = "\(UserDefaults.int(forKey: .userId))"
|
||||||
|
bootUser.username = UserDefaults.string(forKey: .nickname)
|
||||||
|
|
||||||
|
payload.user = bootUser
|
||||||
|
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} else {
|
} else {
|
||||||
if let message = decoded.message {
|
if let message = decoded.message {
|
||||||
|
@ -90,81 +94,42 @@ final class CanPgPaymentViewModel: ObservableObject {
|
||||||
let receiptId = data["receipt_id"] as! String
|
let receiptId = data["receipt_id"] as! String
|
||||||
let orderId = data["order_id"] as! String
|
let orderId = data["order_id"] as! String
|
||||||
|
|
||||||
if paymentMethod == .phone {
|
repository.pgVerifyHecto(receiptId: receiptId, orderId: orderId)
|
||||||
repository.pgVerify(receiptId: receiptId, orderId: orderId)
|
.sink { result in
|
||||||
.sink { result in
|
switch result {
|
||||||
switch result {
|
case .finished:
|
||||||
case .finished:
|
DEBUG_LOG("finish")
|
||||||
DEBUG_LOG("finish")
|
case .failure(let error):
|
||||||
case .failure(let error):
|
ERROR_LOG(error.localizedDescription)
|
||||||
ERROR_LOG(error.localizedDescription)
|
}
|
||||||
}
|
} receiveValue: { [unowned self] response in
|
||||||
} receiveValue: { [unowned self] response in
|
self.isLoading = false
|
||||||
self.isLoading = false
|
let responseData = response.data
|
||||||
let responseData = response.data
|
|
||||||
|
do {
|
||||||
|
let jsonDecoder = JSONDecoder()
|
||||||
|
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||||
|
|
||||||
do {
|
if decoded.success {
|
||||||
let jsonDecoder = JSONDecoder()
|
self.errorMessage = "캔이 충전되었습니다"
|
||||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
self.isShowPopup = true
|
||||||
|
|
||||||
if decoded.success {
|
onSuccess()
|
||||||
self.errorMessage = "캔이 충전되었습니다"
|
} else {
|
||||||
self.isShowPopup = true
|
if let message = decoded.message {
|
||||||
|
self.errorMessage = message
|
||||||
onSuccess()
|
|
||||||
} else {
|
} else {
|
||||||
if let message = decoded.message {
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
self.errorMessage = message
|
|
||||||
} else {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
}
|
|
||||||
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
self.isShowPopup = true
|
self.isShowPopup = true
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
|
self.isShowPopup = true
|
||||||
}
|
}
|
||||||
.store(in: &subscription)
|
}
|
||||||
} else {
|
.store(in: &subscription)
|
||||||
repository.pgVerifyHecto(receiptId: receiptId, orderId: orderId)
|
|
||||||
.sink { result in
|
|
||||||
switch result {
|
|
||||||
case .finished:
|
|
||||||
DEBUG_LOG("finish")
|
|
||||||
case .failure(let error):
|
|
||||||
ERROR_LOG(error.localizedDescription)
|
|
||||||
}
|
|
||||||
} receiveValue: { [unowned self] response in
|
|
||||||
self.isLoading = false
|
|
||||||
let responseData = response.data
|
|
||||||
|
|
||||||
do {
|
|
||||||
let jsonDecoder = JSONDecoder()
|
|
||||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
|
||||||
|
|
||||||
if decoded.success {
|
|
||||||
self.errorMessage = "캔이 충전되었습니다"
|
|
||||||
self.isShowPopup = true
|
|
||||||
|
|
||||||
onSuccess()
|
|
||||||
} else {
|
|
||||||
if let message = decoded.message {
|
|
||||||
self.errorMessage = message
|
|
||||||
} else {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
}
|
|
||||||
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.store(in: &subscription)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
isLoading = false
|
isLoading = false
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
|
|
Loading…
Reference in New Issue