openedx-unsupported / edx-app-android

The Open edX mobile app for Android!
https://docs.google.com/document/d/15MYZ2LAmahB82P5wkPkQOqjszfou0Qkeae3qz7STxUQ/edit
Apache License 2.0
300 stars 336 forks source link

feat: Consumable In-App Purchases #1846

Closed HamzaIsrar12 closed 4 months ago

HamzaIsrar12 commented 5 months ago

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

codecov[bot] commented 5 months ago

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 :warning:
...rg/edx/mobile/model/api/EnrolledCoursesResponse.kt 0.00% 17 Missing :warning:
.../org/edx/mobile/inapppurchases/BillingProcessor.kt 0.00% 13 Missing :warning:
...dx/mobile/view/dialog/CourseModalDialogFragment.kt 0.00% 12 Missing :warning:
...c/main/java/org/edx/mobile/model/api/CourseMode.kt 0.00% 9 Missing :warning:
...ava/org/edx/mobile/model/api/EnrollmentResponse.kt 0.00% 7 Missing :warning:
...org/edx/mobile/view/CourseTabsDashboardFragment.kt 0.00% 7 Missing :warning:
...obile/view/CourseUnitMobileNotSupportedFragment.kt 0.00% 7 Missing :warning:
...in/java/org/edx/mobile/extenstion/EncryptionExt.kt 0.00% 5 Missing :warning:
...e/src/main/java/org/edx/mobile/util/TextUtils.java 0.00% 5 Missing :warning:
... and 9 more
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.