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

Always create RefundPayment after CreditMemo #296

Conversation

Zales0123
Copy link
Member

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 the UnitsRefundedProcessStepInterface to implement a more mature and reliable saga pattern 🖖

@Zales0123 Zales0123 added Bug Confirmed bugs or bugfixes. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). DX Issues and PRs aimed at improving Developer eXperience. labels May 24, 2021
@Zales0123 Zales0123 requested a review from a team as a code owner May 24, 2021 13:11
README.md Outdated Show resolved Hide resolved
UPGRADE.md Outdated Show resolved Hide resolved
tests/Behat/Context/Setup/RefundingContext.php Outdated Show resolved Hide resolved
string $state,
int $paymentMethodId
): RefundPaymentInterface {
if (file_exists(self::FAILED_FILE)) {
Copy link
Contributor

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.

Copy link
Member Author

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 🖖

@Zales0123 Zales0123 force-pushed the create-credit-memos-and-refund-payments-synchronously branch 2 times, most recently from d1f320b to f12bc21 Compare May 26, 2021 07:12
@Zales0123 Zales0123 force-pushed the create-credit-memos-and-refund-payments-synchronously branch from f12bc21 to 90db258 Compare May 26, 2021 08:06
@GSadee GSadee merged commit 41fc088 into Sylius:master May 26, 2021
@GSadee
Copy link
Member

GSadee commented May 26, 2021

Thank you, Mateusz! 🥇

@Zales0123 Zales0123 deleted the create-credit-memos-and-refund-payments-synchronously branch June 10, 2021 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bugs or bugfixes. DX Issues and PRs aimed at improving Developer eXperience. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants