此套件提供手機端的全功能付款功能。
- 整合商家信用卡金流服務
- 消費者直接輸入信用卡號並且付款
- 支援信用卡端 3D驗證流程
- 支援非信用卡付款方式
- 支援AE卡
- XCode 16.2+ (目前 Apple Store 上架最低版本)
Since April 24, 2025
Apps uploaded to App Store Connect must be built with Xcode 16 or later using an SDK for iOS 18, iPadOS 18, tvOS 18, visionOS 2, or watchOS 11.
- Swift 5.5+
- iOS 13+
- Cocoapods 1.12.1+
- 因 SDK 部分功能需使用相機進行拍攝,請於主專案的 Info.plist 檔中加入 NSCameraUsageDescription 權限說明字串,以確保應用程式能正常取得相機使用權限。
- 承上, SDK 版本 1.8.1 範例程式我們也更新了 Info.plist, 添加了相機權限請求詢問字串
- 關閉了 SDK 內部啟用鍵盤套件 IQKeyboard 的 enabled 參數 (設定 true/false), 避免了一些閃退的問題
- 如要啟用, 請在 SDK 外部啟用
// AppDelegate.swift IQKeyboardManager.shared.enable = true
- 承上, 此變更於 SDK 版本 1.8.0 變動, 於 SDK 版本 1.8.1 的範例程式加入該程式碼
- 如有不啟用 IQKeyboard 套件的廠商, SDK 版本 1.8.1 我們做了修正, 可在信用卡編輯頁面的任一鍵盤外區域點擊即可關閉鍵盤
請注意,此套件使用 XCFramework 製作,Cocoapods 的版本必須要是 1.12.1 以上。
Podfile內容 請把 use_frameworks 使用 linkage static 移除
use_frameworks! :linkage => :static ### 如果有使用 static, 請移除此行
#正確如下
use_frameworks!指定 SDK
pod 'ECPayPaymentGatewayKit', '1.10.0'在 Podfile 內找到原本設定的相依套件的敘述,直接將其註解掉(Remark) 或者 刪除。
# pod 'PromiseKit' , '6.8.5'
# pod 'Alamofire', '5.10.1'
# pod 'IQKeyboardManagerSwift', '7.0.0'
# pod 'KeychainSwift', '16.0.1'
# #pod 'SwiftyJSON', '~> 4.2.0' #自版本號 1.3.2 起, 移除了 SwiftyJSON 的套件參考.
# pod 'SwiftyXMLParser', :git => 'https://github.com/yahoojapan/SwiftyXMLParser.git'
# pod 'CryptoSwift', '1.4.1'在 Podfile 內找到以下,並且將其註解掉(Remark) 或者 刪除
# static_frameworks = ['ECPayPaymentGatewayKit']
# pre_install do |installer|
# installer.pod_targets.each do |pod|
# if static_frameworks.include?(pod.name)
# puts "#{pod.name} installed as static framework!"
# def pod.static_framework?;
# true
# end
# end
# end
# end在 Podfile 內找到以下,並且多加入一行有 "BUILD_LIBRARY_FOR_DISTRIBUTION" 的內容
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' #######請加入這行
end
end
end範例專案以 Swift 為主,安裝時請在 [Podfile] 同層目錄下執行以下指令:
pod install若要避免快取,我們可以改由以下的指令安裝。
#曾經安裝過SDK的話,請先解除安裝
pod deintegrate '可能需要有 .xcodeproj 的路徑'
#再清除快取 (若有多個,請多次執行該指令刪除)
pod cache clean ECPayPaymentGatewayKit
#重新安裝更新的版本
pod install --repo-updateimport ECPayPaymentGatewayKit建議於 AppDelegate.swift 內執行初始化的動作,環境參數請參考下段說明。
ECPayPaymentGatewayManager.sharedInstance().initialize(env: .Stage)請參考AppDelegate.swift 程式碼如下,可直接修改您想使用的環境:
//var envStr:String = "prod"
//if let env = Bundle.main.object(forInfoDictionaryKey: "ENV") as? String {
// envStr = env.lowercased()
//}
//switch envStr {
//case "stage":
// ECPayPaymentGatewayManager.sharedInstance().initialize(env: .Stage)
// break
//default:
// ECPayPaymentGatewayManager.sharedInstance().initialize(env: .Prod)
// break
//}
//或者把上述程式碼 remark,並且直接改成您想使用的環境。
ECPayPaymentManager.sharedInstance().initialize(env: .Stage)信用卡交易。填入交易 Token 以及交易編號等待 callback 即可。請參考 ViewController.swift 程式碼如下:
ECPayPaymentGatewayManager.sharedInstance().createPayment(token: token,
merchantID: "",
useResultPage: use_resultPage_Switch.isOn ? 1 : 0,
app"測試的商店(\(ECPayPaymentGatewayManager.sharedInstance().sdkEnvironmentString()))",
language: use_enUS_Switch.isOn ? "en-US" : "zh-TW")
{ (state) in
//
self.resultTextView.text = state.description
// print(state)
// print("")
// if state.callbackStateStatus == .Success {
//
// let state_ = state as! CreatePaymentCallbackState
// print("CreatePaymentCallbackState:")
// print(" RtnCode = \(state_.RtnCode)")
// print(" RtnMsg = \(state_.RtnMsg)")
// print(" MerchantID = \(state_.MerchantID)")
// print(" OrderInfo = \(state_.OrderInfo)")
// print(" CardInfo = \(state_.CardInfo)")
//
// }
if let callbackState = state as? CreatePaymentCallbackState {
print("CreatePaymentCallbackState:")
print("RtnCode = \(callbackState.RtnCode)")
print("RtnMsg = \(callbackState.RtnMsg)")
if let order = callbackState.OrderInfo {
print("\(order)")
print("\(order.MerchantTradeNo ?? "")")
print("\(order.TradeNo ?? "")")
print("\(order.TradeDate)")
print("\(order.TradeStatus ?? 0)")
}
if let card = callbackState.CardInfo {
print("\(card)")
print("\(card.AuthCode ?? "")")
print("\(card.Gwsr ?? "")")
print("\(card.ProcessDate)")
print("\(card.Stage ?? 0)")
print("\(card.Stast ?? 0)")
print("\(card.Staed ?? 0)")
print("\(card.Amount ?? 0)")
print("\(card.Eci ?? 0)")
print("\(card.Card6No ?? "")")
print("\(card.Card4No ?? "")")
print("\(card.RedDan ?? 0)")
print("\(card.RedDeAmt ?? 0)")
print("\(card.RedOkAmt ?? 0)")
print("\(card.RedYet ?? 0)")
}
if let atm = callbackState.ATMInfo {
print("\(atm)")
print("\(atm.BankCode ?? "")")
print("\(atm.vAccount ?? "")")
print("\(atm.ExpireDate)")
}
if let cvs = callbackState.CVSInfo {
print("\(cvs)")
print("\(cvs.PaymentNo ?? "")")
print("\(cvs.ExpireDate)")
print("\(cvs.PaymentURL ?? "")")
}
if let barcode = callbackState.BarcodeInfo {
print("\(barcode)")
print("\(barcode.ExpireDate)")
print("\(barcode.Barcode1 ?? "")")
print("\(barcode.Barcode2 ?? "")")
print("\(barcode.Barcode3 ?? "")")
}
if let unionpay = callbackState.UnionPayInfo {
print("\(unionpay.UnionPayURL ?? "")")
}
}
let ac = UIAlertController(title: "提醒您", message: "已經 callback,請看 console!", preferredStyle: UIAlertController.Style.alert)
let aa = UIAlertAction(title: "好", style: UIAlertAction.Style.default, handler: nil)
ac.addAction(aa)
self.present(ac, animated: true, completion: nil)
}綠界科技 技術客服信箱:techsupport@ecpay.com.tw
Copyright © 1996-2021 Green World FinTech Service Co., Ltd. All rights reserved.