Add the library into an iOS Swift project

1. Import the “IntegratedPaymentSolutionSDK.framework” into the project

2. In the project, add following dependencies “Link Binary With Libraries” under “Build Phases”

3. Add a URL scheme in “URL Types” under “Info”

Using the library for payment for iOS App

1. Import the SDK

import IntegratedPaymentSolutionSDK

2. Implement the protocol PaymentResultCallback

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

3. Cretae a SpiralPayment object. The apiURL will be provided during account opening.

let payment = SpiralPayment(apiURL)


4. Call the “pay” method with a session ID and a PaymentResultCallback object

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 Definition

PaymentResult

FieldTypeSample
sessionIdStringMPGSSESSION0002121895830J8251291G62
paymentStatusPaymentStatusAPPROVED

  PaymentStatus

ValueRemark
APPROVED 
CANCELLED 
DECLINED 
NOT_SUPPORTED 
UNCONFIRMEDUnable to determine the result and need to make further query at backend
QUERY_FAILEDCannot get the required transaction information by the session ID.
The transaction is not initialed on the payment APP.
APP_NOT_INSTALLEDFor Octopus, which means the Octopus App is not installed