RevenueCat / purchases-flutter

Flutter plugin for in-app purchases and subscriptions. Supports iOS, macOS and Android.
https://www.revenuecat.com/
MIT License
599 stars 164 forks source link

Subscription upgrades getting automatically canceled immediately after purchasing #1107

Open chenna8464 opened 2 months ago

chenna8464 commented 2 months ago

‼️ Required data ‼️

Environment

Screenshot 2024-06-28 at 2 02 44 PM

Describe the bug

initially, i made a monthly payment of $14 which had a free trial, and then after I made a yearly payment of $134. here the payment has gone through successfully but in the revenue cat, it is showing like below (see screenshot). and sometimes it's happening for initial payment as well.
the main issue is the payment is cancelled due to a billing error, and the webhook is sending the price as 0

Screenshot 2024-06-28 at 2 11 10 PM

Additional context

the code i am using for the upgrade is if (oldProductId.isNotEmpty && Platform.isAndroid) { purchaserInfo = await Purchases.purchasePackage(product!, googleProductChangeInfo: GoogleProductChangeInfo(oldProductId, prorationMode: GoogleProrationMode.immediateAndChargeFullPrice)); } else { purchaserInfo = await Purchases.purchasePackage(product!); }

RCGitBot commented 2 months ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

chenna8464 commented 2 months ago

and we have enabled pub/sub also

vegaro commented 2 months ago

how are you configuring the SDK @chenna8464 ? Can you share some of the configure code? Without your API key of course 😄

chenna8464 commented 2 months ago

this is the initialization of the SDK

static Future<void> init() async { if (await Purchases.isConfigured) return; await Purchases.configure(PurchasesConfiguration( Platform.isIOS ? EnvironmentConfig.revenueCatPublicKeyiOS : EnvironmentConfig.revenueCatPublicKeyAndroid, )); Purchases.addReadyForPromotedProductPurchaseListener( (productIdentifier, startPurchase) { startPurchase.call(); }); Purchases.getOfferings(); await Purchases.collectDeviceIdentifiers(); }

and this is where the purchase is happening

` Package? product; CustomerInfo? purchaserInfo;

  final context = navigator.currentContext!;
  final appProvider = context.read<AppProvider>();

  product = await _getPackage(appProvider.selectedPlan);

  if (Platform.isIOS) {
    await Purchases.checkTrialOrIntroductoryPriceEligibility(
        [product!.storeProduct.identifier]);
  }
  await Purchases.setEmail(email);

  if (oldProductId.isNotEmpty && Platform.isAndroid) {
    purchaserInfo = await Purchases.purchasePackage(product!,
        googleProductChangeInfo: GoogleProductChangeInfo(oldProductId,
            prorationMode:
                GoogleProrationMode.immediateAndChargeFullPrice));
  } else {
    purchaserInfo = await Purchases.purchasePackage(product!);
  }

  final isPurchaseSuccesful =
      purchaserInfo.entitlements.all["mentor_access"]!.isActive;`  
chenna8464 commented 2 months ago

@vegaro

chenna8464 commented 2 months ago

and we have the same ticket, this we raised long back and it closed saying that revcat fixed the issue https://github.com/RevenueCat/purchases-flutter/issues/803

chenna8464 commented 2 months ago

@vegaro any update on this?

vegaro commented 2 months ago

@chenna8464 your code looks correct. In that other issue, the UI looks slightly different since it actually shows there was a product change.

Without having the user id it's going to be hard to understand what happened. Do you mind sharing an app user id (or the url link to the user page in the dashboard) so we can look into the details of the purchase? You can send a message to support with more details at support@revenuecat.com if you prefer not to share here, and post the ticket number when you do.

chenna8464 commented 2 months ago

@vegaro user id ketan.gurav+1334@magnifi.com, testsub10@yopmail.com

vegaro commented 2 months ago

Thanks @chenna8464

We have been looking into the receipts of those users and it looks like when we check the purchases with Google, they are already cancelled, with a system initiated cancellation. Is it possible you are purchasing using the wrong test card in the purchase screen?

image

I was looking at ketan.gurav+1334@magnifi.com purchases and that one doesn't have a product change and when RevenueCat gets the purchase, Google indicates it's already canceled, which is odd.

chenna8464 commented 2 months ago

the plans expired/were cancelled because it has some time limit to expire, but if you check the webhook that was sent for this user which has price 0. and it happened for some other users, whose subscriptions expired/cancelled it is happening In two cases only for android , iOS is working fine in all cases

  1. in the initial payment itself
  2. while doing the upgrade

