將程式庫加入iOS Swift 項目

  1. 導入”IntegratedPaymentSolutionSDK.framework”

2. 在Project中, 在”Build Phases”底下增加 dependencies “Link Binary With Libraries”

3. 在”Info”下的”URL Types” 增加一個URL scheme。

使用支付程式庫

  1. 導入 SDK
import IntegratedPaymentSolutionSDK

2. 加入 PaymentResultCallback

extension MyViewController: PaymentResultCallback {
    func onSuccess(_ paymentResult: PyamentResult) {
        // do something
    }
    func onFailure(_ paymentResult: PyamentResult) {
        // do something
    }
}

3. ent 的物件,apiURL 會在開啓賬戶時告知商戶。

let payment = SpiralPayment(apiURL)


4. 呼叫 “pay” 並提供session ID 以及 PaymentResultCallback物件。

payment.pay(sessionId, callback: self as PaymentResultCallback)


5. (For Alipay Only) If Alipay app is installed, a URL will be returned by Alipay Client.Call the “processResultUrl” method with the URL in the function “func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool”

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    if payment.isAlipayResultUrl(url) {
        payment.processResultUrl(url)
    }
    return true
}

Class 定義

PaymentResult

FieldTypeSample
sessionIdStringMPGSSESSION0002121895830J8251291G62
paymentStatusPaymentStatusAPPROVED

  PaymentStatus

ValueRemark
APPROVED 
CANCELLED 
DECLINED 
NOT_SUPPORTED 
UNCONFIRMED未能確定結果,需要後台再進行查詢 。
QUERY_FAILED未能根據session ID取得交易所需資料。交易未在支付APP上發起。
APP_NOT_INSTALLED(適用於八達通) 相關支付App未安裝 。