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

feat: allow redemption at requested prices #185

Merged
merged 1 commit into from
Nov 28, 2023
Merged

Conversation

iloveagent57
Copy link
Contributor

@iloveagent57 iloveagent57 commented Nov 27, 2023

Assignments (in enterprise-access) contain a field that represents the price of the content at the time of assignment. We need to allow for that price to be passed through to the transaction creation view. ENT-8035

See updated API docs at http://localhost:18280/api/schema/redoc/#tag/transactions/operation/api_v2_subsidies_admin_transactions_create

Use curl/postman to make a request to create a new transaction for a price that's slightly different from the true price, e.g.

curl --location 'http://localhost:18280/api/v2/subsidies/4c53f616-5ea0-42a0-9430-ba165cb2c916/admin/transactions/' \
--header 'Authorization: JWT [your-jwt]' \
--header 'Content-Type: application/json' \
--data '{
    "subsidy_access_policy_uuid": "[your policy uuid]",
    "lms_user_id": [your user id int],
    "content_key": "edX+DemoX",
    "requested_price_cents": 14200
}'

Merge checklist

  • All reviewers approved
  • CI build is green
  • Documentation updated (not only docstrings)
  • Commits are squashed

@@ -499,7 +517,7 @@ def _create_redemption(
All other exceptions raised during the creation of an enrollment. This should have already triggered
the rollback of a pending transaction.
"""
quantity = -1 * self.price_for_content(content_key)
quantity = -1 * content_price
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IDK why we made a second call to get the price here - we already have it from calling is_redeemable() further up in the body of redeem().

@@ -549,7 +567,25 @@ def _create_redemption(

return ledger_transaction

def is_redeemable(self, content_key):
def validate_requested_price(self, content_key, requested_price_cents, canonical_price_cents):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

borrowed from the enterprise-access implementation

@iloveagent57 iloveagent57 marked this pull request as ready for review November 27, 2023 20:47
Assignments (in enterprise-access) contain a field that represents the price of the content at the time of assignment.
We need to allow for that price to be passed through to the transaction creation view.
ENT-8035
Copy link
Contributor

@pwnage101 pwnage101 left a comment

Choose a reason for hiding this comment

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

LGTM!

@iloveagent57 iloveagent57 merged commit 6a67117 into main Nov 28, 2023
8 checks passed
@iloveagent57 iloveagent57 deleted the aed/override-price branch November 28, 2023 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants