PHP code example of danialpanah / webpay
1. Go to this page and download the library: Download danialpanah/webpay 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/ */
danialpanah / webpay example snippets
DanialPanah\Webpay\WebpayServiceProvider::class
'Webpay': DanialPanah\Webpay\Facades\Webpay::class
bash
php artisan vendor:publish --provider "DanialPanah\Webpay\WebpayServiceProvider"
$paymentDetails = [
'amount' => 10000, // - invoice number
];
$webPay = new Webpay();
$response = $webPay->verifyPayment($paymentDetails);
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DanialPanah\WebPay\Facades\Webpay;
class PaymentController extends Controller
{
/**
* @return RedirectResponse|Redirector
* @throws WebpayException
*/
public function pay()
{
$userTrustedCards = ['6219196262191962', '6104046161040461'];
$samplePayment = [
'amount' => 10000,
'reference_number' => '999999',
'payer_mobile' => '09121111111',
'cards' => $userTrustedCards,
];
$paymentUrl = Webpay::sendPayment($samplePayment);
return redirect($paymentUrl);
}
/**
* @param Request $request
* @throws VerifyException
*/
public function verify(Request $request)
{
$paymentDetails = [
'amount' => 10000,
'reference_number' => '999999',
];
$response = Webpay::verifyPayment($paymentDetails);
if(!$reponse['ok'] === true) {
//Transactions was not successful
}
//Do something for successful transactoin
}
}