Introduction

As of v.1.17.0 some SDK settings are moved away from the SDK in favour of being set within the client session.

The fields that are deprecated from the PrimerSettings are

Set these data when creating a client session with POST /client-session to make them available to all SDKs.

Integration

Whenever the PrimerDelegate clientTokenCallback(:) delegate function is called, you should set the desired fields to your backend, which will subsequently set them through a POST on /client-session.

This will return a client token, that you have to pass to the SDK as usual.

Example

import PrimerSDK
import UIKit

class ViewController: UIViewController {
	
		override func viewDidLoad() {
        super.viewDidLoad()

				Primer.shared.delegate = self

				// Example `PrimerSettings` object.
				// Notice that we don't need to set the deprecated fields.
				let settings = PrimerSettings(
            isFullScreenOnly: false,
            hasDisabledSuccessScreen: false,
            isInitialLoadingHidden: false
        )

        Primer.shared.delegate = self
				Primer.shared.configure(settings: settings)
		}
}

extension ViewController: PrimerDelegate {
    
    func clientTokenCallback(_ completion: @escaping (String?, Error?) -> Void) {
        // This data would likely be put in your backend
				let bodyJson: [String: Any] = [
				    "customerId": "john_smith",
				    "customer": [
				        "emailAddress": "[email protected]",
				        "mobileNumber": "0841234567",
				        "firstName": "John",
				        "lastName": "Smith",
				        "shippingAddress": {
				            "addressLine1": "47A",
				            "postalCode": "CB94BQ",
				            "city": "Cambridge",
				            "state": "Cambridgeshire",
				            "countryCode": "GB"
				        ],
				        "nationalDocumentId": "9011211234567"
				    ],
				    "currencyCode": "GBP",
				    "orderId": "ord-12345",
				    "order": {
				        "countryCode":"GB",
				        "lineItems": [
				            [
				                "amount": 100,
				                "quantity": 2,
				                "itemId": "item-123",
				                "description": "this item",
				                "discountAmount": 40
				            ]
				        ]
				    ]
				]

				requestClientToken(with: bodyJson, completion: completion)
    }

}

Detailed API documentation on POST /client-session can be found here.