SDK for iOS
The library allows you to implement payment acceptance into iOS mobile apps and acts as an extension of the Yandex.Checkout API.
Mobile SDK includes ready-made payment interfaces, such as the payment form and everything related to it. Using the SDK, you can receive tokens for processing payments made via bank cards, Apple Pay, Sberbank Online, or the Yandex.Money wallet.
 Demo app
You can preview payment interfaces and the payment process in our special demo application. After installing the demo app, you will be able to experience the entire payment process from the point of view of your customers: click the Buy button, enter your bank card details or the Yandex.Money wallet details. The app allows you to play out different payment scenarios.
To install the demo app on iOS, you will need to download and install Testflight to your iPhone or iPad, accept the license agreement, and install the mSDK demo app.
By downloading this demo app, you accept the license agreement.
 Using the SDK
First of all, you need to implement payment acceptance via the Yandex.Checkout API. After that:
  1. Tell the manager you want to process payments using the mobile SDK.
  2. Once mobile SDK is enabled, issue a key for it in the Integration — API keys section of your Merchant Profile.
  3. Add the SDK to the app and configure it to generate one-time payment tokens.
  4. Set up the process of sending one-time tokens from the mobile app to your system (for example, to the back-end of your website that interacts with Yandex.Checkout).
  5. Make payments using payment tokens via the Yandex.Checkout API.
 Implementation
Requirements: iOS 8.0, 9, 10, 11, 12, and 13
Load the Yandex.Checkout libraries for installing the SDK.
You can implement a library via CocoaPods, the dependency manager for Swift and Objective-C-based Cocoa projects. At this time, Carthage is not supported.
 Implementing dependencies via CocoaPods
Step 1. Install CocoaPods.
cURL
$ gem install cocoapods
Step 2. Add dependencies to Podfile. Instead of 
Your Target Name
, specify the target’s name in Xcode for your app.
tag
is the SDK version, you can check it in the Releases section on GitHub.
Example of Podfile from the demo app
cURL
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'Your Target Name' do
  pod 'YandexCheckoutPayments',
    :git => 'https://github.com/yandex-money/yandex-checkout-payments-swift.git',
    :tag => 'tag'
end
Step 3. Add the
TrustDefender.framework
library to the Frameworks folder of your project.
The Yandex.Checkout manager will send you the
TrustDefender.framework
folder after you agree upon the mobile SDK implementation.
cURL
App
├─ Pods
└─ Frameworks
   └─ TrustDefender.framework
 Quick integration
 Step 1. Importing the dependencies
Import the dependencies to the initial file to work with
YandexCheckoutPayments
entities.
Swift
import YandexCheckoutPayments
import YandexCheckoutPaymentsApi
 Step 2. Preparing payment acceptance
Create
TokenizationModuleInputData
. In this model, you send payment parameters (currency and amount), payment form parameters that will be shown to the user during payment (payment methods, store name and order description), and the client apps key from the Integration — API keys section of your Merchant Profile.
Swift
let clientApplicationKey = "<Clients app key>"
let amount = Amount(value: 999.99, currency: .rub)
let tokenizationModuleInputData =
          TokenizationModuleInputData(clientApplicationKey: clientApplicationKey,
                                      shopName: "Space objects",
                                      purchaseDescription: """
                                          A very bright comet with an orbital period of 112 years
                                          """,
                                      amount: amount)
Create
inputData
for displaying payment form and assign it a value of 
TokenizationFlow.tokenization
with an associated value of 
TokenizationModuleInputData
.
Swift
let inputData: TokenizationFlow = .tokenization(tokenizationModuleInputData)
 Step 3. Getting the token
Create
ViewController
from
TokenizationAssembly
and put it on the screen.
Swift
let viewController = TokenizationAssembly.makeModule(inputData: inputData,
                                                     moduleOutput: self)
present(viewController, animated: true, completion: nil)
In 
moduleOutput
, send the object that implements the
TokenizationModuleOutput
protocol.
Implement the
TokenizationModuleOutput
protocol.
Swift
extension ViewController: TokenizationModuleOutput {
  func tokenizationModule(_ module: TokenizationModuleInput,
                          didTokenize token: Tokens,
                          paymentMethodType: PaymentMethodType) {
    DispatchQueue.main.async { [weak self] in
        guard let self = self else { return }
        self.dismiss(animated: true)
    }
    // Send the token to your system
  }

  func didFinish(on module: TokenizationModuleInput,
                   with error: YandexCheckoutPaymentsError?) {
      DispatchQueue.main.async { [weak self] in
          guard let self = self else { return }
          self.dismiss(animated: true)
      }
  }
}
 Step 4. Paying with the token
Close
ViewController
and send the token to your system. Then create a Yandex.Checkout API payment and specify the token received from SDK in the
payment_token
parameter. Confirmation scenario during payment creation depends on the payment method selected by the user. Payment method will be sent with the token in 
paymentMethodType
.
 SDK functionality
Using the SDK, you can:
  • tokenize user’s payment details;
  • for bank card payments, scan the card details and process 3-D Secure;
  • configure the payment form interface.
For tokenization debugging, you can use network request logging. Use the test mode to check if the SDK is integrated properly.
Learn more about the iOS SDK functionality in our documentation on GitHub (in Russian).
 See also
Payment tokenPayment processPayment methodsNotifications