{"id":36272512,"url":"https://github.com/php-monsters/shaparak","last_synced_at":"2026-02-20T14:02:38.791Z","repository":{"id":56949938,"uuid":"236586017","full_name":"php-monsters/shaparak","owner":"php-monsters","description":"Iranian IPG gateways handler for Laravel framework","archived":false,"fork":false,"pushed_at":"2024-12-30T15:55:19.000Z","size":169,"stargazers_count":31,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-11T13:37:35.724Z","etag":null,"topics":["asanpardakht","laravel","mellat","melli","parsian","pasargad","payment","payment-gateway","sadad","saderat","saman","sepehr","zarinpal"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-monsters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-01-27T20:21:28.000Z","updated_at":"2025-12-16T09:13:36.000Z","dependencies_parsed_at":"2023-11-25T13:25:01.225Z","dependency_job_id":"e6bee355-f78a-4288-b825-d02fcb41e566","html_url":"https://github.com/php-monsters/shaparak","commit_stats":{"total_commits":122,"total_committers":3,"mean_commits":"40.666666666666664","dds":"0.19672131147540983","last_synced_commit":"7567b130db1b4cb8f62730af56f1fa5fe423983e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/php-monsters/shaparak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-monsters%2Fshaparak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-monsters%2Fshaparak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-monsters%2Fshaparak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-monsters%2Fshaparak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-monsters","download_url":"https://codeload.github.com/php-monsters/shaparak/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-monsters%2Fshaparak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29653477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T09:27:29.698Z","status":"ssl_error","status_checked_at":"2026-02-20T09:26:12.373Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asanpardakht","laravel","mellat","melli","parsian","pasargad","payment","payment-gateway","sadad","saderat","saman","sepehr","zarinpal"],"created_at":"2026-01-11T08:52:09.559Z","updated_at":"2026-02-20T14:02:38.784Z","avatar_url":"https://github.com/php-monsters.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shaparak :: Laravel Online Payment Component\nOnline Payment Component for Laravel 5+ known as Shaparak component completely compatible with [BankTest](http://banktest.ir) simulator.\nShaparak integrated all Iranian/Shetab payment gateways to one component.\n\n## What is Banktest?\n- [BankTest](http://banktest.ir) is a sandbox service for all Iranian online payment gateways\n- [بانک تست](http://banktest.ir) یک سرویس شبیه ساز درگاه های پرداخت آنلاین ایرانی برای اهداف توسعه و تست نرم افزار می باشد\n\n## Support This Project\n\nPlease support the package by giving it :star: and contributing to its development.\n\n## Currently supported PSPs:\n\n- Mellat Bank Gateway - درگاه بانک ملت (به پرداخت ملت) لاراول\n- Saman Bank Gateway - درگاه بانک سامان (پرداخت الکترونیک سامان) لاراول\n- Saderat Bank Gateway - درگاه بانک صادرات (پرداخت الکترونیک سپهر) لاراول\n- Pasargad Bank Gateway - درگاه بانک پاسارگاد (پرداخت الکترونیک پاسارگاد) لاراول\n- Parsian Bank Gateway - درگاه بانک پارسیان (تجارت الکترونیک پارسیان) لاراول\n- Melli Bank Gateway - درگاه بانک ملی (سداد) لاراول\n- ...\n\n## Requirements\nShaparak require PHP 7.1+\n\n## Installation\n1. Installation via php composer\n\n```bash\ncomposer require php-monsters/shaparak\n```\n2. Add package service provider to your app service providers:\n\n```php\nPhpMonsters\\Shaparak\\ShaparakServiceProvider::class,\n```\n3. Add package alias to your app aliases:\n\n```php\n'Shaparak' =\u003e PhpMonsters\\Shaparak\\Facades\\Shaparak::class,\n```\n4. Publish package assets and configs\n\n```bash\nphp artisan vendor:publish --provider=\"PhpMonsters\\Shaparak\\ShaparakServiceProvider\"\n```\n\n## Configuration\nIf you complete installation step correctly, you can find Shaparak config file as `shaparak.php` in you project config file.\n\nFor using sandbox environment you should set ```SHAPARAK_MODE=development``` in your .env file otherwise set ```SHAPARAK_MODE=production```\n\nif you choose development mode, Shaparak uses [banktest.ir](https://banktest.ir) as its payment gateway.\n\n\n## Usage\n### Add required fields to the model migration\n```php\n$table-\u003estring('token', 40)-\u003enullable(); // It keeps token that we get from the IPG\n$table-\u003ejsonb('gateway_callback_params')-\u003enullable(); // It keeps the IPG callback parameters (just for tracking and debugging)\n\n$table-\u003eboolean('verified')-\u003edefault(false); // Transaction verified or not\n$table-\u003eboolean('after_verified')-\u003edefault(false); // Transaction settled or not\n$table-\u003eboolean('reversed')-\u003edefault(false); // Transaction revered/refunded or not\n$table-\u003eboolean('accomplished')-\u003edefault(false); // Transaction accomplished or not\n```\n### Prepare required model(s)\nYour Transaction, Invoice or Order model MUST implement Shaparak Transaction Interface. \n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse App\\Traits\\JsonbField;\nuse App\\Traits\\ShaparakIntegration;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse PhpMonsters\\Shaparak\\Contracts\\Transaction as ShaparakTransaction;\n\nclass Transaction extends Model implements TransactionTransaction\n{\n```\n\n### Shaparak Integration Trait\nYou can use a trait as below in order integrate your model with Shaparak and implement Shaparak's Transaction contract.\n\n**Sample integration trait (THIS IS JUST AN EXAMPLE)**: \n\n```php\ntrait ShaparakIntegration\n{\n    /**\n     * return callback url for payment process\n     */\n    public function getCallbackUrl(): string\n    {\n        return makeHttpsUrl(route(\n            'ipg.transaction_callback',\n            [\n                'token' =\u003e $this-\u003etoken,\n            ]\n        ));\n    }\n\n    /**\n     * set gateway token that fetched from ipg provider gateway\n     */\n    public function setGatewayToken(string $token, bool $save = true): bool\n    {\n        $this-\u003etoken = $token;\n        $this-\u003estatus = (TransactionStatusEnum::GoneToGate)-\u003evalue;\n\n        if ($save) {\n            return $this-\u003esave();\n        }\n\n        return true;\n    }\n\n    public function getGatewayToken(): string\n    {\n        return $this-\u003etoken;\n    }\n\n    /**\n     * check if you transaction is ready for requesting payment token\n     */\n    public function isReadyForTokenRequest(): bool\n    {\n        return intval($this-\u003estatus) \u003c= (TransactionStatusEnum::Callback)-\u003evalue;\n    }\n\n    /**\n     * check if transaction is ready for requesting verify transaction\n     */\n    public function isReadyForVerify(): bool\n    {\n        return intval($this-\u003estatus) \u003c= (TransactionStatusEnum::Verified)-\u003evalue;\n    }\n\n    /**\n     * check if transaction is ready for requesting inquiry transaction (if supported by gateway)\n     */\n    public function isReadyForInquiry(): bool\n    {\n        return intval($this-\u003estatus) \u003e= (TransactionStatusEnum::GoneToGate)-\u003evalue;\n    }\n\n    /**\n     * check if transaction is ready for requesting settle/... transaction (if needed by gateway)\n     */\n    public function isReadyForSettle(): bool\n    {\n        return intval($this-\u003estatus) == (TransactionStatusEnum::Verified)-\u003evalue;\n    }\n\n    /**\n     * check if transaction is ready to mark as  accomplished\n     */\n    public function isReadyForAccomplish(): bool\n    {\n        return (intval($this-\u003estatus) \u003e= (TransactionStatusEnum::Verified)-\u003evalue) \u0026\u0026\n            (intval($this-\u003estatus) \u003c (TransactionStatusEnum::Accomplished)-\u003evalue);\n    }\n\n    public function ipgProviderSupportsRefund(): bool\n    {\n        return ! empty($this-\u003eprovidable) \u0026\u0026\n            $this-\u003eprovidable-\u003erefund_support === true;\n    }\n\n    public function isReadyForReverse(): bool\n    {\n        return $this-\u003estatus === TransactionStatusEnum::Callback-\u003evalue;\n    }\n\n    public function isReadyForCancel(): bool\n    {\n        return $this-\u003estatus === TransactionStatusEnum::Verified-\u003evalue;\n    }\n\n    /**\n     * check if transaction is ready for accomplishment (merchant verify)\n     */\n    public function isReadyForRefund(): bool\n    {\n        return\n            $this-\u003eipgProviderSupportsRefund() \u0026\u0026\n            (int) $this-\u003estatus !== (TransactionStatusEnum::Accomplished)-\u003evalue;\n    }\n\n    /**\n     * update transaction by paid card number (if provided by gateway)\n     */\n    public function setCardNumber(string $cardNumber, bool $save = true): bool\n    {\n        $this-\u003ecardNumber = $cardNumber;\n\n        if ($save) {\n            return $this-\u003esave();\n        }\n\n        return true;\n    }\n\n    /**\n     * mark transaction as verified\n     */\n    public function setVerified(bool $save = true): bool\n    {\n        $this-\u003estatus = (TransactionStatusEnum::Verified)-\u003evalue;\n\n        if ($save) {\n            return $this-\u003esave();\n        }\n\n        return true;\n    }\n\n    /**\n     * mark transaction as settled/...\n     */\n    public function setSettled(bool $save = true): bool\n    {\n        $this-\u003estatus = (TransactionStatusEnum::Settled)-\u003evalue;\n\n        if ($save) {\n            return $this-\u003esave();\n        }\n\n        return true;\n    }\n\n    /**\n     * mark transaction as reversed\n     */\n    public function setRefunded(bool $save = true): bool\n    {\n        $this-\u003estatus = (TransactionStatusEnum::Refund)-\u003evalue;\n\n        if ($save) {\n            return $this-\u003esave();\n        }\n\n        return true;\n    }\n\n    /**\n     * get transaction amount\n     */\n    public function getPayableAmount(): int\n    {\n        return $this-\u003epayable_amount;\n    }\n\n    /**\n     * save ipg provider's gateway callback parameters into transaction\n     */\n    public function setCallBackParameters(array $parameters, bool $save = true): bool\n    {\n        $this-\u003egateway_callback_params = $parameters;\n\n        if ($save) {\n            return $this-\u003esave();\n        }\n\n        return true;\n    }\n\n    /**\n     * @return false|mixed|string\n     */\n    public function getCallbackParams(): mixed\n    {\n        return $this-\u003egateway_callback_params;\n    }\n}\n```\n\n### Initialize a Shaparak instance\n```php\n// method I: init Shaparak by passing custom gateway options\n$gatewayProperties = [\n    'terminal_id' =\u003e 'X1A3B5CY-X1DT4Z',\n    'terminal_pass' =\u003e '12345',\n];\n$shaparak = Shaparak::with($psp, $transaction, $gatewayProperties)\n    -\u003esetParameters($request-\u003eall());\n    \n// method II: init shaparak by config based gateway options\n// if you don't pass the third item it will use gateway's options from `config/shaparak.php` config file\n$shaparak = Shaparak::with($psp, $transaction)\n    -\u003esetParameters($request-\u003eall());\n```\n\n### Create goto IPG form (Payment form)\nCreate a form in order to go to payment gateway. This form is auto-submit by default\n```php\n// create your transaction as you desired\n$transaction = new Transaction();\n$transaction-\u003euser_id = $user-\u003eid;\n// ...\n$transaction-\u003eip_address = $request-\u003egetClientIp();\n$transaction-\u003edescription = $request-\u003einput('description');\n$transaction-\u003esave();\n\ntry {\n    $form = Shaparak::with('saman', $transaction)-\u003egetForm();\n} catch (\\Exception $e) {\n    XLog::exception($e);\n    flash(trans('gate.could_not_create_goto_bank_form'))-\u003eerror();\n    return redirect()-\u003eback();\n}\n```\nShow the form in your blade like:\n```php\n{!! $form !!}\n```\n\n### Callback URL/route on your application\nIn your callback action create a Shaparak instance and handle the transaction \n```php\n$shaparak = Shaparak::with('saman', $order)\n    -\u003esetParameters($request-\u003eall());\n    \nif ($shaparak-\u003ecanContinueWithCallbackParameters($request-\u003eall()) !== true) {\n    flash(trans('gate.could_not_continue_because_of_callback_params'))-\u003eerror();\n    // do what you need\n}\n\n$shaparak-\u003esetCallBackParameters($request-\u003eall());\n\n$verifyResult = $shaparak-\u003everifyTransaction($request-\u003eall());\n\n```\n\n### Next steps (optional steps)\nUse the following methods based on your needs\n\n```php\n$inquiryResult = $shaparak-\u003einquiryTransaction($request-\u003eall());\n$settleResult = $shaparak-\u003esettleTransaction($request-\u003eall());\n$refundResult = $shaparak-\u003erefundTransaction($request-\u003eall());\n```\n\n## Security\n\nIf you discover any security related issues, please email aboozar.ghf@gmail.com instead of using the issue tracker.\n\n## Team\n\nThis component is developed by the following person(s) and a bunch of [awesome contributors](https://github.com/iamtartan/laravel-online-payment/graphs/contributors).\n\n[![Aboozar Ghaffari](https://avatars2.githubusercontent.com/u/502961?v=3\u0026s=130)](https://github.com/iamtartan) |  [![Maryam Nabiyan](https://avatars.githubusercontent.com/u/47553919?s=120\u0026v=4)](https://github.com/maryamnbyn)\n--- | --- |\n[Aboozar Ghaffari](https://github.com/iamtartan) | [Maryam Nabiyan](https://github.com/maryamnbyn)\n\n\n## License\n\nThe Laravel Online Payment Module is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-monsters%2Fshaparak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-monsters%2Fshaparak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-monsters%2Fshaparak/lists"}