Answers for "flutterwave laravel api"

PHP
0

flutterwave laravel api

$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);
Posted by: Guest on August-24-2021

Browse Popular Code Answers by Language