- 🇫🇷France solene_ggd
I wanted to use this patch to get multiple Paypal options (offsite payments) with the right display label. But when I set one of my Paypal options as default payment method with the #13 patch installed, I get this error :
Drupal\Core\Entity\EntityStorageException : Missing bundle for entity type commerce_payment_method dans Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (ligne 125 de /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).
This is because the payment method type id is not set in the option with the patch, but it is required by buildPaymentMethodForm() method called to construct the default payment option in PaymentInformation class.
I think this is what @DamienMo wanted to patch in his comment but I don't think he did it the right way.
I think the condition on offsite gateway should not be on the first condition to build the option but on the one inside that checks if there are multiple methods. This solution allows to keep the payment method type id in the option.And to get the payment gateway display label as option label, I change the default call of createLabel.
- Status changed to Needs review
11 months ago 5:34pm 9 February 2024 - last update
11 months ago 786 pass, 1 fail The last submitted patch, 21: 3250069-commerce-offsite-payment-methods-21.patch, failed testing. View results →
- 🇫🇷France solene_ggd
My bad, I did not think my patch could affect on site payment methods. Here is a new patch that should pass tests.
- Status changed to Needs review
11 months ago 6:10pm 9 February 2024 - last update
11 months ago 789 pass - 🇧🇪Belgium vaidas_a
I tested with commerce 2.38. Patch applied successfully and PayPal payment method label appeared as it should (e.g. 'Pay with PayPal'). Yet, if I proceed with payment, cancel it I'm returned to the order information page with payment method just 'PayPal' instead of the label (behaviour the same as without the patch).
It just a heads up, I didn't test with 3.x and clean setup.
- 🇫🇷France solene_ggd
Hello @vaidas_a,
If you want to see your display label instead of just "Paypal" when you go back, you need to install this patch in addition (on drupal/commerce_paypal module) : https://www.drupal.org/project/commerce_paypal/issues/3420132#comment-15... 🐛 Use payment gateway label instead of Paypal by default Active
#24 Worked for us using webform commerce order + commerce paypal, thanks!
+1 for RTBC- 🇺🇸United States rszrama
I think this may need to be tested against payment gateway integrations like the Stripe Payment Element. They are technically implemented as offsite payment gateways even though all payment occurs on site. I haven't applied this patch to review the before / after, but I wonder if that use case was considered when this patch was written.
- 🇺🇦Ukraine tbkot
@rszrama
Here are some screenshots before/after the patch
Before:
After:
Also, I have a small objection to the patch
It has a structure like:if ($payment_gateway->getPlugin() instanceof OffsitePaymentGatewayInterface) { /// } else { if ($payment_method_type_counts[$payment_method_type_id] > 1 && !$payment_gateway->getPlugin() instanceof OffsitePaymentGatewayInterface) { /// } }
The second condition
!$payment_gateway->getPlugin() instanceof OffsitePaymentGatewayInterface
is not necessary as it will always TRUE in this case - Status changed to Needs work
4 months ago 12:43pm 14 August 2024 - 🇮🇱Israel jsacksick
Setting the status back to "needs work" due to the useless condition.
- 🇮🇱Israel jsacksick
Ok, I've been testing this extensively this afternoon and the patch from #24 would actually break PayPal Checkout if configured to use the card fields instead of the smart payments buttons so the patch in its current form is definitely a no go.
Additionally, I believe instead of checking that the payment gateway plugin does not implement the
OffsitePaymentGatewayInterface
, we should instead enter the if, if the payment gateway plugin implements theSupportsCreatingPaymentMethodsInterface
.Making this change would fix the crash reported in #21, but would cause PayPal to remain unaddressed.
I now believe PayPal should be addressed separately, and I think this is now possible since 2.40, using the
PaymentEvents::FILTER_PAYMENT_OPTIONS
event. I'll do this as part of 🐛 Use payment gateway label instead of Paypal by default Active .Will open an MR to make the changes I just described.
- 🇮🇱Israel jsacksick
jsacksick → changed the visibility of the branch 3250069-list-offsite-payment to hidden.
- 🇮🇱Israel jsacksick
jsacksick → changed the visibility of the branch 3250069-list-offsite-payment to active.
- Merge request !317Issue #3250069 by berdir, solene_ggd, jsacksick, damienmckenna, damienmo: List... → (Merged) created by jsacksick
-
jsacksick →
committed 895611fa on 3.0.x
Issue #3250069 by berdir, solene_ggd, jsacksick, damienmckenna, damienmo...
-
jsacksick →
committed 895611fa on 3.0.x
- Status changed to Fixed
4 months ago 3:29pm 26 August 2024 Automatically closed - issue fixed for 2 weeks with no activity.