1. Go to this page and download the library: Download gcorpllc/paypey 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/ */
use Gcorpllc\Paypey\Facades\Paypey;
// Using default gateway or specific driver via via() / driver()
$response = Paypey::via('zarinpal')
->amount(10000) // Amount in global currency (Toman by default)
->callbackUrl(route('payment.callback'))
->description('Order #1024')
->with(['order_id' => 1024, 'user_id' => 42])
->request(); // purchase() is an identical alias
if ($response->isSuccessful()) {
// Redirect user to gateway payment page
return $response->redirect();
}
return back()->with('error', $response->getErrorMessage());
use Gcorpllc\Paypey\Facades\Paypey;
public function test_checkout_flow()
{
// Default success fake for all drivers
Paypey::fake();
$response = Paypey::via('zarinpal')->amount(5000)->request();
$this->assertTrue($response->isSuccessful());
$receipt = Paypey::verify(['Authority' => $response->getAuthority()]);
$this->assertTrue($receipt->isSuccessful());
}
public function test_failed_payment_scenario()
{
Paypey::fake([
'zarinpal' => Paypey::fakeFailed('Card balance insufficient'),
]);
$this->expectException(\Gcorpllc\Paypey\Exceptions\VerificationFailedException::class);
Paypey::via('zarinpal')->verify(['Authority' => 'INVALID_AUTH']);
}
use Gcorpllc\Paypey\Facades\Paypey;
use Gcorpllc\Paypey\Drivers\AbstractDriver;
Paypey::extend('my_custom_gateway', function ($app) {
return new MyCustomDriver();
});