Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Update receipt-imports.md with warning callouts for the issues for historical data from Google Play and Stripe #690

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WesleyClarkRC
Copy link
Contributor

Motivation / Description

this issues can cause some confusion when looking at Charts, like the Subscription Retention Chart

Changes introduced

turned the mentions of issues with historical data being migrated from Stripe and Google Play into Warning Callouts

Linear ticket (if any)

Zendesk ticket 35871

Additional comments

turned the mentions of issues with historical data being migrated from Stripe and Google Play into Warning Callouts
@WesleyClarkRC WesleyClarkRC requested a review from a team February 6, 2024 00:40
@RCGitBot
Copy link
Contributor

RCGitBot commented Feb 6, 2024

Previews

temp/receipt-imports.md

See contents

If you already have existing purchases or subscriptions and have been saving the complete raw receipt files or tokens, you can import those purchases into RevenueCat. If you don't have the proper data saved on your server, see the client-side migration section of the Migrating Subscriptions doc.

Before kicking off an import, if you do not have the SDK deployed in your app, consider first setting up a server-side Observer Mode implementation. This ensures that new purchases happening during and after the import are still captured in RevenueCat.
[block:callout]
{
"type": "warning",
"title": "Complete Apple base64 receipt file required",
"body": "RevenueCat requires the raw base64 encoded Apple receipt to import the subscription properly. Partial receipts or the receipt information from the Apple server-to-server notifications are insufficient."
}
[/block]

Importing Existing Data

Using the REST API

If you have the correct data saved already for your customers, you can import them through the REST API POST /receipts endpoint. This will create the customer in RevenueCat and start tracking their subscription status.

More info in the API Reference here.

This is the quickest way to get your existing subscribers into RevenueCat.

Bulk imports

For extraordinarily large imports, we offer batch imports as a service on our plans offered via sales. Contact sales to see how we can help with the process.

Please note that depending on the size, bulk imports can take time to complete, sometimes up to several days or weeks for the largest data sets. Please keep this in consideration as you are planning your launch.
[block:callout]
{
"type": "info",
"title": "Bulk imports DO NOT trigger webhooks or integrations",
"body": "Bulk imports done by RevenueCat will not trigger any webhook or integration events. If this is a requirement, then you'll need to perform an import using the REST API as mentioned above."
}
[/block]
To do a receipt import we'll need 3 csv files for iOS, Android and Stripe with the following fields:

iOS:

  • app_user_id
  • receipt (the raw receipt file)
  • product_id
  • price
  • introductory_price (if not a free trial)
  • currency

You can find a sample iOS reference csv file here.

*If you don't have prices and currency with the transactions we can take a separate file with a mapping of product_id, price, currency as well. If there were any known price changes, those should also be included here. You can find a sample price mapping here. Note that the duration and introductory_price_duration fields use the ISO 8601 format for representing durations.
[block:callout]
{
"type": "info",
"title": "Product prices are required for iOS imports",
"body": "Whether you include the products and prices with each receipt in the CSV file or attach a separate file of products and prices, the prices of products is required so that RevenueCat can accurately compute your charts and send events with correct revenue data."
}
[/block]

[block:callout]
{
"type": "warning",
"title": "latest_receipt_info not supported for iOS imports",
"body": "The entire iOS receipt file must be used for imports. The latest_receipt_info is not supported as it's only a subset of the entire receipt."
}
[/block]
Google Play:

  • app_user_id
  • product_id
  • token

You can find a reference Google Play import csv file here.

**Important: **We need to know your API quota with Google and approximately how many remaining requests per day you have so we don't exceed your quota.

🚧

Google Play receipts that have been expired for more than 60 days ago can't be imported, and only the current status can be retrieved from each receipt. This means that historical data won't be presented accurately in Charts.

Stripe:

  • app_user_id
  • subscription_token (e.g. sub_xxxxxx)

You can find a reference Stripe import csv file here.

🚧

Stripe subscription tokens contain only the current status can be retrieved from each Stripe subscription token. This means that Charts will not accurately reflect the historical data from migrated Stripe tokens.

temp/unity.md

See contents

What is RevenueCat?

RevenueCat provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy. With our SDK, you can build and manage your app business on any platform without having to maintain IAP infrastructure. You can read more about how RevenueCat fits into your app or you can sign up free to start building.

