Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:35:25+00:00 2026-06-10T05:35:25+00:00

I need to collect an input (‘x_amount’) with a php form, then post it

  • 0

I need to collect an input (‘x_amount’) with a php form, then post it to a page that generates a hash and then posts it to a third party site. I don’t want the customer to have a two step process, so can this be done with ajax and php? Here’s what I have so far, but it needs to be ajaxified (i think?)

          <form action="https://globalgatewaye4.firstdata.com/pay" method="POST">

        <?php
              $x_login = "xxx-xxx";  //  Take from Payment Page ID in Payment Pages interface
              $transaction_key = "xxxxxxx"; // Take from Payment Pages configuration interface
              $x_currency_code = "CAD"; // Needs to agree with the currency of the payment page
              srand(time()); // initialize random generator for x_fp_sequence
              $x_fp_sequence = rand(1000, 100000) + 123456;
              $x_fp_timestamp = time(); // needs to be in UTC. Make sure webserver produces UTC

              // The values that contribute to x_fp_hash 
              $hmac_data = $x_login . "^" . $x_fp_sequence . "^" . $x_fp_timestamp . "^" . $x_amount . "^" . $x_currency_code;
              $x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);

              echo ('<label>x_login</label><input name="x_login"  type="hidden" value="' . $x_login . '">' );
              echo ('<label>x_amount</label><input name="x_amount"  type="hidden" value="' . $x_amount . '">' );
              echo ('<label>x_fp_sequence</label><input name="x_fp_sequence"  type="hidden" value="' . $x_fp_sequence . '">' );
              echo ('<label>x_fp_timestamp</label><input name="x_fp_timestamp"  type="hidden" value="' . $x_fp_timestamp . '">' );
              echo ('<label>x_fp_hash</label><input name="x_fp_hash"  type="hidden" value="' . $x_fp_hash . '" size="50">' );
              echo ('<label>x_currency_code</label><input name="x_currency_code"  type="hidden" value="' . $x_currency_code . '">');
        ?>

              <input type="hidden" name="x_show_form" value="PAYMENT_FORM"/>
              <input type="hidden" name="x_test_request" value="FALSE"/>
              Enter Payment Amount:<br>
              <input type="text" name="x_amount"/>
              <input type="submit" value="Pay with Payment Pages"/>
            </form>

In other words, can I collect the x amount, generate the hash and then post it to the third party with just one click of the submit button? How can I accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:35:26+00:00Added an answer on June 10, 2026 at 5:35 am

    Ok, so I saw that firstdata.com actually suggests you to do that. I’ve managed to make something for you.

    You have to use ajax, post to same page the amount the client entered, process it and return to form. Sumbit form only when data is processed.

    I made you entire script because it was getting frustrating at some point figuring out how to do it.

    test.php

    <?php
        if(isset($_POST['amount']) && ($_POST['amount'] != '')){
            $x_amount = $_POST['amount'];
            $x_login = "xxx-xxx";  //  Take from Payment Page ID in Payment Pages interface
            $transaction_key = "xxxxxxx"; // Take from Payment Pages configuration interface
            $x_currency_code = "CAD"; // Needs to agree with the currency of the payment page
            srand(time()); // initialize random generator for x_fp_sequence
            $x_fp_sequence = rand(1000, 100000) + 123456;
            $x_fp_timestamp = time(); // needs to be in UTC. Make sure webserver produces UTC
    
            // The values that contribute to x_fp_hash 
            $hmac_data = $x_login . "^" . $x_fp_sequence . "^" . $x_fp_timestamp . "^" . $x_amount . "^" . $x_currency_code;
            $x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);
    
            $values = array('login' => $x_login, 'amount' => $x_amount, 'sequence' => $x_fp_sequence, 'timestamp' => $x_fp_timestamp, 'hash' => $x_fp_hash, 'currency' => $x_currency_code);
            echo json_encode($values);
            die;    
        }
    
    ?><html>
    <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    
    <script type="text/javascript">
        var processed = false;
        function makeProcessed(type){
            processed = type;
        }
    
        function prepareForm(){
            $('#submitPayment').val('Please wait ...');
    
            var processPayment = $.ajax({
                type: 'POST',       
                url: "test.php",
                data: {"amount": $('#x_my_amount').val()},
                dataType: 'json',
                async: false,
                success: function(data) {
                    $('#x_login').val(data.login); 
                    $('#x_amount').val(data.amount); 
                    $('#x_fp_sequence').val(data.sequence); 
                    $('#x_fp_timestamp').val(data.timestamp); 
                    $('#x_fp_hash').val(data.hash); 
                    $('#x_currency_code').val(data.currency);
                    if(data.hash){
                        makeProcessed(true);
                    }
                }
            });
            return processed;
        };
    </script>
    
    </head>
    <body>
    <form action="https://globalgatewaye4.firstdata.com/pay" method="POST" id="payment" onsubmit="return prepareForm();">
          <input type="hidden" name="x_show_form" value="PAYMENT_FORM"/>
          <input type="hidden" name="x_test_request" value="FALSE"/>
    
          <input name="x_login" id="x_login"  type="hidden" value="">
          <input name="x_amount" id="x_amount"  type="hidden" value="">
          <input name="x_fp_sequence" id="x_fp_sequence"  type="hidden" value="">
          <input name="x_fp_timestamp" id="x_fp_timestamp"  type="hidden" value="">
          <input name="x_fp_hash" id="x_fp_hash"  type="hidden" value="" size="50">
          <input name="x_currency_code" id="x_currency_code"  type="hidden" value="">
    
          Enter Payment Amount:<br>
          <input type="text" name="x_my_amount" id="x_my_amount" />
          <input type="submit" id="submitPayment" value="Pay with Payment Pages" />
        </form>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to collect the form elements of a cart. The items are in
I have a site.master page in which I need to collect a newsletter signup,
i have the following markup <form method=post action= id=form_1> <input type=hidden name=night[] value=1311976800/> <input
I need to log in, collect any cookie, and continue to the next page
I need to collect usage information on my on-demand application. This should include things
I need to use PerfMon to collect data from several machines, and I need
i need to write a program in c# to collect information about processes running
Need a map reduce function by mongo in php This my mongo structure [_id]
Need help with a query that I wrote: I have three tables Company id
Say I have this entity with a lot of attributes. In the input form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.