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

OCC-34: Successful payment should include the Order view #163

Merged
merged 11 commits into from Aug 25, 2022

Conversation

DemeSzabolcs
Copy link
Contributor

OCC-34

Fixes #156

Comment on lines 3 to 9
@inject IContentManager contentManager

@{
var order = await contentManager.GetAsync(Context.Request.Query["Order"]);

order.DisplayText = T["Success"].Value;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do this in the controller and pass the resulting shape as the model.

In general, do as little C# in the view as possible. In most cases if you have to use @inject that's a hint the code should be refactored into the controller. The reason is, if there was an exception (for example if the Order query is missing) any error handling middlewares will be already too late by the time the view runs. So you only get the ASP.Net Core error screen. That would be a pain point for any consumer that wants custom error handling/page.


return Json(new { success = true });
return Json(new { success = true, order_content_item_id = order.ContentItemId });
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using snake_case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To match with requires_action and payment_intent_client_secret. What should be the default, camel case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. You can use PascalCase, because Json(...) automatically converts it to camelCase anyway.
Don't worry about being consistent with payment_intent_client_secret, because I will change that in OCC-33 as well.

{
var order = await _contentManager.GetAsync(orderId);

if (order != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

If the order is null it should return NotFound();. Otherwise the view will error out.
image

@@ -69,7 +69,7 @@ function stripeCardForm(stripe, urlPrefix, fetchErrorText) {
.then(handleStripeJsResult);
} else {
// Show success message.
window.location.href = `${urlPrefix}/success`;
window.location.href = `${urlPrefix}/success/${response.OrderContentItemId}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

It sends me to https://localhost:5001/success/undefined. It's because this should be response.orderContentItemId? Like I said in the other thread, return Json(new { ... }) automatically converts the result into camelCase.

@sarahelsaig sarahelsaig merged commit 66a7d89 into main Aug 25, 2022
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.

Successful payment should redirect to the Order view (OCC-34)
2 participants