This release adds pre-release support for Amazon store.
- Download the
Purchases-UnityIAP.unitypackage
in the release - Open your Unity Project
- Select Import package -> Custom package
- Select Purchases_Amazon.unityPackage and make sure all of the files are selected and press import
-
If
Package Manager Resolver
asks to solve conflicts, choose library versions and select OK -
Select Use Amazon in the Editor
If calling setup on runtime, you can select “Use Runtime Setup” and call setup this way.
var builder = PurchasesConfiguration.Builder.Init("amazon_specific_api_key")
.SetUseAmazon(true);
purchases.Setup(builder.Build());
Due to some limitations, RevenueCat will only validate purchases made in production or in Live App Testing and won't validate purchases made with the Amazon App Tester. You can read more about the different testing environments in our Amazon (Beta) docs.
- If your app also targets the Google Play Store, you will want to conditionally exclude the BillingClient to prevent duplicated classes. If you don't have a
mainTemplate.gradle
, make sure you haveCustom Main Gradle Template
selected in theAndroid Player Settings
, which should create amainTemplate.gradle
inside the Assets/Plugins/Android. Add the following to yourmainTemplate.gradle
to prevent duplicated classes when Unity IAP is targeting the Play Store:
dependencies {
...
// ** ADD THIS **
if (!project(":unityLibrary").fileTree(dir: 'libs', include: ['billing-3*.aar']).isEmpty()) {
configurations.all {
exclude group: 'com.android.billingclient', module: 'billing'
}
}
}
- Due to some limitations with the Amazon SDK,
SyncPurchases
doesn't work when on Amazon observer mode. In order to sync purchases with RevenueCat you have to send the current active subscriptions when Unity IAP initializes and after every successful purchase. For example:
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
m_StoreController = controller;
storeExtensionProvider = extensions;
var purchases = GetComponent<Purchases>();
purchases.SetDebugLogsEnabled(true);
foreach (Product product in controller.products.all)
{
if (product.hasReceipt) {
var amazonExtensions = storeExtensionProvider.GetExtension<IAmazonExtensions>();
var userId = amazonExtensions.amazonUserId;
purchases.SyncObserverModeAmazonPurchase(
product.definition.id,
product.transactionID,
userId,
product.metadata.isoCurrencyCode,
Decimal.ToDouble(product.metadata.localizedPrice)
);
}
}
}
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
{
var purchases = GetComponent<Purchases>();
var amazonExtensions = storeExtensionProvider.GetExtension<IAmazonExtensions>();
var userId = amazonExtensions.amazonUserId;
purchases.SyncObserverModeAmazonPurchase(
e.purchasedProduct.definition.id,
e.purchasedProduct.transactionID,
userId,
e.purchasedProduct.metadata.isoCurrencyCode,
Decimal.ToDouble(e.purchasedProduct.metadata.localizedPrice)
);
return PurchaseProcessingResult.Complete;
}
-
Perform a Resolve using the editor option
Assets/External Dependency Manager/Android Resolver/Resolve
menu. This will add the right dependencies to themainTemplate.gradle
. -
In observer mode, adding the Amazon in-app-purchasing library jar is not necessary since it will be added by Unity IAP when targeting the Amazon Store