From a95966d68702c6848b7964a108d9a1217133def8 Mon Sep 17 00:00:00 2001 From: youjmen Date: Sat, 23 Nov 2024 19:26:35 +0900 Subject: [PATCH] feat: support new pgs --- Example/iamport-ios/Model/Order.swift | 5 +- Example/iamport-ios/Utils.swift | 6 +-- Example/iamport-ios/View/ContentView.swift | 19 +++++-- Example/iamport-ios/ViewModel.swift | 58 +++++++--------------- Sources/iamport-ios/Classes/Data/PG.swift | 13 +++++ iamport-ios.podspec | 2 +- 6 files changed, 52 insertions(+), 51 deletions(-) diff --git a/Example/iamport-ios/Model/Order.swift b/Example/iamport-ios/Model/Order.swift index 69a16c1..a270140 100644 --- a/Example/iamport-ios/Model/Order.swift +++ b/Example/iamport-ios/Model/Order.swift @@ -11,11 +11,14 @@ class Order: ObservableObject, Then { var userCode = PubData() var payMethod = PubData() var pg = PubData() - var orderName = PubData() var price = PubData() var name = PubData() var appScheme = PubData() var merchantUid = PubData() var digital = PubData() var cardCode = PubData() + var buyerName = PubData() + var buyerTel = PubData() + var buyerEmail = PubData() + var buyerAddr = PubData() } diff --git a/Example/iamport-ios/Utils.swift b/Example/iamport-ios/Utils.swift index 624502e..c6460c1 100644 --- a/Example/iamport-ios/Utils.swift +++ b/Example/iamport-ios/Utils.swift @@ -10,7 +10,6 @@ import SwiftUI class Utils { enum SampleUserCode: String, CaseIterable { - case imp96304110 case iamport case imp19424728 case imp10391932 @@ -24,6 +23,7 @@ class Utils { case imp02690184 case imp89347847 case imp67688738 + case imp58026550 var name: String { switch self { @@ -53,8 +53,8 @@ class Utils { return "tosspayments(신모듈) 테스트" case .imp67688738: return "KSNET 테스트" - case .imp96304110: - return "빙봉" + case .imp58026550: + return "PortOne Internal Test(Do Not Use)" } } } diff --git a/Example/iamport-ios/View/ContentView.swift b/Example/iamport-ios/View/ContentView.swift index eee0a71..8782ef3 100644 --- a/Example/iamport-ios/View/ContentView.swift +++ b/Example/iamport-ios/View/ContentView.swift @@ -52,6 +52,12 @@ struct ContentView: View { }.padding() } } + + Section(header: Text("구매자")) { + ForEach(viewModel.customerInfos, id: \.0) { + getNaviCustomerInfoView($0.0, $0.1.value) + } + } } HStack(spacing: 30) { @@ -60,7 +66,7 @@ struct ContentView: View { buttonPaymentWebViewMode() }.padding() - }.navigationBarTitle(Text("아임포트로 결제~~"), displayMode: .inline) + }.navigationBarTitle(Text("포트원 V1 IOS 결제 테스트"), displayMode: .inline) }.tabItem { Image(systemName: "list.dash") Text("결제") @@ -99,7 +105,7 @@ struct ContentView: View { } }.actionSheet(isPresented: $viewModel.showResult) { - ActionSheet(title: Text("결제 결과 도착~"), + ActionSheet(title: Text("결제 결과:"), message: Text("\(String(describing: viewModel.iamportResponse))"), buttons: [.default(Text("닫기"))]) } @@ -130,6 +136,12 @@ struct ContentView: View { listItem(title, value) } } + + private func getNaviCustomerInfoView(_ title: String, _ value: String) -> some View { + NavigationLink(destination: OrderInfoView(infos: $viewModel.customerInfos)) { + listItem(title, value) + } + } // 웹뷰모드 @@ -137,7 +149,6 @@ struct ContentView: View { ZStack { Button(action: { buttonTag = 1 - viewModel.updateMerchantUid() }) { NavigationLink(destination: paymentWebViewMode, tag: 1, selection: $buttonTag) { Text("웹뷰모드 결제") @@ -152,7 +163,6 @@ struct ContentView: View { ZStack { Button(action: { viewModel.isPayment = true - viewModel.updateMerchantUid() }) { Text("결제하기") .font(.headline) @@ -173,7 +183,6 @@ struct ContentView: View { ZStack { Button(action: { viewModel.isCert = true - viewModel.updateMerchantUid() }) { Text("본인인증") .font(.headline) diff --git a/Example/iamport-ios/ViewModel.swift b/Example/iamport-ios/ViewModel.swift index bd3aeed..e3aebf6 100644 --- a/Example/iamport-ios/ViewModel.swift +++ b/Example/iamport-ios/ViewModel.swift @@ -39,6 +39,7 @@ public class ViewModel: ObservableObject, Then { @Published var iamportInfos: Array<(ItemType, PubData)> = [] @Published var orderInfos: Array<(String, PubData)> = [] @Published var certInfos: Array<(String, PubData)> = [] + @Published var customerInfos: Array<(String, PubData)> = [] @Published var isDigital = false @Published var isCardDirect = false @@ -52,8 +53,7 @@ public class ViewModel: ObservableObject, Then { order = Order().then { order in order.userCode.value = Utils.SampleUserCode.iamport.rawValue order.price.value = "1000" - order.orderName.value = "주문할건데요?" - order.name.value = "박포트" + order.name.value = "테스트 결제" order.pg.value = PG.html5_inicis.rawValue order.appScheme.value = "iamport" } @@ -62,8 +62,6 @@ public class ViewModel: ObservableObject, Then { cert.userCode.value = Utils.SampleUserCode.iamport.rawValue } - updateMerchantUid() - // pub data init iamportInfos = [ (.UserCode, order.userCode), @@ -73,9 +71,8 @@ public class ViewModel: ObservableObject, Then { ] orderInfos = [ - ("주문명", order.orderName), + ("주문명", order.name), ("가격", order.price), - ("이름", order.name), ("주문번호", order.merchantUid), ] @@ -87,6 +84,13 @@ public class ViewModel: ObservableObject, Then { ("(선택)최소나이", cert.minAge), ] + customerInfos = [ + ("구매자 이름", order.buyerName), + ("구매자 연락처", order.buyerTel), + ("구매자 이메일", order.buyerEmail), + ("구매자 주소", order.buyerAddr), + ] + updatePayMethodList(pg: order.pg.value) } @@ -99,8 +103,12 @@ public class ViewModel: ObservableObject, Then { merchant_uid: order.merchantUid.value, amount: order.price.value).then { $0.pay_method = payMethod - $0.name = order.orderName.value - $0.buyer_name = order.name.value + $0.name = order.name.value + $0.buyer_name = order.buyerName.value + $0.buyer_tel = order.buyerTel.value + $0.buyer_email = order.buyerEmail.value + $0.buyer_addr = order.buyerAddr.value + if (payMethod == PayMethod.phone.rawValue) { $0.digital = order.digital.flag } else if (payMethod == PayMethod.vbank.rawValue) { @@ -115,33 +123,6 @@ public class ViewModel: ObservableObject, Then { if (isCardDirect) { $0.card = Card(direct: CardDirect(code: order.cardCode.value)) } - $0.custom_data = """ - { - "employees": { - "employee": [ - { - "id": "1", - "firstName": "Tom", - "lastName": "Cruise", - "photo": "https://jsonformatter.org/img/tom-cruise.jpg", - "cuppingnote": "[\\"일\\",\\"이\\",\\"삼\\",\\"사\\",\\"오\\",\\"육\\",\\"칠\\"]" - }, - { - "id": "2", - "firstName": "Maria", - "lastName": "Sharapova", - "photo": "https://jsonformatter.org/img/Maria-Sharapova.jpg" - }, - { - "id": "3", - "firstName": "Robert", - "lastName": "Downey Jr.", - "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg" - } - ] - } - } - """ } return req @@ -181,12 +162,7 @@ public class ViewModel: ObservableObject, Then { setPayMethodList(pg: pg) initPayMethod() } - - func updateMerchantUid() { - order.merchantUid.value = UUID().uuidString - cert.merchantUid.value = UUID().uuidString - } - + private func initPayMethod() { order.payMethod.value = payMethodList[0].rawValue } diff --git a/Sources/iamport-ios/Classes/Data/PG.swift b/Sources/iamport-ios/Classes/Data/PG.swift index fc0c84c..2d5afe5 100644 --- a/Sources/iamport-ios/Classes/Data/PG.swift +++ b/Sources/iamport-ios/Classes/Data/PG.swift @@ -32,6 +32,11 @@ public enum PG: String, CaseIterable, Codable { case smartro case tosspayments case ksnet + case nice_v2 + case smartro_v2 + case welcome + case hyphen + public var name: String { switch self { @@ -89,6 +94,14 @@ public enum PG: String, CaseIterable, Codable { return "토스페이" case .smartro: return "스마트로" + case .nice_v2: + return "나이스 V2(신모듈)" + case .smartro_v2: + return "스마트로 V2(신모듈)" + case .welcome: + return "웰컴페이먼츠" + case .hyphen: + return "하이픈 바로계좌결제" } } diff --git a/iamport-ios.podspec b/iamport-ios.podspec index d0cd6c0..75b39e2 100644 --- a/iamport-ios.podspec +++ b/iamport-ios.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'iamport-ios' - s.version = '1.4.6' + s.version = '1.4.7' s.summary = 'iamport-ios will help develop for your iOS App payments' # This description is used to generate tags and improve search results.