-
Notifications
You must be signed in to change notification settings - Fork 71
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
Always create RefundPayment after CreditMemo #296
Always create RefundPayment after CreditMemo #296
Conversation
features/not_seeing_refund_payments_and_credit_memos_on_admin_order_view.feature
Outdated
Show resolved
Hide resolved
features/not_seeing_refund_payments_and_credit_memos_on_admin_order_view.feature
Outdated
Show resolved
Hide resolved
features/not_seeing_refund_payments_and_credit_memos_on_admin_order_view.feature
Outdated
Show resolved
Hide resolved
features/not_seeing_refund_payments_and_credit_memos_on_admin_order_view.feature
Outdated
Show resolved
Hide resolved
features/not_seeing_refund_payments_and_credit_memos_on_admin_order_view.feature
Outdated
Show resolved
Hide resolved
string $state, | ||
int $paymentMethodId | ||
): RefundPaymentInterface { | ||
if (file_exists(self::FAILED_FILE)) { |
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 guess we should delete that file on __construct
to make sure that we're always starting from the same point. Eg. if the app breaks between failRefundPaymentCreation
and createWithData
, we're left in an incorrect state.
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.
Apparently, it does not work as expected :/ The constructor is called twice and removes the file unnecessarily. I've added a @AfterScenario
hook to the context, to do the trick 🖖
d1f320b
to
f12bc21
Compare
f12bc21
to
90db258
Compare
Thank you, Mateusz! 🥇 |
Partially solves #91
With the current implementation, both CreditMemo and RefundPayment are generated separately, which can results in a situation when one of them exists and the other does not. With the proposed change, we're protected from such a situation.
For sure, the solution is not perfect. The whole compensation/rollback functionality is based on the DoctrineTransactionMiddleware, which works in this case but does not have to be enough for some more complicated processes. A possible improvement of the proposed architecture would be adding the
prev/compensate/rollback
function to theUnitsRefundedProcessStepInterface
to implement a more mature and reliable saga pattern 🖖