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

Add Google Sheets-based refund workflow #222

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jkachel
Copy link
Collaborator

@jkachel jkachel commented Feb 18, 2025

What are the relevant tickets?

Closes mitodl/hq#6042

Description (What does it do?)

This is the last part of the refunds processing support, and adds the Google Sheets processing code. This will allow the system to read a specific Google Sheet that has been set up in a particular way for refund requests, process those requests, and write the result back to the sheet.

This does not implement writing self-service requests into the Google Sheet. The existing functionality in ol-django doesn't expose an API for writing new rows, so this punts that down the road until that can be added.

How can this be tested?

Automated tests should work.

You will need to have a Google Sheet set up appropriately, and an API key set up that can access the sheet. Once you've done that, the system should check the sheet periodically and process rows within the sheet. You can also run the process_google_sheet command to trigger the task manually.

The README.md is updated with links to the relevant documentation in the ol-django apps - follow those instructions for setup info. There is a Google Sheet that can be used in the Open Learning Engineering share that has been cleared out and has some updates to the form logic to work with UE order IDs - you can either copy this to your own Drive or use it as is.

Once everything is set up, you should be able to request a refund via the Google Form and it should process in UE:

  • Successfully if the order is in the right state ("fulfilled"), the item you requested is in the order, and the order wasn't paid for via PayPal
  • With an error if the order contains a PayPal transaction
  • With an error if the order doesn't contain the item you requested
  • With an error if the order isn't in the proper state (pending, refunded, etc.)

Additionally, this should fix some issues with the refunds processing code:

  • Orders weren't being set to "refunded" when a refund was completed
  • Webhooks weren't being dispatched after a refund was approved - they should be sent now, so if you have something set up to capture webhooks, you should see them come through.

Additional Context

Punting writing new rows to the Google Sheet: with this, the system will process self-service and Google Forms requests, but these exist in different "buckets". The idea was that the self-service requests would also get written to the Google Sheet (for visibility) but the ol-django apps don't support writing new rows to a sheet. It's not strictly required though so focusing just on processing things in the sheet for now.

@jkachel jkachel force-pushed the jkachel/6042-add-refunds-pt-3 branch from 9074f77 to 6bc4c38 Compare February 21, 2025 19:54
- Adds refunds app to store refunds-related code
- Adds models, APIs, and views for refunds
- Adds plugin system for refunds - used to generate notification emails, approval codes
- Adds ol-django google_sheets and google_sheets_refunds dependencies (but doesn't use them yet)

..added F401, F811 because importing fixtures makes ruff unhappy
- Adds some more hooks for refund denied/issued
- Adds some email stubs
- Adds more tests and factories
- Updates the refund processing code to call CyberSource (iow, actually issue the refund)
- Will now process rows that are added to the specified Google Sheet, using the ol-django apps for this
- Set the order to refunded when an approved refund is completed
- Adds a task to periodically check the Google Sheet
- Adds some really basic documentation for the Google Sheet integration (which mostly punts you to ol-django)
@jkachel jkachel force-pushed the jkachel/6042-add-refunds-pt-3 branch from 6bc4c38 to 9245519 Compare February 21, 2025 20:00
Changed the unique on transaction_id; didn't need to but forgot to put the field back.
@jkachel jkachel marked this pull request as ready for review February 21, 2025 20:12
@jkachel
Copy link
Collaborator Author

jkachel commented Feb 21, 2025

Marking this as ready for review but: tests are currently failing because the two Google Sheets apps in ol-django have pending migrations. This needs to be fixed upstream but it doesn't affect the code in this PR.

@jkachel jkachel added Needs Review An open Pull Request that is ready for review product:unified-ecommerce Issues related to the Unified Ecommerce project labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review An open Pull Request that is ready for review product:unified-ecommerce Issues related to the Unified Ecommerce project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant