Set Up an iOS Payment Link
This article explains how to set up a payment link in your app using Appcharge.
Step 1 | Send item details to your game server
When a player selects an offer in your game, such as a coin pack or a character skin, send the item details from the game client to your game server.
Step 2 | Call the Create Checkout Session API
First call the Appcharge Create Checkout Session API from your server.
Include the following in the request:
- Offer name and ID
- Item list and images
- Item prices
- Redirect URL (a universal link that brings the player back to the game)
Appcharge returns the following:
Parameter | Type | Description |
---|---|---|
checkoutSessionToken | String | A unique token that identifies and validates the checkout session. |
purchaseId | String | A unique ID to track the transaction. |
url | URL | The base URL for the Appcharge checkout page. |
Next, return the session data to the game client.
Step 3 | Build and open the checkout URL
In the game client, build the checkout URL using this format:
{$url}/{$checkoutSessionToken}?cot={$Checkout_Public_Key}
You can find the Checkout Public Key in the Publisher Dashboard under Settings -> Integration -> Checkout Public Key.
Important: The
cot
parameter is required, and without it, the checkout page will not load correctly.
Your checkout URL should look something like this:
https://appcharge-checkout-url.com/eb02bb412ccb47948f7d62667a7774b1?cot=0b2b42ab8a3d491ba76b6b8919d8e0ee
Next, open this URL in the browser.
Note: Notify players that they’ll briefly leave the app to complete their purchase securely in a mobile browser.
Step 4 | Handle checkout payment completion
The player selects a payment method and completes the purchase on the Appcharge checkout page. The Player Order Reporting Webhook is triggered, and your game server receives a POST request with the complete transaction data.
Step 5 | Redirect player to the game
Once payment is processed, Appcharge redirects the player to the redirectUrl
you provided in the Create Checkout Session API request.
The URL includes one of the following status query parameters:
Status | Meaning |
---|---|
?status=success | The purchase was completed successfully. |
?status=fail | An error occurred during the purchase process, and the user closed the checkout. |
?status=cancel | The player actively canceled the purchase. |
Note: The redirect uses a Universal Link, which may trigger a confirmation dialog on iOS. Learn how to remove it and send players straight back into the game.
Step 6 | Validate and fulfill the order
Next, in your game, parse the redirect URL and extract the status
. Send this data to your game server, validating the transaction against the date received from the Order Reporting Webhook. If the purchase is valid, apply the corresponding items to the player’s account.
Example
For a reference implementation, see our sample Unity app, which demonstrates the recommended process for integrating payment links into an iOS game.