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

118
Visualizações
Autoclose the approve PayPal window in the PayPal Orders REST API v2?

After you

  1. generate a bearer token and
  2. create an order with the PayPal REST API,
# step 0: get token
curl  --request POST --compressed --silent  'https://api-m.sandbox.paypal.com/v1/oauth2/token'  --header 'accept: application/json'  --header 'accept-language: en_us'  --user '<clientid>:<secret>'  --data 'grant_type=client_credentials'

# step 1: create the order (use the token from step 0)
curl  --request POST --compressed --silent  'https://api-m.sandbox.paypal.com/v2/checkout/orders'  --header 'content-type: application/json'  --header 'authorization: bearer <token>' \
  --data '{
    "intent": "CAPTURE",
    "purchase_units": [{"amount":              {"value":"10.00", "currency_code":"USD"},
                        "description":         "hello",
                        "application_context": {"brand_name":"mybrand", "shipping_preference":"NO_SHIPPING", "return_url":""}}]
  }'

you show the user the approval page, where he can enter his credentials and approve the payment:

# step 2: show the user the approval page
https://www.sandbox.paypal.com/checkoutnow?<order_id>

I'm trying to implement step 2 in the client, with Javascript, without redirects (ie. without passing a return_url to /checkout/orders in step 1), and without using the PayPal buttons that come with the JS SDK.

This means you open a new window

window.open('https://www.sandbox.paypal.com/checkoutnow?<order_id>')

and let the user do his thing.

I've got everything working well, except the part that closes the approval window in step 2.

After the user logs in and approves the order in the newly created window, how can I automatically close it?

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