Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to billing 5.1 (reverse compatible) #392

Merged
merged 8 commits into from
Mar 7, 2023

Conversation

SamBergeron
Copy link
Contributor

@SamBergeron SamBergeron commented Dec 2, 2022

This is build off of @youssefali424 #387 PR because that one had a couple issues. It didn't pass back the prices properly for items that were created in android billing 4.0 amongst other issues.

I created two new dart objects that reflect android 5.0 billing objects SubscriptionOffer and PricingPhase that pass back all the information associated with a play store item, so you can navigate those to extract introductory offers and discounted subscriptions as opposed to just having a single offer price.

I've also kept the price, currency and localizedPrice values and made them backwards compatible with items that were updated from billing 4.0 if your app relies on those (ours did)

Note that the tests fail because of ios and android receipt validation only, which appears to not point to a valid URL anymore.

All tests are passing and extra code coverage has been added

youssefali424 and others added 4 commits July 25, 2022 01:02
…s and pricing phases

Reverse compatible with billing 4.0 items that have been auto migrated to 5.0
Fixed some warnings
@SamBergeron SamBergeron changed the title Upgrade to billing 5.1 Upgrade to billing 5.1 (reverse compatible) Dec 2, 2022
Fix issue where "default" price was a subscription offer instead of the base plan
@codecov
Copy link

codecov bot commented Dec 3, 2022

Codecov Report

Merging #392 (e12fe7b) into main (2ed8e1d) will increase coverage by 5.51%.
The diff coverage is 96.77%.

@@            Coverage Diff             @@
##             main     #392      +/-   ##
==========================================
+ Coverage   42.18%   47.69%   +5.51%     
==========================================
  Files           4        4              
  Lines         467      478      +11     
==========================================
+ Hits          197      228      +31     
+ Misses        270      250      -20     
Impacted Files Coverage Δ
lib/flutter_inapp_purchase.dart 46.95% <87.50%> (ø)
lib/modules.dart 46.96% <100.00%> (+15.19%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@nizwar
Copy link

nizwar commented Dec 5, 2022

Hi, i've try your PR and i got what i expected, but there is one issue in this PR and i believe its from native side
image

Also for minors, add toJson() and toString() on SubscriptionOfferAndroid and PricingPhaseAndroid will be much appreciated

@SamBergeron
Copy link
Contributor Author

@nizwar gotcha, I didn't manually re-test all the methods I didn't modify but that error makes sense to me, I'll try and fix it today and do a bit more hands-on testing

…equired offerToken parameter needed for billing 5.0 product purchase on Android.
@SamBergeron
Copy link
Contributor Author

Any chance we can get a timeline on this? Would be great to be able to not have to use a forked plugin in production

@SamBergeron
Copy link
Contributor Author

@hyochan what's missing for this to be merged in? We've been using it in production for over a month without issue.

Copy link
Contributor

@xPutnikx xPutnikx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, would be nice to merge it =)

@hyochan hyochan added the feature label Mar 7, 2023
Copy link
Owner

@hyochan hyochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for the delay in providing a review, but I wanted to express my gratitude for your excellent work. I did have some questions, but it appears that others have already tested and reviewed your PR, so I will merge my feedback.

Thanks again for your contribution 👍

Comment on lines +1397 to +1404
// expect(product.subscriptionPeriodAndroid,
// expectedProduct.subscriptionPeriodAndroid);
// expect(product.introductoryPriceCyclesAndroid,
// expectedProduct.introductoryPriceCyclesAndroid);
// expect(product.introductoryPricePeriodAndroid,
// expectedProduct.introductoryPricePeriodAndroid);
// expect(product.freeTrialPeriodAndroid,
// expectedProduct.freeTrialPeriodAndroid);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this bing deprecated?

Comment on lines -1450 to -1452
http.Client mockClient = MockClient((request) async {
return Response(json.encode({'status': 0}), 200);
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is mocking not working or the validation functionality is gone?

Comment on lines -237 to -242
expect(product.introductoryPriceCyclesAndroid,
expectedProduct.introductoryPriceCyclesAndroid);
expect(product.introductoryPricePeriodAndroid,
expectedProduct.introductoryPricePeriodAndroid);
expect(product.freeTrialPeriodAndroid,
expectedProduct.freeTrialPeriodAndroid);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they being deprecated 🧐?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have been deprecated yes, these were essentially a way to make it look like an ios purchase but it's changed too much under the hood to be functional with the new Android billing

@hyochan hyochan merged commit 4d35e6e into hyochan:main Mar 7, 2023
@hyochan
Copy link
Owner

hyochan commented Mar 7, 2023

@SamBergeron @xPutnikx @nizwar shipped as 5.4.0 🚀

@deakjahn
Copy link
Contributor

deakjahn commented Mar 19, 2023

@SamBergeron Is this still the reason why I can't see my price after upgrading to 5.4.0? I get introductoryPrice all right but nothing else, no price or localizedPrice. All Android libraries are up-to-date, price is set correctly in Google Play, it still works all right with my current release version out there, just not with the upgraded plugin here. Do I need to make changes in my code or is it just a regression of some sort?

(No subscription, just a single in-app product.)

@deakjahn
Copy link
Contributor

deakjahn commented Mar 19, 2023

By the way, small error, toString() of IAPItem has an error, it displays two items with the label introductoryPricePaymentModeIOS, the first one is superfluous, it's a repeated display of introductoryPrice.

JoyHong pushed a commit to JoyHong/flutter_inapp_purchase that referenced this pull request Jul 6, 2023
This is build off of @youssefali424 hyochan#387 PR because that one had a couple issues. It didn't pass back the prices properly for items that were created in android billing 4.0 amongst other issues.

I created two new dart objects that reflect android 5.0 billing objects `SubscriptionOffer` and `PricingPhase` that pass back all the information associated with a play store item, so you can navigate those to extract introductory offers and discounted subscriptions as opposed to just having a single offer price.

I've also kept the `price`, `currency` and `localizedPrice` values and made them backwards compatible with items that were updated from billing 4.0 if your app relies on those (ours did)

~~Note that the tests fail because of ios and android receipt validation only, which appears to not point to a valid URL anymore.~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants