How shopify/unity-buy-sdk works
Main components
• Unity Editor / Build Pipeline
– Assets/Editor: mock loaders, build classes, test utilities
– ExternalDependencyManager plugin (manages platform libs)
• Runtime SDK Core
– Assets/Shopify/Unity/SDK:
• ConnectionLoader / QueryLoader (HTTP GraphQL client)
• BaseLoader & ILoaderProvider (loader abstraction)
• ResponseMergeUtil, Serialization & GraphQL query definitions
• NativeMessage & NativePayment interfaces
• UI Toolkit
– Assets/Shopify/UIToolkit:
• Components (HTTPUtils, RemoteImageLoader, ProductCache)
• ShopControllers (CartController, MultiProductShopController)
• Shops (generic and single‐product prefabs, views, animation assets)
• Native Plugins
– iOS (Assets/Shopify/Plugins/iOS + PluginDependencies/iOSPlugin):
• Swift/Objective‐C bridge (UnityBuySDKPlugin.a, UnityBuyAppController)
• Apple Pay event dispatch, PKPayment serialization
– Android (Assets/Shopify/Plugins/Android/libs):
• AAR libraries for web pay and common logic
• External Services
– Shopify Storefront API (GraphQL endpoint)
– Safari Web View / Chrome Custom Tab for web checkout
– Apple Pay / Android Pay mobile payment networks
• Testing Framework
– Assets/IntegrationTests & Assets/NativeTesting
– UIToolkit tests under Assets/Shopify/UIToolkit/Test
• CI/CD
– .github/workflows (build, test, CLA checks)
– scripts/ (build, test, docs generation, publish)
– Doxygen docs in docs/
Relationships & data flows
• Editor layer → (build pipeline) configures & bundles native plugins
• Runtime C# SDK → uses QueryLoader → HTTPUtils → Shopify GraphQL API
• SDK → emits NativeMessage → native plugin modules handle Apple Pay / web checkout
• UI Toolkit controllers → call SDK loaders → update UI views & cache images
• Tests → drive the SDK & UI in Unity Editor or native harness
• CI workflows → execute scripts/**/* → build docs, run tests, package .unitypackage
Architectural patterns & principles
• Layered architecture: Editor tools vs Runtime SDK vs UI vs Native
• Abstraction of loader (ILoaderProvider) for pluggable transports (EditorLoader, UnityLoader, NativeLoader)
• MVC‐style separation in UIToolkit: Controllers ↔ Views ↔ Models (Product, Cart)
• GraphQL code generation (scripts/generator) for type‐safe query classes
• CI as code with GitHub Actions for reproducible builds & docs
Technologies & frameworks
• Unity (C# / Mono)
• GraphQL (HTTP queries to Shopify API)
• Swift & Objective-C bridging (iOS plugin)
• Android AAR libraries (Chrome Custom Tabs)
• ExternalDependencyManager (Unity package manager plugin)
• Doxygen (native code docs), GitHub Actions