Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
Using Apple Pay in a dynamically rendered iframe (same-origin)

I'm trying to use Apple Pay within an iframe that I create and populate its DOM with Javascript.

(Context: I work on 3rd party widget that websites can embed into their existing websites, hence the need to isolate everything in an iframe; there are other options for isolating, but this is what we currently use).

Apple Pay has two requirements, as far as I know:

  1. The frame has a secure source
  2. The frame has the same origin as the main frame on the page.

In order to satisfy these two requirements, I have tried to use the following code (tested in Safari):

const iframe = document.createElement('iframe')
document.body.appendChild(iframe)
// the iframe origin is 'about:blank'
// let's try to fix that
iframe.contentDocument.open()
// Render the DOM content here
iframe.contentDocument.close()
// That seems to set the origin of the iframe to the origin of the caller of `open`

// Test 
const script = iframe.contentDocument.createElement('script')
script.text = `
console.log(location.origin == parent.location.origin)
// true, so iframe origin should be secure now like the parent

console.log(ApplePaySession.supportsVersion(2))
// But it still triggers the following error:
// "InvalidAccessError: Trying to start an Apple Pay session from an insecure document."
`
iframe.contentDocument.head.appendChild(script)

As you can see, this does not work despite the fact that the document origin is recognized as being the same as the parent origin and it is secure.

In conclusion: Is there any way I can use Apple Pay from within an iframe which I dynamically create on a 3rd party website?

Any help will be appericiated.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda