Skip to main content

I’m facing an issue in my React Expo Android app where, after successfully completing a payment via Google Pay UPI, the app is being redirected to an incorrect page, which prevents the purchase-related code from executing. As a result, I’m unable to fetch or log the customerInfo and syncedCustomerInfo objects as expected.

Scenario

  1. The user selects Google Pay UPI and completes the payment successfully.
  2. Instead of being redirected to the correct app screen where the purchase process can be handled, the app is being redirected to a different page(first page).
  3. Consequently, the code responsible for processing the purchase (customerInfo and syncedCustomerInfo) is not executed.

 

 

const handlePurchase = async (packageToPurchase) => {
    try {
        alert(packageToPurchase.identifier);    
        const { customerInfo } = await Purchases.purchasePackage(packageToPurchase);
      
        alert("Customer Info: " + JSON.stringify(customerInfo, null, 2));

        const syncedCustomerInfo = await Purchases.syncPurchases();

        alert("Synced Customer Info: " + JSON.stringify(syncedCustomerInfo, null, 2));

        if (syncedCustomerInfo.entitlements && syncedCustomerInfo.entitlements.active) {
            const activeEntitlementKeys = Object.keys(syncedCustomerInfo.entitlements.active);
            const activeEntitlement = syncedCustomerInfo.entitlements.activetactiveEntitlementKeyso0]];

            alert(`Product Identifier: ${activeEntitlement.productIdentifier}`);
            alert(`Latest Purchase Date: ${activeEntitlement.latestPurchaseDate}`);
            alert(`Expiration Date: ${activeEntitlement.expirationDate}`);
            alert(`Purchase Token: ${activeEntitlement.purchaseToken || 'No purchase token available'}`);

            // Send purchase data to backend
            await sendPurchaseToBackend({
                productId: activeEntitlement.productIdentifier,
                purchaseToken: activeEntitlement.purchaseToken || 'No token',
                purchaseDate: activeEntitlement.latestPurchaseDate,
            });
        } else {
            alert('No active entitlements found.');
        }
    } catch (e) {
        alert(`Purchase failed: ${e.message}`);            
        try {
            const syncedCustomerInfo = await Purchases.syncPurchases();
            alert("Synced Customer Info after failure: " + JSON.stringify(syncedCustomerInfo, null, 2));
        } catch (syncError) {
            console.error('Error syncing purchases: ', syncError);
            alert(`Failed to sync purchases: ${syncError.message}`);
        }
    }
};
 

Debugging Steps Already Taken:

  1. Incorrect Redirection: After the successful Google Pay UPI payment, the app is being redirected to an unexpected page, which disrupts the flow of the purchase process. This is why customerInfo and syncedCustomerInfo are not being fetched or logged.

Questions:

  1. Why is the app being redirected to an incorrect page after the Google Pay UPI payment?
  2. How can I ensure that the app redirects back to the correct page to execute the post-purchase logic and fetch customerInfo and syncedCustomerInfo?
  3. Is there any specific handling needed for Google Pay UPI redirection within RevenueCat?
  4. What’s the best way to verify and handle this payment on the backend?

Hey @nihal-vishwakarma-d015e2,

 

We’d be happy to help here. Can you please create a support ticket for this so we can dive more into detail about what might be happening here? 

 

You can create a ticket here: https://app.revenuecat.com/settings/support

 

In this ticket, can you please provide this community post as well as debug logs reproducing the issue? 

 

We look forward to helping more and looking deeper into this!