Skip to main content
Version: 3.6.0

In-App purchases

Automatic verification and sending of purchase information

info

Starting Appodeal SDK 3.7.0+, it is possible to automatically verify and submit purchases/subscription to Appodeal, as well as receive purchase information from the Appodeal SDK using Appsflyer.

To activate this feature contact us via email at support@appodeal.com or the live chat, and ask to enable ad ROI360 feature.

Before implementing the ROI360 needs to be integrated with AppStoreConnect. To do this, you need to perform the following steps:

Step 1. Set the App Store credentials for ROI360 receipt validation

Obtain the following credentials from App Store Connect and forward this information to our support team.

  • In-App Purchase key
  • Key ID
  • Issuer ID

To set iOS credentials:

  1. In the App Store Connect, go to Users and Access
  1. Go to Users and Access > Integrations, and from the Keys list, select In-App Purchase.
  1. Click + to generate a new In-App Purchase key.
  1. Enter a name for your API key.

  2. Click Generate.

  3. Click Download In-App Purchase Key next to the key you just generated to download it. Note: You can only download the key once.

  4. In App Store Connect, copy the Key ID of the key you just generated and paste it into the AppsFlyer purchases & subscriptions setting for Key ID.

  1. In App Store Connect, copy the Issuer ID. Note:** If the Issuer ID is not displayed at the top of the page, create an App Store Connect API key (with any access level). After that, the Issuer ID will appear at the top of the page for the In-App Purchase key.

Step 2. Send App Store notifications directly to AppsFlyer

Before continuing, make sure to request the AppsFlyer server notifications endpoint from our support team.

  1. In App Store Connect, in the App Information section, scroll to App Store Server Notifications, and next to Production Server URL, click Edit.
  1. Paste the URL provided by our support team, select Version 2 Notifications, and click Save.
  1. In App Store Connect, in the App Information section, scroll to App Store Server Notifications, and next to Sandbox Server URL, click Edit.
  1. Paste the URL copied from AppsFlyer, select Version 2 Notifications, and click Save.

Optional. Step 3 Setting up AppodealPurchaseCallback

Once the functionality is enabled and configured, when a purchase is made in your app, Appodeal SDK will automatically detect, verify and send the inApps/subscription details to Appodeal Dashboard. If you want to receive purchase information in your app, you need to perform the following steps:

  1. Set the purchase delegate. We recommend doing it in the AppDelegate -didFinishLaunchingWithOptions: function:
@UIApplicationMain
final class MyAppDelegate: UIResponder, UIApplicationDelegate, AppodealInitializationDelegate {
func application(
_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
Appodeal.setLogLevel(.verbose)

// New optional delegate for initialization completion
Appodeal.setInitializationDelegate(self)

// Optional delegate for for ROI360
Appodeal.setPurchaseDelegate(self)

/// Any other pre-initialization
/// app specific logic

Appodeal.initialize(
withApiKey: "APP_KEY",
types: .interstitial
)

return true
}
}
  1. Implement the following methods of the AppodealPurchaseDelegate protocol:
extension AppDelegate: AppodealPurchaseDelegate {
func didReceivePurchase(_ successPurchases: [String: Any]?) {
print("[ROI360] successPurchases: ", successPurchases)
}

func didFailPurchase(_ error: (any Error)?) {
print("[ROI360] failPurchases: ", error?.localizedDescription)
}
}

The purchase object contains the following information:

ParameterDescription
product_idThe identifier of the purchased product
purchase_dateThe date and time when the purchase was made
transaction_idThe unique identifier for the transaction assigned by the App Store

At this point, the connection of automatic purchases is fully completed.

note

Purchase reports will be automatically uploaded to the Dashboard of your personal cabinet 2 times a day

Manual verification and sending of purchase information

info

In-App purchase tracking will work only in connection with Adjust/AppsFlyer. To connect them, follow this guide for Adjust and this guide for AppsFlyer.

It's possible to track in-app purchase information and send info to Appodeal servers for analytics. It allows to group users by the fact of purchasing in-apps. This will help you to adjust the ads for such users or simply turn it off, if needed. To make this setting work correctly, please submit the purchase info via the Appodeal SDK.

Step 1. Validate In-app Purchases

To make this work correctly, please submit the purchase information via Appodeal SDK.

info

Please make sure to use all the parameters from the method below and don't comment out any of them.

Appodeal.validateAndTrack( 
inAppPurchase: "some product id",
type: .autoRenewableSubscription,
price: "9.99",
currency: "USD",
transactionId: "some transaction id",
additionalParameters: additionalParameters,
success: { [weak self] in self?.alert("Purchase is valid", message: $0.description) },
failure: { [weak self] error, _ in self?.alert("Purchase is invalid", message: error?.localizedDescription) }
)
info

Please make sure if you have created in-app product in App Store Connect to use:

  • .consumable or .nonConsumable for purchase type,
  • .autoRenewableSubscription or .nonRenewingSubscription for subscription.
ParameterDescriptionUsage
inAppPurchasesome product idAdjust/AppsFlyer
type

Type must be :

  • .consumable or .nonConsumable
  • .autoRenewableSubscription or .nonRenewingSubscription
Adjust/AppsFlyer
priceIn-app event revenue.Adjust/AppsFlyer/Appodeal
currencyIn-app event currency.Adjust/AppsFlyer/Appodeal
transactionIdsome transaction idAdjust/AppsFlyer
additionalParametersAdditional parameters of the in-app event.
info

If you are using your own Adjust account you need to complete Step 2 from our Event Tracking guide and create some required events on Adjust side.

Step 2. Contact Us

After all completed steps contact our support team via email support@appodeal.com or a live chat with the following information :

  1. Purchases implementation logic in your app (when and where you call validate method and validate purchases).
  2. Allow us to test purchases in your app and send us the testflight to email support@appodeal.com.

Step 3. Testing

After you have contacted our Support Team and provided all the required information you can test your app to make sure purchases are validated.

  1. Please go to your App Settings → Attribution Settings → and change Adjust Environment from Production to Sandbox to be able to test validation and don't forget to press Save at the end of the page.

  2. Connect your device to your computer with the opened console (iOS Console) and tag logs by purchase

  3. Now you can open your App and make a test purchase, if you can see Valid purchase in the console, then validation went successfully.

  4. If validation has failed, then please recheck all the steps above.

  5. After testing, change your Adjust Environment to Production in App Settings → Attribution Settings.