Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!