iOS
The Kryptonim iOS SDK is a library that allows you to easily integrate Kryptonim payments into your app. Use iOS SDK repo from this project https://github.com/kryptonim-sdk/ios
If you want to add Kryptonim payments to your app without using the SDK, you can do so using a browser. Check iOS via browser
Installation
Swift Package Manager
Swift Package Manager is a tool for managing the distribution of Swift packages. It’s integrated with the Swift build system and Xcode.
To integrate Kryptonim into your project using Swift Package Manager, add it to your Xcode project or to your Package.swift:
dependencies: [
.package(url: "https://github.com/kryptonim-sdk/ios.git", .upToNextMajor(from: "1.0.0"))
]
Usage
Use KryptonimView (SwiftUI) or KryptonimViewController (UIKit) which has three parameters:
init(
configuration: Configuration,
resultHandler: ((TransactionResult) -> Void)? = nil,
errorHandler: ((KryptonimError) -> Void)? = nil
)
configuration: Create aConfigurationobject with all data you want to pass as parameters so your app user doesn’t have to fill them during transaction process. All parameters and restrictions on their use can be checked here.resultHandler: Called when transaction process finishes with either success or failure.errorHandler: Called when any error occurs during the creation of the transaction.
You can see an example usage below:
SwiftUI
.fullScreenCover(isPresented: $showKryptonimView) {
KryptonimView(
configuration: buildKryptonimConfig(),
resultHandler: handleKryptonimResult(_:),
errorHandler: { error in
print("Error: \(error)")
}
)
}
private func buildKryptonimConfig() -> Configuration {
let configuration = Configuration(
transaction: .init(
amount: "0.5",
currency: .eur,
convertedCurrency: .usdc,
blockchain: .polygon,
walletAddress: "0x7BHcc84710728EB39aA4d460418816C3FfW28977"
),
creditCard: .init(
cardNumber: "11111111111111",
cardCVV: "111",
cardHolder: "John Smith"
),
theme: .dark
)
return configuration
}
private func handleKryptonimResult(_ result: KryptonimView.TransactionResult) {
showKryptonimView = false
switch result {
case .success:
print("SUCCESS")
case .failure:
print("FAILURE")
}
}
UIKit
class DemoViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: .system)
button.setTitle("Present KryptonimViewController", for: .normal)
button.addTarget(self, action: #selector(presentKryptonimViewController), for: .touchUpInside)
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
}
@objc private func presentKryptonimViewController() {
let kryptonimViewController = KryptonimViewController(
configuration: buildKryptonimConfig(),
resultHandler: { [weak self] in self?.handleKryptonimResult($0) },
errorHandler: { error in
print("Error: \(error)")
}
)
present(kryptonimViewController, animated: true, completion: nil)
}
private func buildKryptonimConfig() -> Configuration {
let configuration = Configuration(
transaction: .init(
amount: "0.5",
currency: .eur,
convertedCurrency: .usdc,
blockchain: .polygon,
walletAddress: "0x7BHcc84710728EB39aA4d460418816C3FfW28977"
),
creditCard: .init(
cardNumber: "11111111111111",
cardCVV: "111",
cardHolder: "John Smith"
),
theme: .dark
)
return configuration
}
private func handleKryptonimResult(_ result: KryptonimView.TransactionResult) {
self.dismiss(animated: true, completion: nil)
switch result {
case .success:
print("SUCCESS")
case .failure:
print("FAILURE")
}
}
}