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

263
Views
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 answers
Answer question

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 Report
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!