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

Both options seem to do the same thing but they have different markup and I'm not sure what's causing the 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.
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2020-11-11 at 00.16.25.png | 159.26 KB | danharper | |
| Screenshot 2020-11-10 at 23.43.19.png | 29.62 KB | danharper |
Comments
Comment #2
xamountI am experiencing the same issue. Didn't find a solution as yet...
I am also using PayPal Commerce Platform (Preferred) on D8
Comment #3
xamountComment #4
sekoz commentedI 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
Comment #5
danharper commentedIt 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.
Comment #6
frocha commentedI getting the same problem!
Drupal core 8.9.9
Drupal Commerce 2.21
Commerce Paypal ^1.0@RC
Comment #7
attisanI'm having this issue too, but only when returning to the form to edit the billing information (same as described in #5)
Comment #8
zenimagine commentedI confirm
Comment #9
kevster commentedSame 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"
Comment #10
no sssweat commentedTo 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.
Comment #11
attisanafter 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.
Comment #12
no sssweat commented@attisan, looking at PaymentOptionsBuilder.php I couldn't find any
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.
Comment #13
attisanI'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.
Comment #14
no sssweat commentedThis is actually a commerce payment module issue, and it's getting fixed here https://www.drupal.org/project/commerce/issues/3184254