Fix 500 error on program checkout completion#3338
Conversation
…d_object.course.title Co-authored-by: jkachel <945611+jkachel@users.noreply.github.com>
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
jkachel
left a comment
There was a problem hiding this comment.
Looks pretty good; testing the wrong API for the cookie, though.
ecommerce/views/legacy/views_test.py
Outdated
| "transaction_id": "12345", | ||
| } | ||
|
|
||
| resp = api_client.post(reverse("checkout_result_api"), payload) |
There was a problem hiding this comment.
This is not the correct API to use for this purpose. This resolves to the BackofficeCallbackView, which is an out-of-band endpoint that doesn't set cookies or redirect the user, because it's consumed by a webhook from the payment processor. The CheckoutCallbackView endpoint is where the payment processor sends the user after they've completed checkout (and will set the cookie we're looking for).
There was a problem hiding this comment.
Fixed in fa25be9 — changed to user_client.post(reverse("checkout-result-callback"), ...) (the CheckoutCallbackView) and updated the expected status code to 302 since it returns a redirect.
…llbackView Co-authored-by: jkachel <945611+jkachel@users.noreply.github.com>
post_checkout_redirectinecommerce/views/legacy/__init__.pyto useline.coursewareinstead ofpurchased_object.course.title(which fails for Programs)test_checkout_api_result_program_acceptusing the correctCheckoutCallbackViewendpoint (checkout-result-callback) that sets the redirect cookie, notBackofficeCallbackView(checkout_result_api)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.