IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/Http/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Http/Billdesk.php

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Http;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;

/**
 * Description of Billdesk
 *
 * @author HKCL
 */
class Billdesk {

    static function getPaymentString($msg) {
        self::initiatePayment($msg);
        self::initiatePaymentGuzzle($msg);
        return redirect()->back()->with('message', 'Payment Successful');
    }

    static function initiatePayment($msg) {
        $isError = 0;
        
        //Preparing post parameters
        $postData = array(
            'msg' => $msg,
        );

        $url = "https://pgi.billdesk.com/pgidsk/PGIMerchantPayment";
        $ch = curl_init();
        curl_setopt_array($ch, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => false,
            CURLOPT_POSTFIELDS => $postData
        ));


        //Ignore SSL certificate verification
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);


        //get response
        $output = curl_exec($ch);

        //Print error if any
        if (curl_errno($ch)) {
            $isError = true;
            $errorMessage = curl_error($ch);
        }
        curl_close($ch);


        if ($isError) {
            return array('error' => 1, 'message' => $errorMessage);
        } else {
            return array('error' => 0);
        }
    }

    static function initiatePaymentGuzzle($msg) {
        $client = new Client();
        $response = $client->post('https://pgi.billdesk.com/pgidsk/PGIMerchantPayment', [
            'verify' => false,
            'form_params' => [
                'msg' => $msg,
            ],
        ]);
        //$response = json_decode($response->getBody(), true);
        $response = json_decode($response->getBody()->getContents());
        dd($response);
    }

}

Copyright © 2021 - 2025 IMMREX7