Skip to main content
Solved

How to use syncPurchases() in React Native


Forum|alt.badge.img+4

I migrated my app to RC, however my previous users are having the sync problem.

Previously, I was not using a back-end for the subscriptions, so I was using the client-side receipt validation on iOS (React Native IAP package).

I am trying to sync my previous users, but a little bit confused about the steps;

if (isSubscribedInOldSystem && !isSubscribedInRevenueCat) {

Purchases.syncPurchases();

}

 

1 - What should I provide to the syncPurchases() function?

2 - If I need to provide the receipt, should I provide full receipt? or just the receipt body? I mean, I was using this validation method;

const receiptBody = {
      'receipt-data': receipt, // Should I provide this to RC?
      password: 'PASSWORD',
    };

 await IAP.validateReceiptIos(receiptBody, false) 
      .then(response => {
        try {
          const renewalHistory = response.latest_receipt_info;
          const expirationDate = renewalHistory[0].expires_date_ms;
          const isExpired = Date.now() > expirationDate;

          if (!isExpired) {
            setIsUserHasReceiptOLD(true);
          }
        } catch (error) {
        }
      })
      .catch(e => {
      });

 

Thank you in advance,

Best,

Uğur

Best answer by tina

Hey @Ugur Genc 

I’ll answer your questions in-line below:

1 - What should I provide to the syncPurchases() function?

You don’t need to provide anything to the syncPurchases() function. You can just call that method as is and RevenueCat will sync the receipt from the device to our servers. The only thing you need to handle is figuring out if the customer has a subscription in your old subscription system.

 

2 - If I need to provide the receipt, should I provide full receipt? or just the receipt body? I mean, I was using this validation method;

No receipt necessary. If you are already collecting receipts in your backend, you can always perform a server side migration and send the receipt to us directly. For more information: https://docs.revenuecat.com/docs/migrating-existing-subscriptions#importing-existing-data 

 

View original
Did this post help you find an answer to your question?
This post has been closed for comments

2 replies

tina
RevenueCat Staff
Forum|alt.badge.img+10
  • RevenueCat Staff
  • 338 replies
  • Answer
  • January 7, 2022

Hey @Ugur Genc 

I’ll answer your questions in-line below:

1 - What should I provide to the syncPurchases() function?

You don’t need to provide anything to the syncPurchases() function. You can just call that method as is and RevenueCat will sync the receipt from the device to our servers. The only thing you need to handle is figuring out if the customer has a subscription in your old subscription system.

 

2 - If I need to provide the receipt, should I provide full receipt? or just the receipt body? I mean, I was using this validation method;

No receipt necessary. If you are already collecting receipts in your backend, you can always perform a server side migration and send the receipt to us directly. For more information: https://docs.revenuecat.com/docs/migrating-existing-subscriptions#importing-existing-data 

 


Forum|alt.badge.img+4
  • Author
  • New Member
  • 1 reply
  • January 10, 2022

Thank you, Tina for the tips. Now, it works really well.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings