Skip to content
trustedshops-publicPublic

About

Trusted Shops iOS SDK

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trusted Shops iOS SDK

SwiftUI SDK for displaying Trusted Shops trust widgets and handling buyer protection checkout.

Platform iOS Swift

Table of Contents

Requirements

  • iOS 17+
  • Xcode with Swift 6.2 toolchain
  • Swift Package Manager
  • SwiftUI

Installation

Swift Package Manager

In Xcode, go to File > Add Package Dependencies and enter:

https://github.com/trustedshops-public/ios-sdk

Or add it directly to your Package.swift:

dependencies: [
    .package(url: "https://github.com/trustedshops-public/ios-sdk", from: "1.1.0")
]

Then add "trustedshops_ios_sdk" to your target's dependencies:

.target(
    name: "YourApp",
    dependencies: ["trustedshops_ios_sdk"]
)

Quick Start

1. Initialize the SDK

Call start(configs:) once at app launch, for example in your App.init():

import trustedshops_ios_sdk

@main
struct MyApp: App {
    init() {
        TrustedShopsSDK.start(
            configs: TrustedShopsConfigs(
                defaultMarket: .DEU,
                integrationIds: [.DEU: "your-integration-id"]
            )
        )
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

2. Display the Trustbadge

Place a TrustbadgeView in any SwiftUI view:

import trustedshops_ios_sdk

struct ContentView: View {
    var body: some View {
        TrustbadgeView(type: .horizontal)
    }
}

Trustbadge

Display Types

The Trustbadge supports two layouts:

// Compact horizontal banner
TrustbadgeView(type: .horizontal)

// Larger card layout with more detail
TrustbadgeView(type: .card)

Customization

TrustbadgeView supports standard SwiftUI modifiers for layout customization:

TrustbadgeView(type: .horizontal)
    .padding(16)
    .frame(maxWidth: .infinity)

Checkout Integration

OrderData

Construct an OrderData value with the order details. Only shopOrderId is required; every other field is optional:

import trustedshops_ios_sdk

let orderData = OrderData(
    email: "buyer@example.com",
    shopOrderId: "ORDER-123",
    amount: 59.99,
    currency: .EUR,
    paymentType: "CREDIT_CARD",
    estimatedDeliveryDate: "2026-04-01",
    products: [
        Product(name: "Wireless Headphones", sku: "WH-001")
    ]
)

Initiate Checkout

Call initiateCheckout to start the buyer protection flow. The SDK must be initialized first. This is an async method that must be called from an async context:

await TrustedShopsSDK.initiateCheckout(orderData: orderData)

Example in a button action:

Button("Secure Purchase") {
    Task {
        await TrustedShopsSDK.initiateCheckout(orderData: orderData)
    }
}

Note: checkout relies on the shop's Trustbadge data being loaded first. Make sure a TrustbadgeView has been shown (or otherwise given the SDK a chance to load) before calling initiateCheckout.

Supported Currencies

CHF, EUR, GBP, PLN, NOK, SEK, DKK, RON, CZK

Configuration

All configuration is passed to start(configs:) via a TrustedShopsConfigs value.

Multi-Market (Locale-Aware)

For apps operating in multiple markets, provide an integrationIds map keyed by TargetMarket. The SDK automatically resolves the correct integration ID based on the device's region:

TrustedShopsSDK.start(
    configs: TrustedShopsConfigs(
        defaultMarket: .DEU,
        integrationIds: [
            .DEU: "integration-id-de",
            .AUT: "integration-id-at",
            .GBR: "integration-id-gb",
        ]
    )
)

The resolution order is:

  1. Exact match for the device's region (e.g. DE → .DEU)
  2. .EUO fallback (if present in the map)
  3. defaultMarket, otherwise the first entry in the map

To manually switch the active market at runtime (instance method — call via getInstance()):

// Override to a specific market
TrustedShopsSDK.getInstance().setTargetMarket(.AUT)

// Revert to automatic system locale resolution
TrustedShopsSDK.getInstance().setTargetMarket(nil)

Environment

TrustedShopsConfigs defaults to .production, which is the environment integrators should use:

TrustedShopsSDK.start(
    configs: TrustedShopsConfigs(
        integrationIds: [.DEU: "your-integration-id"],
        environment: .production
    )
)
Environment Description
.production Production (default)

Logging

Enable SDK logging for debugging:

TrustedShopsSDK.start(
    configs: TrustedShopsConfigs(
        integrationIds: [.DEU: "your-integration-id"],
        logging: SDKLoggingConfig(
            isEnabled: true,
            level: .debug
        )
    )
)
Property Type Default Description
isEnabled Bool false Enable/disable logging
level SDKLogLevel .error Minimum log level
includeOSLog Bool true Bridge to Apple's unified logging
redactSensitiveData Bool true Redact PII in logs
customHandler SDKLogHandler? nil Custom log handler

Log levels: .off, .error, .warning, .info, .debug, .trace

API Reference

Symbol Type Description
TrustedShopsSDK.start(configs:) Function Initialize the SDK (call once)
TrustedShopsSDK.getInstance() Function The SDK singleton (after start)
TrustedShopsSDK.initiateCheckout(orderData:) Async function Start buyer protection checkout
TrustedShopsSDK.getInstance().setTargetMarket(_:) Function Override active market (multi-market only); pass nil to revert
TrustbadgeView SwiftUI View Displays the Trustbadge widget
TrustbadgeType Enum .horizontal, .card
TrustedShopsConfigs Struct SDK initialization configuration
TrustedShopsEnvironment Enum .production
TargetMarket Enum Supported markets (.DEU, .AUT, .GBR, etc.)
OrderData Struct Order information for checkout
Product Struct Product in an order
Currency Enum Supported currencies
SDKLoggingConfig Struct Logging configuration
SDKLogLevel Enum Log levels (.off through .trace)

License

The Trusted Shops iOS SDK is proprietary and closed source. See the LICENSE file for details.

About

Trusted Shops iOS SDK

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages