-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Implemented order available payment methods and order update payment #422
Conversation
a55667c
to
02a1f72
Compare
@GSadee @mamazu I'm struggling here with the tests... Can't figure out what's wrong. If I run the tests alone on local they work fine, but when running them one after the other there's an unrelated error. Seems to me some sort of race condition while loading the fixtures for the second time. Is something obvious that I'm not seeing here? |
I fixed the tests by changing the item used on the order. Sadly, I couldn't figure out what was the problem but it is related to mug item having product attributes. Since the items on the order are irrelevant for the test purposes I've just used another one and updated the expected responses accordingly. |
Ill have a look at it this evening. |
There are still some open conversations if you could resolve that, this would be great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it was a while, but can you apply my changes as well?
Sorry, for late review
doc/swagger.yml
Outdated
@@ -1009,6 +1009,53 @@ paths: | |||
description: "Order with given tokenValue not found" | |||
security: | |||
- bearerAuth: [] | |||
/{channelCode}/orders/{token}/payment: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payment
-> payments
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep it like this to be homogeneous with /{channelCode}/checkout/{token}/payment
ec33962
to
f76e387
Compare
Hello David, Sorry for such a long response time. I found some time to dig into ShopAPI and recently fix the way, how we handle placed orders in the test environment (0e445e4) This made this PR conflicted. Would you like to fix it? |
467db1f
to
2f174e9
Compare
@lchrusciel I've updated the tests. But now I can't set the payment state to something different from awaiting_payment to test it_does_not_allow_to_update_payment_method_on_paid_order, any suggestion? |
You can not set the payment method once the payment is completed. |
Ah, I see your problem. Currently there is no way for the API to mark an order as payed. What you can do is try to generate a fixture with a payed order. Other than that I don't know see #310 |
What's the status of this issue? Is there any hope to get merged? It would be great. So if I choose a payment method, paypal for example, complete the order but then I cancel in paypal, I could change the payment method. |
I have rebased the issue but I can not push it. @dlobato Please allow edits from maintainers to your branch. |
@mamazu I don't know how to enable that. I was trying this: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork But I don't see said checkbox anywhere... |
Implemented validator and tests Update to symfony messenger Use tokenValue from fixture Revert small changes on non related order fixtures Check order state on UpdatePaymentMethodHandler Assert payment is in new state
Hm, very strange. I can push to other merge request. Anyhow I have pushed my version of the branch to my repository mamazu/handle_order_payment. You can run the following commands to get this merge request up to speed: # Add me as a remote
git remote add mamazu git@github.com:mamazu/ShopApiPlugin.git
# Fetch all the branches
git fetch mamazu
# If you are not on your local branch change to it. Otherwise just run
git reset --hard mamazu/handle_order_payment
# Push the new changes to git (you might need to explicitly add `origin handle_order_payment`)
git push --force-with-lease If you have any questions, don't hesitate to ask. |
Your changes are already on my branch... |
This can't be I have fixed the tests (eg. removed the channelcode from the route). |
51034f4
to
10050cc
Compare
Check it out now |
Looks good. Can you run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you apply those fixes this should be all.
Co-Authored-By: mamazu <14860264+mamazu@users.noreply.github.com>
Co-Authored-By: mamazu <14860264+mamazu@users.noreply.github.com>
Co-Authored-By: mamazu <14860264+mamazu@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last one I promise. :D
Co-Authored-By: mamazu <14860264+mamazu@users.noreply.github.com>
Can you please checkout the code and put the right doc comment in there. |
Thank you, David! 🥇 |
$order = $this->orderRepository->findOneBy(['tokenValue' => $choosePaymentMethod->orderToken()]); | ||
|
||
Assert::notNull($order, 'Order has not been found.'); | ||
Assert::notSame(OrderInterface::STATE_CART, $order->getState(), 'Only orders can be updated.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% true, I suppose. Order's in fulfilled state should be blocked as well.
Assert::notSame(OrderInterface::STATE_CART, $order->getState(), 'Only orders can be updated.'); | |
Assert::same(OrderInterface::STATE_NEW, $order->getState(), 'Only new orders can be updated.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validator checks if the payment you are trying to edit was not payed yet. This would be a safer option as an assertion?
Hi,
We have implemented two new actions to handle payment state on placed orders:
1 is just reusing the same action from checkout, not sure if I should reimplement this as a different action.
2 adds validation as I've seen on other controllers, is this the preferred approach?
Tests are failing, there's something weird I couldn't figure out on loading the fixtures. I bet I'm doing something wrong. Am I missing something obvious there?
I've also added a new field to placedorder view: paymentState.
David.