- 🇬🇧United Kingdom jonathanshaw Stroud, UK
+++ b/src/Plugin/Commerce/PaymentGateway/Stripe.php @@ -472,6 +473,16 @@ class Stripe extends OnsitePaymentGatewayBase implements StripeInterface { + $intent_attributes = $event->getIntentAttributes(); + $intent_array = NestedArray::mergeDeep($intent_array, $intent_attributes);
I think we can simply do $intent_array = $event->getIntentAttributes() here.
And then in PaymentIntentEvent let's add an addIntentAttributes() method that uses NestedArray::mergeDeep() to merge the added attributes to the ones originally provided to the event. It's just a convenience so the event subscribers don't have to call getIntentAttributes(), merge deep with whatever additional attributes they want, and then call setIntentAttributes().
- 🇯🇴Jordan mhawwari
Needed to use this patch for adding an intent description.
I applied the approach in #17 and added a new addIntentAttributes() method. I also just added a @deprecated tag for #16The only concern here is if we should dispatch the event in the same place the transaction data event is being dispatched in the createPayment() method and pass the payment object if a project needed to pass info about the drupal payment to stripe.
- 🇯🇴Jordan mhawwari
I guess we can pass an empty intent array to only update attributes added from the event subscriber and that can avoid updating all the intent attributes in createPayment() after payment save. So we can pass
new PaymentIntentEvent($order, [], $payment)
to replacenew TransactionDataEvent($payment)
. - 🇳🇿New Zealand john pitcairn
The only concern here is if we should dispatch the event in the same place the transaction data event is being dispatched in the createPayment() method
No. See #5 ✨ Allow customising payment intent attributes and metadata Fixed .
- 🇳🇿New Zealand john pitcairn
PaymentIntentEvent
is missing ause
statement forNestedArray
. - 🇳🇿New Zealand john pitcairn
The comments in
StripeEvents
also need attention.PaymentIntentEvent
is only dispatched when a payment intent is created. It does not allow modification of transation data if a payment intent is updated.TransactionDataEvent
did allow that, but is now deprecated, and it is only passed the payment at__construct()
, not the intent attributes.The only place we call
PaymentIntent::update()
is following theTransactionData
event dispatch, to merge in any added metadata, and that is going to be removed.I think we can remove any mention of updating a payment intent.
- Status changed to Needs review
almost 2 years ago 11:06pm 13 February 2023 - 🇬🇧United Kingdom jonathanshaw Stroud, UK
+++ b/src/Event/StripeEvents.php @@ -7,12 +7,24 @@ namespace Drupal\commerce_stripe\Event; + const PAYMENT_INTENT = 'commerce_stripe.payment_intent';
I think we should call this PAYMENT_INTENT_CREATE in cae we also want to create a PAYMENT_INTENT_UPDATE in the future.
- Status changed to Needs work
almost 2 years ago 7:17pm 14 February 2023 - 🇬🇧United Kingdom jonathanshaw Stroud, UK
This is not a replacement for every conceivable use case for TRANSACTION_DATA event because it is called earlier. But it should handle the 99% use cases rather better than the current approach, so I think its fine as is. We can always add further events in future if demmand is there.
- Status changed to Needs review
almost 2 years ago 10:14pm 14 February 2023 - 🇳🇿New Zealand john pitcairn
OK and we'd just use the same event class when dispatching an update event.
This patch changes the event constant. Anyone relying on it will need to update their subscriber
getSubscribedEvents()
method.It also adds "Will be removed in 2.x" to the deprecation notices, and the docblock clarifies that the event fires before the payment intent is created.
- Status changed to RTBC
almost 2 years ago 12:42pm 15 February 2023 - 🇬🇧United Kingdom jonathanshaw Stroud, UK
+++ b/src/Event/StripeEvents.php @@ -7,12 +7,23 @@ namespace Drupal\commerce_stripe\Event; + * @deprecated Will be removed in 2.x. Use StripeEvents::PAYMENT_INTENT to
Constant needs changing here too.
RTBC as trivial and can be fixed on commit.
- Status changed to Fixed
almost 2 years ago 3:09pm 20 March 2023 Automatically closed - issue fixed for 2 weeks with no activity.