- First commit to issue fork.
- @tbkot opened merge request.
- 🇮🇱Israel jsacksick
@tBKoT: For determining that a payment is authorized or completed, we need to follow the same logic as in the
Payment::presave()
method.For example, for determining that a payment is authorized, you need to do the following:
$state = $payment->getState()->getId(); $original_state = isset($payment->original) ? $payment->original->getState()->getId() : ''; if ($state === 'authorization' && $original_state !== 'authorization') {
For determining that a payment is completed, same principle:
if ($state === 'completed' && $original_state !== 'completed') {
So this means you should call a common method that is called from payment insert and payment update.
Also, I'm thinking we should react to
PaymentEvents::PAYMENT_DELETE
instead ofPaymentEvents::PAYMENT_PREDELETE
since it is invoked AFTER the deletion. - Status changed to Needs review
almost 2 years ago 1:28pm 14 March 2023 - Status changed to Needs work
almost 2 years ago 7:46am 15 March 2023 - 🇮🇱Israel jsacksick
@tBKot: Looks good, we're close!
Did some manual testing and ended up with the following crash on checkout completion:
Error: Call to a member function label() on null in Drupal\commerce_log\EventSubscriber\PaymentEventSubscriber->onPaymentAdd()
Not all payments have a payment method so:
$payment->getPaymentMethod()->label()
should be updated, we should ensure the payment method is set/exists before accessing it.Also, let's rename
onPaymentAdd()
toonPaymentInsert()
.And the payment event subscriber is missing an empty line at end of file.
Would be great if we could expand the tests to ensure creating a payment doesn't crash when the payment method is empty so we're covered :).
- 🇮🇱Israel jsacksick
Also, we should be consistent with the variable names we use in templates (i.e we used "method" for "payment_authorized", "payment_completed" and "payment_updated", but we used payment_method_label for the "payment_deleted" template.
Additionally, I see that we don't include the gateway in the payment deletion template, which... is probably fine though.
Since the method can be NULL, I guess we need to adapt the templates to add conditions so "using" is only added when the method is known.
- Status changed to Needs review
almost 2 years ago 11:19am 15 March 2023 - Status changed to Needs work
almost 2 years ago 11:47am 15 March 2023 - 🇮🇱Israel jsacksick
There are confusing comments in logs:
// Check that log was not added on creation. $payment->save(); $logs = $this->logStorage->loadMultipleByEntity($this->order); $this->assertEquals(1, count($logs));
We're literally checking that a log was created here. Same with the method comment.
- Status changed to Needs review
almost 2 years ago 10:00am 16 March 2023 -
jsacksick →
committed 54c7d5f3 on 8.x-2.x authored by
tBKoT →
Issue #2845321 by lisastreeter, tBKoT, AndyF, jonathanshaw, rszrama,...
-
jsacksick →
committed 54c7d5f3 on 8.x-2.x authored by
tBKoT →
- 🇮🇱Israel jsacksick
Decided to go ahead and commit this! We've been dragging this for too long :).
Thanks to everyone involved!
- Status changed to Fixed
almost 2 years ago 4:26pm 16 March 2023 -
jsacksick →
committed 7ef5e68b on 3.0.x authored by
tBKoT →
Issue #2845321 by lisastreeter, tBKoT, AndyF, jonathanshaw, rszrama,...
-
jsacksick →
committed 7ef5e68b on 3.0.x authored by
tBKoT →
- 🇮🇱Israel jsacksick
I'm wondering if we shouldn't revisit this already before it goes into the release as it doesn't really look good with manual payments;
This is how it looks for "manual" payments:
After checkout, when the order is placed:
When "receiving" the payment:
Perhaps we need specific templates for manual payments? Notice the extra docs and "capture" which isn't the right term as there isn't an actual capture occurring here...
Also, wouldn't it make sense to log the order balance too? Perhaps on payment capture I guess?
Should we open a followup issue instead? Thoughts?
- Status changed to Needs review
almost 2 years ago 11:24am 22 March 2023 - 🇮🇱Israel jsacksick
Made some changes to the patch.
The "payment_added" template wasn't built the same as the others, the attached patch is making it more consistent with the others. Also added a "payment_manual_received" template.
-
jsacksick →
committed 9d9c5de6 on 8.x-2.x
Issue #2845321 followup by jsacksick: Improvement the log templates...
-
jsacksick →
committed 9d9c5de6 on 8.x-2.x
- 🇮🇱Israel jsacksick
Decided to commit the followup changes as it improves the current templates. The rest can be implemented via followup issues.
- Status changed to Fixed
almost 2 years ago 11:43am 22 March 2023 -
jsacksick →
committed 10291406 on 3.0.x
Issue #2845321 followup by jsacksick: Improvement the log templates...
-
jsacksick →
committed 10291406 on 3.0.x
Automatically closed - issue fixed for 2 weeks with no activity.