Swiftpack.co - 2C2P/OneTwoThreeSDK-iOS as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by 2C2P.
2C2P/OneTwoThreeSDK-iOS 1.0.2
OneTwoThreeSDK for iOS
⭐️ 0
🕓 2 weeks ago
iOS
.package(url: "https://github.com/2C2P/OneTwoThreeSDK-iOS.git", from: "1.0.2")

OneTwoThreeSDK

Installation

Swift Package Manager

To integrate OneTwoThreeSDK using Swift Package Manager, you can easily add this to your Xcode project:

dependencies: [
    .package(url: "https://github.com/OrawanM/OneTwoThreeSDK.git", .upToNextMajor(from: "1.0.2"))
]

Import

import OneTwoThreeSDK

Usage

import OneTwoThreeSDK

class ViewController: UIViewController {

    let service = OneTwoThreeSDKService(
        checksumKey: "CHECKSUM_KEY",
        publicKey: "PUBLIC_KEY",
        privateKey: "PRIVATE_KEY",
        passphrase: "PASSPHASE"
    )
    
    let merchant = Merchant(
        id: "[email protected]",
        redirectURL: "onetwothreeapp://",
        notificationURL: "https://uat2.123.co.th/DemoShopping/apicallurl.aspx",
        merchantData: [
            MerchantData(key: "item", value: "943-cnht302gg"),
            MerchantData(key: "item", value: "FH403"),
            MerchantData(key: "item", value: "10,000.00"),
            MerchantData(key: "item", value: "Ref. 43, par. 7")
        ]
    )
    let transaction = Transaction(
        merchantReference: "309321249653",
        preferredAgent: "SCB",
        productDesc: "",
        amount: "100",
        currencyCode: "THB",
        paymentInfo: "",
        paymentExpiry: "2021-12-10 11:21:36"
    )
    let buyer = Buyer(
        email: "[email protected]",
        mobile: "09912345678",
        language: "EN",
        notifyBuyer: true,
        title: "Mr",
        firstName: "Bruce",
        lastName: "Wayne"
    )
    
    func startDeeplink() {
        service.startDeeplink(merchant: merchant, transaction: transaction, buyer: buyer) { response in
            // TODO: Success
            
            // NOTE: Redirect to bank app using 'deeplinkURL' from the response.
            if let deeplinkURL = response?.deeplinkURL, let url = URL(string: deeplinkURL) {
                UIApplication.shared.open(url) { (result) in
                    if result {
                        // TODO: Success
                    } else {
                        // TODO: Failed
                    }
                }
            }
            
        } failureBlock: { error in
            // TODO: Failed
        }
    }
        
}

Contributing

2C2P

License

MIT

GitHub

link
Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics