purchases-flutter icon indicating copy to clipboard operation
purchases-flutter copied to clipboard

Subscription upgrades getting automatically canceled immediately after purchasing

Open chenna8464 opened this issue 1 year ago • 20 comments

‼️ Required data ‼️

Environment

  • [x] Output of flutter doctor
Screenshot 2024-06-28 at 2 02 44 PM
  • [x] Version of purchases-flutter : 6.29.4
  • [x] Testing device version : Android API 33.
  • [x] How often the issue occurs- every one of your customers is impacted? Only in dev? till now we checked in sandbox mode with productions API's basically app was running in beta
  • [ ] Debug logs that reproduce the issue
  • [ ] Steps to reproduce, with a description of expected vs. actual behavior Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

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!); }

chenna8464 avatar Jun 28 '24 08:06 chenna8464

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

RCGitBot avatar Jun 28 '24 08:06 RCGitBot

and we have enabled pub/sub also

chenna8464 avatar Jun 28 '24 08:06 chenna8464

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

vegaro avatar Jun 28 '24 08:06 vegaro

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 avatar Jun 28 '24 09:06 chenna8464

@vegaro

chenna8464 avatar Jun 28 '24 09:06 chenna8464

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 avatar Jun 28 '24 09:06 chenna8464

@vegaro any update on this?

chenna8464 avatar Jul 01 '24 05:07 chenna8464

@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 [email protected] if you prefer not to share here, and post the ticket number when you do.

vegaro avatar Jul 01 '24 08:07 vegaro

@vegaro user id [email protected], [email protected]

chenna8464 avatar Jul 01 '24 10:07 chenna8464

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 [email protected] 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.

vegaro avatar Jul 01 '24 13:07 vegaro

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 avatar Jul 01 '24 14:07 chenna8464

@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 [email protected] ( 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

chenna8464 avatar Jul 02 '24 05:07 chenna8464

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.

vegaro avatar Jul 02 '24 11:07 vegaro

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 [email protected],

  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

chenna8464 avatar Jul 03 '24 10:07 chenna8464

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.

nyeu avatar Jul 03 '24 16:07 nyeu

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?

chenna8464 avatar Jul 09 '24 06:07 chenna8464

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

nyeu avatar Jul 09 '24 10:07 nyeu

@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

[email protected], 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 avatar Jul 09 '24 12:07 chenna8464

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

chenna8464 avatar Jul 16 '24 07:07 chenna8464

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.

nyeu avatar Jul 16 '24 14:07 nyeu