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

181
Visualizações
PayPal JS SDK server integration - including additional parameters

I wanted to integrate the new JS button. I'm on this page trying to figure out how to do this. I understand how it's supposed to work, but I don't get how to call a server script to handle the database updates.

It seems this line:

return fetch('/demo/checkout/api/paypal/order/' + data.orderID + '/capture/', {method: 'post'}

is calling a script, but how can I include arguments?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In the line you quote, the content of data.orderID becomes a path (URL) argument, and that URL is fetched. This URL needs to be a route on your server.

If you want to pass additional arguments, or put the order ID in the body of the request instead of the URL, you can do so. Use body in the options to fetch, and give it a JSON object/string. Something like:

return fetch('/path/on/your/server/to/capture/order', {
  method: 'POST',
  body: {
    id: data.orderID,
    your_argument_name: 'some data';
  }
});

On the server end handling the route, you'll need to deserialize that JSON object. Plenty of guides out there on how to read JSON input for whatever backend environment you're using (notably you do not use PHP's $_POST as that is for form encoded data only)

about 4 years ago · Juan Pablo Isaza Relatório
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