1. Go to this page and download the library: Download lakshmaji/payubiz 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/ */
namespace Trending\Http\Controllers\File;
use Carbon;
use PayUbiz;
use Illuminate\Http\Request;
use Trending\Http\Controllers\Controller;
/**
* -----------------------------------------------------------------------------
* PayUbizTest - a class illustarting the usage of PayUbiz package
* -----------------------------------------------------------------------------
* This class having the functionality to do payment using
* PayUbiz services
*
* @since 1.0.0
* @version 1.0.0
* @author lakshmaji
*/
class PayUbizTest extends AnotherClass
{
public function doPayment()
{
// get input data
$data = $this->request->all();
// All of these parameters are mandatory!
$params = array(
'txnid' => $data['transaction_id'],
'amount' => $data['amount'],
'productinfo' => $data['product_info']',
'firstname' => $data['user_name'],
'email' => $data['user_email']',
'phone' => $data['mobile_number'],
'surl' => 'http://localhost/payubiz_app_development/public/back',
'furl' => 'http://localhost/payubiz_app_development/public/back',
);
// Call to PayUbiz method
$result = PayUbiz::initializePurchase($params);
// Redirect to PayUbiz Payment Gateway services
return $result;
}
/**
* A method to process the results returned from the PayUbiz services
*
*/
public function processResultFromPayUbiz()
{
$result = PayUbiz::completePurchase($_POST);
$params = $result->getParams();
echo $result->getStatus()."\n";
echo $result->getTransactionId()."\n";
echo $result->getTransactionStatus()."\n";
echo $result->getStatus()."\n";
}
}
// end of class PayUbizTest
// end of file PayUbizTest.php