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

261
Visualizações
How can I pass variable numbers into PayPal REST API and give customers a receipt?

I am building a lottery web application where customers can select their own numbers or get 4 random numbers. How can I carry these numbers that the customer inputs/randomly generates into my shopping cart / paypal button? Thanks for any help. This is my code so far for the generation of random lottery numbers on JSP page.

<div id="num1" class="ball col-md-2"><span id="one"></span></div>
<div id="num2" class="ball col-md-2"><span id="two"></span></div>
<div id="num3" class="ball col-md-2"><span id="three"></span></div>
<div id="num4" class="ball col-md-2"><span id="four"></span></div>
                               
                           
 <%-- onclick to execute JavaScript function--%>      
 <button onclick="random()">QuickPick!</button>
</div>
               

This is the JS file to execute the random numbers to be generated.

function random(){
 //selects the 4 circles on the page
var one= document.getElementById('one');
var two= document.getElementById('two');
var three= document.getElementById('three');
var four= document.getElementById('four');


//create random number for each of the circles between 1-30
var a = Math.floor(Math.random()*30);
var b = Math.floor(Math.random()*30);
var c = Math.floor(Math.random()*30);
var d = Math.floor(Math.random()*30);


//put the random number into each of the 4 circles
one.textContent = a;
two.textContent = b;
three.textContent = c;
four.textContent = d;

}

I have set up a PayPal REST API integration by following instructions on the website, I also can use a buy now smart button from PayPal. My question is, how can I issue the customers a receipt of the numbers they have selected up successful purchase of the ticket? Is there a way to pass the values of the JS code into the PayPal checkout page, any help is greatly appreciated as I cannot find a way to do this, thanks.

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

0

In the Integrate Checkout guide, see the bullet #6 which has this example of transferring item information to PayPal:

    createOrder: function(data, actions) {
      return actions.order.create({
         "purchase_units": [{
            "amount": {
              "currency_code": "USD",
              "value": "100",
              "breakdown": {
                "item_total": {  /* Required when including the `items` array */
                  "currency_code": "USD",
                  "value": "100"
                }
              }
            },
            "items": [
              {
                "name": "First Product Name", /* Shows within upper-right dropdown during payment approval */
                "description": "Optional descriptive text..", /* Item details will also be in the completed paypal.com transaction view */
                "unit_amount": {
                  "currency_code": "USD",
                  "value": "50"
                },
                "quantity": "2"
              },
            ]
          }]
      });
    },

You can pass the same type of line item information whether using actions.order.create to create the order in the client side JS, or the REST API to create the order on the server. It is the same Orders v2 JSON format either way.

(A server-side REST API integration to create and capture the order is the most robust way; you can pair this with a JS SDK button for approval per the guide in bullet #5 of the above link.)

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