Skip to content

Latest commit

 

History

History
67 lines (55 loc) · 3.03 KB

AMAZON-INSTRUCTIONS.md

File metadata and controls

67 lines (55 loc) · 3.03 KB

Instructions

  • Download the Purchases.unitypackage in the release.
  • Open your Unity Project
  • Select Import package -> Custom package

Screen Shot 2021-11-24 at 3 55 50 PM

  • Select Purchases.unitypackage and make sure all of the files are selected and press import

Screen Shot 2021-11-24 at 3 56 10 PM

  • If Package Manager Resolver asks to solve conflicts, choose library versions and select OK

  • Select Use Amazon in the Editor

Screen Shot 2021-11-24 at 3 57 01 PM

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 technical 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.

  • Due to technical 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.SyncAmazonPurchase( 
               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.SyncAmazonPurchase(
       e.purchasedProduct.definition.id,
       e.purchasedProduct.transactionID,
       userId,
       e.purchasedProduct.metadata.isoCurrencyCode,
       Decimal.ToDouble(e.purchasedProduct.metadata.localizedPrice)
   );
   return PurchaseProcessingResult.Complete;
}