Search by

paystar3 / laravel-ipg

aminprox

A package for PayStar payment gateway and those for whom time is important

Package info

github.com/aminprox/paystar-ipg

pkg:composer/paystar3/laravel-ipg

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-06-12 07:18 UTC

This package is not auto-updated.

Last update: 2026-10-21 22:18:08 UTC


README

PayStar Logo

This is a Laravel package for PayStar payment gateway.

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

⬇️ Installation guide

Install package

composer require paystar3/laravel-ipg

Publish configs

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

📖 List of available methods

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

✔️ 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

👨‍💻 Author