On Mon, 1 Jul 2024 at 18:31, Cesar de la Vega @.***> wrote:

Thanks @chenna8464 https://github.com/chenna8464

We have been looking into the receipts of those users and it looks like when we check the purchases with Google, they are already cancelled, with a system initiated cancellation. Is it possible you are purchasing using the wrong test card in the purchase screen?

image.png (view on web) https://github.com/RevenueCat/purchases-flutter/assets/664544/7e1b140e-2769-4bae-9c0f-68425ecb8c55

I was looking at @.*** purchases and that one doesn't have a product change and when RevenueCat gets the purchase, Google indicates it's already canceled, which is odd.

— Reply to this email directly, view it on GitHub https://github.com/RevenueCat/purchases-flutter/issues/1107#issuecomment-2200083956, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVI27N65ZF2GUCZFBNM2TUTZKFHLBAVCNFSM6AAAAABKBOBBYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBQGA4DGOJVGY . You are receiving this because you were mentioned.Message ID: @.***>

chenna8464 commented 2 months ago

@vegaro sent an email with the reply, but adding the same message here

we are using the correct test cards for purchase, check this user testsub7@yopmail.com ( this user did the payment and the upgrade also worked but some users still getting the same error (BILLING ERROR))

the plans expired/were cancelled because it has some time limit to expire, but if you check the webhook that was sent for this user which has a price 0. and it happened for some other users, whose subscriptions expired/cancelled it is happening In two cases only for Android, iOS is working fine in all cases

  1. in the initial payment itself
  2. while doing the upgrade
vegaro commented 2 months ago

Hi @chenna8464

Been looking into this a bit more and we've realised that what you are seeing is expected for Indian subscriptions. We have a whole blogpost about it, but the tldr; is that India has laws that regulate auto renewing subscriptions that are over 5000 INR so Google immediately cancels this purchases, and sends a notification to our servers with a systemInitiatedCancellation reason. This is why you see the yearly subscription cancelled and not renewing, but the monthly subscription is working as expected.

There's for sure some work to do in our dashboard to make this less confusing, so I will pass that feedback along and hopefully we can add more clarification for Indian subscriptions in our UI.

chenna8464 commented 2 months ago

Hi @vegaro , understood, now i changed the region to United States(US) to check the payment above 5000INR, by using https://developer.android.com/google/play/billing/test#play-billing-lab

now this user have some issues after payment testsub13@magnifi.com,

  1. I made the monthly payment of $14, without a free trial
  2. after 3 minutes i did a payment for $134 as an upgrade plan which doesn't have free trail.

now the issue is. I received a webhook for $14 successfully,

but for $134. **Started a subscription of** This webhook has the correct price of $134 and **Changed their renewal preference to** webhook has a $0 price, which is not correct right? it should have the correct price

Screenshot 2024-07-03 at 3 49 31 PM
nyeu commented 2 months ago

Hi @chenna8464,

The webhook for product changes is anticipated to have a $0 price. This is designed to simply notify you of the change. You will subsequently receive a renewal webhook with the updated subscription details, reflecting the correct pricing. For more information about product changes, please refer to our documentation here.

chenna8464 commented 1 month ago

Hi @vegaro , thanks for the update, and also have a small doubt,

The webhook for product changes is anticipated to have a $0 price. This is designed to simply notify you of the change. You will subsequently receive a renewal webhook with the updated subscription details, reflecting the correct pricing. For more information about product changes, please refer to our documentation

will this be the same behaviour in production as well, when we do payments using real money not in sandbox?

nyeu commented 1 month ago

Hi @chenna8464, You are correct, this is the expected behavior in sandbox and production.

chenna8464 commented 1 month ago

@vegaro have one more doubt, in the flow INITIAL PURCHASE event will come when i do the initial purchase let's say monthly and then after the free trial. it will convert to a paid user after that, i upgraded from monthly to yearly, and then again i received an INITIAL PURCHASE event

INITIAL PURCHASE -- $14 monthly free tail RENEWAL (converted from free trail to paid) INITIAL PURCHASE -- $134.99 yearly no free tail PRODUCT_CHANGE RENEWAL

we got two INITIAL PURCHASE events

testsub22@magnifi.com, can you please check this user and give me some clarity on this. we are stuck on this flow to handle in our BE

chenna8464 commented 1 month ago

Hi @vegaro any update on this. we stuck on this, can you please give me some info on this

nyeu commented 1 month ago

Hi @chenna8464, Since this is different from the initial GitHub ticket and you've opened one in Zendesk, let's continue the conversation there to keep everything organized and focused on the same topic.