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

114
Views
Javascript anonymous function parameters

i am just learning how to code javascript. got confused by this chunk of code. from my reading function(data, actions) is an anonymous function that passes two parameters to the function body. however, i don't see "data" being referenced anywhere inside the function. am i reading it wrong?

<script>
  paypal.Buttons({
    createOrder: function(data, actions) {
      // Set up the transaction
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '0.01'
          }
        }]
      });
    }
  }).render('#paypal-button-container');
</script>
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

All the PayPal JS SDK callback functions have two parameters, data and actions. This is just the name/convention the SDK chooses to use for those parameters' names.

When creating a PayPal order or subscription on button click there isn't anything useful in the data object, so you won't find samples that make use of it -- but if you wanted to check its contents while developing you can log it to your browser console with something like:

        createOrder: function(data, actions) {
            console.log("createOrder data param", data, JSON.stringify(data,null,2) );
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: '0.01'
                    }
                }]
            });
        }
about 4 years ago · Santiago Gelvez 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!