Home > Enterprise >  How to use basic auth in cURL Laravel using guzzle
How to use basic auth in cURL Laravel using guzzle

Time:03-28

I need to make cURL for razorpay Order Id the postman of api

it uses basic auth enter image description here

i need to make this api work in laravel 8

CodePudding user response:

by using the code below you can build the Needed cURL

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;

class PayController extends Controller

public function order(Request $request)

{

 $key = "YOUR API KEY";
 $secret = "YOUR API SECRET";
 $receipt = "unique recipt no"
 $amount = "1000"
 $currency = "INR"

    $client = new Client();
    $response = Http::withBasicAuth($key,$secret)
    ->post('https://api.razorpay.com/v1/orders',
      [
        'receipt'=> $receipt,
        'amount'=> $amount,
        'currency'=> $currency
      ]
);
  • Related