{"id":36978942,"url":"https://github.com/rapidphp/gateway-ir","last_synced_at":"2026-01-13T22:48:30.723Z","repository":{"id":270745464,"uuid":"910833355","full_name":"rapidphp/gateway-ir","owner":"rapidphp","description":"Iranian Payment Gateways","archived":false,"fork":false,"pushed_at":"2025-09-26T12:41:49.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-26T13:09:38.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapidphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-01T15:17:11.000Z","updated_at":"2025-09-26T12:41:52.000Z","dependencies_parsed_at":"2025-01-02T20:24:50.422Z","dependency_job_id":"e1bcb63c-acfb-42df-8a66-c3b96d2564ac","html_url":"https://github.com/rapidphp/gateway-ir","commit_stats":null,"previous_names":["rapidphp/gateway-ir"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rapidphp/gateway-ir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidphp%2Fgateway-ir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidphp%2Fgateway-ir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidphp%2Fgateway-ir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidphp%2Fgateway-ir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapidphp","download_url":"https://codeload.github.com/rapidphp/gateway-ir/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidphp%2Fgateway-ir/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2026-01-13T22:48:30.080Z","updated_at":"2026-01-13T22:48:30.718Z","avatar_url":"https://github.com/rapidphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gateway IR\n\nThis package allows you to easily and powerfully use Iranian gateways in Laravel.\n\n## Installation\n\n```shell\ncomposer require rapid/gateway-ir\n```\n\n_Optional to publish assets:_\n\n```shell\nphp artisan vendor:publish --provider=\"Rapid\\GatewayIR\\GatewayIRServiceProvider\"\n```\n\n## Supported Portals\n\n|      Portal      |       Class       | Has Sandbox | Tested |         Description          |\n|:----------------:|:-----------------:|:-----------:|:------:|:----------------------------:|\n| Internal Sandbox | `InternalSandbox` |     ---     |  yes   | Testing portal in local host |\n|    Zarin Pal     |    `ZarinPal`     |     yes     |   no   |     https://zarinpal.com     |\n|     Next Pay     |     `NextPay`     |     no      |   no   |     https://nextpay.org      |\n|      ID Pay      |      `IDPay`      |     yes     |   no   |       https://idpay.ir       |\n\n## Portals\n\n### Fixed Portals\n\nThis section defines the available payment gateway portals that can be used for\nprocessing payments. Each portal should be configured with the necessary\nsettings and credentials.\n\n```php\nuse Rapid\\GatewayIR\\Portals;\n\n'portals' =\u003e [\n\n    'zarinpal' =\u003e [\n        'driver' =\u003e Portals\\ZarinPal::class,\n        'key' =\u003e env('GATEWAY_ZARINPAL_KEY', '9f82b83f-7893-4b2e-93b8-9a096ceb3428'),\n        'sandbox' =\u003e env('GATEWAY_ZARINPAL_SANDBOX', false),\n    ],\n\n    'idpay' =\u003e [\n        'driver' =\u003e Portals\\IDPay::class,\n        'key' =\u003e env('GATEWAY_IDPAY_KEY', ''),\n        'sandbox' =\u003e env('GATEWAY_IDPAY_SANDBOX', false),\n    ],\n\n    'nextpay' =\u003e [\n        'driver' =\u003e Portals\\NextPay::class,\n        'key' =\u003e env('GATEWAY_NEXTPAY_KEY', ''),\n    ],\n\n    'internal_sandbox' =\u003e [\n        'driver' =\u003e Portals\\InternalSandbox::class,\n    ],\n\n],\n```\n\nYou can now define default and secondary values using the portals you have created:\n\n```php\n\n'default' =\u003e env('GATEWAY_DEFAULT', 'zarinpal'),\n\n'secondary' =\u003e env('GATEWAY_SECONDARY', 'idpay'),\n\n```\n\nAnd you can use the `payment` helper to access the portal instance:\n\n```php\n$default = payment();\n$secondary = Payment::secondary();\n$idpay = payment('idpay');\n```\n\n### Dynamic Portals\n\nYou can also define dynamic portals using the `define` method in service providers:\n\n```php\nPayment::define('my_portal', function () {\n    return new ZarinPal('key');\n});\n```\n\n\n## Payment\n\n### New Transaction\n\n```php\nreturn payment()\n    -\u003erequest(2000, 'Description', MyHandler::class, ['meta' =\u003e null])\n    -\u003eredirect();\n```\n\n```php\nclass MyHandler extends PaymentHandler\n{\n    public function setup(HandleSetup $setup): void\n    {\n        $setup\n            -\u003esuccess(function (PaymentVerifyResult $result) {\n                return \"Payment success!\";\n            });\n    }\n}\n```\n\nOr pass an instance of handler:\n\n```php\nreturn payment()\n    -\u003erequest(2000, 'Description', new MyHandler(), ['meta' =\u003e null])\n    -\u003eredirect();\n```\n\n### Payment Handler\n\nHandlers remember their variables and respond to payments.\nTherefore, you can store payment information in these classes that you define\nyourself and then implement payment logic.\n\n```php\nclass BuyProductHandler extends PaymentHandler\n{\n    public function __construct(\n        protected User $user,\n        protected Product $product,\n    ) {}\n\n    public function setup(HandleSetup $setup): void\n    {\n        $setup\n            -\u003evalidate(function (PaymentPrepare $prepare) {\n                return !$this-\u003euser-\u003eboughts()-\u003ewhere('product_id', $this-\u003eproduct-\u003eid)-\u003eexists() \u0026\u0026\n                    $this-\u003eproduct-\u003eprice == $prepare-\u003eamount;\n            })\n            -\u003esuccess(function (PaymentVerifyResult $result) {\n                $this-\u003euser-\u003eboughts()-\u003ecreate(['product_id' =\u003e $this-\u003eproduct-\u003eid]);\n                \n                event(new ProductBought($this-\u003euser, $this-\u003eproduct));\n                \n                return view('payment.success', ['to' =\u003e route('product.show', $this-\u003eproduct)]);\n            })\n            -\u003ecancel(function () {\n                return view('payment.cancel');\n            })\n            -\u003efail(function () {\n                return view('payment.fail');\n            });\n    }\n}\n```\n\nUsage:\n\n```php\npublic function buy(Product $product)\n{\n    return payment()\n        -\u003erequest($product-\u003eprice, 'Buy ' . $product-\u003ename, new BuyProductHandler(auth()-\u003euser(), $product))\n        -\u003eredirect();\n}\n```\n\n## Exception Handling\n\nInitially, you should prevent errors from occurring in your Handler!\nBecause executing an error after payment verification can result in the loss\nof the customer's money.\n\nHowever, if for any reason an error occurs,\nGateway-IR tries to resolve the issue in two ways:\n\n1. If the payment gateway supports refunds, it will execute it.\nIf it fails for any reason, the second method will be executed next.\n2. In the end, the program tries to re-execute the operation with the help of\na queue. Your code will be re-executed in the queue approximately 10 times\nuntil no more errors occur! However, if the error persists,\nthere is nothing more we can do. All errors are logged,\nand in the transactions table, the state of incomplete transactions is set\nto `pend_in_queue`.\n\n\u003e Important: Don't throw errors for reverting the transaction!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidphp%2Fgateway-ir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidphp%2Fgateway-ir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidphp%2Fgateway-ir/lists"}