iOS — SPayLater Widget Installation
This guide walks you through adding the SPayLater Promotional Widget to your iOS app. Once installed, ShopeePayKit automatically shows instalment pricing alongside your product prices — and hides itself silently if no pricing data is available, so your layout is never broken by an empty widget.
What this does
ShopeePayKit adds two native iOS views: a banner for Homepage awareness, and an instalment message view for Category and Product Detail Pages. Both views handle their own data fetching and rendering. If the SDK cannot retrieve pricing data (for example, because the product is ineligible), the view collapses to zero height automatically — no empty space is left behind. Installation is a developer task; the steps below include everything your iOS developer needs.
Before you start
- Access Key — your unique SPayLater plugin key. Get it from your ShopeePay account manager if you don't have one yet.
- Store External ID — your ShopeePay store ID (
storeExtId). Same source. - iOS 12+ target, Xcode 15+ — the SDK supports iOS 12 and later. Your build environment must be Xcode 15 or above.
- An iOS developer — the steps below require someone who can edit your Podfile and Objective-C or Swift source files.
- CocoaPods installed — the third-party dependencies are managed via CocoaPods. Run
gem install cocoapodsif it is not already installed.
Merchant tip: Send your developer this page along with your Access Key and Store External ID. That is everything they need to complete the installation.
Installation steps
Step 1 — Add the third-party CocoaPods libraries
ShopeePayKit depends on SDWebImage and Masonry. Add both to your Podfile, then run pod install from your project root:
source 'https://cdn.cocoapods.org/'
platform :ios, '12.0'
use_frameworks!
target 'YourMerchantApp' do
pod 'SDWebImage'
pod 'Masonry'
endAfter pod install completes, open the newly created .xcworkspace file instead of the .xcodeproj file for all future Xcode sessions.
Step 2 — Add the ShopeePayKit files to your project
Two XCFrameworks are provided by your ShopeePay account manager (not public CocoaPods pods). Drag and drop both into your Xcode project navigator:
ShopeePayKit.xcframeworkSDBProtectFramework.xcframework
In the dialog that appears for each framework:
- Check Copy items if needed.
- Select your app target under Add to targets.
Navigate to Your Target → General → Frameworks, Libraries, and Embedded Content and confirm both XCFrameworks are listed. Set each to Do Not Embed — they are static XCFrameworks and should only be linked, not embedded.
In Build Settings, also confirm:
- Other Linker Flags contains
-ObjC - Framework Search Paths includes the folder containing
ShopeePayKit.xcframework
Step 3 — Link the required Apple system frameworks
In Your Target → Build Phases → Link Binary With Libraries, add the following frameworks if they are not already present:
UIKit.frameworkFoundation.frameworkNetworkExtension.frameworkDeviceCheck.frameworkStoreKit.frameworklibresolv.9.tbdlibc++.tbd
Step 4 — Initialize the SDK
In your AppDelegate (or the equivalent SwiftUI app entry point), initialize ShopeePayKit inside application:didFinishLaunchingWithOptions:. Replace the placeholder values with your real credentials:
SPLConfiguration *configuration =
[[SPLConfiguration alloc] initWithAccessKey:@"YOUR_ACCESS_KEY"
storeExtId:@"YOUR_STORE_EXT_ID"
country:SPLCountryID
currency:SPLCurrencyIDR
language:SPLLanguageEN
environment:SPLEnvironmentUAT]; // switch to SPLEnvironmentLive for release
[[ShopeePayLaterKit sharedKit] configureWithConfiguration:configuration];Update SPLCountryID, SPLCurrencyIDR, and SPLLanguageEN to match your target market. Use SPLEnvironmentLive when building for App Store release.
Step 5 — Place the widget on your pages
ShopeePayKit provides two distinct views depending on the page type:
Homepage — Banner view (awareness messaging, no price required):
SPLBannerView *bannerView = [SPLBannerView new];
[self.view addSubview:bannerView];Category and Product pages — Instalment message view (pricing messaging, requires product ID and amount):
SPLInstallmentMessageView *messageView = [SPLInstallmentMessageView new];
[self.view addSubview:messageView];
[messageView loadWithProductId:@"product_123" amount:@10000 pageType:SPLPageTypeProduct];Pass SPLPageTypeCategory for listing pages and SPLPageTypeProduct for Product Detail Pages. The amount should be the product price in the smallest currency unit (e.g. cents).
Developer note — exact SDK parameters, environments, and page types
SPLConfiguration parameters
| Parameter | Type | Description |
|---|---|---|
accessKey | NSString * | SPL plugin key provided by ShopeePay |
storeExtId | NSString * | Your ShopeePay Store External ID |
country | SPLCountry | e.g. SPLCountryMY, SPLCountryTH, SPLCountryID |
currency | SPLCurrency | e.g. SPLCurrencyMYR, SPLCurrencyTHB, SPLCurrencyIDR |
language | SPLLanguage | e.g. SPLLanguageEN, SPLLanguageTH, SPLLanguageID |
environment | SPLEnvironment | SPLEnvironmentUAT for testing; SPLEnvironmentLive for App Store |
loadWithProductId parameters
| Parameter | Type | Description |
|---|---|---|
productId | NSString * | Your product's SKU or ID |
amount | NSNumber * | Price in smallest currency unit (e.g. cents) |
pageType | SPLPageType | SPLPageTypeCategory or SPLPageTypeProduct |
Optional: call [[ShopeePayLaterKit sharedKit] setLogEnabled:YES] during development to enable SDK debug logs in the Xcode console. Disable this in your App Store build. For the full iOS developer reference, refer to the Confluence documentation provided by your ShopeePay account manager.
Configuration
| Setting | Where to set it | Notes |
|---|---|---|
| Access Key | accessKey in SPLConfiguration | Required. Provided by your ShopeePay account manager. |
| Environment | environment in SPLConfiguration | Use SPLEnvironmentUAT for development and testing; switch to SPLEnvironmentLive before App Store submission. |
| Country / Currency / Language | SPL enums in SPLConfiguration | Must match the market your SPayLater agreement covers. |
| Store ID | storeExtId | Required. Set once at SDK initialization. |
| Page type | pageType in loadWithProductId | Controls which variant of the widget is shown. Use the correct type for each screen. |
| Styling | Not configurable | The widget uses SPayLater's standard visual style. Custom colors or fonts are not supported. |
How to verify the installation
- Build and run your app in SPLEnvironmentUAT mode on a real iOS device or Simulator.
- Navigate to a page where you placed the widget (Homepage, Category, or Product page).
- Confirm the "Buy Now, Pay Later with SPayLater" messaging appears at the expected position — typically just below the product price.
- On a Product page, tap the ⓘ info icon next to the instalment line. A pop-up should appear listing the available instalment plans and monthly amounts.
- Once everything looks correct in UAT, change the environment to
SPLEnvironmentLiveand submit your App Store build.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Widget is blank / zero height | SDK not initialized before the view loads | Ensure configureWithConfiguration: is called in application:didFinishLaunchingWithOptions:, before any view controller is shown. |
| Build error: framework not found | ShopeePayKit not correctly linked in Xcode | Check that ShopeePayKit appears in Frameworks, Libraries, and Embedded Content under your target and is set to Embed & Sign. |
| Widget shows but no instalment price | Wrong country/currency or amount is nil | Verify SPLCountry and SPLCurrency match your market, and that amount is passed as a non-nil NSNumber in smallest currency units. |
| CocoaPods install fails | Outdated CocoaPods or repo not found | Run pod repo update then pod install again. Confirm your CocoaPods version is current with pod --version. |
| Widget visible in UAT but not in LIVE | Store not yet activated in ShopeePay's live environment | Contact your ShopeePay account manager to confirm your store is activated for the production environment. |
FAQ
Does the SDK support Swift?
The SDK's public API is in Objective-C, and it is fully interoperable with Swift. Call ShopeePayKit methods from Swift exactly as you would any Objective-C framework — no bridging header is required for projects that use the .xcframework format.
What happens if the instalment data can't be loaded?
The view collapses to zero height and hides itself. No error message is shown to the customer and no empty widget container is left behind. Your layout is unaffected.
Can I customize the widget's appearance?
No. The widget uses SPayLater's standard visual style and cannot be themed. Custom colors or fonts are not supported — this preserves regulatory-reviewed messaging and a consistent trust signal for customers.
Do I need a separate Access Key for UAT and LIVE?
No. Your Access Key is the same across both environments. The environment is controlled by the environment parameter in SPLConfiguration. Switching between UAT and LIVE is a one-line change and a rebuild.