{"id":16085700,"url":"https://github.com/infinitypaul/laravel-cbs","last_synced_at":"2025-03-18T06:30:34.181Z","repository":{"id":56991129,"uuid":"258252808","full_name":"infinitypaul/laravel-cbs","owner":"infinitypaul","description":"A Laravel Package for working with central billing system seamlessly","archived":false,"fork":false,"pushed_at":"2020-05-01T19:41:46.000Z","size":42,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T07:37:08.135Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infinitypaul.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-23T15:43:57.000Z","updated_at":"2021-11-17T21:27:18.000Z","dependencies_parsed_at":"2022-08-21T12:20:37.688Z","dependency_job_id":null,"html_url":"https://github.com/infinitypaul/laravel-cbs","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-cbs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-cbs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-cbs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitypaul%2Flaravel-cbs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infinitypaul","download_url":"https://codeload.github.com/infinitypaul/laravel-cbs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243906028,"owners_count":20366957,"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":[],"created_at":"2024-10-09T13:09:03.215Z","updated_at":"2025-03-18T06:30:33.922Z","avatar_url":"https://github.com/infinitypaul.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Central Billing System\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/infinitypaul/laravel-cbs.svg?style=flat-square)](https://packagist.org/packages/infinitypaul/laravel-cbs)\n[![Build Status](https://img.shields.io/travis/infinitypaul/laravel-cbs/master.svg?style=flat-square)](https://travis-ci.org/infinitypaul/laravel-cbs)\n[![Quality Score](https://img.shields.io/scrutinizer/g/infinitypaul/laravel-cbs.svg?style=flat-square)](https://scrutinizer-ci.com/g/infinitypaul/laravel-cbs)\n[![Total Downloads](https://img.shields.io/packagist/dt/infinitypaul/laravel-cbs.svg?style=flat-square)](https://packagist.org/packages/infinitypaul/laravel-cbs)\n\nA Laravel Package For Working With CBS (Central Billing System) Seamlessly\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require infinitypaul/laravel-cbs\n```\n\n\n\u003e If you use **Laravel \u003e= 5.5** you can skip this step and go to [**`configuration`**](https://github.com/infinitypaul/laravel-cbs#configuration)\n\n* `Infinitypaul\\Cbs\\CbsServiceProvider::class`\n\nAlso, register the Facade like so:\n\n```php\n'aliases' =\u003e [\n    ...\n    'Cbs' =\u003e Infinitypaul\\Cbs\\Facades\\Cbs::class,\n    ...\n]\n```\n\n## Configuration\n\nYou can publish the configuration file using this command:\n\n```bash\nphp artisan vendor:publish --provider=\"Infinitypaul\\Cbs\\CbsServiceProvider\"\n```\n\nA configuration-file named `cbs.php` with some sensible defaults will be placed in your `config` directory:\n\n```php\nreturn [\n    /**\n     * Client ID From CBS \n     *\n     */\n    'clientId' =\u003e getenv('CBS_CLIENT_ID'),\n\n    /**\n     * Secret Key From CBS \n     *\n     */\n    'secret' =\u003e getenv('CBS_SECRET'),\n\n    /**\n     * switch to live or test\n     *\n     */\n    'mode' =\u003e getenv('CBS_MODE', 'test'),\n\n    /**\n     * CBS Test Payment URL\n     *\n     */\n    'testUrl' =\u003e getenv('CBS_TEST_BASE_URL'),\n\n    /**\n     * CBS Live Payment URL\n     *\n     */\n    'liveURL' =\u003e getenv('CBS_LIVE_BASE_URL'),\n\n\n    /**\n     * Revenue Head\n     *\n     */\n    'revenueHead' =\u003e getenv('CBS_REVENUE_HEAD'),\n\n    /**\n     * Revenue Head\n     *\n     */\n    'categoryId' =\u003e getenv('CBS_CATEGORY_ID'),\n];\n```\n\n\n\n## Usage\nOpen your .env file and add your cbs key,  cbs secret key, cbs revenue head, category id, live url , and test url like so:\n\n``` php\nCBS_CLIENT_ID=****\nCBS_SECRET=****\nCBS_REVENUE_HEAD=***\nCBS_CATEGORY_ID=***\nCBS_LIVE_BASE_URL=***\nCBS_TEST_BASE_URL=***\n```\nSet up routes and controller methods like so:\n\n```php\n// Laravel 5.1.17 and above\nRoute::post('/pay', 'InvoiceController@redirectToGateway')-\u003ename('pay'); \n```\n\nOR\n\n```php\nRoute::post('/pay', [\n    'uses' =\u003e 'InvoiceController@redirectToGateway',\n    'as' =\u003e 'pay'\n]);\n\nRoute::post('/pay2', [\n    'uses' =\u003e 'InvoiceController@getInvoice',\n    'as' =\u003e 'data'\n]);\n```\n\n```php\nRoute::get('/payment/callback', 'InvoiceController@handleGatewayCallback')-\u003ename('callback');\n```\n\nOR\n\n```php\n// Laravel 5.0\nRoute::get('payment/callback', [\n    'uses' =\u003e 'InvoiceController@handleGatewayCallback'\n]); \n```\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\n\nuse App\\Http\\Requests;\nuse App\\Http\\Controllers\\Controller;\nuse Cbs;\n\nclass InvoiceController extends Controller\n{\n\n    /**\n     * Redirect the User to Cbs Payment Page\n     * @return Url\n     */\n    public function redirectToGateway()\n    {\n        return Cbs::setInvoice()-\u003eredirectNow();\n    }\n\n    /**\n     * Get The Invoice Information\n     * @return array\n     */\n    public function getInvoice()\n    {\n        return Cbs::setInvoice()-\u003egetData();\n    }\n\n    /**\n     * Obtain Cbs payment information\n     * @return void\n     */\n    public function handleGatewayCallback()\n    {\n        $paymentDetails = Cbs::getPaymentData();\n\n        dd($paymentDetails);\n        // Now you have the payment details,\n        // you can store the authorization_code in your db to allow for recurrent subscriptions\n        // you can then redirect or do whatever you want\n    }\n}\n```\n\nLet me explain the fluent methods this package provides a bit here.\n\n```php\n/**\n *  This fluent method does all the dirty work of sending a POST request with the form data\n *  to Cbs Api, then it gets the payment Url and redirects the user to Cbs\n *  Payment Page. I abstracted all of it, so you don't have to worry about that.\n *  Just eat your cookies while coding!\n */\nCbs::setInvoice()-\u003eredirectNow();\n\n/**\n*  SetInvoice can also accept an array instead of a request object and you are good to go, it will be in this format\n */\n\n        $data = [\n            \"payerID\" =\u003e \"ST-000408\",\n  \"amount\" =\u003e \"230\",\n  \"description\" =\u003e \"Testing\",\n  \"callback\" =\u003e route('callback'),\n  \"quantity\" =\u003e \"5\",\n            'externalRefNumber' =\u003e time()\n];\n        $data = Cbs::setInvoice($data)-\u003egetData();\n\n\n/**\n * This fluent method does all the dirty work of verifying that the just concluded transaction was actually valid,\n */\nCbs::getPaymentData();\n\n/**\n * This method gets the invoice information generated on Cbs\n * @returns array\n */\nCbs::setInvoice()-\u003egetData();\n\n```\n\n\nA sample form will look like so:\n\n```html\n\u003cform method=\"POST\" action=\"{{ route('pay') }}\" accept-charset=\"UTF-8\" class=\"form-horizontal\" role=\"form\"\u003e\n        \u003cdiv class=\"row\" style=\"margin-bottom:40px;\"\u003e\n          \u003cdiv class=\"col-md-8 col-md-offset-2\"\u003e\n            \u003cp\u003e\n                \u003cdiv\u003e\n                    Infinity Biscuit\n                    ₦ 5,980\n                \u003c/div\u003e\n            \u003c/p\u003e\n            \u003cinput type=\"hidden\" name=\"email\" value=\"infinitypaul@live\"\u003e {{-- required --}}\n            \u003cinput type=\"hidden\" name=\"fullname\" value=\"Edward Paul\"\u003e\n\u003cinput type=\"hidden\" name=\"address\" value=\"Lagos\"\u003e\n\u003cinput type=\"hidden\" name=\"mobile_number\" value=\"0702323463\"\u003e\n\u003cinput type=\"hidden\" name=\"tin\" value=\"1234567890\"\u003e\n            \u003cinput type=\"hidden\" name=\"amount\" value=\"1000\"\u003e {{-- required --}}\n            \u003cinput type=\"hidden\" name=\"quantity\" value=\"3\"\u003e\n            \u003cinput type=\"hidden\" name=\"description\" value=\"Test Buy\" \u003e \n            \u003cinput type=\"hidden\" name=\"callback\" value=\"{{ route('callback') }}\"\u003e {{-- required --}}\n\u003cinput type=\"hidden\" name=\"externalRefNumber\" value=\"{{ time() }}\" \u003e {{-- optional --}}\n\n          \n            {{ csrf_field() }} {{-- works only when using laravel 5.1, 5.2 --}}\n\n             \u003cinput type=\"hidden\" name=\"_token\" value=\"{{ csrf_token() }}\"\u003e {{-- employ this in place of csrf_field only in laravel 5.0 --}}\n\n\n            \u003cp\u003e\n              \u003cbutton class=\"btn btn-success btn-lg btn-block\" type=\"submit\" value=\"Pay Now!\"\u003e\n              \u003ci class=\"fa fa-plus-circle fa-lg\"\u003e\u003c/i\u003e Pay Now!\n              \u003c/button\u003e\n            \u003c/p\u003e\n          \u003c/div\u003e\n        \u003c/div\u003e\n\u003c/form\u003e\n```\n\n\nWhen clicking the submit button the customer gets redirected to the Cbs site.\n\nSo now we've redirected the customer to Cbs. The customer did some actions there (hopefully he or she paid the order) and now gets redirected back to our  site.\n\nA Request is sent to our callback url (we don't want imposters to wrongfully place non-paid order).\n\nIn the controller that handles the request coming from the payment provider, we have\n\n`Cbs::getPaymentData()` - This function does the calculation and ensure it is a valid transction else it throws an exception.\n\n\u003eFor A Returnee User Rather Than sending the full Name, email, mobile_number , all you need to send it the PayerId which is gotten the first time you generate an invoice\n\nHave A Look\n\n```html\n\u003cform method=\"POST\" action=\"{{ route('pay') }}\" accept-charset=\"UTF-8\" class=\"form-horizontal\" role=\"form\"\u003e\n        \u003cdiv class=\"row\" style=\"margin-bottom:40px;\"\u003e\n          \u003cdiv class=\"col-md-8 col-md-offset-2\"\u003e\n            \u003cp\u003e\n                \u003cdiv\u003e\n                    Infinity Biscuit\n                    ₦ 5,980\n                \u003c/div\u003e\n            \u003c/p\u003e\n            \u003cinput type=\"hidden\" name=\"PayerId\" value=\"12343\"\u003e {{-- required --}}\n        \n\u003cinput type=\"hidden\" name=\"tin\" value=\"1234567890\"\u003e\n            \u003cinput type=\"hidden\" name=\"amount\" value=\"1000\"\u003e {{-- required --}}\n            \u003cinput type=\"hidden\" name=\"quantity\" value=\"3\"\u003e\n            \u003cinput type=\"hidden\" name=\"description\" value=\"Test Buy\" \u003e \n\u003cinput type=\"hidden\" name=\"externalRefNumber\" value=\"{{ time() }}\" \u003e {{-- optional --}}\n            \u003cinput type=\"hidden\" name=\"callback\" value=\"{{ route('callback') }}\"\u003e {{-- required --}}\n           \n            {{ csrf_field() }} {{-- works only when using laravel 5.1, 5.2 --}}\n\n             \u003cinput type=\"hidden\" name=\"_token\" value=\"{{ csrf_token() }}\"\u003e {{-- employ this in place of csrf_field only in laravel 5.0 --}}\n\n\n            \u003cp\u003e\n              \u003cbutton class=\"btn btn-success btn-lg btn-block\" type=\"submit\" value=\"Pay Now!\"\u003e\n              \u003ci class=\"fa fa-plus-circle fa-lg\"\u003e\u003c/i\u003e Pay Now!\n              \u003c/button\u003e\n            \u003c/p\u003e\n          \u003c/div\u003e\n        \u003c/div\u003e\n\u003c/form\u003e\n```\n\n\n### Bug \u0026 Features\n\nIf you have spotted any bugs, or would like to request additional features from the library, please file an issue via the Issue Tracker on the project's Github page: [https://github.com/infinitypaul/laravel-cbs-filter/issues](https://github.com/infinitypaul/laravel-cbs/issues).\n\n## How can I thank you?\n\nWhy not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!\n\nDon't forget to [follow me on twitter](https://twitter.com/infinitypaul) || [or on medium](https://medium.com/@infinitypaul)\n\nThanks!\nEdward Paul.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitypaul%2Flaravel-cbs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinitypaul%2Flaravel-cbs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitypaul%2Flaravel-cbs/lists"}