sonect-shop-sdk-ios

Sonect Shop SDK


License
SCEA
Install
pod try sonect-shop-sdk-ios

Documentation

Sonect Shop SDK for iOS

In this document we will go through the necessary steps to integrate Sonect Shop SDK in your iOS app.

Contact support@sonect.ch if additional info is needed.

Installation:

Via dependency managers:

  • Cocoapods: pod 'sonect-shop-sdk-ios' Installation guide
  • Carthage: github "sonect/sonect-shop-sdk-ios"
  • Manual

Sonect Shop SDK is written from ground up in Objective - C, and doesn’t have any external dependencies, so that it plays well with older code bases.

Minimum version: iOS 9.0+

The main entry point to the SDK is SNCSonectShop object. To present the Sonect view controller, you have to obtain the SDK token, the user ID and the signature, which must be calculated on your bank's serverside for security reasons.

Obj-C

Simple SDK Integration

SNCShopCredentials *credentials = [[SNCShopCredentials alloc] initWithSdkToken:_SHOP_SDK_TOKEN_
								    merchantId:_YOUR_MERCHANT_ID_
							       	      deviceId:_YOUR_DEVICE_ID_];

//Create a SonectShopConfiguration.plist, alternatively use initWithContentsOfFile:
SNCShopConfiguration *configuration = [SNCShopConfiguration defaultConfiguration];

//In order to scan the barcodes, you need to set your preferred scanning plugin, or implement your own. 
id <SNCScanCodePlugin> scanPlugin = [MyScanCodePlugin new];
SNCSonectShop.scanCodePlugin = scanPlugin;

//In order to check user's KYC, use a Idenfy KYC plugin or implement your own.  
id <SNCKycProviderPlugin> kycPlugin = [MyKycProviderPlugin new];
SNCSonectShop.kycProviderPlugin = kycPlugin;

//In order to add address autocompletion use Google Autocompletion, or implemnent your own.
id <SNCAddressAutocompletionPlugin> plugin = [MyAddressAutocompletionPlugin new];
SNCSonectShop.addressAutocompletionPlugin = plugin;

//Present the shop interface on top of your app. 
[SNCSonectShop presentWithCredentials:credentials
                        configuration:configuration
             presentingViewController:self.viewController];

Barcode scanning

The Sonect Shop SDK allows you to use your barcode scanning SDK, by implementing a simple SNCScanCodePlugin protocol, and plugging it in the Sonect Shop SDK.

id <SNCScanCodePlugin> scanPlugin = [MyScanCodePlugin new];
SNCSonectShop.scanCodePlugin = scanPlugin;

Optimally, for best barcode and QR code scanning experience, Sonect has partnered with Scandit, so you can also use the Scandit Plugin. Sonect will provide additional details for integration.

KYC Check

The Sonect Shop SDK allows you to use Idenfy as the KYC check provider. Integrate the Idenfy KYC Plugin as described in the repository README page to get the benefits of Idenfy scanning. Sonect will provide additional details for integration.

Address Autocompletion

With Sonect Shop SDK allows you can use Google autocompletion as the default address autocompletion plugin. Integrate the Sonect Google Address Autocompletion Plugin as described in the repository README page. If your company does not allow the usage of Google API-s you can roll your own autocomplete solution by implementing the SNCAddressAutocompletionPlugin protocol, and assigning it to the Sonect Shop SDK like so

id <SNCAddressAutocompletionPlugin> plugin = [MyAddressAutocompletionPlugin new];
SNCSonectShop.addressAutocompletionPlugin = plugin;

Configuration file

In order to configure the SDK, create a SonectShopConfiguration.plist file, and fill out the mandatory fields. You can load the configuration by using the SNCShopConfiguration object. A sample plist file might look like this, for more info consult the SNCShopConfiguration interface documentation.

Sample SonectShopConfiguration.plist values:

<dict>
	<key>SonectAlpha2CountryCode</key>
	<string>ch</string>
	<key>SonectCurrency</key>
	<string>CHF</string>
	<key>SonectShouldShowPaymentId</key>
	<true/>
	<key>SonectAllowedCountryCodes</key>
	<array>
		<integer>41</integer>
		<integer>1</integer>
	</array>
</dict>

Passing arbitrary shop attributes

If you need to pass arbitrary shop attributes i.e. a VAT number, then you can use Shop Attributes structure to do so.

SNCShopConfiguration *configuration = ... //YOUR_CONFIGURATION
SNCShopAttributes *attributes = [SNCShopAttributes attributesByAddingData: @{ @"VAT": @"123456789"}];
configuration.shopAttributes = attributes;

Themes

Sonect SDK supports theming colors and fonts to allow you to customize the SDK, so that it looks and feels right when embedded in your app. To apply a theme, you need to create a new SNCTheme object and apply a theme like in the following example.

SNCTheme *theme = [SNCTheme new];
theme.type = SNCThemeTypeLight;
theme.fontName = "Futura-Medium";
theme.boldFontName = "Futura-CondensedExtraBold";
theme.detailColor1 = UIColor.yellowColor;
theme.detailColor2 = UIColor.yellowColor;
theme.detailColor3 = UIColor.yellowColor;
theme.detailColor4 = UIColor.yellowColor;
theme.detailColor5 = UIColor.yellowColor;
theme.navigationBarTintColor = UIColor.yellowColor;
theme.navigationBarTitleImage = [UIImage imageNamed:@"rba"];
[theme set];