The Swedbank Pay iOS SDK facilitates the implementation of the Swedbank Pay API Platform in an iOS application.
The SDK has two components,
SwedbankPaySDKMerchantBackend. The first one is the core SDK, and
the second one contains utilities for interfacing with a server implementing
the Merchant Backend API.
If you are not using the Merchant Backend API for backend communication,
you only need to use the
SwedbankPaySDK component. Otherwise, you
should add both components to your project.
The SDK is available through the Swift Package Manager. This is the simplest way of adding the SDK to an Xcode project.
Follow the instructions here to add a SwiftPM dependency.
as the repository URL. Select either only the
SwedbankPaySDK library or both
libraries depending on your use-case.
The SDK is also available through CocoaPods. There are separate
pods for the two components, named
Add the relevant dependencies in your
pod 'SwedbankPaySDK', '~> 3.0'
pod 'SwedbankPaySDKMerchantBackend', '~> 3.0'
Please refer to the Developer Portal for usage instructions.
To explore a working app using the SDK, see the Example Project.
To start making payments you need four things:
Instead of just talking about it we have provided you with an example app, showing you in detail how integration can be done. Use that as a reference when building your own solution:
Using the MerchantBackendConfiguration you only need to provide the URL for your backend and header values for api key and an access token. Have a look at the configuration variable in PaymentViewModel.swift in the example app for a reference.
The SDK will then communicate with your backend, expecting the same API as our example backends. You don't have to provide all of the API, making payments only require /paymentorders, but you will want to support /tokens and /patch soon as well. To get started you can look at our backend example implementations which provides a complete set of functionality and describes in a very clear and easy manner how requests can be handled.
Using the Merchant example backend you can setup (for example) a Node.js backend and have it serve a client in debug-mode while integrating the app. Remember to supply your api-key and other values in the appconfig.json file in order for requests to work properly.
In PaymentViewModel.swift there is a paymentOrder property that describes how we create it. PaymentOrders have default values for properties that can, so that you only need to supply values for what the customer intends to purchase, or for to access advanced functionality.
The last step is to just create an instance of the SwedbankPaySDKController and present it to the user. In the example app we add it as a sub view controller, but it could be managed in any other way, see PaymentViewController.swift for details.
The delegate pattern is well known and widely used in the iOS community. Implement the delegate callbacks you are interested in to get notified of the state of the purchase. Typically you would need at least to know when payments succeed, is canceled or fail, but there are a few more callbacks to your disposal. See the SwedbankPaySDKDelegate protocol, or the example app implementation for more details.
This is all you need to get started and accepting payments, the next step is to let your customers save their card details, or to create purchase tokens for subscriptions or tokens for charges at a later stage. Depending on your specific use case.
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct and sign the contributor's license agreement.
|Last commit: 23 hours ago|
The SDK now supports Checkout version 3 (specifically Payments Only). The way instruments are set is different from previous version, and might be a breaking change depending on your specific usage. Other than this, changes are mostly non-visible from an API-standpoint which means that upgrading should be a smooth experience.