Any credit card information is done on the payment Gateway, not your system, you really need to fix that first.
Then the payment Gateway will have API instructions to follow.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am building an integration to a payment gateway and have some pieces working independently and am now at the point where I need to handover some tokenized data to my controller so it can POST to to the payment gateway and get the response. So the flow is:
So I know I am handing over the request to the controller because I have tested with dump(request ()->all());
How do I hand the array to my JSON? Here is the controller with hard coded data that I have tested successfully with the Gateway using guzzle.
public function store()
{
$client = new Client();
$url = "https://fts.cardconnect.com:6443/cardconnect/rest/auth";
$response = $client->put($url,[
'headers' => ['Content-type' => 'application/json'],
'auth' => [
'testing',
'testing123'
],
'json' => ['merchid' => '999990873888',
'account' => '9424209629051443',
'expiry' => '1020',
'cvv2' => '123',
'amount' => '25.97',
'curreny' => 'USD',
'orderid' => '1001',
'name' => 'First Name',
'address' => '123 Test Street',
'region' => 'MD',
'country' => 'US',
'postal' => '21212',
'capture' => 'y',
'invoiceid' => 'TEST-API'],
]);
echo $response->getBody();
}
So it is the JSON array with the card detail that needs to have the form variables passed in. I was starting to try to use $request as New Request and build out the values but I am not calling local data, just the form Request.
(NOTE - This is just the basic, assumed to be successful code. Will add more response and error handling later. Hence the echo at the end.)
Thanks in advance!
I had to re-read your question like 10 times... are you just trying to figure out how to pass the request data to Guzzle???
Bruh...
public function store(Request $request)
{
//dump(request()->all());
//$request_data = $this->mapData();
$client = new Client();
$url = "https://fts.cardconnect.com:6443/cardconnect/rest/auth";
$response = $client->put($url,[
'headers' => ['Content-type' => 'application/json'],
'auth' => [
'testing',
'testing123'
],
'json' => [
'merchid' => $request->merchid,
'account' => $request->account,
'expiry' => $request->expiry,
'cvv2' => $request->cvv2,
'amount' => $request->amount,
'curreny' => $request->curreny,
'orderid' => $request->orderid,
'name' => $request->name,
'address' => $request->address,
'region' => $request->region,
'country' => $request->country,
'postal' => $request->postal,
'capture' => $request->capture,
'invoiceid' => $request->invoiceid
],
]);
echo $response->getBody();
}
Just swap the request-> with what ever your keys are.
Make sure to pass the Request $request into the store function.
...and pull in request at the top of your file...
use Illuminate\Http\Request;
Please or to participate in this conversation.