Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ThinkingMan's avatar

Send data from Blade form view to external POST

I am creating a simple donation form for my local church and have decided to integrate to Payeezy. So essentially church members will go to the church profile page, fill in their name, address and the amount they want to donate. This can send via POST to the Payeezy hosted page. (Sample code here https://support.payeezy.com/hc/en-us/articles/204011429-Sample-Code-Creating-a-Pay-Button-to-use-with-a-Hosted-Payment-Page)

I have this working in a non-Laravel HTML form. I think my problem is something with routing as I cannot pass the form field data to the First Data hosted page. It doesnt know the value that I entered on the form. I have hard coded all fields except the $x_amount listed below. This amount is filled in on the Church Profile Laravel Blade form then I call the route to the Payeezy POST form and am trying to pass the amount over. But the amount never passes. It just comes back with the error and the variable id.

So what am I doing wrong in trying to send via the POST? Since this is not posting in my application I wasnt using the POST methods in Laravel, just trying to hand over to the Payeezy page.

<?php
$x_login = "HARD CODED FOR NOW"; // Take from Payment Page ID in Payment Pages interface
$transaction_key = "HARD CODED FOR NOW"; // Take from Payment Pages configuration interface
$x_amount = $_POST["x_amount"];
$x_currency_code = "USD"; // Needs to agree with the currency of the payment page
$x_recurring_billing = "TRUE";
$x_recurring_billing_id = "HARD CODED FOR NOW";
$x_recurring_billing_amount = "HARD CODED FOR NOW";
$x_recurring_billing_start_date = "HARD CODED FOR NOW";
$x_recurring_billing_end_date = "HARD CODED FOR NOW";
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
0 likes
18 replies
ThinkingMan's avatar

Is anyone able to see my posts? I am wondering only because I am having issues accessing and a couple of my posts have not been replied to at all.

Snapey's avatar

yes but you are not posting anything that can be commented on. You just show a load of variables being assigned in php.

jlrdw's avatar

Are you sure you're not supposed to go to that site and have them fill out the information there and that site is linked to the church. Kind of like the way PayPal works with a donate link.

In other words the donate Link in your church site opens another site for the actual donation if you can follow that.

I think you need a correct link.

I know PayPal gives you the code to grab and put in your view, but no routing is necessary it's just an external link.

If you're not grasping how to handle this you might want to talk to someone else in the computer industry that can help you locally.

ThinkingMan's avatar

The form on my site is allowed to post to the variables on the hosted payment page. As mentioned, I have this working with straight HTML and PHP. It is the pass in the Laravel MVC that I am trying to resolve. Obviously I am doing something wrong in Laravel. Will post some more code to illustrate. Thanks

jlrdw's avatar

I just ran your sample in one of my views, had no probem.

Just put the sample files in root and link in view like:

<a href="<?php echo DIR . 'Samplegge4payment.html'; ?>">click here</a>

Ran perfect

You could tweak as needed.

Don't use DIR it's a constant I setup for me, use your way of linking to root.

Cronix's avatar

I think my problem is something with routing as I cannot pass the form field data to the First Data hosted page. It doesnt know the value that I entered on the form.

You're not showing us that though...so how can we help? As @snapey said, all you are doing is showing us variables being assigned values. You're not showing the form, or the route, or the controller method, etc. Show all of the relevant code.

jlrdw's avatar

@Cronix it's in a zip file on the site, the example. https://support.payeezy.com/hc/en-us/articles/204011429-Sample-Code-Creating-a-Pay-Button-to-use-with-a-Hosted-Payment-Page

It's just a html form

<html>
<h1>Payment Page</h1>
<br><form action="Samplegge4payment.php" method="post">
Payment Amount $<input name="x_amount" value="" type="text">
<input type="submit" value="Pay Now">
</form>
</html>

then

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
Payment Pages: Sample PHP Payment Form
</title>
<style type="text/css">
label {
display: block;
margin: 5px 0px;
color: #AAA;
}
input {
display: block;
}
input[type=submit] {
margin-top: 20px;
}
</style>

</head>
<body>
<h1>Processing Please Wait...</h1>

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

<?php
$x_login = ""; // Take from Payment Page ID in Payment Pages interface
$transaction_key = ""; // Take from Payment Pages configuration interface
$x_amount = $_POST["x_amount"];
$x_currency_code = "USD"; // 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 ('<input name="x_login" value="' . $x_login . '" type="hidden">' );
echo ('<input name="x_amount" value="' . $x_amount . '" type="hidden">' );
echo ('<input name="x_fp_sequence" value="' . $x_fp_sequence . '" type="hidden">' );
echo ('<input name="x_fp_timestamp" value="' . $x_fp_timestamp . '" type="hidden">' );
echo ('<input name="x_fp_hash" value="' . $x_fp_hash . '" size="50" type="hidden">' );
echo ('<input name="x_currency_code" value="' . $x_currency_code . '" type="hidden">');

// create parameters input in html
foreach ($_POST as $a => $b) {
    echo "<input type='hidden' name='".htmlentities($a)."' value='".htmlentities($b)."'>";
}

?>

<input type="hidden" name="x_show_form" value="PAYMENT_FORM"/>
</form>

<script type='text/javascript'>document.myForm.submit();</script>

</body>
</html>

Form is external site:

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

OP just needs to properly place this stuff in a folder.

ThinkingMan's avatar

Thank you in advance everyone. I apologize for simple questions. I do have the HTML and PHP working much like @jlrdw has posted. Works no issue. But I am storing the values for the Church pay pages and some other variables that are needed for posting. I am building this in Laravel because the church can sign up members for historical reasons. That said here is the code thus far:

Here is the Church List/Profile Page

Donations Site - Church List Page

Donations

This will be the church list.

@if($churches)
    @foreach($churches as $church)
        <div class="card" style="width:400px">
            <img class="card-img-bottom" src="\storage\users\default.png" style="width:25%;" alt="Church image">
            <div class="card-body">
                <h4 class="card-title">{{$church->church_name}}</h4>
                <p class="card-text">{{$church->id}}</p>
                <p class="card-text">{{$church->user->name}}</p>
                <a href="{{route('profile',[$church->id])}}" class="btn btn-primary">Church Page</a>

                <form action="{{route('donate',[$church->id])}}" method="post">
                    <input class="form-control" type="text" placeholder="Name">
                    <input class="form-control" type="text" placeholder="Address 1">
                    <input class="form-control" type="text" placeholder="Address 2">
                    <input class="form-control" type="text" placeholder="Address 3">
                    <input class="form-control" type="text" placeholder="City">
                    <input class="form-control" type="text" placeholder="State">
                    <input class="form-control" type="text" placeholder="Zip">
                    <input class="form-control" name="x_amount" value="" placeholder="Payment Amount $" type="text">
                    <br>
                    <a href="{{route('donate',[$church->id])}}" class="btn btn-primary">Donate Route</a>
                    
                </form>

            </div>
            <br>
        </div>
        <br>
    @endforeach
@endif
</div>

Here is my Route

Route::get('churchpay/{id}', 'ChurchController@donate')->name('donate');

Here is the Church controller

public function donate($id)
{
    //
    $churches = Church::findOrFail($id);

    return view('churches.churchpay', compact('churches'));
}

Here is the Churchpay view (with detail to post to the Payeezy external site)

Church Donation Page label { display: block; margin: 5px 0px; color: #AAA; } input { display: block; } input[type=submit] { margin-top: 20px; }

{!! Form::model($churches, ['method'=>'GET', 'action'=>['ChurchController@donate', $churches->id], 'files'=>true]) !!}
<div class="card card-body">
    <div class="card-body">
        <h1>Please wait for the secure donation page...</h1>
        <h4 class="card-title">{{$churches->church_name}}</h4>
    </div>
</div>
<br>
<?php
$x_login = "HCO-KW-EN-279"; // Take from Payment Page ID in Payment Pages interface
$transaction_key = "ioSB4gSXyyYiaS23BXc1"; // Take from Payment Pages configuration interface
$x_amount = $_POST["x_amount"];
$x_currency_code = "USD"; // Needs to agree with the currency of the payment page
$x_recurring_billing = "TRUE";
$x_recurring_billing_id = "MB-KW-EN-25-7722";
$x_recurring_billing_amount = "8.89";
$x_recurring_billing_start_date = "2018-08-01";
$x_recurring_billing_end_date = "2035-01-31";
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 ('<input name="x_login" value="' . $x_login . '" type="hidden">' );
echo ('<input name="x_amount" value="' . $x_amount . '" type="hidden">' );
echo ('<input name="x_fp_sequence" value="' . $x_fp_sequence . '" type="hidden">' );
echo ('<input name="x_fp_timestamp" value="' . $x_fp_timestamp . '" type="hidden">' );
echo ('<input name="x_fp_hash" value="' . $x_fp_hash . '" size="50" type="hidden">' );
echo ('<input name="x_currency_code" value="' . $x_currency_code . '" type="hidden">');
echo ('<input name="x_recurring_billing_amount" value="' . $x_recurring_billing_amount . '" type="hidden">' );
echo ('<input name="x_recurring_billing" value="' . $x_recurring_billing . '" type="hidden">');
echo ('<input name="x_recurring_billing_id" value="' . $x_recurring_billing_id . '" type="hidden">');
echo ('<input name="x_recurring_billing_start_date" value="' . $x_recurring_billing_start_date . '" type="hidden">');
echo ('<input name="x_recurring_billing_end_date" value="' . $x_recurring_billing_end_date . '" type="hidden">');

// create parameters input in html
foreach ($_POST as $a => $b) {
    echo "<input type='hidden' name='".htmlentities($a)."' value='".htmlentities($b)."'>";
}

?>

<input type="hidden" name="x_show_form" value="PAYMENT_FORM"/>
document.myForm.submit();
jlrdw's avatar

He means old procedural Style. It looks like it would be hard to tie their code to keeping track of a donation.

If this site is like PayPal you could periodically download a report and the bookkeeper for the church could manually enter who made a donation in The Laravel app. I did similar with the Humane Society made small accounting application for the treasurer and bookkeeper.

Edit:

Why don't you use PayPal?

ThinkingMan's avatar

Yeah, thats what I thought he meant.

I guess I will just ask for an approach with laravel. I will take it from there.

jlrdw's avatar

I guess I will just ask for an approach with laravel

You answered your own question.

Use a pay system that has an api or code integration to work with, like stripe, even paypal. But if they get a savings on the package use it. And just add a couple or 3 fields to get donatees info. But that can backfire also, they could change their mind.

There are ways to deal with your pay system. Don't over think the simple.

ThinkingMan's avatar

@jlrdw thanks for being constructive. Unfortunately I have to use what this church has provided. So will try to keep it simple.

jlrdw's avatar

Good luck and God speed with it.

ThinkingMan's avatar

@jlrdw One last question; what do you think about these approaches? https://medium.com/@axaygadekar/laravel-passing-data-from-view-to-controller-fe0f0df50fbc

This one might be more in line with what I am attempting to accomplish. https://laracasts.com/discuss/channels/laravel/post-to-controller-from-a-form-action

So essentially have the form on the profile view > pass the values to the controller > controller returns the external hosted payment hosted page with the posted values. I think if that is the right approach (looking for a little confirmation) then I will roll up the sleeves some more. Thanks in advance.

Please or to participate in this conversation.