{"id":26407857,"url":"https://github.com/rtler/zarinpal-composer-library","last_synced_at":"2025-04-09T20:12:25.450Z","repository":{"id":34108687,"uuid":"37937280","full_name":"RTLer/zarinpal-composer-library","owner":"RTLer","description":"transaction request library for zarinpal","archived":false,"fork":false,"pushed_at":"2021-11-28T14:17:31.000Z","size":246,"stargazers_count":54,"open_issues_count":15,"forks_count":44,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T20:12:20.444Z","etag":null,"topics":["composer","laravel","php","zarinpal"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RTLer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-23T18:30:26.000Z","updated_at":"2024-08-09T12:45:08.000Z","dependencies_parsed_at":"2022-07-29T20:19:53.017Z","dependency_job_id":null,"html_url":"https://github.com/RTLer/zarinpal-composer-library","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTLer%2Fzarinpal-composer-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTLer%2Fzarinpal-composer-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTLer%2Fzarinpal-composer-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RTLer%2Fzarinpal-composer-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RTLer","download_url":"https://codeload.github.com/RTLer/zarinpal-composer-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["composer","laravel","php","zarinpal"],"created_at":"2025-03-17T18:20:31.849Z","updated_at":"2025-04-09T20:12:25.398Z","avatar_url":"https://github.com/RTLer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zarinpal-composer-library \n[![Build Status](https://travis-ci.org/RTLer/zarinpal-composer-library.svg?branch=master)](https://travis-ci.org/RTLer/zarinpal-composer-library) \n[![StyleCI](https://styleci.io/repos/37937280/shield)](https://styleci.io/repos/37937280)\n[![Coverage Status](https://coveralls.io/repos/github/RTLer/zarinpal-composer-library/badge.svg?branch=master)](https://coveralls.io/github/RTLer/zarinpal-composer-library?branch=master)\n\n\ntransaction request library for zarinpal\n\n## usage\n### installation\n``composer require zarinpal/zarinpal``\n\n### request\n```php\nuse Zarinpal\\Zarinpal;\n\n$zarinpal = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');\n$zarinpal-\u003eenableSandbox(); // active sandbox mod for test env\n// $zarinpal-\u003eisZarinGate(); // active zarinGate mode\n$results = $zarinpal-\u003erequest(\n    \"example.com/testVerify.php\",          //required\n    1000,                                  //required\n    'testing',                             //required\n    'me@example.com',                      //optional\n    '09000000000',                         //optional\n    [                          //optional\n        \"Wages\" =\u003e [\n            \"zp.1.1\"'=\u003e [\n                \"Amount\"'=\u003e 120,\n                \"Description\"'=\u003e \"part 1\"\n            ],\n            \"zp.2.5\"'=\u003e [\n                \"Amount\"'=\u003e 60,\n                \"Description\"'=\u003e \"part 2\"\n            ]\n        ]\n    ]\n);\necho json_encode($results);\nif (isset($results['Authority'])) {\n    file_put_contents('Authority', $results['Authority']);\n    $zarinpal-\u003eredirect();\n}\n//it will redirect to zarinpal to do the transaction or fail and just echo the errors.\n//$results['Authority'] must save somewhere to do the verification\n```\n\n### verify\n```php\nuse Zarinpal\\Zarinpal;\n\n$zarinpal = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');\n$authority = file_get_contents('Authority');\necho json_encode($zarinpal-\u003everify('OK', 1000, $authority));\n//'Status'(index) going to be 'success', 'error' or 'canceled'\n```\n\n## laravel ready\nthis package is going to work with all kinds of projects, but for laravel i add provider to make it as easy as possible.\njust add **(if you are using laravel 5.5 or higher skip this one)**:\n```php\n'providers' =\u003e [\n    ...\n    Zarinpal\\Laravel\\ZarinpalServiceProvider::class\n    ...\n]\n``` \nto providers list in \"config/app.php\". then add this to `config/services.php`\n```php\n'zarinpal' =\u003e [\n    'merchantID' =\u003e 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',\n    'zarinGate' =\u003e false,\n    'sandbox' =\u003e false,\n],\n```\nand you are good to go (legacy config still works)\nnow you can access the zarinpal lib like this:\n```php\nuse Zarinpal\\Laravel\\Facade\\Zarinpal;\n\n$results = Zarinpal::request(\n    \"example.com/testVerify.php\",          //required\n    1000,                                  //required\n    'testing',                             //required\n    'me@example.com',                      //optional\n    '09000000000',                         //optional\n    [                          //optional\n        \"Wages\" =\u003e [\n            \"zp.1.1\" =\u003e [\n                \"Amount\" =\u003e 120,\n                \"Description\" =\u003e \"part 1\"\n            ],\n            \"zp.2.5\" =\u003e [\n                \"Amount\" =\u003e 60,\n                \"Description\" =\u003e \"part 2\"\n            ]\n        ]\n    ]\n);\n// save $results['Authority'] for verifying step\nZarinpal::redirect(); // redirect user to zarinpal\n\n// after that verify transaction by that $results['Authority']\nZarinpal::verify('OK',1000,$results['Authority']);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtler%2Fzarinpal-composer-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtler%2Fzarinpal-composer-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtler%2Fzarinpal-composer-library/lists"}