humayunjavaid/laravel-payzen

A simple package to generate Payzen PSID.

v1.0.0 2023-09-04 07:00 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Streamline Payzen payment integration in Laravel. Generate Payment Service Identifiers (PSIDs) for P2G, P2P, B2G, and B2B payments with ease.

Installation

You can install the package via composer:

composer require humayunjavaid/laravel-payzen

Set Up Environment

Check your .env file, and ensure that your following parameters are set with valid credentials obtained from Payzen.

PAYZEN_CLIENT_ID =
PAYZEN_CLIENT_SECRET_KEY =
PAYZEN_AUTH_URL = (Optional)
PAYZEN_PSID_URL = (Optional)

Optionally you can publish the config file with:

php artisan vendor:publish --tag="laravel-payzen-config"

This is the contents of the published config file:

return [

    'clientId' => env('PAYZEN_CLIENT_ID'),

    'clientSecretKey' => env('PAYZEN_CLIENT_SECRET_KEY'),

    'authUrl' => env('PAYZEN_AUTH_URL'),

    'psidUrl' => env('PAYZEN_PSID_URL'),

];

Usage

Generate PSID method will return Illuminate\Http\Client\Response instance. That mean's, you have access to following methods.

$response->body() : string;
$response->json() : array|mixed;
$response->collect() : Illuminate\Support\Collection;
$response->status() : int;
$response->ok() : bool;
$response->successful() : bool;
$response->failed() : bool;
$response->serverError() : bool;
$response->clientError() : bool;
$response->header($header) : string;
$response->headers() : array;

Generate PSID

Payzen::setConsumerName('Dummy User')
    ->setCnic('123456789')
    ->setEmail('dummyuser@email.com')
    ->setMobileNumber('3324232321')
    ->setChallanNumber('2323232323')
    ->setServiceId('12')
    ->setAccountNumber('32323')
    ->setAccountTitle('Bibi Pak Damin')
    ->setDueDate('2023-08-29')
    ->setExpiryDate('2023-08-29')
    ->setAmountWithinDueDate(500)
    ->setAmountAfterDueDate(500)
    ->generate();

Credits

License

The MIT License (MIT). Please see License File for more information.