alright i got it working only change form_params to json and no public_key required only tx_ref , amount and redirect_url.
Dec 4, 2020
1
Level 1
Implementing Flutter API
Hi, I'm trying to implement this "https://api.flutterwave.com/v3/payments/" api in laravel. what i want is to send some data to this api and get a url in response so I can send that url back to the ajax request on client side. client side opens that url in a new tab and pays whatever amount was set in controller now how can i implement that. This is my code so far.
$amount = some amount;
$referenceno = some ref number;
$currency = "NGN";
$redirect_url = some url;
$authorization = 'Bearer'." ".$this->fsk;
$data = [
'amount' => $amount,
'email' => email,
'metadata' => json_encode($array = [
'contest_id'=>contest_id ,
'contestent_id'=>contestant_id,
'no_of_votes'=>no_of_votes
]),
'reference' => $referenceno,
];
$client = new \GuzzleHttp\Client();
$url = "https://api.flutterwave.com/v3/payments/";
$request = $client->post($url, [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => $authorization,
],
'form_params' => [
'public_key'=>$this->fpk,
"tx_ref"=>$referenceno,
"amount"=>$amount,
"currency"=>$currency,
"redirect_url"=>$redirect_url,
'customer'=>[
'email' => email,
'phone_number'=>some number,
'name'=>'voter',
],
"meta"=>$data,
'customizations' =>[
'title' => title,
'description' => 'Pay to vote',
]
]
]);
$response = $request->send();
dd($response);
this returns me the error
Server error: `POST https://api.flutterwave.com/v3/payments/` resulted in a `500 Internal Server Error` response:↵{"error_id":"ERRNO738287451T1607106126413","message":"Application error. Please contact support","code":"app_error"}↵"
which is not very helpful so if someone can guide me. also i dont want to send payment method so customer can just chose one from payment page.
Level 1
Please or to participate in this conversation.