
IAP Payment Providers
Tutorial
intermediate
+10XP
10m
Unity Technologies
Unity IAP enables you to offer your players more payment choices and get more margin from your game’s revenue. In this tutorial, we dive into how you can leverage Unity In-App Purchasing (IAP 5) alongside third-party payment providers like Stripe and Coda Payments. From configuring your project environment, item catalogues, to defining payment routing logic, we cover everything you need to get an alternative, direct-to-player checkout system rolling in your next game.
Resources
Overview Video
1. Prerequisites and account setup
Historically, mobile game monetization has been tightly controlled by traditional app stores and their respective fees. However, the ecosystem is shifting, opening up possibilities for developers to sell game catalogs directly to players using their own payment systems. In Unity’s In-App Purchasing (IAP) 5.4 and newer, third-party payment providers like Stripe and Coda Payments are now available alongside webshops which we will cover in the next tutorial of the series. The new alternative payment flows significantly reduce platform fees and allow you to keep more of your game’s revenue.
This tutorial provides a comprehensive, step-by-step guide to integrating payment providers with IAP 5. You can alternatively watch the overview video for a walkthrough of the same topic.
Before diving into the Unity Editor, you must establish accounts with your target payment providers and prepare a cloud-connected project.
Cloud-Connected Project: Ensure your Unity project is linked to a valid Unity Organization and Project ID via the Services window.
Payment Provider Accounts: Set up developer accounts at Stripe and/or Coda Payments. For initial implementation, you will operate entirely within their respective Sandbox environments to test transactions safely without real money.
2. Setting Up the Unity project
Import Packages
1. Open the Package Manager
2. Select In-App Purchasing (5.4 newer) or update it if you already had it installed.
3. Under the package details, navigate to the Samples tab and import the IAP 5 Coded Sample. This sample includes the foundational scripts and pre-configured catalog configurations needed for this workflow.
Configure Unity Authentication
Because checkout occurs externally (on a web page), you must uniquely identify players to verify that purchased items are delivered to the correct account.
- In the Package Manager, locate and install the Authentication package.
- Navigate to your Unity Gaming Services (UGS) Dashboard.
- Go to Access Management > Player Authentication > Identity Providers.
- Click Add Identity Provider and select Unity Player Accounts or utilize Anonymous Login for initial sandbox testing, if you want to know more about how to integrate authentication with Facebook, Apple or Google you can watch this video of the Gaming Services series.
3. Product Catalog Deployment
Unity IAP 5 allows you to manage product lists both locally in the Editor and remotely via the UGS Dashboard. Remote deployment is highly recommended, as it allows your sales and marketing teams to modify pricing and run promotional events without requiring a client-side app update.
Editor-Led Configuration
- Locate your catalog items from the sample in the project structure under Assets > Samples > In-App Purchasing > [Version] > IAP 5 Coded Sample > Assets > Catalog.
- Inspect a catalog item (e.g., infinitySword or gemst30).
- Set the Product Type (Consumable, Non-Consumable, or Subscription) and assign a base price.
Deploying to the Cloud
- Select your catalog assets.
- Open the Deployment Window (Services > Deployment).
- Check the items you wish to push online and click Deploy Selected.
- To verify the upload, open the UGS Dashboard, navigate to LiveOps > In-App Purchases > Catalog, and confirm that your items appear with their matching SKUs and values.
4. Configuring Environments and Scripts
To avoid breaking live production features while developing your checkout loop, separate your service data into environments.
Initialize the Development Environment
- In the Unity Editor, open your project properties (Edit > Project Settings > Services > Environments).
- By default, only the production environment exists. Click Manage environments to jump to the dashboard and create a new environment named development.
- Return to Project Settings and change the Environment Selector to development.
Note: You can configure a payment provider for the development environment, like a sandbox Stripe environment and an actual live account for the production environment.
Sync Code Configurations
Open the IAPService script bundled with the imported sample. Locate the constant managing the environment context and match it to your environment string:
const string k_Environment = "development";
5. Connecting Payment Providers to UGS
With your cloud catalog ready, you must grant Unity permission to securely interact with your payment gateways via OAuth.
- Open the UGS Dashboard and select LiveOps > In-App Purchases > Payment Providers.
- Locate Stripe or Coda and click Connect.
- Choose Sandbox Account for testing.
- An external OAuth dialog will launch. Sign into your provider account and authorize the Unity IAP application to link the accounts.
Implementing Redirects and Deep Linking
Once a player completes a web-based purchase, the provider needs to know where to send them. In the payment configuration card, click Configure to establish your Redirect URLs.
Important UX Note: If you simply input a standard web page as your Success URL, the player will be left stranded inside an external mobile browser or web view after paying. They would have to manually switch back to your game app, resulting in a clunky user experience.
To solve this elegantly, implement Deep Linking:
- A deep link is a specialized URL format (e.g., mygame://checkout-success) that a mobile operating system automatically intercepts.
- When the payment provider triggers this success URL, the mobile OS instantly closes the web browser and forces focus directly back to your active game application, automatically fulfilling the item.
- Consult the Unity Deep Linking Documentation to declare your application’s custom URL schemes.
Players expect some confirmation when they are taken back to the app.
6. Simulating Transactions and Verifying Logs
Testing direct-to-player flows can be accomplished safely inside the Editor.
- Open the scene from the Coded Sample and press Play.
- Initialize boots UGS and authenticates the user via your identity provider. In the console logs we can see how it then fetches your newly deployed catalog items.
- Click the button corresponding to your product (e.g., 30 Gems).
- The system automatically launches the web-based Stripe checkout interface. Because you are in sandbox mode, you can copy a mock credit card number, and input it into the checkout page.
- Finalize the payment. The interface will route through your deep link redirect, returning you to your running game screen with an “Order Confirmed” success banner.
Validating the Loop
To ensure your transactions are logging correctly on the back end:
- Provider Side: Check your Stripe or Coda dashboard analytics graphs under “Test Mode” to see transaction volume numbers tick up.
- Unity Side: Open UGS and go to LiveOps > In-App Purchases > Logs. Use the query tool to view incoming transaction payloads. Look for logs stating Order Creator Success followed by Order Status Update (Fulfilled Success).### Validating the Loop
To ensure your transactions are logging correctly on the back end:
- Provider Side: Check your Stripe or Coda dashboard analytics graphs under “Test Mode” to see transaction volume numbers tick up.
- Unity Side: Open UGS and go to LiveOps > In-App Purchases > Logs. Use the query tool to view incoming transaction payloads. Look for logs stating Order Creator Success followed by Order Status Update (Fulfilled Success).
7. Advanced Configurations: Branding and Routing
Before pushing your alternative store setup live to production, customize your presence and establish traffic logic.
Branding Your Checkout
Do not settle for a default, generic payment portal. Inside your provider’s native account dashboard (e.g., Stripe’s settings under Business > Branding), customize the design of your checkout menu. You can match the precise hex color codes of your game’s UI layout, choose custom typography styles, and upload official app icons or studio logos.## 7. Advanced Configurations: Branding and Routing
Before pushing your alternative store setup live to production, customize your presence and establish traffic logic.
A branded checkout will create a more consistent experience for players
Setting Up Provider Routing Rules
If you choose to leverage both Stripe and Coda Payments simultaneously to maximize global coverage, you must create operational boundaries. At the bottom of the UGS Payment Providers panel, click Add new rule.
Here, you can create conditional routing workflows:
- By Platform: you can route desktop standalone checkouts exclusively to Stripe, for example, while shifting mobile browser clicks to alternative partners.
- By Country: you can, for example, route North American and European transactions directly to Stripe, while establishing rules that route Southeast Asian or Latin American players to Coda Payments to leverage localized e-wallets and alternative carrier billing networks.
This is an overview for integrating payment providers in your game or app, in the next and last article of the series we will be looking at webshops and the creation tools that Unity provides to host your purchases cross-platform.