{"id":16467200,"url":"https://github.com/alkhatibdev/laravel-zain","last_synced_at":"2025-09-12T21:12:04.092Z","repository":{"id":45375225,"uuid":"513556916","full_name":"alkhatibdev/laravel-zain","owner":"alkhatibdev","description":"Zain DSP API integration with Laravel, was made to simplify the process and API calls and let developers focus on other integration parts and logic.","archived":false,"fork":false,"pushed_at":"2022-08-12T07:58:56.000Z","size":171,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T00:12:12.337Z","etag":null,"topics":["laravel","php"],"latest_commit_sha":null,"homepage":"https://github.com/alkhatibdev/laravel-zain","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alkhatibdev.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}},"created_at":"2022-07-13T14:36:49.000Z","updated_at":"2025-02-15T14:24:34.000Z","dependencies_parsed_at":"2022-08-05T08:00:14.531Z","dependency_job_id":null,"html_url":"https://github.com/alkhatibdev/laravel-zain","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flaravel-zain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flaravel-zain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flaravel-zain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flaravel-zain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkhatibdev","download_url":"https://codeload.github.com/alkhatibdev/laravel-zain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244296939,"owners_count":20430336,"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":["laravel","php"],"created_at":"2024-10-11T11:46:33.129Z","updated_at":"2025-03-23T11:32:37.885Z","avatar_url":"https://github.com/alkhatibdev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"/socialcard.png\" alt=\"Social Card of Laravel Zain Package\"\u003e\u003c/p\u003e\n\n# Zain DSP API integration with Laravel\n\n[![Latest Version](https://img.shields.io/github/release/alkhatibdev/laravel-zain.svg?style=flat-square)](https://github.com/alkhatibdev/laravel-zain/releases)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\n# Introduction\nLaravel Zain is Zain DSP API integration with Laravel, made to simplify the process and API calls and let developers focus on other integration parts and logic. See also [Laravel Sudani](https://github.com/alkhatibdev/laravel-sudani).\n\n# Installation\n\n## Requirements\n\n- PHP \u003e= `7.4.x`\n- Laravel \u003e= `7.x`\n\n## install via composer\n\n```shell\ncomposer require alkhatibdev/laravel-zain\n```\n\n## Publish Configs \n```shell\nphp artisan vendor:publish --tag=laravel-zain-config\n```\nA `laravel-zain.php` config file will be published on your `configs` directory, with the following content:\n\n```php\n\u003c?php\n\nreturn [\n\n    'base_url' =\u003e env('ZAIN_SERVER_BASE_API_URL'),\n\n    'product_code' =\u003e env('ZAIN_PRODUCT_CODE'),\n\n    'username' =\u003e env('ZAIN_USERNAME'),\n\n    'password' =\u003e env('ZAIN_PASSWORD'),\n\n    'remember_token' =\u003e env('ZAIN_REMEMBER_TOKEN', false),\n\n    'enable_logging' =\u003e false,\n];\n\n```\nDon't forget to set all these variable on your `.env` file\n\n```env\nZAIN_SERVER_BASE_API_URL=https://test.zaindsp.com:3030/api/v1/json/\nZAIN_PRODUCT_CODE=xxxxxx\nZAIN_USERNAME=xxxxx\nZAIN_PASSWORD=xxxxx\nZAIN_REMEMBER_TOKEN=false\n```\n\n\n# Usage\n\n## Initial Payment/Subscription\n\n```php\nuse AlkhatibDev\\LaravelZain\\Facades\\Zain;\n\n// Initiate payment request\n$response = Zain::initiate($phone)\n\n```\n\nWhen `initiate` payment request successfully sent, a SMS with `OTP` code will be send to the `$phone` number, and `$response` will contain a `subscribe_request_id` and you should save it to the next step `verify`.\n\n## Verify Payment/Subscription\n\n```php\n\n$response = Zain::verify($otp, $requestId)\n\n```\n\n## Check Subscription\n\n```php\n\n$response = Zain::checkSubscription($phone)\n\n```\n\n## Unsubscribe\n\n```php\n\n$response = Zain::unsubscribe($phone)\n\n// cacheToken($response['token'])\n\n```\n\n## Login and Cache DSP token\n\n\nOut of the box the package will login automatically and get the `token` and use it for each action `initiate`, `verify` ..etc per request.\n\nIf you want to cache the token and use it for furthor requests, you can request `token` like this:\n\n```php\n$token = Zain::token()\n```\nAnd you can cache it and use it for each request for the next 24 hours.\nIf you set `ZAIN_REMEMBER_TOKEN=true` token will be expired after 30 days.\n\nExample of using cached token:\n\n```php\n// $token = getCachedToken()\n\n$response = Zain::withToken($token)-\u003einitiate($phone)\n$response = Zain::withToken($token)-\u003everify($phone)\n...\n```\n\n## Logging\nYou can enable logging from package config file \n```\n'enable_logging' =\u003e true,\n```\n\n# Other Packages\n-   ### [Laravel Sudani](https://github.com/alkhatibdev/laravel-sudani) SPay API Integration\n\n# License\n\nLaravel Zain is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkhatibdev%2Flaravel-zain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkhatibdev%2Flaravel-zain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkhatibdev%2Flaravel-zain/lists"}