Skip to content
Last updated

Initial Setup

Overview

The Ryft iOS Drop-In SDK lets you integrate card (and optionally Apple Pay) payments into your iOS application with minimal effort, allowing secure and safe payments using customisable UI components.

Requirements

Before you begin, ensure that you have the following prerequisites in place:

  • iOS 12.0 or later.
  • Xcode 15.0 or later.
  • Swift 5.0 or later.

Installation

The Ryft iOS Drop-In SDK is available via Swift Package Manager.

See Apple's guide on how to add a package dependency to your Xcode project.

Additionally, use the following URL to add the Ryft iOS SDK as a package dependency: https://github.com/RyftPay/ryft-ios

Initialisation

To initialise the Ryft Drop-In SDK in your iOS application, you need to import the Ryft module and create an instance of the RyftDropIn class. This instance will be used to present the Drop-In UI when processing payments.

We recommend initialising the drop-in instance each time it is displayed.

Here's an example of how to initialise the Ryft Drop-In SDK in your view controller:

Initialise Ryft iOS Drop-In SDK - Single Payment
import UIKit
import RyftCore
import RyftUI

class CheckoutViewController: UIViewController, RyftDropInPaymentDelegate {

    private var ryftDropIn: RyftDropInPaymentViewController?

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @objc private func showDropIn() {
        ryftDropIn = RyftDropInPaymentViewController(
            config: RyftDropInConfiguration(
                clientSecret: "{{the client secret of the payment-session}}"
            ),
            publicApiKey: "{{your public API key}}",
            delegate: self
        )
        present(ryftDropIn!, animated: true, completion: nil)
    }

    func onPaymentResult(result: RyftPaymentResult) {
        // see next section
    }
}

The Drop-In will automatically detect the appropriate environment (test or live) based on the provided Public Key.

Although you can safely hardcode your Public Key in the app for testing purposes, it is recommended to fetch it securely from your backend server when the customer initiates a payment, without requiring an app update. You can consider returning it alongside the clientSecret when creating a Payment Session.

Next Steps

Now that you have initialised the Ryft iOS Drop-In SDK, you can proceed to listen for payment results and display the payment UI to your users.

For more information on how to do this, please refer to the Drop-In Payment Listener section.