skip to Main Content

I have qustion on how to use wise payment in larevel
is there any tutorial or steps to do that because the documentation is not clear about the order of the steps and how to implement it in the most easy way
And Is there way to do the payment using checkout link frome there side not using the apis

Following the documentation

2

Answers


  1. I can share my codes for wise payment. You need guzzlehttp/guzzle to make HTTP requests.

    composer require guzzlehttp/guzzle
    

    Store credentials in your .env file:

    WISE_API_KEY=your_api_key_here
    

    Create a Wise Service:

    namespace AppServices;
    
    use GuzzleHttpClient;
    
    class WiseService
    {
        protected $client;
    
        public function __construct()
        {
            $this->client = new Client([
                'base_uri' => 'https://api.wise.com/', 
                'headers' => [
                    'Authorization' => 'Bearer ' . env('WISE_API_KEY'),
                    'Content-Type' => 'application/json',
                ],
            ]);
        }
    
        public function getCheckoutUrl($amount, $currency)
    {
        $response = $this->client->post('checkout/create', [
            'json' => [
                'amount' => $amount,
                'currency' => $currency,
            ],
        ]);
    
        $data = json_decode($response->getBody(), true);
        
        return $data['checkout_url'];
    }
    }
    

    In your controller, you can then call this service to get the checkout URL and redirect the user:

    use AppServicesWiseService;
    
    public function checkout(WiseService $wiseService)
    {
        $url = $wiseService->getCheckoutUrl(100, 'USD');  
        return redirect($url);
    }
    

    After the user completes the payment on Wise’s platform, Wise might redirect the user back to your application with some data about the payment. You should have routes and logic to handle these callbacks (webhooks).

    Look at Wise documentation and modify codes if needed.

    Login or Signup to reply.
  2. $data = json_decode($response->getBody(), true);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search