Skip to content

cassianomoraes/yuno-sdk-ios

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YunoSDK

Version License Platform iOS Minimum Deploy Target - 13.0

A fast checkout that integrates your company to the payments and fraud ecosystem. ‍ Checkout + Routing + Reconciliations + Alternative Payment Methods

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

To integrate Yuno SDK with Cocoapods, please add the line below to your Podfile and run pod install.

pod 'YunoSDK', '~> 1.0.12'

Then run pod install in your directory:

$ pod install

Usage

YunoSDK minimum required version is iOS 13.0

First, you'll need to get your Yuno app ID and iOS API key. Then initialize Yuno by importing Yuno and adding the following to your application delegate:

Note: If your app is using a UISceneDelegate you will need to put your Yuno initialisation code into your SceneDelegate

import YunoSDK

Yuno.initialize(apiKey: "<Your iOS API Key>")

Functions

Enroll a new payment method

To display a view controller with the flow to enroll a new payment method, call the following method:

protocol YunoEnrollmentDelegate: AnyObject {
        
    var customerSession: String { get }
    func yunoEnrollmentResult(_ result: Yuno.Result)
}

class ViewController: YunoEnrollmentDelegate {

    @IBAction func startEnrollment(sender: Any) {
        Yuno.enrollPayment(with: self, showPaymentStatus: Bool)
    }
}

Note: showPaymentStatus by default is true

Checkout

To start a new payment process, it is necessary to call the following method with a payment delegate as a parameter

protocol YunoPaymentDelegate: AnyObject {
        
    var checkoutSession: String { get }
    var countryCode: String { get }
    var language: String { get }
    var navigationController: UINavigationController? { get }
    
    func yunoCreatePayment(with token: String)
    func yunoPaymentResult(_ result: Yuno.Result)
}

class ViewController: YunoPaymentDelegate {

    func viewDidLoad() {
        super.viewDidLoad()
        Yuno.startCheckout(with: self)
    }
}

Show Payment Methods

When you implement a SDK Full you have to add the next view on your layout to show the payment methods available

Yuno.methodsView(delegate: self)
    generator.getPaymentMethodsView(checkoutSession: checkoutSession) { [weak self] (view: UIView) in
        // Add view to your superview
    }
}

Start Payment

To start a payment process you have to call the method startPayment but if your are using the lite version you must to call startPaymentLite

Yuno.startPayment()

for the Lite version you need to send an additional parameter, these consist, the vaulted token and/or payment type with which the user will pay

protocol PaymentMethodSelected {
    var vaultedToken: String? { get }
    var paymentMethodType: String { get }
}

Yuno.startPaymentLite(paymentSelected: paymentSelected)

At the end of this process you will obtain the One Time Token to create back-back the payment, this data you can obtain from the callback of the delegate.

You can get some information like OTT after call a startPayment or startPaymentLite method, how is showing in the next code:

func yunoCreatePayment(with token: String) { ... }

Complete Payment

If the payment required a start an action to complete the payment, you can call the following method to execute the payment and get state of the transaction

Yuno.continuePayment(showPaymentStatus: Bool)

showPaymentStatus by default is true

Callback

The transactions could return three different states: success, fail, processing and reject, to listen this state you have to implement the delegate, like in the follow piece of code:

enum Result {
    case reject, success, fail, processing, internalError, userCancell
}

func yunoPaymentResult(_ result: Yuno.Result) { ... }
func yunoEnrollmentResult(_ result: Yuno.Result) { ... }

Author

Yuno Payments Inc.

License

YunoSDK is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 91.2%
  • Ruby 8.8%