Next.js Discord

Discord Forum

PayPal REST API with NextJs

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hello. I would like help on how to integrate PayPal with the REST API as I really dont have idea on how to replace the SDK with REST API.

I´ve tried some stuff and well, Im out of ideas. I am using Route Handlers but Im not sure if I am doing it correctly, help or suggestions will be much appreciated 🙂

# GITHUB REPO
https://github.com/yoboywhat/paypal-sdk-issue/tree/main/app/api/checkout

79 Replies

Masai LionOP
@Masai Lion btw Im using the documentation # https://developer.paypal.com/docs/api/orders/v2/#orders_create
@Ray Click to see attachment
Masai LionOP
long live Ray
let me test it and see if it works 🙂
@Masai Lion let me test it and see if it works 🙂
updated the code
@Ray Click to see attachment
Masai LionOP
with this code, Cloudflare shows this new error... but it has nothing to do with the file we just fixed
@Ray Click to see attachment
Masai LionOP
imma copy this and run the site on my local to see if it works correctly
@Ray look like your site is too heavy for cloudflare page <:noice:753872185185009774>
Masai LionOP
heheheh a little bit, wait, my website is that single file?
cache/webpack/client-rpduction/0.pack?
dayum
@Ray Click to see attachment
Masai LionOP
the code gives Error [TypeError]: Request with GET/HEAD method cannot have body.
you sure?
@averydelusionalperson you sure?
Masai LionOP
terminal says that
blame it on npm run dev
imma blame you
you copied correctly right?
@averydelusionalperson imma blame you
Masai LionOP
😮
@averydelusionalperson you copied correctly right?
Masai LionOP
yes
just give me a lil screenshot of your code
I've some trust issues
@averydelusionalperson I've some trust issues
Masai LionOP
its github 😦
github cool
@averydelusionalperson just give me a lil screenshot of your code
Masai LionOP
well, Ray sent an updated version of it 🙂
noice
@Ray Click to see attachment
Masai LionOP
it now says {
error: 'invalid_client',
error_description: 'Client Authentication failed'
}
sounds like paypal error
nothing wrong with next.js
@averydelusionalperson noice
Masai LionOP
give me recommendations on how to make a cache file smaller
@averydelusionalperson ~~you don't use cache~~
Masai LionOP
impossible
@Masai Lion impossible
I'm possible
@Masai Lion it now says { error: 'invalid_client', error_description: 'Client Authentication failed' }
try again
Masai LionOP
and my project is kinda fat
i need to take it to the gym
Masai LionOP
bro my site is 1.28 gb
and i can only have 26 mb
Masai LionOP
i think i will remove internationalization
cuz damn
its easier to create a second page in spanish with a subdomain and just publish it
than having it as a route
sed
lmao
@averydelusionalperson sed
Masai LionOP
Guess what
I deleted int stuff
And at the end
It wasn’t about that
:galactic_brain:
It’s like 4 am and I need to sleep
Tomorrow I will try get internationalization back
:sunglasses_1:
Masai LionOP
The main problem here is
# PayPal 😱 (🤮)
@Ray try again
Masai LionOP
Now it says Error [TypeError]: fetch failed
I think we need to pass some props
Some like this
'{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
      "amount": {
        "currency_code": "USD",
        "value": "100.00"
      }
    }
  ],
  "payment_source": {
    "paypal": {
      "experience_context": {
        "payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
        "brand_name": "EXAMPLE INC",
        "locale": "en-US",
        "landing_page": "LOGIN",
        "shipping_preference": "SET_PROVIDED_ADDRESS",
        "user_action": "PAY_NOW",
        "return_url": "https://example.com/returnUrl",
        "cancel_url": "https://example.com/cancelUrl"
      }
    }
  }
}
On the return and cancel url we have to give the host name
On the purchase units well it has to be the same as the one I have rn
here you go
@averydelusionalperson 🖐️
Masai LionOP
hahahaha so funny
:meow_stare:
what, I gave you a hand
I might be of help
@Masai Lion <@743561772069421169> can you give me a hand ?
I can try to see what happen if you could send me the id and secret, otherwise I have no clue
ray trying to scam you, don't send him id & secret
I think it is more of something that we missing this stuff
then you fix it
I have no clue
@Ray then you fix it
Masai LionOP
K
I don't use paypal
sadge