{"id":21565846,"url":"https://github.com/prevailexcel/laravel-flick","last_synced_at":"2026-01-08T01:02:56.323Z","repository":{"id":250680368,"uuid":"835183021","full_name":"PrevailExcel/laravel-flick","owner":"PrevailExcel","description":"A Laravel SDK for Flick","archived":false,"fork":false,"pushed_at":"2024-07-29T10:48:10.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T06:17:39.060Z","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/PrevailExcel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-07-29T10:25:07.000Z","updated_at":"2024-07-29T14:42:16.000Z","dependencies_parsed_at":"2024-07-29T12:37:03.616Z","dependency_job_id":null,"html_url":"https://github.com/PrevailExcel/laravel-flick","commit_stats":null,"previous_names":["prevailexcel/laravel-flick"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrevailExcel%2Flaravel-flick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrevailExcel%2Flaravel-flick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrevailExcel%2Flaravel-flick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrevailExcel%2Flaravel-flick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PrevailExcel","download_url":"https://codeload.github.com/PrevailExcel/laravel-flick/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246091715,"owners_count":20722267,"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-11-24T10:22:04.653Z","updated_at":"2026-01-08T01:02:56.298Z","avatar_url":"https://github.com/PrevailExcel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laravel-flick\n\n[![Latest Stable Version](https://poser.pugx.org/prevailexcel/laravel-flick/v/stable.svg)](https://packagist.org/packages/prevailexcel/laravel-flick)\n[![License](https://poser.pugx.org/prevailexcel/laravel-flick/license.svg)](LICENSE.md)\n[![PHP Code Style](https://img.shields.io/badge/code_style-PSR--12-brightgreen)](https://www.php-fig.org/psr/psr-12/)\n\u003e A Laravel Package for working with Flick Payments seamlessly.\n\nSingle connection to access financial data, identity, global accounts and multi-currency payments. Collect payments from individuals or businesses locally and globally, and settle them in multiple currencies, ensuring a cost-effective and hassle-free payment process.\n\nThis package also allows you to receive all types of webhooks from [Flick](https://getflick.co) which it verifies and handles the payloads for you. You can start collecting payment in payments in minutes.\n\n    Bank Transfers\n    Cards\n    Virtual Bank Accounts\n    Payouts\n\n## Installation\n\n\nTo get the latest version of Laravel Flick, simply require it\n\n```bash\ncomposer require prevailexcel/laravel-flick\n```\n\nOr add the following line to the require block of your `composer.json` file.\n\n```\n\"prevailexcel/laravel-flick\": \"1.0.*\"\n```\n\nYou'll then need to run `composer install` or `composer update` to download it and have the autoloader updated.\n\nOnce Laravel Flick is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key. \n\u003e If you use **Laravel \u003e= 5.5** you can skip this step and go to [**`configuration`**](https://github.com/PrevailExcel/laravel-flick#configuration)\n\n```php\n'providers' =\u003e [\n    ...\n    PrevailExcel\\Flick\\FlickServiceProvider::class,\n    ...\n]\n```\n\nAlso, register the Facade like so:\n\n```php\n'aliases' =\u003e [\n    ...\n    'Flick' =\u003e PrevailExcel\\Flick\\Facades\\Flick::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=\"PrevailExcel\\Flick\\FlickServiceProvider\"\n```\n\nA configuration-file named `flick.php` with some sensible defaults will be placed in your `config` directory:\n\n```php\n\u003c?php\n\nreturn [\n    \n    /**\n     * Public Key From FLICK Dashboard\n     *\n     */\n    'secretKey' =\u003e getenv('FLICK_SECRET_KEY'),\n\n    /**\n     * You enviroment can either be live or stage.\n     * Make sure to add the appropriate API key after changing the enviroment in .env\n     *\n     */\n    'env' =\u003e env('FLICK_ENV', 'live'), // OR \"sandbox\"\n\n    /**\n     * FLICK Base URL\n     *\n     */\n    'baseUrl' =\u003e env('FLICK_LIVE_URL', \"https://flickopenapi.co\"),\n\n];\n```\n\n## General payment flow\n\nThough there are multiple ways to pay an order, most payment gateways expect you to follow the following flow in your checkout process:\n\n### 1. The customer is redirected to the payment provider\nAfter the customer has gone through the checkout process and is ready to pay, the customer must be redirected to the site of the payment provider.\n\nThe redirection is accomplished by submitting a form with some hidden fields. The form must send a POST request to the site of the payment provider. The hidden fields minimally specify the amount that must be paid, the order id and a hash.\n\nThe hash is calculated using the hidden form fields and a non-public secret. The hash used by the payment provider to verify if the request is valid.\n\n\n### 2. The customer pays on the site of the payment provider\nThe customer arrives on the site of the payment provider and gets to choose a payment method. All steps necessary to pay the order are taken care of by the payment provider.\n\n### 3. The customer gets redirected back to your site\nAfter having paid the order the customer is redirected back. In the redirection request to the shop-site some values are returned. The values are usually the order id, a payment result and a hash.\n\nThe hash is calculated out of some of the fields returned and a secret non-public value. This hash is used to verify if the request is valid and comes from the payment provider. It is paramount that this hash is thoroughly checked.\n\n## Usage\n\nOpen your .env file and add all the necessary keys like so:\n\n```bash\nFLICK_SECRET_KEY=sk_****_****************************************\nFLICK_ENV=live\n```\n*If you are using a hosting service like heroku, ensure to add the above details to your configuration variables.*\n*Remember to change FLICK_ENV to 'live' and update the keys when you are in production*\n\n#### Next, you have to setup your routes. \nThere are 3 routes you should have to get started.\n1. To initiate payment\n2. To setup callback - Route::flick_callback.\n3. To setup webhook and handle the event responses - Route::flick_webhook.\n\n```php\n// Laravel 8 \u0026 above\nRoute::post('/pay', [PaymentController::class, 'createPayment'])-\u003ename('pay');\nRoute::flick_callback(PaymentController::class, 'handleGatewayCallback');\nRoute::flick_webhook(WebhookController::class, 'handleWebhook');\n```\n\n\n#### Let's set our controller\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 Illuminate\\Support\\Facades\\Redirect;\nuse PrevailExcel\\Flick\\Facades\\Flick;\n\nclass PaymentController extends Controller\n{\n\n    /**\n     * Redirect the User to Flick Payment Page\n     * @return Url\n     */\n    public function redirectToGateway()\n    {\n        try{\n            return Flick::getLink()-\u003eredirectNow();\n        }catch(\\Exception $e) {\n            return Redirect::back()-\u003ewithMessage(['msg'=\u003e $e-\u003egetMessage(), 'type'=\u003e'error']);\n        }        \n    }\n\n    /**\n     * Obtain Flick payment information\n     * @return void\n     */\n    public function handleGatewayCallback()\n    {\n        $paymentDetails = flick()-\u003egetPaymentData();\n\n        dd($paymentDetails);\n        // Now you have the payment details,\n        // you can store the reference ID in your db.\n        // you can then redirect or do whatever you want\n    }\n}\n```\n\n```php\n/**\n *  In the case where you need to pass the data from your\n *  controller or via your client or app instead of a form\n *  \n */\n $data = [       \n        'email' =\u003e \"example@gmail.com\",\n        'Phoneno' =\u003e \"08100000000\",\n        'amount' =\u003e \"9000\", // in naira\n    ];\n\n    // if monolithic, do\n    return Flick::getLink($data)-\u003eredirectNow();\n\n    // if API, do\n    return Flick::getLink($data, true);\n\n```\n\u003e You can also seet other details for yourself if the defaults does not work for you.\n```php\n $data = [       \n        'email' =\u003e \"example@gmail.com\",\n        'Phoneno' =\u003e \"08100000000\",\n        'amount' =\u003e \"9000\", // in naira\n\n        'transactionId' =\u003e \"Generate your own ID\",\n        'currency_collected' =\u003e \"NGN\", // USD, GBP, CAD\n        'currency_settled' =\u003e 'NGN', // USD, GBP, CAD\n    ];\n```\n\n### Lets pay with card now.\nIf you have saved user card in it's encrypted string, you can use it to initate a payment. \n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse PrevailExcel\\Flick\\Facades\\Flick;\n\nclass PaymentController extends Controller\n{  \n    /**\n     * You collect data from your blade form\n     * and this returns the Account details for payment\n     */\n    public function createPayment()\n    {\n        try {\n            // You can use the global helper flick()-\u003emethod() or the Facade Flick::method().\n           \n           \n            $card = \"eZl0T7elDC3VWefiqYT4RujW7t...\";\n\n            return Flick::chargeCard($card);\n            \n        } catch (\\Exception $e) {\n            return redirect()-\u003eback()-\u003ewithMessage(['msg' =\u003e $e-\u003egetMessage(), 'type' =\u003e 'error']);\n        }\n    }\n}\n```\nUser will pass a PIN or OTP to complete the payment.\n\n### Handling Webhook\nYou can listen to the webhook and service the user. Write the heavy operations inside the `handleWebhook()` method.\nThis package will verify the webhook using the secret hash.\n\n#### In your controller\n\n```php\n    public function handleWebhook()\n    {\n        // verify webhook and get data\n        flick()-\u003egetWebhookData()-\u003eproccessData(function ($data) {\n            // Do something with $data\n            logger($data);\n            $decodedData = json_decode($data, true);\n            // Do Something with $decodedData\n            \n            // If you have heavy operations, dispatch your queued jobs for them here\n            // OrderJob::dispatch($decodedData);\n        });\n        \n        // Acknowledge you received the response\n        return http_response_code(200);\n    }\n```\n\n\u003e This package recommends to use a queued job to proccess the webhook data especially if you handle heavy operations like sending mail and more \n\n##### How does the webhook routing `Route::flick_webhook(Controller::class, 'methodName')` work?\n\nBehind the scenes, by default this will register a POST route `'flick/webhook'` to the controller and method you provide. Because the app that sends webhooks to you has no way of getting a csrf-token, you must add that route to the except array of the VerifyCsrfToken middleware:\n```php\nprotected $except = [\n    'flick/webhook',\n];\n```\nIn Laravel 11, You can do this inside the bootstrap/app.php file.\n```php\n-\u003ewithMiddleware(function (Middleware $middleware) {\n    $middleware-\u003evalidateCsrfTokens(except: [\n        'flick/webhook', \n    ]);\n})\n```\n\nAdd the  `'flick/webhook'` endpoint URL to the three webhook fields on your Flick Dashboard;\n\n    Webhook URL : 127.0.0.1:8000/flick/webhook\n\n![Add Webhook to dashboard](image.png)\n\n\n\n \n#### A sample form will look like so:\n```blade\n\u003cform method=\"POST\" action=\"{{ route('pay') }}\"\u003e\n    @csrf\n    \u003cdiv class=\"form-group\" style=\"margin-bottom: 10px;\"\u003e\n        \u003clabel for=\"phone-number\"\u003ePhone Number\u003c/label\u003e\n        \u003cinput class=\"form-control\" type=\"tel\" name=\"Phoneno\" required /\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"form-group\" style=\"margin-bottom: 10px;\"\u003e\n        \u003clabel for=\"email\"\u003eEmail\u003c/label\u003e\n        \u003cinput class=\"form-control\" type=\"email\" name=\"email\" required /\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"form-group\" style=\"margin-bottom: 10px;\"\u003e\n        \u003clabel for=\"amount\"\u003eAmount\u003c/label\u003e\n        \u003cinput class=\"form-control\" type=\"number\" name=\"amount\" required /\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"form-submit\"\u003e\n        \u003cbutton class=\"btn btn-primary btn-block\" type=\"submit\"\u003e Pay \u003c/button\u003e\n    \u003c/div\u003e\n\u003c/form\u003e\n```\nWhen clicking the submit button the customer gets redirected to the Payment page.\n\nSo now the customer did some actions there (hopefully he or she paid the order) and now the package will redirect the customer to the Callback URL `Route::flick_callback()`.\n\nWe must validate if the redirect to our site is a valid request (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`Flick::getPaymentData()` - This function calls the `verifyTransaction()` methods and ensure it is a valid transaction else it throws an exception.\n\n\n### Some Other fluent methods this package provides are listed here.\n\n#### Collection\n\n```php\n\n/**\n * OTP verification\n *\n * @param string $otp\n * @param string $ref transaction ref or id.\n * @return array\n */\nFlick::verifyOtp($otp, $ref);\n// Or\nflick()-\u003everifyOtp($otp, $ref);\n\n/**\n * PIN verification\n *\n * @param string $pin\n * @param string $ref transaction ref or id.\n * @return array\n */\nFlick::verifyPin($pin, $ref);\n// Or\nflick()-\u003everifyPin($pin, $ref);\n\n/**\n * Get Info About Card\n */\nFlick::lookupCard($card_first_six_digits);\n```\n\n#### Account\n\n```php\n\n/**\n * Check your balance for the different currencies and categories available. Default is payouts.\n * \n * @param null|string $category  Can be payouts, walletapi, or collections\n * @param null|string $currency  NGN, USD, GBP, or CAD. Default is NGN\n * @returns array\n */\nFlick::checkBalance();\n\n/**\n * Get Flick exchange rate. Either of the parameters must be NGN\n *\n * @param null|string $from  NGN, USD, GBP, or CAD. Default is NGN\n * @param null|string $to  NGN, USD, GBP, or CAD. Default is NGN\n *\n * @return array\n */\nFlick::exchangeRate(?string $from = null, ?string $to = null);\n\n/**\n * Generate transfer history statements with custom date ranges\n * @returns array\n */\nFlick::transferHistory($data);\n```\n\n#### Payout\n\n```php\n/**\n * Move funds from your Flick balance to a bank account.\n * @returns array\n */\nFlick::transfer($data = null);\n```\n\n#### Tools\n\n```php\n/**\n * Get all the bank codes for all existing banks in our operating countries.\n * @returns array\n */\nFlick::banks();\n\n/**\n * Verify the status of a transaction carried out on your Flick account\n * @returns array\n */\nFlick::verifyTransaction(?string $ref = null);\n// Or\nrequest()-\u003eref = \"transactionId\";\nflick()-\u003everifyTransaction();\n\n/**\n * Resend webhook for a transaction.\n * @returns array\n */\nFlick::resendWebhook(?string $ref = null);\n// Or\nrequest()-\u003eref = \"transactionId\";\nflick()-\u003eresendWebhook();\n\n/**\n * Verify the status of a transfer carried out from your Flick account \n * @returns array\n */\nFlick::verifyTransfer(?string $ref = null);\n\n/**\n * Verify the owner of a bank account using the bank code and the account uumber \n * @returns array\n */\nFlick::confirmAccount(?string $bank_code = null, ?string $account_number = null);\n\n```\n\n## Todo\n\n* Add webhook Functionality\n* Add Comprehensive Tests\n\n## Contributing\n\nPlease feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.\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\nThanks!\n[Chimeremeze Prevail Ejimadu](https://x.com/EjimaduPrevail)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprevailexcel%2Flaravel-flick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprevailexcel%2Flaravel-flick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprevailexcel%2Flaravel-flick/lists"}