Installation

We provide 2 ways to install our SDK: via Unity Package Manager (UPM) in the OpenUPM registry, or as a .unitypackage.

Option 1 (recommended): Install using OpenUPM

  1. First you need to import the EDM4U plugin into your project if you haven't already. This plugin will add all the Android and iOS dependencies automatically when building your project. To do this, you can:
    • Download the external-dependency-manager-latest.unitypackage file from the root of the EDM4U repo.
    • Import the downloaded unitypackage to your project.
  2. Then, you can add the OpenUPM scoped registry. To do this, go to your project's settings -> Package Manager, and add a new scoped registry with URL https://package.openupm.com and scopes: com.openupm and com.revenuecat.purchases-unity. It should look like this:
  3. Then, go to the Package Manager and from "My Registries", select the RevenueCat package and click on Install.

[block:callout]
{
"type": "info",
"title": "Using OpenUPM-CLI",
"body": "If you prefer, you can also use OpenUPM-CLI to add the scoped registry and the package through the command line. To do that, install the OpenUPM-CLI if you haven't already, then run openupm add com.revenuecat.purchases-unity. That should be it!"
}
[/block]

[block:callout]
{
"type": "warning",
"title": "If using UnityIAP alongside RevenueCat",
"body": "If you're using UnityIAP, you need to follow special instructions outlined below."
}
[/block]

Configure a Main Gradle Template

Go to Project -> Build Settings -> Player Settings -> Android tab -> Publishing Settings, and check "Custom Base Gradle Template", then close that window.

Screenshot 2024-02-02 at 12 52 35 PM

Go to Assets -> External Dependency Manager -> Android Resolver -> Settings, then check "Patch mainTemplate.gradle"

Screenshot 2024-02-01 at 12 13 50 PM Screenshot 2024-02-02 at 12 52 35 PM

Option 2: Import the Purchases Unity package

Download the latest version of Purchases.unitypackage.

Import the downloaded unitypackage to your Unity project. Make sure the PlayServiceResolver and the ExternalDependencyManager folders are also added. These folders will install the EDM4U plugin, which will add all the Android and iOS dependencies automatically when building your project.
If you're running purchases-unity v3.5.1 or later, also make sure that the RevenueCatPostInstall script is added, since it will set up StoreKit for iOS and prevent issues when uploading builds to App Store Connect in Unity 2020.

[block:callout]
{
"type": "warning",
"title": "ExternalDependencyManager plugin",
"body": "Make sure the ExternalDependencyManager is properly installed. Otherwise our plugin will not be able to compile. If you don't see the option under the Assets menu after restarting the editor, try reinstalling the RevenueCat plugin or manually importing the EDM4U plugin."
}
[/block]

Configure a Main Gradle Template

Go to Project -> Build Settings -> Player Settings -> Android tab -> Publishing Settings, and check "Custom Base Gradle Template", then close that window.

Screenshot 2024-02-02 at 12 52 35 PM

Go to Assets -> External Dependency Manager -> Android Resolver -> Settings, then check "Patch mainTemplate.gradle"

Screenshot 2024-02-01 at 12 13 50 PM Screenshot 2024-02-02 at 12 52 35 PM

Create a GameObject with the Purchases behavior

The Purchases package will include a MonoBehavior called Purchases. This will be your access point to RevenueCat from inside Unity. It should be instantiated once and kept as a singleton. You can use properties to configure your API Key, app user ID (if you have one), and product identifiers you want to fetch.

Link StoreKit (iOS only)

StoreKit should automatically be linked. If you run into any issues, add StoreKit.framework to Linked Frameworks and Libraries in Xcode.

Subclass Purchases.Listener MonoBehavior

The Purchases behavior takes one additional parameter, a GameObject with a Purchases.Listener component. This will be where you handle purchase events, and updated subscriber information from RevenueCat. Here is a simple example:

using System;
using System.Collections.Generic;
using UnityEngine;

public class PurchasesListener : Purchases.UpdatedCustomerInfoListener
{
    public override void CustomerInfoReceived(Purchases.CustomerInfo customerInfo)
    {
        // display new CustomerInfo
    }

