{"id":22087705,"url":"https://github.com/asciisd/knet","last_synced_at":"2025-08-22T02:06:14.431Z","repository":{"id":62488434,"uuid":"224519442","full_name":"asciisd/knet","owner":"asciisd","description":"Knet package for Laravel","archived":false,"fork":false,"pushed_at":"2025-07-24T16:51:56.000Z","size":483,"stargazers_count":14,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-22T02:03:21.561Z","etag":null,"topics":["knet","kuwait","laravel","php"],"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/asciisd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2019-11-27T21:25:21.000Z","updated_at":"2025-07-24T16:52:01.000Z","dependencies_parsed_at":"2024-02-27T01:36:06.327Z","dependency_job_id":"1a7ca78c-02aa-4f2a-87dd-eb06e8934de8","html_url":"https://github.com/asciisd/knet","commit_stats":{"total_commits":62,"total_committers":2,"mean_commits":31.0,"dds":"0.016129032258064502","last_synced_commit":"71b3f6c2e78c309a2e2e4ed283ad9f5e107fd211"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/asciisd/knet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciisd%2Fknet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciisd%2Fknet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciisd%2Fknet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciisd%2Fknet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asciisd","download_url":"https://codeload.github.com/asciisd/knet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciisd%2Fknet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271574431,"owners_count":24783319,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["knet","kuwait","laravel","php"],"created_at":"2024-12-01T02:06:28.717Z","updated_at":"2025-08-22T02:06:14.379Z","avatar_url":"https://github.com/asciisd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Total Downloads][ico-downloads]][link-downloads]\n\n# Laravel KNET Payment Integration\n\nA robust Laravel package for integrating KNET payment gateway services in your applications. This package provides a clean and elegant way to handle payment processing, refunds, and transaction management with KNET.\n\n## Features\n\n- 🔒 Secure payment processing\n- 💳 Transaction management\n- 🔄 Payment status inquiries\n- ↩️ Refund processing\n- 🎯 Event-driven architecture\n- 📝 Detailed transaction logging\n- 🛡️ Error handling\n- 🔍 Transaction tracking\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require asciisd/knet\n```\n\nAfter installation, publish the configuration file:\n\n```bash\nphp artisan knet:publish\"\n```\n\n## Configuration\n\nConfigure your KNET credentials in your `.env` file:\n\n```env\nKNET_TRANSPORT_ID=your_transport_id\nKNET_TRANSPORT_PASSWORD=your_transport_password\nKNET_RESOURCE_KEY=your_resource_key\n\n# URLs Optional\nKNET_RESPONSE_URL=/knet/response\nKNET_REDIRECT_URL=/dashboard\nKNET_DEBUG=false\n```\n\n## Basic Usage\n\n### Creating a Payment\n\n```php\nuse Asciisd\\Knet\\Services\\KnetPaymentService;\n\nclass PaymentController extends Controller\n{\n    public function createPayment(\n        Request $request, \n        KnetPaymentService $paymentService\n    ) {\n        $transaction = $paymentService-\u003ecreatePayment(\n            user: $request-\u003euser(),\n            amount: 10.000,\n            options: [\n                'udf1' =\u003e 'custom_data_1',\n                'udf2' =\u003e 'custom_data_2',\n            ]\n        );\n\n        return redirect($transaction-\u003eurl);\n    }\n}\n```\n\n### Manual Handling Payment Response\n\n```php\npublic function handleResponse(\n    Request $request, \n    KnetPaymentService $paymentService\n) {\n    $transaction = $paymentService-\u003ehandlePaymentResponse($request-\u003eall());\n\n    if ($transaction-\u003epaid) {\n        return redirect()-\u003eroute('payment.success');\n    }\n\n    return redirect()-\u003eroute('payment.failed');\n}\n```\n\n### Processing Refunds\n\n```php\npublic function refund(\n    KnetTransaction $transaction, \n    KnetPaymentService $paymentService\n) {\n    // Full refund\n    $result = $paymentService-\u003erefundPayment($transaction);\n\n    // Partial refund\n    $result = $paymentService-\u003erefundPayment($transaction, 5.000);\n\n    return $result;\n}\n```\n\n### Checking Transaction Status\n\n```php\npublic function checkStatus(\n    KnetTransaction $transaction, \n    KnetPaymentService $paymentService\n) {\n    $updatedTransaction = $paymentService-\u003einquireAndUpdateTransaction($transaction);\n    return $updatedTransaction;\n}\n```\n\n## Events\n\nThe package dispatches several events that you can listen to:\n\n- `KnetResponseReceived`: Fired when a payment response is received\n- `KnetResponsehandled`: Fired when a payment response is handled\n\n### Event Listeners Example\n\n```php\nuse Asciisd\\Knet\\Events\\KnetResponseReceived;\n\nclass PaymentReceivedListener\n{\n    public function handle(KnetResponseReceived $event)\n    {\n        $transactionArray = $event-\u003epayload;\n        // Handle payload\n    }\n}\n```\n\n## Transaction Model\n\nThe `KnetTransaction` model provides several helpful methods:\n\n```php\n$transaction-\u003erawAmount(); // Get the raw amount\n$transaction-\u003eisPaid(); // Check if transaction is paid\n$transaction-\u003eisRefunded(); // Check if transaction is refunded\n$transaction-\u003eisRefundable(); // Check if transaction can be refunded\n```\n\n## Error Handling\n\nThe package includes comprehensive error handling:\n\n```php\ntry {\n    $result = $paymentService-\u003erefundPayment($transaction);\n} catch (\\Exception $e) {\n    Log::error('Refund failed', [\n        'message' =\u003e $e-\u003egetMessage(),\n        'transaction_id' =\u003e $transaction-\u003eid\n    ]);\n}\n```\n\n## Database Schema\n\nThe package includes migrations for the `knet_transactions` table with the following fields:\n\n- `id`: Primary key\n- `user_id`: Foreign key to users table\n- `trackid`: KNET tracking ID\n- `amt`: Transaction amount\n- `paymentid`: KNET payment ID\n- `tranid`: KNET transaction ID\n- `ref`: Reference number\n- `result`: Transaction result\n- `auth`: Authorization code\n- `avr`: AVR value\n- `postdate`: Posting date\n- `paid`: Payment status\n- `error_text`: Error message if any\n- `url`: Payment URL\n- `livemode`: Production/Test mode flag\n- Various UDF fields (udf1 to udf5)\n- Refund-related fields\n- Timestamps\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Security\n\nIf you discover any security-related issues, please email security@asciisd.com instead of using the issue tracker.\n\n## Credits\n\n- [Amr Emad](https://github.com/aemaddin)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/asciisd/knet.svg?style=flat\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat\n[ico-downloads]: https://img.shields.io/packagist/dt/asciisd/knet.svg?style=flat\n\n[link-packagist]: https://packagist.org/packages/asciisd/knet\n[link-downloads]: https://packagist.org/packages/asciisd/knet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasciisd%2Fknet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasciisd%2Fknet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasciisd%2Fknet/lists"}