Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

feat: Consumable In-App Purchases #1846

Merged
merged 2 commits into from
Mar 6, 2024
Merged

feat: Consumable In-App Purchases #1846

merged 2 commits into from
Mar 6, 2024

Conversation

HamzaIsrar12
Copy link
Contributor

@HamzaIsrar12 HamzaIsrar12 commented Feb 15, 2024

Description

LEARNER-9818 | LEARNER-9878

Remote Config Changes for Store SKU

The storeSku will be the combination of prodcut_prefix value from Remote Config and min_price from course modes in enrolments API.

Implementation

  1. Fetch the courseSku and storeSku using the enrollments API.

  2. Utilize the courseSku for the add_to_basket and checkout APIs.

  3. Handling Play Console purchases:

    • Store courseSku within the purchase as a payload using obfuscatedProfileId (ref).
    • Utilize the storeSku for the purchase.
  4. After a successful purchase:

    • Retrieve the courseSku from obfuscatedProfileId.
    • Extract storeSku from the product ID.
    • Implement a similar approach for the restore process.
  5. Share this information with the execute API:

    • Upon a successful response, consume the purchase.
    • Refresh the courses.
  6. In case of a restore (payment done, but execute API or consume not called):

    • For Execute:
      • Leverage the existing mechanism for execute.
      • Integrate consumption following the above approach.
    • **For Consume (when execute is called but the product isn't consumed):
      • Proceed with the consumption straightforwardly.
      • The course is already verified from the server and locally.**
  7. Tada!!

References

@HamzaIsrar12 HamzaIsrar12 marked this pull request as draft February 15, 2024 08:28
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 133 lines in your changes are missing coverage. Please review.

Project coverage is 1.07%. Comparing base (bd6299c) to head (d74b621).

Files Patch % Lines
...rg/edx/mobile/viewModel/InAppPurchasesViewModel.kt 0.00% 31 Missing ⚠️
...rg/edx/mobile/model/api/EnrolledCoursesResponse.kt 0.00% 17 Missing ⚠️
.../org/edx/mobile/inapppurchases/BillingProcessor.kt 0.00% 13 Missing ⚠️
...dx/mobile/view/dialog/CourseModalDialogFragment.kt 0.00% 12 Missing ⚠️
...c/main/java/org/edx/mobile/model/api/CourseMode.kt 0.00% 9 Missing ⚠️
...ava/org/edx/mobile/model/api/EnrollmentResponse.kt 0.00% 7 Missing ⚠️
...org/edx/mobile/view/CourseTabsDashboardFragment.kt 0.00% 7 Missing ⚠️
...obile/view/CourseUnitMobileNotSupportedFragment.kt 0.00% 7 Missing ⚠️
...in/java/org/edx/mobile/extenstion/EncryptionExt.kt 0.00% 5 Missing ⚠️
...e/src/main/java/org/edx/mobile/util/TextUtils.java 0.00% 5 Missing ⚠️
... and 9 more
Additional details and impacted files
@@             Coverage Diff             @@
##             master   #1846      +/-   ##
===========================================
- Coverage      1.07%   1.07%   -0.01%     
  Complexity      137     137              
===========================================
  Files           539     539              
  Lines         26385   26448      +63     
  Branches       3400    3412      +12     
===========================================
  Hits            284     284              
- Misses        26074   26137      +63     
  Partials         27      27              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HamzaIsrar12 HamzaIsrar12 marked this pull request as ready for review February 20, 2024 12:00
Copy link
Contributor

@farhan-arshad-dev farhan-arshad-dev left a comment

Choose a reason for hiding this comment

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

The overall code LGTM 🚀 , and executed the happy path using the hardcoded values. but still need a proper manual testing process by the QA team.

Introduce consumable In-App Purchase (IAP) functionality to overcome the
1000-product limit on the Play Console. This includes:

- Adding a new field, `storeSku`, to store the Play Console product ID. The
  `storeSku` is derived from the combination of the `product_prefix` value
  from Remote Config and `min_price` from course modes in the enrolments API.
- Implementing the process of consuming the product after verifying the
  purchase.

Fixes: LEARNER-9818
The billing SDK's queryPurchases returns a list of purchases that
are currently in a purchased, pending, or unspecified state. For
the unfulfilled purchase flow, we only need to consider the
'purchased' state.

Fixes: LEARNER-9878
@HamzaIsrar12 HamzaIsrar12 merged commit 89d8d4e into master Mar 6, 2024
4 checks passed
@HamzaIsrar12 HamzaIsrar12 deleted the hamza/LEARNER-9818 branch March 6, 2024 10:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants