Integrate SDK on application side
You need a token to make the SDK work properly. A payment token is a string that is used to initiate the payment process.
You can get a token using createOrder
, createOrderByItemSku
, createOrderFromCartById
or createOrderFromCurrentCart
method from Store library. You can also use a token obtained on your application server using the Create payment token for purchase API call.
To open the payment UI inside the application, the SDK uses WKWebView. This makes the in-app purchase process seamless, because users won’t see transitions between the application and the web page.
We recommend to set up a close button for the payment UI, since the browser bar and standard navigation elements are not visible to the user in WKWebView. To do this, in the StorePaymentProjectSettings
structure in the ui.mobilePlatformSettings
parameter, pass the header = StorePaymentProjectSettings.UISettings.PlatformSettings.Header
object with the closeButton: true
parameter.
You can select the icon that will be displayed on the button. To do this, pass one of the following values in the closeButtonIcon
parameter in instances of the PurchaseParams
class:
“arrow”
— to display the ← icon (used by default)“cross”
— to display the × icon
- swift
let mobileHeaderSettings = StorePaymentProjectSettings.UISettings.PlatformSettings.Header(closeButton: true, closeButtonIcon: "arrow")
let mobilePlatformSettings = StorePaymentProjectSettings.UISettings.PlatformSettings(header: mobileHeaderSettings)
let uiSettings = StorePaymentProjectSettings.UISettings(theme: "63295aab2e47fab76f7708e3", size: StorePaymentProjectSettings.UISettings.Size.medium, mobilePlatformSettings: mobilePlatformSettings)
let redirectPolicy = StorePaymentProjectSettings.RedirectPolicy(redirectConditions: .any, delay: 5, statusForManualRedirection: .any, redirectButtonCaption: "Back to the game")
let paymentProjectSettings = StorePaymentProjectSettings(ui: uiSettings, returnUrl: "xsollasdk123456://xsollaconfirm/payment", redirectPolicy: redirectPolicy)
Example of setting up a close button for the payment UI:
Found a typo or other text error? Select the text and press Ctrl+Enter.