Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render the express payment button in the editor #215

Open
alexflorisca opened this issue Sep 9, 2024 · 5 comments
Open

Render the express payment button in the editor #215

alexflorisca opened this issue Sep 9, 2024 · 5 comments
Labels
changelog: fix Took care of something that wasn't working. impact: high This issue impacts a lot of users as reported by our Happiness Engineers. type: bug The issue is a confirmed bug. type: enhancement The issue is a request for an enhancement.

Comments

@alexflorisca
Copy link
Member

Currently, two preview images of both the Apple Pay and Google Pay buttons are being rendered in the editor. The first issue here is that only one of these should be rendered per slot, otherwise it breaks the grid layout (see screenshot)

Screenshot 2024-09-09 at 16 29 40
The first 2 images of Apple Pay and Google Pay in the top left come from the Square extension.

With new changes about to be introduced in Core in woocommerce/woocommerce#50791, we are asking payment extensions to render the actual buttons in the editor instead of a preview. This has several benefits:

  • It gives the merchant a more accurate representation of what the shopper would see on the front end of a store
  • It provides feedback to the merchant as to which express payment buttons support the new height and border radius controls

This will involve:

  • loading the SDK or client side scripts which load the button in the editor
  • When calling registerExpressPaymentMethod, passing the same component to the edit property as the content property.

Please reach out if you need any help

@alexflorisca alexflorisca added impact: high This issue impacts a lot of users as reported by our Happiness Engineers. type: bug The issue is a confirmed bug. type: enhancement The issue is a request for an enhancement. changelog: fix Took care of something that wasn't working. labels Sep 9, 2024
@Sidsector9
Copy link
Member

@alexflorisca this is difficult to implement with the Square extension, the main problem being the editor loading inside an iframe.

We provide an HTML container (DIV, SPAN) which Square uses to inject the buttons, but before that it checks for el instanceof HTMLElement which evaluates to false because by default the parent document window object is referred to for HTMLElement.

As a workaround, I tried loading the Square Web API inside the iframe and did a override such as:

window.HTMLElement - iframe.contentWindow.HTMLElement

which fixed this problem.

The second check the Square Web API performs is the window.location.protocol to check for :https.
The problem here is that the iframe containing the editor sets src as a :blob URL, so this check evaluates to false which prevents the buttons to render.

Do you know of any similar cases with other gateways that were resolved?

@alexflorisca
Copy link
Member Author

alexflorisca commented Sep 18, 2024

Could you use window.parent.location.protocol instead? That should give you the parent window location. If in the global window, I think it just returns that, so it might be all round better to check for that

@Sidsector9
Copy link
Member

@alexflorisca that check is done by Square's 3rd party script so we can't modify that part.

@alexflorisca
Copy link
Member Author

Is it worth reaching out to Square to see if they are able to accommodate this situation and change their script to check for window.parent?

@Sidsector9
Copy link
Member

Sidsector9 commented Sep 23, 2024

I have raised the following issue:

square/web-payments-quickstart#244

cc: @vikrampm1 / @jeffpaul it would be helpful if you can escalate the issue above. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Took care of something that wasn't working. impact: high This issue impacts a lot of users as reported by our Happiness Engineers. type: bug The issue is a confirmed bug. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants