I've created a payment gateway using PayPal Commerce Platform (Preferred) and on the checkout page I have paypal twice see screenshot.

paypal twice

Both options seem to do the same thing but they have different markup and I'm not sure what's causing the options.

markup


On the flip side, you could say the Commerce Paypal module introduces this bug by saving the payment_method to the order when you go to the next step/pane. In contrast, for example, the Commerce Payment Example does not do this nor if you add a payment gateway of "manual" plugin, it doesn't save the payment_method to the order either.

I haven't been able to track down where or why the Commerce Paypal module saves the payment_method to the order.

Comments

danharper created an issue. See original summary.

xamount’s picture

Priority: Normal » Major

I am experiencing the same issue. Didn't find a solution as yet...
I am also using PayPal Commerce Platform (Preferred) on D8

xamount’s picture

Title: Paypal displaying twice » Paypal payment method displaying twice when using PayPal Commerce Platform (Preferred)
sekoz’s picture

I confirm I'm getting the same problem with
Drupal core 8.9.9
Drupal Commerce 8.x-2.21
Commerce PayPal 8.x-1.0-rc1

danharper’s picture

It has something do with the fact you may have already selected paypal and then left the cart and come back or at least it knows who you are,

If I test it with an anonymous user and checkout as guest I get a single option, if then add my email address and continue to review but leave and come back then I get two checkboxes.

frocha’s picture

I getting the same problem!

Drupal core 8.9.9
Drupal Commerce 2.21
Commerce Paypal ^1.0@RC

attisan’s picture

I'm having this issue too, but only when returning to the form to edit the billing information (same as described in #5)

zenimagine’s picture

I confirm

kevster’s picture

Same here - I get this issue when logged in testing as admin. I only have paypal sandbox enabled and test payment enabled - paypal live is disabled...

The labels are different:

first one I wasnt expecting:
label for="edit-payment-information-payment-method-7--xxx"

second which is my sandbox one:
label for="edit-payment-information-payment-method-new-paypal-checkout-paypal-test--xxx"

no sssweat’s picture

To me, seems this bug is introduced by the way the payment module names the options keys, see Inconsistent options array key names in PaymentOptionsBuilder can lead to duplicate options.


On the flip side, you could say the Commerce Paypal module introduces this bug by saving the payment_method to the order when you go to the next step/pane. In contrast, for example, the Commerce Payment Example does not do this nor if you add a payment gateway of "manual" plugin, it doesn't save the payment_method to the order either.

I haven't been able to track down where or why the Commerce Paypal module saves the payment_method to the order.

attisan’s picture

after reviewing the code, I think this is due to commerce trying to always provide the option to "add a new payment-emthod of the already used type" (see /commerce/modules/payment/src/PaymentOptionsBuilder.php function buildOptions). This can be useful in some cases, but never is so for offsite methods like paypal as no actual data is retained whithin drupal after payment was completed that could be altered by adding another paypal payment method for the user 🤷‍♂️.

As the paypal payment gateway is an instance of SupportsStoredPaymentMethodsInterface, this is what commerce does.

no sssweat’s picture

after reviewing the code, I think this is due to commerce trying to always provide the option to "add a new payment-emthod of the already used type" (see /commerce/modules/payment/src/PaymentOptionsBuilder.php function buildOptions).

@attisan, looking at PaymentOptionsBuilder.php I couldn't find any

"add a new payment-emthod of the already used type"

I know there is a typo, but still, CTRL + F "already" doesn't find anything. So I take it you didn't mean that as a direct quote... I thought you were quoting a code comment.

Anyways, I posted my findings in this other issue. Let me know if yours is the same conclusion? If not can you be more specific as to what you're talking about, as I don't quite get what you're trying to say. Pointing at lines of code would be more helpful.

attisan’s picture

I'm sorry for that, it actually wasn't meant as a direct quotation but summarizing what is done in the function buildOptions.

As far as I understand the intention behind the code, it seems clear to me, that PaymentOptionsBuilder provides "one additional" radio option for payment gateways of instance SupportsStoredPaymentMethodsInterface if the current user / order already used that payment gateway - as to allow for an alternative.

the mechanic behind buildOptions is to allow the user to add an additional / -other "of the already used" (in this case paypal; which incidentally makes no sense) payment type.

no sssweat’s picture

Status: Active » Closed (duplicate)

This is actually a commerce payment module issue, and it's getting fixed here https://www.drupal.org/project/commerce/issues/3184254