    private void Start()
    {
        var purchases = GetComponent<Purchases>();
        purchases.SetDebugLogsEnabled(true);
        purchases.GetOfferings((offerings, error) =>
        {
            if (error != null)
            {
                // show error
            }
            else
            {
                // show offering
            }
        });
    }

    public void BeginPurchase(Purchases.Package package)
    {
        var purchases = GetComponent<Purchases>();
        purchases.PurchasePackage(package, (productIdentifier, customerInfo, userCancelled, error) =>
        {
            if (!userCancelled)
            {
                if (error != null)
                {
                    // show error
                }
                else
                {
                    // show updated Customer Info
                }
            }
            else
            {
                // user cancelled, don't show an error
            }
        });
    }

    void RestoreClicked()
    {
        var purchases = GetComponent<Purchases>();
        purchases.RestorePurchases((customerInfo, error) =>
        {
            if (error != null)
            {
                // show error
            }
            else
            {
                // show updated Customer Info
            }
        });
    }
}

Unity Editor

Running the Purchases SDK is unsupported in the Unity Editor at this time, and may result in NullReferenceException: Object reference not set to an instance of an object errors. Please build and run your app instead.

Proguard rules

If you have enabled Minify in Unity, make sure to add these custom rules to your Assets/Plugins/Android/proguard-user.txt and enable the Custom Proguard File setting in Publishing Settings:

-keep class com.revenuecat.** { *; }

Installation with Unity IAP side by side

[block:callout]
{
"type": "danger",
"body": "Make sure to use version 5.3.0 of our plugin. Due to incompatibilities with the version of BillingClient used by Unity IAP, the latest versions of the plugin won't work alongside Unity IAP until Unity IAP gets updated to BillingClient 6.x.x.",
"title": "Unity IAP doesn't work with version 6 of the purchases plugin"
}
[/block]

Purchases Unity 5.0.0+

RevenueCat's Purchases Unity SDK 5.0.0+

side by side with Unity IAP 4.8.0

This version is only compatible with version 4.8.0 and above of Unity IAP which are the ones that include BillingClient 5.

To install download Purchases.unityPackage and install as normal. Then follow the instructions indicated in the "Troubleshooting "duplicated class" errors"

If using RevenueCat alongside Unity IAP 2.2.0+ or other plugin that includes the Android BillingClient library you will be getting an error when compiling that warns about some BillingClient classes being duplicated.

The easiest way to remove the error would be to tell Gradle to not include the billingclient library that Unity IAP is already including.

In order to do that, make sure you have Custom Main Gradle Template selected in the Android Player Settings... That should create a mainTemplate.gradle inside the Assets/Plugins/Android.

Modify the mainTemplate.gradle to include the following at the end of the dependencies block:

dependencies {
    ...
    
    // ** ADD THIS **
    configurations.all {
        exclude group: 'com.android.billingclient', module: 'billing'
    }
}

Perform a clean up of the resolved dependencies using the Assets/External Dependency Manager/Android Resolver/Delete Resolved Libraries menu. This will cleanup the previously downloaded .aars in Assets/Plugins/Android. Otherwise you could end up with duplicated classes errors.

Also make sure to perform a resolve, so External Dependency Manager adds the right dependencies to the generated build.gradle.

[block:callout]
{
"type": "danger",
"body": "The above instructions instructions will also apply if using other plugin that includes the Android InAppBillingService class, or for some other reason you get an error regarding duplicated classes."
}
[/block]

Troubleshooting "ClassNotFoundException" errors at Runtime in Android

When exporting your project to Android, in the Build Settings window, make sure you uncheck the Symlink Sources checkbox. That will make it so Unity actually uses the correct source files for our SDK.

Installing old versions of the plugin

Purchases Unity 4.2.0+

RevenueCat's Purchases Unity SDK 4.2.0+

side by side with Unity IAP 4.4.0 < 4.8.0

Download Purchases-UnityIAP.unityPackage and install as normal. Skip the rest of the instructions in this page.

Purchases Unity 4.0.0 and 4.1.0

RevenueCat's Purchases Unity SDK 4.1.0+

side by side with Unity IAP 3.3.0 < 4.4.0

Download Purchases-UnityIAP.unityPackage and install as normal. Skip the rest of the instructions in this page.

Next Steps

Copy link
Collaborator

@rglanz-rc rglanz-rc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you switch this to the new repo?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants