This tutorial suggests how you can integrate Appcharge Payment Links into a Unity iOS game. To demonstrate the integration, we created a sample Unity app that implements the full flow. We provide a step-by-step breakdown of the implementation, detailing each part of the process to help you adapt it to your own project. You can view the sample app on our GitHub repository.
We create a PurchaseManager class to act as the bridge between our game and the Appcharge payment system. Then we add an event that is triggered when our game receives a deeplink:
We parse the payment status from the deeplink, and then implement our game logic based on the status.
Copy
Ask AI
private void onDeepLinkActivated(string deeplinkURL) { Debug.Log("Deeplink URL: " + deeplinkURL); PurchaseStatus status = PurchaseStatusUtils.ParseStatusFromDeepLink(deeplinkURL); // Validate the order and game balance here before handling the payment result switch (status) { case PurchaseStatus.Success: Debug.Log("Purchase successful"); break; case PurchaseStatus.Fail: Debug.Log("Purchase failed"); break; case PurchaseStatus.Cancel: Debug.Log("Purchase canceled"); break; case PurchaseStatus.Close: Debug.Log("Purchase closed"); break; default: Debug.Log("Unknown purchase status"); break; }}
We make a request to our game server to create a session and retrieve the checkout URL. If the checkout URL is retrieved, we use the link to open the checkout from our game.