I am not sure if I understood the question correctly. Do you need Guzzle at all here? Your end-user posts a HTML form, and that form contains generated link for the external service to post response back (eventually). Hmm.
Anyways, here is my example doing a Guzzle post request to external SMS service:
// Do the actual SMS stuff
// First instantiate Guzzle client
$client = new Client([
'timeout' => 5.0,
]);
$smsData = [
'username' => config('app.zoneruser'),
'password' => config('app.zonerpw'),
'numberto' => config('app.zonerdefaultphone'),
'numberfrom' => '1234567',
'message' => 'Hello there'
];
// Call external API
$response = $client->post(config('app.zonerurl'), ['form_params' => $smsData]);
// Check whether API call was successfull or not...
$zonerStatusCode = $response->getStatusCode();
$zonerResponse = (string)$response->getBody();
If a user is not filling anything in the form, do you need it? Instead of using hidden fields (where a user easily can change the values), make a POST request from a controller method using Guzzle and define the return_url to another method on your controller and collect the data using $_GET['subject'] (assuming that your payment provider returns the data in a GET request).
@eriktobben The way I understood this is that when the end-user posts the hidden HTML form he is directed to some page (on paymentservice.com) where he then fills his credit card details. In this case the form is pretty much required.
@jondoe Maybe you just need a Route matching that return URL. Something like:
@jusahah87 i tried your code but in laravel i need to send csrf token. when i send with csrf token it does not match because its two different project.