I'm trying to make a post request in laravel to a payment endpoint with the following code
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class AddCardController extends Controller
{
//
public function index()
{
return view("addcard");
}
public function requestPayment(Request $request)
{
$paystack_key = \config("app.paystack_key");
$url = "https://api.paystack.co/transaction/initialize";
$email = $request->user("distributors")->email;
$fields = [
"email"=>$email,
"amount"=>50*100,
"channels"=>["card"],
"callback_url"=>"d"
];
$query = http_build_query($fields);
$response = Http::post($url,$fields)::withHeaders(["Authorization: Bearer $paystack_key",
"Cache-Control: no-cache",])::withOptions(["verify"=>false]);
return $response;
}
}
Im geting the following error:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.paystack.co/transaction/initialize
Im running my Laravel app locally on Apache so I acknowledge the fact that there is no SSL running, but how can I bypass this error. In production ssl will be provided??
You should use withoutVerifying()
with your Post request.
$response = Http::withoutVerifying()
->withHeaders(['Authorization' => 'Bearer ' . $paystack_key, 'Cache-Control' => 'no-cache'])
->withOptions(["verify"=>false])
->post($url,$fields);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With