PHP code example of diadal / laravel-watu-payment-gateway

1. Go to this page and download the library: Download diadal/laravel-watu-payment-gateway library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

diadal / laravel-watu-payment-gateway example snippets



WATU_PUBLIC_KEY_TEST= WTP-T-PK-******************
WATU_SECRET_KEY_TEST= WTP-T-SK-******************
WATU_ENCRYPTION_KEY_TEST= ******************
WATU_IV_KEY_TEST= ******************

WATU_PUBLIC_KEY= WTP-L-PK-******************
WATU_SECRET_KEY= WTP-L-SK-******************
WATU_ENCRYPTION_KEY= ******************
WATU_IV_KEY= ******************
WATU_URL = https://api.watu.global/v1




namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Diadal\Watu\Watu;


class InvoiceController extends Controller
{
    /**
     * __construct
     *
     * @return void
     */
    public function __construct()
    {
        ...
        $this->watu = new Watu();
    }





// this work with any motheds Api called  mainData is default wata data or payload
public function OtherMethods()
    {

        $data = [];
        $data['mainData'] = [
            "service_type" => 'watu-pay',
            "amount" => '10000',
            "currency" => 'NGN',
            "payment_type" => 'card'
        ];
        $data['keyType'] = 'publicKey';
        $data['requestType'] = 'post';
        $data['path'] = '/payment/fees';
        $data = $data;
        return $this->watu->OtherMethods($data);
    }


public function GetBankList()
    {

        $data = 'NG';
        $data = $data;
        return $this->watu->GetBankList($data);
    }

public function Chargex()
    {

        $data = [

            "email" => "[email protected]",
            "payment_type" => "ussd",
            "amount" => 1000,
            "country" => "NG",
            "currency" => "NGN",
            "merchant_reference" => Str::random(),
            "service_type" => "watu-pay",
            "public_key" => config('watu.publicKey'),
            "service_type" => "watu-pay",
            "bank_id" => "057",
        ];

        $data = $data;
        logger($data);
        return $this->watu->Charge($data);
    }


public function InitiateInvoice()
    {

        $data = [

            "email" => "[email protected]",
            "amount" => 1000,
            "country" => "NG",
            "currency" => "NGN",
            "merchant_reference" => Str::random(),
            "service_type" => "watu-pay",
            "payment_methods" => "card"
        ];

        logger($data);


        return $this->watu->PaymentInitiate($data);
    }
    public function WatuFee()
    {

        $data = [
            "service_type" => 'watu-pay',
            "amount" => '10000',
            "currency" => 'NGN',
            "payment_type" => 'card'
        ];


        return $this->watu->GetFee($data);
    }

php artisan vendor:publish --provider="Diadal\Watu\WatuServiceProvider"