Looking to hire Laravel developers? Try LaraJobs

laravel-ipg maintained by paystar3

Description
A package for PayStar payment gateway and those for whom time is important
Author
Last update
2025/07/29 19:50 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Latest Version on Packagist GitHub issues GitHub stars GitHub forks Total Downloads GitHub license


:arrow_down: Installation guide

Install package

composer require paystar3/laravel-ipg

Publish configs

php artisan vendor:publish --tag=paystar-ipg

:book: List of available methods

  • create(): return a token
  • payment(): auto redirect to gateway
  • verify(): verify transaction

:heavy_check_mark: How to use exists methods and options

  • Use create() method

    List of extra option
    Option description
    name customer name
    phone customer phone
    mail customer mail
    description description of order
    allotment Share per transaction
    callback_method -
    wallet_hashid -
    national_code national code of customer
    How to use this options
    <?php
        use PayStar\Ipg\Driver\PayStar;
        use PayStar\Ipg\Facades\Encryption;
                $paystar = new PayStar();
                $res = $paystar->create($amount, $payment->id, route('callback', ['additional|_parameters' => 'additional_parameters']),null,
                [
                    'national_code' => 'National ID',
                    'card_number' => 'Card Number',
                    'callback_method' => 1
                ]);
                $result = $res->json();
                if ($result['status'] === 1) {
                    $payment->reference_id = $result['data']['ref_num'];
                    $payment->save();
                    return \redirect("https://api.paystar.shop/api/pardakht/payment?token={$result['data']['token']}");
                }
    
  • Use verify() method

    <?php
        use PayStar\Ipg\Driver\PayStar;
        use PayStar\Ipg\Facades\Encryption;
        $paystar = new PayStar();
        $sign = Encryption::hash(
                    config('paystar-ipg.encryption_algorithm'),
                    $payment->amount . '#'.
                    $request->input('ref_num') . '#'.
                    $request->input('card_number') . '#'.
                    $request->input('tracking_code'),
                    config('paystar-ipg.encryption_key')
        );
        if (request()->input('status') > 0 && !$last_4_digit_of_users_card_number != substr($request->input('card_number'), -4)) {
            throw new \Exception(__('Card doesnt belong to the user!'));
        }
        $res = $paystar->verify($payment->reference_id, $payment->amount, $sign);
        $result = $res->json();
        if ($result['status'] === 1) {
            $amount = $result['data']['price'];
            $trackingCode = $request->input('tracking_code');
        } else {
            throw new \Exception(__('Payment failed!'));
        }
    

#️⃣ How to generate sign

<?php
use PayStar\Ipg\Facades\Encryption;

// The Encryption Facade has 3 methods

Encryption::sign($amount, $orderId, $callbackUrl); // Generate a sign with set algorithm in config file

Encryption::algos(); // Show list of hash Algorithms (hash_algos() method)
Encryption::hash($algo, $string, $key, $binary); // use hash_hmac() method

:man_technologist: Author