Skip to content

TrustlyInc/trustly-ios-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This example app provides a simple integration of the Trustly Lightbox iOS SDK in a SwiftUI iOS app.

Getting Started

  • clone
  • open project
  • Install Trustly SDK - This can be done 2 ways
    • Cocoapods
    • Swift Package Manager

Cocoapods

TrustlySDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'TrustlySDK'

In order to develop or test against an unreleased version of this SDK it is possible to install the pod from a branch of this repo:

pod 'TrustlySDK', :git => 'https://github.com/TrustlyInc/trustly-ios.git', :branch => '<BRANCH_NAME>'
Swift Package Manager - SPM

TrustlySDK is available through Swift Package Manager. To install it from Xcode simply click on File -> Add packages -> Search or Enter Package URL, paste the github url about this package https://github.com/TrustlyInc/trustly-ios.git:

Add package url

For production choose the main branch, but in order to develop or test against an unreleased version of this SDK choose the branch listed in the release version table.


Implementation Notes

In the MerchantViewController file, you will find a controller simulating the a merchant app screen. This controller will call the TrustlyLightboxViewController class, and this class will be responsible to call the PayWithMyBank SDK.

Note that the application has a URL Scheme configured in order for the app to have a Deep Link of demoapp://. A Deep Link is required for a successful Trustly Lightbox integration within a mobile app.

Define Establish Data with a Request Signature

As the Trustly Lightbox SDK runs on the client, requests between it and the Trustly API must be secured. Calculate a requestSignature using your Access Key from your server and fetch it from your iOS app prior to rendering the Trustly Lightbox. For more information read the section Define Establish Data with a Request Signature in this documentation, and check the code snipets bellow in the TrustlyLightboxViewController.swift file.

        ...

        /* Uncomment this function only if your merchant setup has the "Extended Security" enable in Admin console, and uncomment the code between the lines
        79-93 */
        self.updateEstablishWithRequestSignature()

        ...
    ...

    /* Uncomment this fuction if your merchant setup has the "Extended Security" enable in Admin console,
       and if did you alredy iimplemented in your backend the generate Request Signature endpoint.
    */
    func updateEstablishWithRequestSignature() {

        signatureApi.generateRequestSignatureFor(establishData: self.establishData) { (result) in
            do {
                try self.establishData["requestSignature"] = result.get()
                print("generateRequestSignature - requestSignature: \(self.establishData["requestSignature"])")

                self.buildLightbox()

            } catch {
                print("Error trying to get requestSignature")
            }
        }
    }

    ...

Server Side Features

This example project can be run entirely as a frontend app in order to quickly test basic Trustly functions. However, your application will likely require backend integration with Trustly as well. Check out our trustly-nestjs-example project to learn more and follow the steps below to integrate it with this app.

Contributing

You can participate in this project by submitting bugs and feature requests in the Issues tab. Please, add @lukevance as an assignee.

If you are interested in fixing issues and contributing directly to the code base, feel free to open a Pull Request with your changes. Please, make sure to fulfill our Pull Request Template and add @lukevance as code reviewer.

About

Simple Swift example app using the Trustly SDK for iOS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages