From 2566794e90e427c8a8f440bafd9774a3a0f2b19f Mon Sep 17 00:00:00 2001 From: Ahmed Elbanby Date: Fri, 4 Dec 2026 23:06:01 +0200 Subject: [PATCH] Rename Tahseel to Paykit (0.5.0) --- .github/ISSUE_TEMPLATE/bug_report.md | 4 +- CHANGELOG.md | 22 +- CONTRIBUTING.md | 6 +- README.md | 346 +++++++++--------- SECURITY.md | 4 +- composer.json | 14 +- config/{tahseel.php => paykit.php} | 66 ++-- ...0_create_paykit_manual_payments_table.php} | 11 +- ...ence_unique_on_paykit_manual_payments.php} | 11 +- ...000_create_paykit_manual_events_table.php} | 11 +- docs/ar/README.md | 266 +++++++------- docs/ar/quickstart.md | 38 +- docs/ar/sandboxes.md | 10 +- docs/ar/security-audit.md | 14 +- docs/ar/state-transitions.md | 6 +- docs/ar/troubleshooting.md | 10 +- docs/quickstart.md | 38 +- docs/sandboxes.md | 10 +- docs/security-audit.md | 16 +- docs/state-transitions.md | 6 +- docs/troubleshooting.md | 10 +- mock/gateway.php | 16 +- phpunit.xml.dist | 2 +- resources/views/manual/index.blade.php | 16 +- src/Console/CheckCommand.php | 38 +- src/Console/DriverRequirements.php | 6 +- src/Console/ManualExpireCommand.php | 8 +- src/Console/ManualPruneProofsCommand.php | 12 +- src/Console/SmokeCommand.php | 42 +-- src/Contracts/Gateway.php | 16 +- src/Contracts/IdempotencyStore.php | 4 +- src/Contracts/SupportsCapture.php | 10 +- src/Contracts/SupportsRefunds.php | 10 +- src/Contracts/SupportsVoids.php | 10 +- src/Data/CaptureRequest.php | 4 +- src/Data/Customer.php | 4 +- src/Data/LineItem.php | 4 +- src/Data/Money.php | 4 +- src/Data/OperationResult.php | 4 +- src/Data/PaymentRequest.php | 4 +- src/Data/PaymentSession.php | 2 +- src/Data/RefundRequest.php | 4 +- src/Data/VoidRequest.php | 4 +- src/Data/WebhookEvent.php | 4 +- src/Enums/ManualPaymentStatus.php | 4 +- src/Enums/PaymentStatus.php | 2 +- src/Events/ManualPaymentAwaitingReview.php | 6 +- src/Events/PaymentFailed.php | 4 +- src/Events/PaymentPending.php | 4 +- src/Events/PaymentRefunded.php | 4 +- src/Events/PaymentSucceeded.php | 4 +- src/Events/PaymentVoided.php | 4 +- src/Events/WebhookReceived.php | 4 +- src/Exceptions/ConcurrentPaymentException.php | 4 +- src/Exceptions/ConfigurationException.php | 4 +- .../DuplicateTransferReferenceException.php | 4 +- src/Exceptions/GatewayException.php | 6 +- .../InvalidPaymentRequestException.php | 4 +- src/Exceptions/InvalidSignatureException.php | 4 +- src/Exceptions/InvalidWebhookException.php | 6 +- .../ManualPaymentClosedException.php | 6 +- .../ManualPaymentNotFoundException.php | 4 +- src/Exceptions/PaykitException.php | 12 + src/Exceptions/TahseelException.php | 12 - .../UnsupportedOperationException.php | 4 +- src/Facades/{Tahseel.php => Paykit.php} | 38 +- src/Gateways/Adyen/AdyenClient.php | 6 +- src/Gateways/Adyen/AdyenGateway.php | 42 +-- .../CheckoutCom/CheckoutComClient.php | 6 +- .../CheckoutCom/CheckoutComGateway.php | 40 +- src/Gateways/Fawry/FawryClient.php | 6 +- src/Gateways/Fawry/FawryGateway.php | 48 +-- src/Gateways/Fawry/FawrySignature.php | 4 +- .../Flutterwave/FlutterwaveClient.php | 6 +- .../Flutterwave/FlutterwaveGateway.php | 42 +-- src/Gateways/Geidea/GeideaClient.php | 6 +- src/Gateways/Geidea/GeideaGateway.php | 44 +-- src/Gateways/Geidea/GeideaSignature.php | 4 +- src/Gateways/HyperPay/HyperPayClient.php | 6 +- src/Gateways/HyperPay/HyperPayCrypto.php | 2 +- src/Gateways/HyperPay/HyperPayGateway.php | 40 +- src/Gateways/HyperPay/HyperPayResultCodes.php | 4 +- src/Gateways/Kashier/KashierClient.php | 6 +- src/Gateways/Kashier/KashierGateway.php | 44 +-- src/Gateways/Kashier/KashierSignature.php | 4 +- src/Gateways/Klarna/KlarnaClient.php | 6 +- src/Gateways/Klarna/KlarnaGateway.php | 42 +-- src/Gateways/Manual/ManualGateway.php | 12 +- src/Gateways/Manual/ManualPayments.php | 46 +-- .../MercadoPago/MercadoPagoClient.php | 6 +- .../MercadoPago/MercadoPagoGateway.php | 44 +-- src/Gateways/Mollie/MollieClient.php | 6 +- src/Gateways/Mollie/MollieGateway.php | 36 +- src/Gateways/Moyasar/MoyasarClient.php | 6 +- src/Gateways/Moyasar/MoyasarGateway.php | 40 +- src/Gateways/MyFatoorah/MyFatoorahClient.php | 6 +- src/Gateways/MyFatoorah/MyFatoorahGateway.php | 38 +- .../MyFatoorah/MyFatoorahSignature.php | 2 +- src/Gateways/PayPal/PayPalClient.php | 6 +- src/Gateways/PayPal/PayPalGateway.php | 44 +-- src/Gateways/PayTabs/PayTabsClient.php | 6 +- src/Gateways/PayTabs/PayTabsGateway.php | 42 +-- src/Gateways/PayU/PayUClient.php | 6 +- src/Gateways/PayU/PayUGateway.php | 40 +- src/Gateways/Paymob/PaymobClient.php | 6 +- src/Gateways/Paymob/PaymobGateway.php | 52 +-- src/Gateways/Paymob/PaymobSignature.php | 4 +- src/Gateways/Paystack/PaystackClient.php | 6 +- src/Gateways/Paystack/PaystackGateway.php | 42 +-- src/Gateways/Razorpay/RazorpayClient.php | 6 +- src/Gateways/Razorpay/RazorpayGateway.php | 46 +-- src/Gateways/Square/SquareClient.php | 6 +- src/Gateways/Square/SquareGateway.php | 38 +- src/Gateways/Stripe/StripeClient.php | 6 +- src/Gateways/Stripe/StripeGateway.php | 40 +- src/Gateways/Tabby/TabbyClient.php | 6 +- src/Gateways/Tabby/TabbyGateway.php | 44 +-- src/Gateways/Tamara/TamaraClient.php | 6 +- src/Gateways/Tamara/TamaraGateway.php | 46 +-- src/Gateways/Tap/TapClient.php | 6 +- src/Gateways/Tap/TapGateway.php | 40 +- src/Gateways/Tap/TapSignature.php | 2 +- src/Gateways/Telr/TelrClient.php | 6 +- src/Gateways/Telr/TelrGateway.php | 36 +- src/Gateways/Viva/VivaClient.php | 6 +- src/Gateways/Viva/VivaGateway.php | 32 +- src/Gateways/Xendit/XenditClient.php | 6 +- src/Gateways/Xendit/XenditGateway.php | 40 +- .../Manual/ManualPanelController.php | 42 +-- .../Manual/ManualProofController.php | 12 +- .../Manual/ManualStatusController.php | 6 +- src/Http/Controllers/WebhookController.php | 34 +- src/Http/Middleware/AuthorizeManualPanel.php | 4 +- src/Idempotency/CacheIdempotencyStore.php | 8 +- src/Idempotency/IdempotentCreation.php | 8 +- src/Idempotency/NullIdempotencyStore.php | 6 +- src/Models/ManualPayment.php | 6 +- src/{TahseelManager.php => PaykitManager.php} | 90 ++--- ...Provider.php => PaykitServiceProvider.php} | 88 ++--- src/Support/HandlesTransportFailures.php | 6 +- src/Support/InstaPayLink.php | 2 +- src/Testing/FakeGateway.php | 36 +- ...hseelManager.php => FakePaykitManager.php} | 18 +- src/Webhooks/WebhookGuard.php | 10 +- tests/Feature/AdyenGatewayTest.php | 66 ++-- tests/Feature/CaptureTest.php | 34 +- tests/Feature/CheckCommandTest.php | 28 +- tests/Feature/CheckoutComGatewayTest.php | 62 ++-- tests/Feature/FawryGatewayTest.php | 52 +-- tests/Feature/FlutterwaveGatewayTest.php | 86 ++--- tests/Feature/GeideaGatewayTest.php | 58 +-- tests/Feature/HyperPayGatewayTest.php | 60 +-- tests/Feature/JourneyTest.php | 62 ++-- tests/Feature/KashierGatewayTest.php | 50 +-- tests/Feature/KlarnaGatewayTest.php | 60 +-- tests/Feature/LegacyTableRenameTest.php | 33 ++ tests/Feature/ManagerTest.php | 30 +- tests/Feature/ManualGatewayTest.php | 32 +- tests/Feature/ManualPanelTest.php | 98 ++--- tests/Feature/ManualRulesTest.php | 64 ++-- tests/Feature/ManualToolsTest.php | 52 +-- tests/Feature/MercadoPagoGatewayTest.php | 66 ++-- tests/Feature/MollieGatewayTest.php | 58 +-- tests/Feature/MoyasarGatewayTest.php | 74 ++-- tests/Feature/MyFatoorahGatewayTest.php | 68 ++-- tests/Feature/PayPalGatewayTest.php | 80 ++-- tests/Feature/PayTabsGatewayTest.php | 78 ++-- tests/Feature/PayUGatewayTest.php | 60 +-- tests/Feature/PaymobGatewayTest.php | 52 +-- tests/Feature/PaystackGatewayTest.php | 74 ++-- tests/Feature/RazorpayGatewayTest.php | 72 ++-- tests/Feature/RefundAndVoidTest.php | 58 +-- tests/Feature/SecurityAttackTest.php | 136 +++---- tests/Feature/SmokeCommandTest.php | 50 +-- tests/Feature/SquareGatewayTest.php | 70 ++-- tests/Feature/StateTransitionTest.php | 32 +- tests/Feature/StripeGatewayTest.php | 64 ++-- tests/Feature/TabbyGatewayTest.php | 60 +-- tests/Feature/TamaraGatewayTest.php | 60 +-- tests/Feature/TapGatewayTest.php | 70 ++-- tests/Feature/TelrGatewayTest.php | 58 +-- tests/Feature/TestingFakeTest.php | 34 +- tests/Feature/TransportFailureTest.php | 18 +- tests/Feature/VivaGatewayTest.php | 50 +-- tests/Feature/WebhookOrderingTest.php | 22 +- tests/Feature/WebhookTest.php | 20 +- tests/Feature/XenditGatewayTest.php | 60 +-- tests/Fixtures/geidea/callback-success.json | 2 +- tests/Fixtures/geidea/session-created.json | 2 +- tests/Fixtures/paytabs/payment-created.json | 2 +- .../Fixtures/payu/notification-completed.json | 2 +- tests/Fixtures/viva/payment-created.json | 2 +- tests/Fixtures/viva/payment-failed.json | 2 +- tests/Pest.php | 2 +- tests/Support/TestUser.php | 2 +- tests/TestCase.php | 90 ++--- tests/Unit/FawrySignatureTest.php | 4 +- tests/Unit/GeideaSignatureTest.php | 4 +- tests/Unit/KashierSignatureTest.php | 2 +- tests/Unit/MoneyTest.php | 4 +- tests/Unit/PaymobSignatureTest.php | 2 +- tests/Unit/WebhookGuardTest.php | 8 +- 202 files changed, 2836 insertions(+), 2754 deletions(-) rename config/{tahseel.php => paykit.php} (94%) rename database/migrations/{2026_11_30_000000_create_tahseel_manual_payments_table.php => 2026_11_30_000000_create_paykit_manual_payments_table.php} (78%) rename database/migrations/{2026_12_01_000000_make_transfer_reference_unique_on_tahseel_manual_payments.php => 2026_12_01_000000_make_transfer_reference_unique_on_paykit_manual_payments.php} (55%) rename database/migrations/{2026_12_02_000000_create_tahseel_manual_events_table.php => 2026_12_02_000000_create_paykit_manual_events_table.php} (62%) create mode 100644 src/Exceptions/PaykitException.php delete mode 100644 src/Exceptions/TahseelException.php rename src/Facades/{Tahseel.php => Paykit.php} (63%) rename src/{TahseelManager.php => PaykitManager.php} (78%) rename src/{TahseelServiceProvider.php => PaykitServiceProvider.php} (69%) rename src/Testing/{FakeTahseelManager.php => FakePaykitManager.php} (89%) create mode 100644 tests/Feature/LegacyTableRenameTest.php diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5961b57..13849e4 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,6 @@ --- name: Bug report -about: Something in Tahseel behaves wrong +about: Something in Paykit behaves wrong title: '' labels: bug --- @@ -9,7 +9,7 @@ labels: bug **What you expected** -**Which driver** (paymob / kashier / fawry / geidea / manual) and Tahseel version (`composer show elbanbydev/tahseel`) +**Which driver** (paymob / kashier / fawry / geidea / manual) and Paykit version (`composer show elbanbydev/paykit`) **Laravel and PHP versions** diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f9a38..af41ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,31 @@ # Changelog -All notable changes to Tahseel are documented here. This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +All notable changes to Paykit (called Tahseel up to 0.4.0) are documented here. This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] Nothing yet. +## [0.5.0] - 2026-12-05 + +**Tahseel is now Paykit.** Same code, same drivers, same behaviour; only the name changed. This is a breaking release for anyone who installed `elbanbydev/tahseel`, because every public name moved. Entries below this one keep the old names as they were written at the time. + +### Upgrading from Tahseel 0.4.x + +1. `composer remove elbanbydev/tahseel && composer require elbanbydev/paykit`. The old package is not updated any more. +2. Replace the namespace: `Tahseel\` becomes `Paykit\` (`use Tahseel\...` statements, the `Tahseel` facade and alias, `TahseelManager`, `TahseelException`, `FakeTahseelManager`, `TahseelServiceProvider`). +3. Config: publish `config/paykit.php` and move your values over from `config/tahseel.php`, then delete the old file. The config key is `paykit.*`, not `tahseel.*`. +4. Env vars: every `TAHSEEL_*` variable is now `PAYKIT_*` (for example `PAYKIT_GATEWAY`, `PAYKIT_WEBHOOKS_PATH`, `PAYKIT_MANUAL_PANEL_LOCALE`). Gateway credential variables such as `PAYMOB_*` and `STRIPE_*` are unchanged. The old names are not read as a fallback. +5. **Webhook URLs move** from `/tahseel/webhooks/{gateway}` to `/paykit/webhooks/{gateway}`. Either update the URL in each gateway dashboard, or keep the old URL by setting `PAYKIT_WEBHOOKS_PATH=tahseel/webhooks/{gateway}`. Do this before deploying or webhooks will return 404. The manual-transfer routes move the same way (`tahseel/manual` to `paykit/manual`, override with `PAYKIT_MANUAL_PROOF_PATH`), and so do the route names (`tahseel.*` to `paykit.*`) and the view namespace (`tahseel::` to `paykit::`). +6. Artisan commands: `tahseel:check`, `tahseel:smoke`, `tahseel:manual:expire`, `tahseel:manual:prune-proofs` are now `paykit:*`. Update your scheduler entries. +7. Database: run `php artisan migrate`. The manual-transfer tables `tahseel_manual_payments` and `tahseel_manual_events` are renamed in place to `paykit_manual_payments` and `paykit_manual_events` with their rows kept. Back up first. +8. Cache: keys prefixed `tahseel:` (idempotency records, webhook replay markers) are not carried over. In-flight idempotency keys and replay protection restart empty; a webhook redelivered across the upgrade can be processed once more. +9. Published views or translations under `resources/views/vendor/tahseel` need to move to `resources/views/vendor/paykit` (same for `lang/vendor`). + +### Changed + +- Package renamed from `elbanbydev/tahseel` to `elbanbydev/paykit`, repository renamed to `elbanbydev/paykit`, README, EN and AR docs, CI badge and issue templates updated. The Arabic docs no longer carry the Arabic product name. + ## [0.4.0] - 2026-12-04 Thirteen more gateways since 0.3.0, taking the package from fourteen drivers to twenty-seven (twenty-six gateways plus manual transfers), every one of them verified against its published documentation and fixture-tested. The package is still experimental: only Kashier and Paymob have ever run against a real provider account, and the README says so driver by driver. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fd34b7..a36cc0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,9 +19,9 @@ composer check # Pint, Larastan and Pest ## Adding a gateway -1. Implement `Tahseel\Contracts\Gateway`. -2. Add a `create{Name}Driver()` method to `TahseelManager`. -3. Add the driver block to `config/tahseel.php`. +1. Implement `Paykit\Contracts\Gateway`. +2. Add a `create{Name}Driver()` method to `PaykitManager`. +3. Add the driver block to `config/paykit.php`. 4. Add fixtures and tests, including a signature test that pins the exact signed string. 5. Document the credentials and the limitations. diff --git a/README.md b/README.md index 3d3e1bf..cf2c894 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Tahseel (تحصيل) +# Paykit -[![CI](https://github.com/elbanbydev/Tahseel/actions/workflows/ci.yml/badge.svg)](https://github.com/elbanbydev/Tahseel/actions/workflows/ci.yml) -[![Packagist](https://img.shields.io/packagist/v/elbanbydev/tahseel)](https://packagist.org/packages/elbanbydev/tahseel) +[![CI](https://github.com/elbanbydev/paykit/actions/workflows/ci.yml/badge.svg)](https://github.com/elbanbydev/paykit/actions/workflows/ci.yml) +[![Packagist](https://img.shields.io/packagist/v/elbanbydev/paykit)](https://packagist.org/packages/elbanbydev/paykit) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) A small, honest Laravel package for payment gateways, wherever they are. @@ -10,7 +10,7 @@ A small, honest Laravel package for payment gateways, wherever they are. New here? Start with the [quickstart](docs/quickstart.md). -Tahseel gives you one clean API for starting a payment, verifying the gateway's callback, and getting a normalised result. Twenty-seven drivers so far: **Paymob** (Intention API + Unified Checkout), **Kashier** (v3 payment sessions), **Fawry** (pay-at-outlet reference numbers), **Geidea** (checkout sessions on the hosted page), **MyFatoorah** (invoice payment links + signed webhook v2), **Tap** (hosted charges + `hashstring` webhooks), **HyperPay** (COPYandPAY widget + AES-256-GCM encrypted webhooks), **Checkout.com** (Hosted Payments Page + `Cko-Signature` webhooks), **PayPal** (Orders v2 + `verify-webhook-signature`), **Stripe** (Checkout Sessions + the documented `Stripe-Signature` HMAC), **Paystack** (hosted checkout for Nigeria, Ghana, South Africa and Kenya + two documented webhook schemes) **Moyasar** (Saudi cards, mada, Apple/Samsung Pay and STC Pay over one API + shared-token webhooks) **Razorpay** (hosted Payment Links for India + HMAC-SHA-256 everything), **Mercado Pago** (Checkout Pro hosted pages for Latin America + manifest-signed notifications) and **Mollie** (hosted checkout for Europe - iDEAL, Bancontact, SEPA, Klarna, cards and more + deliberately unsigned webhooks verified by fetch) and **Adyen** (hosted Checkout sessions for global enterprise + HMAC-signed Standard webhooks) **Flutterwave** (hosted checkout across Africa + `verif-hash` webhooks re-checked through the API) and **PayTabs** (hosted payment pages across the Gulf + raw-body `Signature` callbacks) **Klarna** (hosted payment pages for Europe and the US + one-time-token callbacks re-checked through the API, with the documented place-order step) **Square** (hosted payment links + notifications signed over the notification URL and raw body) **Xendit** (hosted Payment Sessions across South-East Asia + `x-callback-token` webhooks) **Telr** (hosted payment pages across the Gulf + SHA1-signed transaction advice) **Viva.com** (Smart Checkout across Europe + HMAC-signed webhooks) **PayU** (the European PayU platform + MD5-signed notifications) **Tabby** (BNPL checkout across the UAE and Saudi Arabia + capture, refunds and header-authenticated webhooks) and **Tamara** (BNPL across Saudi Arabia and the Gulf + JWT-authenticated notifications, with the documented authorise step). Another, **manual**, covers what no wallet publishes an API for: a transfer to your Vodafone Cash number or InstaPay handle, confirmed by a human in a small approval panel. The Gulf drivers, PayPal, Stripe, Paystack, Moyasar, Razorpay, Mercado Pago, Mollie, Adyen, Flutterwave, PayTabs, Klarna, Square, Xendit, Telr, Viva.com, PayU, Tabby and Tamara are fixture-tested only, no live account has run them yet. +Paykit gives you one clean API for starting a payment, verifying the gateway's callback, and getting a normalised result. Twenty-seven drivers so far: **Paymob** (Intention API + Unified Checkout), **Kashier** (v3 payment sessions), **Fawry** (pay-at-outlet reference numbers), **Geidea** (checkout sessions on the hosted page), **MyFatoorah** (invoice payment links + signed webhook v2), **Tap** (hosted charges + `hashstring` webhooks), **HyperPay** (COPYandPAY widget + AES-256-GCM encrypted webhooks), **Checkout.com** (Hosted Payments Page + `Cko-Signature` webhooks), **PayPal** (Orders v2 + `verify-webhook-signature`), **Stripe** (Checkout Sessions + the documented `Stripe-Signature` HMAC), **Paystack** (hosted checkout for Nigeria, Ghana, South Africa and Kenya + two documented webhook schemes) **Moyasar** (Saudi cards, mada, Apple/Samsung Pay and STC Pay over one API + shared-token webhooks) **Razorpay** (hosted Payment Links for India + HMAC-SHA-256 everything), **Mercado Pago** (Checkout Pro hosted pages for Latin America + manifest-signed notifications) and **Mollie** (hosted checkout for Europe - iDEAL, Bancontact, SEPA, Klarna, cards and more + deliberately unsigned webhooks verified by fetch) and **Adyen** (hosted Checkout sessions for global enterprise + HMAC-signed Standard webhooks) **Flutterwave** (hosted checkout across Africa + `verif-hash` webhooks re-checked through the API) and **PayTabs** (hosted payment pages across the Gulf + raw-body `Signature` callbacks) **Klarna** (hosted payment pages for Europe and the US + one-time-token callbacks re-checked through the API, with the documented place-order step) **Square** (hosted payment links + notifications signed over the notification URL and raw body) **Xendit** (hosted Payment Sessions across South-East Asia + `x-callback-token` webhooks) **Telr** (hosted payment pages across the Gulf + SHA1-signed transaction advice) **Viva.com** (Smart Checkout across Europe + HMAC-signed webhooks) **PayU** (the European PayU platform + MD5-signed notifications) **Tabby** (BNPL checkout across the UAE and Saudi Arabia + capture, refunds and header-authenticated webhooks) and **Tamara** (BNPL across Saudi Arabia and the Gulf + JWT-authenticated notifications, with the documented authorise step). Another, **manual**, covers what no wallet publishes an API for: a transfer to your Vodafone Cash number or InstaPay handle, confirmed by a human in a small approval panel. The Gulf drivers, PayPal, Stripe, Paystack, Moyasar, Razorpay, Mercado Pago, Mollie, Adyen, Flutterwave, PayTabs, Klarna, Square, Xendit, Telr, Viva.com, PayU, Tabby and Tamara are fixture-tested only, no live account has run them yet. > **Status: v0.4.0, experimental. Do not take real money through it yet.** > @@ -24,38 +24,42 @@ Tahseel gives you one clean API for starting a payment, verifying the gateway's | Gateway | Start a payment | Webhook verification | Refund / void | Capture | Notes | | --- | --- | --- | --- | --- | --- | -| **Paymob** | `Tahseel::gateway('paymob')` - Intention API, Unified Checkout | HMAC-SHA512 over Paymob's 20 signed fields | refund and void | card authorizations | Card, wallet and any other method you enable as an integration ID | -| **Kashier** | `Tahseel::gateway('kashier')` - v3 payment sessions | HMAC-SHA256 in `x-kashier-signature` | refund and void | not documented | Hosted page; card and wallet | -| **Fawry** | `Tahseel::gateway('fawry')` - charge API, pay-at-outlet reference number | SHA-256 `messageSignature`, Notification V2 | refund; void cancels an unpaid order | not documented | Reference numbers only; card and wallet are not implemented | -| **Geidea** | `Tahseel::gateway('geidea')` - create session + hosted checkout | HMAC-SHA256 over the returned `order` | refund only | not documented | Hosted page; the methods your Geidea account enables | -| **MyFatoorah** | `Tahseel::gateway('myfatoorah')` - SendPayment invoice links | HMAC-SHA256 (base64) in `myfatoorah-signature`, webhook v2 | refund request, completed by MyFatoorah's finance team | not documented | Kuwait, Saudi Arabia and the Gulf; fixture-tested only, no live run yet | -| **Tap** | `Tahseel::gateway('tap')` - Charges API, hosted page (`src_all`) | HMAC-SHA256 (hex) in `hashstring`, amount formatted to the currency's ISO scale | refund, amount required | not documented | Saudi Arabia, Kuwait, UAE and the Gulf; fixture-tested only, no live run yet | -| **HyperPay** | `Tahseel::gateway('hyperpay')` - server-to-server checkout + payment widget | AES-256-GCM encrypted body; the GCM tag is the signature | refund, amount required | not documented | Saudi Arabia and the Gulf; mada, cards; fixture-tested only, no live run yet | -| **Checkout.com** | `Tahseel::gateway('checkoutcom')` - Hosted Payments Page | HMAC-SHA256 (hex) over the raw body in `Cko-Signature` | refund accepted async (202), completed by the `payment_refunded` webhook | not documented | MENA and worldwide; fixture-tested only, no live run yet | -| **PayPal** | `Tahseel::gateway('paypal')` - Orders v2, approve-link redirect | PayPal's own `verify-webhook-signature` endpoint decides | refund, full or partial, addressed by the capture id | required second call after approval, full amount only | International; no EGP support; fixture-tested only, no live run yet | -| **Stripe** | `Tahseel::gateway('stripe')` - hosted Checkout Sessions | HMAC-SHA256 of `{t}.{raw body}` in `Stripe-Signature`, constant-time, 5-minute replay tolerance | refund, full or partial, addressed by the payment intent id | not implemented | International; no merchant accounts in Egypt or most of the Gulf; fixture-tested only, no live run yet | -| **Paystack** | `Tahseel::gateway('paystack')` - hosted checkout page | two documented schemes: `Paystack-Signature` (HMAC-SHA-512 of `{t}.{raw body}`, `whsec_` secret, 300s replay tolerance) and legacy `x-paystack-signature` (HMAC-SHA-512 of the raw body under the secret key) | refund queued async, pending until the `refund.processed` webhook | server-side `verifyTransactionStatus()` after the redirect | Nigeria, Ghana, South Africa, Kenya; NGN/GHS/ZAR/KES/USD; fixture-tested only, no live run yet | -| **Moyasar** | `Tahseel::gateway('moyasar')` - API payment + 3DS challenge redirect | no signature: the webhook echoes the shared secret token you registered, compared in constant time | refund synchronous, the response already says `refunded` | server-side `fetchPaymentStatus()` after the callback | Saudi Arabia / Gulf; SAR-first, mada + cards + STC Pay + SADAD; fixture-tested only, no live run yet | -| **Razorpay** | `Tahseel::gateway('razorpay')` - hosted Payment Links | HMAC-SHA-256 of the raw body in `X-Razorpay-Signature` (webhook secret), constant-time; the browser callback has its own documented signature, `verifyCallbackSignature()` | refund pending until `refund.processed`; documented `X-Refund-Idempotency` header sent | server-side `fetchPaymentStatus()` after the callback | India (+ Malaysia/Singapore/US on the API); INR-first; fixture-tested only, no live run yet | -| **Mercado Pago** | `Tahseel::gateway('mercadopago')` - Checkout Pro hosted pages | HMAC-SHA-256 of the documented manifest `id:{data.id};request-id:{x-request-id};ts:{ts};` in `x-signature`, constant-time, 300s tolerance; the notification is a signal, the driver fetches the payment for the truth | refund, full (empty body) or partial, in MAJOR units; documented `X-Idempotency-Key` sent | server-side `fetchPaymentStatus()` after the return | Latin America (AR/BR/MX/CL/CO/PE/UY); fixture-tested only, no live run yet | -| **Mollie** | `Tahseel::gateway('mollie')` - hosted checkout page | deliberately unsigned: the webhook carries only the payment id, and the documented security model is the authenticated fetch that follows - a fake call can never mark anything paid | refund, full or partial; the amount object is required on every refund | server-side `fetchPaymentStatus()` after the return | Europe; EUR-first, iDEAL/Bancontact/SEPA/Klarna/cards and more; fixture-tested only, no live run yet | -| **Adyen** | `Tahseel::gateway('adyen')` - hosted Checkout sessions | HMAC-SHA-256 of the documented colon-joined payload, keyed by the hex-decoded HMAC key, base64 in `additionalData.hmacSignature`; every item verified before any is parsed | refund async: acknowledged, pending until the `REFUND` webhook; amount required | none: Adyen settles status by webhook | Global enterprise; MINOR units; fixture-tested only, no live run yet | -| **Flutterwave** | `Tahseel::gateway('flutterwave')` - hosted checkout link (`POST /v3/payments`) | no HMAC: the dashboard's secret hash comes back verbatim in `verif-hash`, compared in constant time, and then the documented `GET /v3/transactions/{id}/verify` decides the truth - a forged call cannot mark anything paid | refund, full (no amount) or partial, in MAJOR units; `completed` means initiated, only `completed-*` is finished | server-side `fetchPaymentStatus()` after the return | Nigeria, Ghana, Kenya, South Africa and more of Africa; MAJOR units; fixture-tested only, no live run yet | -| **PayTabs** | `Tahseel::gateway('paytabs')` - hosted payment page (`POST /payment/request`) | hex HMAC-SHA-256 of the whole raw callback body under the profile's Server Key, in a `Signature` header, constant-time; the documented status set is closed, so an unknown code is refused rather than guessed | refund, amount required, addressed by the original `tran_ref`; `P` is a manual refund still pending | server-side `fetchPaymentStatus()` via `POST /payment/query` | Saudi Arabia, UAE, Egypt, Oman, Jordan, Kuwait, Qatar, Morocco, Iraq; MAJOR units; fixture-tested only, no live run yet | -| **Klarna** | `Tahseel::gateway('klarna')` - payment session + hosted page (`POST /payments/v1/sessions`, then `POST /hpp/v1/sessions`) | no HMAC: the documented one-time token in the `status_update` URL is compared in constant time, then the session is re-read through the API, so a forged call can never mark anything paid | refund, amount required, addressed by Klarna's own order id; there is no full-refund default | `placeOrder()` after the customer authorises: an authorization is not money | Europe and the US; BNPL and pay-now; MINOR units; fixture-tested only, no live run yet | -| **Square** | `Tahseel::gateway('square')` - Square-hosted payment link (`POST /v2/online-checkout/payment-links`) | HMAC-SHA-256, base64, of the notification URL followed by the raw body, keyed by the subscription's signature key, in `x-square-hmacsha256-signature`, constant-time; the notification is the signal, the authenticated payment read is the truth | refund, amount required, addressed by the Square payment id; `PENDING` until Square approves it | server-side `fetchPaymentStatus()`; an `APPROVED` payment is authorised, not captured, and comes through pending | US, Canada, UK, Ireland, Australia, Japan, France, Spain; MINOR units; fixture-tested only, no live run yet | -| **Xendit** | `Tahseel::gateway('xendit')` - Payment Session in `PAYMENT_LINK` mode (`POST /sessions`) | no HMAC: the dashboard's callback token comes back verbatim in `x-callback-token`, compared in constant time, and the documented session status set is closed, so an unknown status is refused rather than guessed | refund, amount required, addressed by Xendit's `payment_id`; `PENDING` until the refund webhook settles it | none: the callback token is the documented authentication | Indonesia, the Philippines, Malaysia, Thailand, Vietnam, Singapore; smallest-unit amounts; fixture-tested only, no live run yet | -| **Telr** | `Tahseel::gateway('telr')` - hosted payment page (`POST /gateway/order.json`, method `create`) | SHA1 of the secret key followed by the documented transaction fields, colon-joined, in `tran_check`, constant-time; percent-encoded values decoded first, a missing field contributing an empty value, exactly as the docs say | not wrapped: Telr documents refunds on a different product surface, so the driver does not claim them | server-side `fetchPaymentStatus()` through the documented `check` method | UAE, Saudi Arabia and the wider Gulf; MAJOR-unit decimal strings; `H` (authorised, on hold) is pending, not paid; fixture-tested only, no live run yet | -| **Viva.com** | `Tahseel::gateway('viva')` - Smart Checkout payment order (`POST /checkout/v2/orders`) | hex HMAC-SHA-256 of the raw body in `Viva-Signature-256`, with the documented SHA-1 `Viva-Signature` as a fallback, constant-time; the event id and the transaction's own `StatusId` have to agree or the notification is refused | not wrapped: Viva documents refunds on a separate product surface, so the driver does not claim them | none: Viva's docs say to confirm with `OrderCode` plus `TransactionId`, `StatusId` and `Amount`, which the driver checks | Europe (Viva.com is a Greek acquirer with a wide European footprint); MINOR units; `F` is finished, `A`/`C` are pending, `R` is refunded; fixture-tested only, no live run yet | -| **PayU** | `Tahseel::gateway('payu')` - PayU Global order + redirect (`POST /api/v2_1/orders`) | MD5 of the raw body concatenated with the POS's second key, in `OpenPayu-Signature`, constant-time; an algorithm the driver has not been grounded in is refused rather than approximated | full (no amount) or partial, lowest-currency-unit amount, addressed by PayU's order id; anything PayU does not spell out stays pending | none: the signed notification is the state | Europe (PayU Global, secure.payu.com - not PayU India); lowest-unit amounts as strings; PENDING and WAITING_FOR_CONFIRMATION are pending, only COMPLETED is paid; fixture-tested only, no live run yet | -| **Tabby** | `Tahseel::gateway('tabby')` - hosted checkout session (`POST /api/v2/checkout`) | Tabby has no body signature: you register a custom header with your own secret and the driver compares it in constant time, as Tabby's docs prescribe | full or partial, amount required (Tabby has no amount-less full refund), addressed by Tabby's payment id | `POST /api/v2/payments/{id}/captures`; only a captured payment is `CLOSED` and settles | UAE and Saudi Arabia (region-pinned base URL: api.tabby.ai / api.tabby.sa); DECIMAL string amounts in AED or SAR; `AUTHORIZED` is pending, only `CLOSED` is paid; fixture-tested only, no live run yet | -| **Tamara** | `Tahseel::gateway('tamara')` - hosted checkout session (`POST /checkout`) | an HS256 JWT signed with your notification token, arriving both as `Authorization: Bearer` and as the `tamaraToken` query parameter; the driver verifies the signature itself, checks the expiry, and refuses any algorithm other than HS256 | full or partial, amount required, addressed by Tamara's `order_id` | not wrapped: Tamara's capture is a documented call that wants the order's items back, so `authorise()` is the step this driver implements | Saudi Arabia, UAE, Bahrain, Kuwait, Oman; MAJOR-unit amounts in `{amount, currency}`; `approved` is pending and `authorised` is paid; `authorise()` is the documented step after the approved notification; fixture-tested only, no live run yet | -| **Manual** (Vodafone Cash, InstaPay) | `Tahseel::gateway('manual')` - a reference, a transfer to your wallet, a human decision | none: a human confirms in the panel | not applicable | not applicable | No merchant API to call; the panel stays closed until you name a Gate ability | +| **Paymob** | `Paykit::gateway('paymob')` - Intention API, Unified Checkout | HMAC-SHA512 over Paymob's 20 signed fields | refund and void | card authorizations | Card, wallet and any other method you enable as an integration ID | +| **Kashier** | `Paykit::gateway('kashier')` - v3 payment sessions | HMAC-SHA256 in `x-kashier-signature` | refund and void | not documented | Hosted page; card and wallet | +| **Fawry** | `Paykit::gateway('fawry')` - charge API, pay-at-outlet reference number | SHA-256 `messageSignature`, Notification V2 | refund; void cancels an unpaid order | not documented | Reference numbers only; card and wallet are not implemented | +| **Geidea** | `Paykit::gateway('geidea')` - create session + hosted checkout | HMAC-SHA256 over the returned `order` | refund only | not documented | Hosted page; the methods your Geidea account enables | +| **MyFatoorah** | `Paykit::gateway('myfatoorah')` - SendPayment invoice links | HMAC-SHA256 (base64) in `myfatoorah-signature`, webhook v2 | refund request, completed by MyFatoorah's finance team | not documented | Kuwait, Saudi Arabia and the Gulf; fixture-tested only, no live run yet | +| **Tap** | `Paykit::gateway('tap')` - Charges API, hosted page (`src_all`) | HMAC-SHA256 (hex) in `hashstring`, amount formatted to the currency's ISO scale | refund, amount required | not documented | Saudi Arabia, Kuwait, UAE and the Gulf; fixture-tested only, no live run yet | +| **HyperPay** | `Paykit::gateway('hyperpay')` - server-to-server checkout + payment widget | AES-256-GCM encrypted body; the GCM tag is the signature | refund, amount required | not documented | Saudi Arabia and the Gulf; mada, cards; fixture-tested only, no live run yet | +| **Checkout.com** | `Paykit::gateway('checkoutcom')` - Hosted Payments Page | HMAC-SHA256 (hex) over the raw body in `Cko-Signature` | refund accepted async (202), completed by the `payment_refunded` webhook | not documented | MENA and worldwide; fixture-tested only, no live run yet | +| **PayPal** | `Paykit::gateway('paypal')` - Orders v2, approve-link redirect | PayPal's own `verify-webhook-signature` endpoint decides | refund, full or partial, addressed by the capture id | required second call after approval, full amount only | International; no EGP support; fixture-tested only, no live run yet | +| **Stripe** | `Paykit::gateway('stripe')` - hosted Checkout Sessions | HMAC-SHA256 of `{t}.{raw body}` in `Stripe-Signature`, constant-time, 5-minute replay tolerance | refund, full or partial, addressed by the payment intent id | not implemented | International; no merchant accounts in Egypt or most of the Gulf; fixture-tested only, no live run yet | +| **Paystack** | `Paykit::gateway('paystack')` - hosted checkout page | two documented schemes: `Paystack-Signature` (HMAC-SHA-512 of `{t}.{raw body}`, `whsec_` secret, 300s replay tolerance) and legacy `x-paystack-signature` (HMAC-SHA-512 of the raw body under the secret key) | refund queued async, pending until the `refund.processed` webhook | server-side `verifyTransactionStatus()` after the redirect | Nigeria, Ghana, South Africa, Kenya; NGN/GHS/ZAR/KES/USD; fixture-tested only, no live run yet | +| **Moyasar** | `Paykit::gateway('moyasar')` - API payment + 3DS challenge redirect | no signature: the webhook echoes the shared secret token you registered, compared in constant time | refund synchronous, the response already says `refunded` | server-side `fetchPaymentStatus()` after the callback | Saudi Arabia / Gulf; SAR-first, mada + cards + STC Pay + SADAD; fixture-tested only, no live run yet | +| **Razorpay** | `Paykit::gateway('razorpay')` - hosted Payment Links | HMAC-SHA-256 of the raw body in `X-Razorpay-Signature` (webhook secret), constant-time; the browser callback has its own documented signature, `verifyCallbackSignature()` | refund pending until `refund.processed`; documented `X-Refund-Idempotency` header sent | server-side `fetchPaymentStatus()` after the callback | India (+ Malaysia/Singapore/US on the API); INR-first; fixture-tested only, no live run yet | +| **Mercado Pago** | `Paykit::gateway('mercadopago')` - Checkout Pro hosted pages | HMAC-SHA-256 of the documented manifest `id:{data.id};request-id:{x-request-id};ts:{ts};` in `x-signature`, constant-time, 300s tolerance; the notification is a signal, the driver fetches the payment for the truth | refund, full (empty body) or partial, in MAJOR units; documented `X-Idempotency-Key` sent | server-side `fetchPaymentStatus()` after the return | Latin America (AR/BR/MX/CL/CO/PE/UY); fixture-tested only, no live run yet | +| **Mollie** | `Paykit::gateway('mollie')` - hosted checkout page | deliberately unsigned: the webhook carries only the payment id, and the documented security model is the authenticated fetch that follows - a fake call can never mark anything paid | refund, full or partial; the amount object is required on every refund | server-side `fetchPaymentStatus()` after the return | Europe; EUR-first, iDEAL/Bancontact/SEPA/Klarna/cards and more; fixture-tested only, no live run yet | +| **Adyen** | `Paykit::gateway('adyen')` - hosted Checkout sessions | HMAC-SHA-256 of the documented colon-joined payload, keyed by the hex-decoded HMAC key, base64 in `additionalData.hmacSignature`; every item verified before any is parsed | refund async: acknowledged, pending until the `REFUND` webhook; amount required | none: Adyen settles status by webhook | Global enterprise; MINOR units; fixture-tested only, no live run yet | +| **Flutterwave** | `Paykit::gateway('flutterwave')` - hosted checkout link (`POST /v3/payments`) | no HMAC: the dashboard's secret hash comes back verbatim in `verif-hash`, compared in constant time, and then the documented `GET /v3/transactions/{id}/verify` decides the truth - a forged call cannot mark anything paid | refund, full (no amount) or partial, in MAJOR units; `completed` means initiated, only `completed-*` is finished | server-side `fetchPaymentStatus()` after the return | Nigeria, Ghana, Kenya, South Africa and more of Africa; MAJOR units; fixture-tested only, no live run yet | +| **PayTabs** | `Paykit::gateway('paytabs')` - hosted payment page (`POST /payment/request`) | hex HMAC-SHA-256 of the whole raw callback body under the profile's Server Key, in a `Signature` header, constant-time; the documented status set is closed, so an unknown code is refused rather than guessed | refund, amount required, addressed by the original `tran_ref`; `P` is a manual refund still pending | server-side `fetchPaymentStatus()` via `POST /payment/query` | Saudi Arabia, UAE, Egypt, Oman, Jordan, Kuwait, Qatar, Morocco, Iraq; MAJOR units; fixture-tested only, no live run yet | +| **Klarna** | `Paykit::gateway('klarna')` - payment session + hosted page (`POST /payments/v1/sessions`, then `POST /hpp/v1/sessions`) | no HMAC: the documented one-time token in the `status_update` URL is compared in constant time, then the session is re-read through the API, so a forged call can never mark anything paid | refund, amount required, addressed by Klarna's own order id; there is no full-refund default | `placeOrder()` after the customer authorises: an authorization is not money | Europe and the US; BNPL and pay-now; MINOR units; fixture-tested only, no live run yet | +| **Square** | `Paykit::gateway('square')` - Square-hosted payment link (`POST /v2/online-checkout/payment-links`) | HMAC-SHA-256, base64, of the notification URL followed by the raw body, keyed by the subscription's signature key, in `x-square-hmacsha256-signature`, constant-time; the notification is the signal, the authenticated payment read is the truth | refund, amount required, addressed by the Square payment id; `PENDING` until Square approves it | server-side `fetchPaymentStatus()`; an `APPROVED` payment is authorised, not captured, and comes through pending | US, Canada, UK, Ireland, Australia, Japan, France, Spain; MINOR units; fixture-tested only, no live run yet | +| **Xendit** | `Paykit::gateway('xendit')` - Payment Session in `PAYMENT_LINK` mode (`POST /sessions`) | no HMAC: the dashboard's callback token comes back verbatim in `x-callback-token`, compared in constant time, and the documented session status set is closed, so an unknown status is refused rather than guessed | refund, amount required, addressed by Xendit's `payment_id`; `PENDING` until the refund webhook settles it | none: the callback token is the documented authentication | Indonesia, the Philippines, Malaysia, Thailand, Vietnam, Singapore; smallest-unit amounts; fixture-tested only, no live run yet | +| **Telr** | `Paykit::gateway('telr')` - hosted payment page (`POST /gateway/order.json`, method `create`) | SHA1 of the secret key followed by the documented transaction fields, colon-joined, in `tran_check`, constant-time; percent-encoded values decoded first, a missing field contributing an empty value, exactly as the docs say | not wrapped: Telr documents refunds on a different product surface, so the driver does not claim them | server-side `fetchPaymentStatus()` through the documented `check` method | UAE, Saudi Arabia and the wider Gulf; MAJOR-unit decimal strings; `H` (authorised, on hold) is pending, not paid; fixture-tested only, no live run yet | +| **Viva.com** | `Paykit::gateway('viva')` - Smart Checkout payment order (`POST /checkout/v2/orders`) | hex HMAC-SHA-256 of the raw body in `Viva-Signature-256`, with the documented SHA-1 `Viva-Signature` as a fallback, constant-time; the event id and the transaction's own `StatusId` have to agree or the notification is refused | not wrapped: Viva documents refunds on a separate product surface, so the driver does not claim them | none: Viva's docs say to confirm with `OrderCode` plus `TransactionId`, `StatusId` and `Amount`, which the driver checks | Europe (Viva.com is a Greek acquirer with a wide European footprint); MINOR units; `F` is finished, `A`/`C` are pending, `R` is refunded; fixture-tested only, no live run yet | +| **PayU** | `Paykit::gateway('payu')` - PayU Global order + redirect (`POST /api/v2_1/orders`) | MD5 of the raw body concatenated with the POS's second key, in `OpenPayu-Signature`, constant-time; an algorithm the driver has not been grounded in is refused rather than approximated | full (no amount) or partial, lowest-currency-unit amount, addressed by PayU's order id; anything PayU does not spell out stays pending | none: the signed notification is the state | Europe (PayU Global, secure.payu.com - not PayU India); lowest-unit amounts as strings; PENDING and WAITING_FOR_CONFIRMATION are pending, only COMPLETED is paid; fixture-tested only, no live run yet | +| **Tabby** | `Paykit::gateway('tabby')` - hosted checkout session (`POST /api/v2/checkout`) | Tabby has no body signature: you register a custom header with your own secret and the driver compares it in constant time, as Tabby's docs prescribe | full or partial, amount required (Tabby has no amount-less full refund), addressed by Tabby's payment id | `POST /api/v2/payments/{id}/captures`; only a captured payment is `CLOSED` and settles | UAE and Saudi Arabia (region-pinned base URL: api.tabby.ai / api.tabby.sa); DECIMAL string amounts in AED or SAR; `AUTHORIZED` is pending, only `CLOSED` is paid; fixture-tested only, no live run yet | +| **Tamara** | `Paykit::gateway('tamara')` - hosted checkout session (`POST /checkout`) | an HS256 JWT signed with your notification token, arriving both as `Authorization: Bearer` and as the `tamaraToken` query parameter; the driver verifies the signature itself, checks the expiry, and refuses any algorithm other than HS256 | full or partial, amount required, addressed by Tamara's `order_id` | not wrapped: Tamara's capture is a documented call that wants the order's items back, so `authorise()` is the step this driver implements | Saudi Arabia, UAE, Bahrain, Kuwait, Oman; MAJOR-unit amounts in `{amount, currency}`; `approved` is pending and `authorised` is paid; `authorise()` is the documented step after the approved notification; fixture-tested only, no live run yet | +| **Manual** (Vodafone Cash, InstaPay) | `Paykit::gateway('manual')` - a reference, a transfer to your wallet, a human decision | none: a human confirms in the panel | not applicable | not applicable | No merchant API to call; the panel stays closed until you name a Gate ability | | **Wallets, BNPL, Meeza, InstaPay** | through Paymob, Kashier or Geidea methods | - | - | - | None publishes a merchant API of its own; see [Wallets, BNPL, Meeza and InstaPay](#wallets-bnpl-meeza-and-instapay) | +## Coming from Tahseel + +Paykit was called Tahseel (`elbanbydev/tahseel`) up to 0.4.x. Switching means a new composer package, the `Paykit\` namespace, `config/paykit.php`, `PAYKIT_*` env vars, `paykit:*` artisan commands, and webhook URLs under `/paykit/webhooks/{gateway}` (set `PAYKIT_WEBHOOKS_PATH=tahseel/webhooks/{gateway}` to keep the old URLs). The manual-transfer tables are renamed in place by `php artisan migrate`. The step-by-step list is in the 0.5.0 [CHANGELOG](CHANGELOG.md) entry. + ## Why -Most payment-gateway integrations are copy-pasted snippets: an intention call here, an HMAC check there, and a callback handler that trusts whatever arrives. Tahseel keeps the pieces separate and testable: +Most payment-gateway integrations are copy-pasted snippets: an intention call here, an HMAC check there, and a callback handler that trusts whatever arrives. Paykit keeps the pieces separate and testable: - **One request object, one session object.** Amounts are integers in piastres, never floats. - **Signature verification is not optional.** A callback is parsed only after its HMAC matches, compared in constant time. @@ -70,30 +74,30 @@ Most payment-gateway integrations are copy-pasted snippets: an intention call he ## Installation -Tahseel is not on Packagist yet. Add the repository, then require it: +Paykit is not on Packagist yet. Add the repository, then require it: ```json { "repositories": [ - { "type": "vcs", "url": "https://github.com/elbanbydev/Tahseel" } + { "type": "vcs", "url": "https://github.com/elbanbydev/paykit" } ] } ``` ```bash -composer require elbanbydev/tahseel:dev-main +composer require elbanbydev/paykit:dev-main ``` Publish the config file: ```bash -php artisan vendor:publish --tag=tahseel-config +php artisan vendor:publish --tag=paykit-config ``` ## Configuration ```dotenv -TAHSEEL_GATEWAY=paymob +PAYKIT_GATEWAY=paymob PAYMOB_BASE_URL=https://accept.paymob.com PAYMOB_CHECKOUT_URL=https://eg.checkout.paymob.com/ @@ -102,7 +106,7 @@ PAYMOB_PUBLIC_KEY=pk_test_... PAYMOB_HMAC_SECRET=... PAYMOB_INTEGRATION_IDS=5123456 PAYMOB_API_KEY= # optional, only for refund, void and capture -PAYMOB_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/paymob +PAYMOB_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/paymob PAYMOB_REDIRECTION_URL=https://your-app.test/checkout/done ``` @@ -110,9 +114,9 @@ PAYMOB_REDIRECTION_URL=https://your-app.test/checkout/done | --- | --- | | `secret_key` | Dashboard → Settings → API Keys. Sent server-side as `Authorization: Token sk_...`. | | `public_key` | Safe for the browser. Used to build the checkout URL. | -| `hmac_secret` | Verifies every callback. Without it Tahseel refuses to parse webhooks. | +| `hmac_secret` | Verifies every callback. Without it Paykit refuses to parse webhooks. | | `integration_ids` | One ID per payment method you enabled, comma separated. Test IDs must match a test secret key. | -| `api_key` | Optional. Lets Tahseel mint the short-lived `auth_token` that the acceptance refund, void and capture calls also accept in the body. | +| `api_key` | Optional. Lets Paykit mint the short-lived `auth_token` that the acceptance refund, void and capture calls also accept in the body. | | `base_url` | `accept.paymob.com` (Egypt), `uae.paymob.com`, `ksa.paymob.com`, `oman.paymob.com`. | | `checkout_url` | Regional Unified Checkout host, e.g. `https://eg.checkout.paymob.com/`. | @@ -121,25 +125,25 @@ The secret key, public key and HMAC secret belong on the server. Only the public ### Check the configuration before the first payment ```bash -php artisan tahseel:check +php artisan paykit:check ``` It prints one row per driver: `ok`, `missing` with the key and the env variable to set, or `not configured` for a driver you never filled in. A driver with no keys at all does not fail the command; the default gateway always has to be complete. It also prints whether the webhook route is enabled and at which path. ### Proving your keys work -`tahseel:check` reads your configuration; it cannot tell whether the keys are valid. This starts one real payment through the driver: +`paykit:check` reads your configuration; it cannot tell whether the keys are valid. This starts one real payment through the driver: ```bash -php artisan tahseel:smoke -php artisan tahseel:smoke --gateway=kashier --amount=1.00 --method=card +php artisan paykit:smoke +php artisan paykit:smoke --gateway=kashier --amount=1.00 --method=card ``` -It prints the endpoint, the reference, the session and order ids, the checkout URL (or Fawry's reference number) and where the callback should land. Nothing is charged: every driver Tahseel ships only reserves a payment page or a reference number at this step. The amount defaults to 1.00 in the driver currency. +It prints the endpoint, the reference, the session and order ids, the checkout URL (or Fawry's reference number) and where the callback should land. Nothing is charged: every driver Paykit ships only reserves a payment page or a reference number at this step. The amount defaults to 1.00 in the driver currency. If the gateway rejects the request, the command exits non-zero and prints the gateway's own message, which is usually the useful one ("Invalid API key", "merchant not enabled for wallets"). When the endpoint is not obviously a test host it warns first, because Paymob serves test and live accounts from the same host: the keys decide, not the URL. -Pay that session with a test card and watch the callback arrive at `/tahseel/webhooks/{gateway}` to prove the whole loop, signature check included. +Pay that session with a test card and watch the callback arrive at `/paykit/webhooks/{gateway}` to prove the whole loop, signature check included. ## Starting a payment @@ -147,13 +151,13 @@ The examples below use Paymob. Every driver takes the same `PaymentRequest`; onl ```php -use Tahseel\Data\Customer; -use Tahseel\Data\LineItem; -use Tahseel\Data\Money; -use Tahseel\Data\PaymentRequest; -use Tahseel\Facades\Tahseel; +use Paykit\Data\Customer; +use Paykit\Data\LineItem; +use Paykit\Data\Money; +use Paykit\Data\PaymentRequest; +use Paykit\Facades\Paykit; -$session = Tahseel::createPayment(new PaymentRequest( +$session = Paykit::createPayment(new PaymentRequest( reference: 'ORDER-1042', // comes back as merchant_order_id amount: Money::of('250.00', 'EGP'), // stored as 25000 piastres customer: new Customer( @@ -173,18 +177,18 @@ return redirect()->away($session->checkoutUrl); `PaymentSession` carries `intentionId`, `orderId`, `clientSecret`, `checkoutUrl` and the untouched gateway `raw` response. Store the reference and the order ID; that is what the callback gives back. -If you retry with the same `idempotencyKey`, you get the same session back and Paymob is not called again. Keys are kept for `tahseel.idempotency.ttl` seconds (one day by default). +If you retry with the same `idempotencyKey`, you get the same session back and Paymob is not called again. Keys are kept for `paykit.idempotency.ttl` seconds (one day by default). ### When the gateway does not answer -A timeout or a dropped connection is not a failed payment, it is an unknown one. Tahseel turns it into a `GatewayException` whose message says so: +A timeout or a dropped connection is not a failed payment, it is an unknown one. Paykit turns it into a `GatewayException` whose message says so: ```text paymob create intention did not get an answer from the gateway (cURL error 28: ...). The request may or may not have been processed: check the gateway dashboard before retrying. ``` -Retrying a create-payment call with the same `idempotencyKey` is safe: the stored session comes back and the gateway is not called again. Retrying a refund is not safe, because the first attempt may already have moved the money. Tahseel never retries by itself. +Retrying a create-payment call with the same `idempotencyKey` is safe: the stored session comes back and the gateway is not called again. Retrying a refund is not safe, because the first attempt may already have moved the money. Paykit never retries by itself. ### Amounts @@ -192,7 +196,7 @@ Retrying a create-payment call with the same `idempotencyKey` is safe: the store ## Receiving the callback -Tahseel registers `POST /tahseel/webhooks/{gateway}` (change it with `tahseel.webhooks.path`). Point Paymob's `notification_url` at `/tahseel/webhooks/paymob`. +Paykit registers `POST /paykit/webhooks/{gateway}` (change it with `paykit.webhooks.path`). Point Paymob's `notification_url` at `/paykit/webhooks/paymob`. The controller: @@ -202,13 +206,13 @@ The controller: ```php use Illuminate\Support\Facades\Event; -use Tahseel\Events\PaymentSucceeded; +use Paykit\Events\PaymentSucceeded; Event::listen(function (PaymentSucceeded $event) { $event->event->reference; // 'ORDER-1042' $event->event->amount->minor; // 25000 $event->event->transactionId; // Paymob transaction id - $event->event->status; // Tahseel\Enums\PaymentStatus + $event->event->status; // Paykit\Enums\PaymentStatus }); ``` @@ -223,23 +227,23 @@ Event::listen(function (PaymentSucceeded $event) { ### Duplicates and out-of-order callbacks -Gateways retry. Paymob retries a callback until it gets a `200`, Kashier and Fawry do the same, so the same transaction will reach you more than once. Tahseel handles that before any event fires: +Gateways retry. Paymob retries a callback until it gets a `200`, Kashier and Fawry do the same, so the same transaction will reach you more than once. Paykit handles that before any event fires: -- **Duplicate** - the same transaction (or, when the callback carries no transaction id, the same payload) is only dispatched once. The repeat gets `{"status":"duplicate"}`. Keys are kept for `tahseel.webhooks.dedupe_ttl` seconds (two days by default). +- **Duplicate** - the same transaction (or, when the callback carries no transaction id, the same payload) is only dispatched once. The repeat gets `{"status":"duplicate"}`. Keys are kept for `paykit.webhooks.dedupe_ttl` seconds (two days by default). - **Out of order** - a callback whose timestamp is older than one already handled for the same order is dropped with `{"status":"stale"}`. A retried `PENDING` landing after the `SUCCEEDED` will not move the order back. A callback with no readable timestamp is never treated as stale. Both need a shared cache when you run more than one server. Point them at one store: ```php 'webhooks' => [ - 'deduplicate' => env('TAHSEEL_WEBHOOKS_DEDUPLICATE', true), - 'ordering' => env('TAHSEEL_WEBHOOKS_ORDERING', true), - 'store' => env('TAHSEEL_WEBHOOKS_STORE'), // null = the app's default cache store - 'dedupe_ttl' => (int) env('TAHSEEL_WEBHOOKS_DEDUPE_TTL', 172800), + 'deduplicate' => env('PAYKIT_WEBHOOKS_DEDUPLICATE', true), + 'ordering' => env('PAYKIT_WEBHOOKS_ORDERING', true), + 'store' => env('PAYKIT_WEBHOOKS_STORE'), // null = the app's default cache store + 'dedupe_ttl' => (int) env('PAYKIT_WEBHOOKS_DEDUPE_TTL', 172800), ], ``` -Turn either check off if your own code already reconciles order state. Returning `200` to a dropped callback is deliberate: a non-2xx makes the gateway retry a callback Tahseel will drop again. +Turn either check off if your own code already reconciles order state. Returning `200` to a dropped callback is deliberate: a non-2xx makes the gateway retry a callback Paykit will drop again. ### Never trust the redirect @@ -247,7 +251,7 @@ Turn either check off if your own code already reconciles order state. Returning ### If your webhook route lives in the `api` group -Add the middleware in `config/tahseel.php`: +Add the middleware in `config/paykit.php`: ```php 'webhooks' => [ @@ -261,21 +265,21 @@ Add the middleware in `config/tahseel.php`: Refunds, voids and captures are their own contracts, `SupportsRefunds`, `SupportsVoids` and `SupportsCapture`, so a driver only claims what its gateway really documents. ```php -use Tahseel\Data\Money; -use Tahseel\Data\RefundRequest; -use Tahseel\Data\VoidRequest; -use Tahseel\Facades\Tahseel; +use Paykit\Data\Money; +use Paykit\Data\RefundRequest; +use Paykit\Data\VoidRequest; +use Paykit\Facades\Paykit; // Full refund of a Paymob transaction. The id comes from the callback. -$result = Tahseel::refund(RefundRequest::forTransaction('555123456'), 'paymob'); +$result = Paykit::refund(RefundRequest::forTransaction('555123456'), 'paymob'); // Partial refund of a Kashier order. -$result = Tahseel::refund(RefundRequest::forOrder($orderId, Money::of('100.00'), 'customer asked'), 'kashier'); +$result = Paykit::refund(RefundRequest::forOrder($orderId, Money::of('100.00'), 'customer asked'), 'kashier'); // Void a payment before it settles. -$result = Tahseel::void(VoidRequest::forTransaction('555123456'), 'paymob'); +$result = Paykit::void(VoidRequest::forTransaction('555123456'), 'paymob'); -$result->status; // Tahseel\Enums\PaymentStatus +$result->status; // Paykit\Enums\PaymentStatus $result->succeeded(); // true, false, or false while pending ``` @@ -308,25 +312,25 @@ $result->succeeded(); // true, false, or false while pending The details that bite: -- **A driver that cannot do it says so.** `Tahseel::refund()` and `Tahseel::void()` raise `UnsupportedOperationException` for a gateway that does not implement the contract, rather than sending something plausible. +- **A driver that cannot do it says so.** `Paykit::refund()` and `Paykit::void()` raise `UnsupportedOperationException` for a gateway that does not implement the contract, rather than sending something plausible. - **Fawry and Geidea need the amount even for a full refund.** Neither API has a "refund whatever is left" call, so pass `Money` on the request. - **Fawry's void is its Cancel Unpaid Order API.** It only works while the order is unpaid, and it is signed in a different order from a refund: `orderRefNo + merchantAccount + lang + secureKey`. - **Kashier serves order operations from a different host.** `https://fep.kashier.io` (`https://test-fep.kashier.io` in test), not the payment sessions host. Set `KASHIER_OPERATION_BASE_URL` if Kashier moves it. -- **Paymob's refund, void and capture endpoints sit on the acceptance API.** Tahseel sends the secret key as `Authorization: Token ...` and, when `PAYMOB_API_KEY` is set, also mints the short-lived `auth_token` those endpoints accept in the body. +- **Paymob's refund, void and capture endpoints sit on the acceptance API.** Paykit sends the secret key as `Authorization: Token ...` and, when `PAYMOB_API_KEY` is set, also mints the short-lived `auth_token` those endpoints accept in the body. ### Capture Capture is the second half of an auth/capture flow: the authorization holds the money on the customer's card, the capture moves it to you. Paymob is the only driver that documents it, and only for cards. ```php -use Tahseel\Data\CaptureRequest; -use Tahseel\Data\Money; +use Paykit\Data\CaptureRequest; +use Paykit\Data\Money; // Take the whole authorized amount. The id is the auth transaction's id. -$result = Tahseel::capture(CaptureRequest::forTransaction('555123456'), 'paymob'); +$result = Paykit::capture(CaptureRequest::forTransaction('555123456'), 'paymob'); // Take part of it. -$result = Tahseel::capture(CaptureRequest::forTransaction('555123456', Money::of('100.00')), 'paymob'); +$result = Paykit::capture(CaptureRequest::forTransaction('555123456', Money::of('100.00')), 'paymob'); ``` What Paymob will not let you do: @@ -334,7 +338,7 @@ What Paymob will not let you do: - **Only a card authorization can be captured.** Paymob documents capture for the card method with the Auth transaction type, so the payment has to be created against an integration configured as Auth, not a normal sale integration. - **Capture before the authorization expires.** An authorization is a hold with a deadline. Once it lapses there is nothing left to capture, and the money goes back to the customer. - **A partial capture cannot exceed the authorized amount.** Capture the rest while the authorization is still live, or let the remainder go. -- **Every other driver refuses.** `Tahseel::capture()` raises `UnsupportedOperationException` for Kashier, Fawry and Geidea, which document no capture step. +- **Every other driver refuses.** `Paykit::capture()` raises `UnsupportedOperationException` for Kashier, Fawry and Geidea, which document no capture step. ## Kashier @@ -344,27 +348,27 @@ KASHIER_SECRET_KEY=ksk_test_... KASHIER_PAYMENT_API_KEY=pk_test_... KASHIER_MERCHANT_ID=MID-1234-567 KASHIER_ALLOWED_METHODS=card,wallet -KASHIER_WEBHOOK_URL=https://your-app.test/tahseel/webhooks/kashier +KASHIER_WEBHOOK_URL=https://your-app.test/paykit/webhooks/kashier KASHIER_REDIRECT_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('kashier')->createPayment($request); +$session = Paykit::gateway('kashier')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` Three Kashier details worth knowing: -- **Amounts are decimal strings.** Kashier takes `"250.00"`, not piastres. Tahseel formats the integer amount into a decimal string, so a 19.99 EGP payment is sent as `"19.99"` and never becomes `19.989999`. -- **The signature is in a header.** Kashier signs each webhook with HMAC-SHA256 keyed by your Payment API Key, over the keys it lists in the payload's own `signatureKeys` array, sorted and URL-encoded. Tahseel verifies `x-kashier-signature` before parsing anything. +- **Amounts are decimal strings.** Kashier takes `"250.00"`, not piastres. Paykit formats the integer amount into a decimal string, so a 19.99 EGP payment is sent as `"19.99"` and never becomes `19.989999`. +- **The signature is in a header.** Kashier signs each webhook with HMAC-SHA256 keyed by your Payment API Key, over the keys it lists in the payload's own `signatureKeys` array, sorted and URL-encoded. Paykit verifies `x-kashier-signature` before parsing anything. - **The redirect is signed too.** Every query parameter except `signature` and `mode`, in the order received: ```php -use Tahseel\Gateways\Kashier\KashierSignature; +use Paykit\Gateways\Kashier\KashierSignature; $query = $request->query(); -$isGenuine = KashierSignature::verifyRedirect($query, $query['signature'] ?? null, config('tahseel.drivers.kashier.api_key')); +$isGenuine = KashierSignature::verifyRedirect($query, $query['signature'] ?? null, config('paykit.drivers.kashier.api_key')); ``` Kashier's `api-key` header is the **Payment API Key**; `Authorization` takes the **Secret Key** raw, with no `Bearer` prefix. The two are not interchangeable, and each mode (test, live) has its own pair. @@ -380,11 +384,11 @@ FAWRY_MERCHANT_CODE=1tSa6uxz2nTwlaAmt38enA== FAWRY_SECURE_KEY=... FAWRY_PAYMENT_METHOD=PayAtFawry FAWRY_LANGUAGE=en-gb -FAWRY_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/fawry +FAWRY_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/fawry ``` ```php -$session = Tahseel::gateway('fawry')->createPayment($request); +$session = Paykit::gateway('fawry')->createPayment($request); // Show these to the customer. There is no checkout URL to redirect to. $session->paymentReference; // "9001234567" @@ -395,13 +399,13 @@ $session->checkoutUrl; // null Three Fawry details worth knowing: - **Signing is plain SHA-256, not HMAC.** The digest is over `merchantCode + merchantRefNum + customerProfileId (empty when absent) + paymentMethod + amount with two decimals + secureKey`. The secure key is concatenated, not used as a key. Using `hash_hmac` here produces a different digest and Fawry rejects every request. -- **Notifications are signed the same way** and arrive as `messageSignature`, over `fawryRefNumber + merchantRefNumber + paymentAmount + orderAmount + orderStatus + paymentMethod + paymentRefrenceNumber + secureKey`. Both amounts are hashed with two decimals, and the payment reference is empty on the order-creation notification. Tahseel verifies this before parsing and maps `orderStatus`: `PAID` succeeded, `REFUNDED` and `PARTIAL_REFUNDED` refunded, `CANCELED`, `EXPIRED` and `FAILED` failed, `NEW` pending. -- **The callback URL is registered with Fawry, not sent per order.** Fawry's operations team sets it at merchant setup; Tahseel also sends it as `orderWebHookUrl` so a per-order override still works. +- **Notifications are signed the same way** and arrive as `messageSignature`, over `fawryRefNumber + merchantRefNumber + paymentAmount + orderAmount + orderStatus + paymentMethod + paymentRefrenceNumber + secureKey`. Both amounts are hashed with two decimals, and the payment reference is empty on the order-creation notification. Paykit verifies this before parsing and maps `orderStatus`: `PAID` succeeded, `REFUNDED` and `PARTIAL_REFUNDED` refunded, `CANCELED`, `EXPIRED` and `FAILED` failed, `NEW` pending. +- **The callback URL is registered with Fawry, not sent per order.** Fawry's operations team sets it at merchant setup; Paykit also sends it as `orderWebHookUrl` so a per-order override still works. **Card and wallet payments are not implemented, deliberately.** Fawry's card charge API takes raw card numbers, which does not belong in a server-side package, and its hosted checkout init signature is not published. The MWALLET flow needs the customer's OTP mid-flight. Asking for either raises `UnsupportedOperationException`: ```php -Tahseel::gateway('fawry')->createPayment($request->withMethod('card')); // throws, loudly +Paykit::gateway('fawry')->createPayment($request->withMethod('card')); // throws, loudly ``` ## Geidea @@ -412,13 +416,13 @@ Geidea takes a create-session call and then sends the payer to its hosted checko GEIDEA_BASE_URL=https://api.merchant.geidea.net # KSA: https://api.ksamerchant.geidea.net, UAE: https://api.geidea.ae GEIDEA_PUBLIC_KEY=... GEIDEA_API_PASSWORD=... -GEIDEA_CALLBACK_URL=https://your-app.test/tahseel/webhooks/geidea +GEIDEA_CALLBACK_URL=https://your-app.test/paykit/webhooks/geidea GEIDEA_RETURN_URL=https://your-app.test/checkout/done GEIDEA_PHONE_COUNTRY_CODE=+20 ``` ```php -$session = Tahseel::gateway('geidea')->createPayment($request); +$session = Paykit::gateway('geidea')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -426,8 +430,8 @@ return redirect()->away($session->checkoutUrl); Three Geidea details worth knowing: - **The public key is the Basic auth username.** Every create-session request is authenticated with `base64(publicKey:apiPassword)` and signed with HMAC-SHA256 keyed by the API password, over `publicKey + amount with two decimals + currency + merchantReferenceId + timestamp`. The timestamp is `Y/m/d H:i:s`; set `GEIDEA_TIMEZONE` when the app timezone is not the one you want signed. -- **Callbacks are signed over the `order` object, not the whole payload.** The digest covers `merchantPublicKey + amount + currency + orderId + status + merchantReferenceId + timeStamp`, base64 encoded. Tahseel verifies `signature` before parsing anything. Geidea asks merchants to trust a payment only when the status is `Success` and both response codes are `000`, so a `Success` with any other code is reported as failed. -- **`merchantReferenceId` is your payment reference.** Geidea's API reference describes the field as a UUID, while its own checkout guide example sends a plain merchant reference. Tahseel sends your reference unchanged so the callback matches your order; if your account rejects a non-UUID reference, pass a UUID as the `PaymentRequest` reference. +- **Callbacks are signed over the `order` object, not the whole payload.** The digest covers `merchantPublicKey + amount + currency + orderId + status + merchantReferenceId + timeStamp`, base64 encoded. Paykit verifies `signature` before parsing anything. Geidea asks merchants to trust a payment only when the status is `Success` and both response codes are `000`, so a `Success` with any other code is reported as failed. +- **`merchantReferenceId` is your payment reference.** Geidea's API reference describes the field as a UUID, while its own checkout guide example sends a plain merchant reference. Paykit sends your reference unchanged so the callback matches your order; if your account rejects a non-UUID reference, pass a UUID as the `PaymentRequest` reference. Which methods the hosted page offers is decided by your Geidea account, so `PaymentRequest::$method` is ignored by this driver. @@ -440,22 +444,22 @@ MYFATOORAH_BASE_URL=https://api.myfatoorah.com # test: https://apitest. MYFATOORAH_API_KEY=... MYFATOORAH_WEBHOOK_SECRET=... MYFATOORAH_CALLBACK_URL=https://your-app.test/checkout/done -MYFATOORAH_WEBHOOK_URL=https://your-app.test/tahseel/webhooks/myfatoorah +MYFATOORAH_WEBHOOK_URL=https://your-app.test/paykit/webhooks/myfatoorah ``` ```php -$session = Tahseel::gateway('myfatoorah')->createPayment($request); +$session = Paykit::gateway('myfatoorah')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` Three MyFatoorah details worth knowing: -- **Amounts are in major units.** MyFatoorah takes `250.00` KWD, not fils. Tahseel formats your integer amount into a decimal number, so a 19.99 payment never becomes `19.989999`. -- **Every call is a POST with a Bearer token, and failures hide in a 200.** MyFatoorah answers errors with HTTP 200 and `IsSuccess: false` in the body; Tahseel checks the flag, not only the status code. -- **The webhook signature covers a documented field list.** Each v2 event type signs its own ordered `Key=Value` list with your webhook secret (HMAC-SHA-256, base64) in the `myfatoorah-signature` header. Tahseel rebuilds that string from the payload and verifies before parsing, and refuses an event type or transaction status it does not recognise instead of guessing. +- **Amounts are in major units.** MyFatoorah takes `250.00` KWD, not fils. Paykit formats your integer amount into a decimal number, so a 19.99 payment never becomes `19.989999`. +- **Every call is a POST with a Bearer token, and failures hide in a 200.** MyFatoorah answers errors with HTTP 200 and `IsSuccess: false` in the body; Paykit checks the flag, not only the status code. +- **The webhook signature covers a documented field list.** Each v2 event type signs its own ordered `Key=Value` list with your webhook secret (HMAC-SHA-256, base64) in the `myfatoorah-signature` header. Paykit rebuilds that string from the payload and verifies before parsing, and refuses an event type or transaction status it does not recognise instead of guessing. -A refund through `Tahseel::refund()` is a **request** MyFatoorah's finance team executes, so the result comes back pending and the completion arrives as a `REFUND_STATUS_CHANGED` webhook. +A refund through `Paykit::refund()` is a **request** MyFatoorah's finance team executes, so the result comes back pending and the completion arrives as a `REFUND_STATUS_CHANGED` webhook. ## Tap @@ -465,11 +469,11 @@ Tap covers Saudi Arabia, Kuwait, the UAE and the rest of the Gulf. The flow is a TAP_BASE_URL=https://api.tap.payments # one host; sk_test_... vs sk_live_... decides the mode TAP_SECRET_KEY=sk_test_... TAP_REDIRECT_URL=https://your-app.test/checkout/done -TAP_WEBHOOK_URL=https://your-app.test/tahseel/webhooks/tap +TAP_WEBHOOK_URL=https://your-app.test/paykit/webhooks/tap ``` ```php -$session = Tahseel::gateway('tap')->createPayment($request); +$session = Paykit::gateway('tap')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -477,7 +481,7 @@ return redirect()->away($session->checkoutUrl); Three Tap details worth knowing: - **One secret key does everything.** It is the Bearer token on every API call and the key that signs webhooks, in the `hashstring` header. -- **The signed amount is currency-formatted.** The `hashstring` recipe formats the amount to the currency's ISO 4217 scale before hashing: `2.00` for SAR but `2.000` for KWD, BHD, OMR and JOD, and a missing gateway reference keeps its label with an empty value. Tahseel rebuilds that string exactly; a naive verifier that hashes the raw JSON amount rejects every real KWD webhook. +- **The signed amount is currency-formatted.** The `hashstring` recipe formats the amount to the currency's ISO 4217 scale before hashing: `2.00` for SAR but `2.000` for KWD, BHD, OMR and JOD, and a missing gateway reference keeps its label with an empty value. Paykit rebuilds that string exactly; a naive verifier that hashes the raw JSON amount rejects every real KWD webhook. - **Refunds need the amount.** Tap's refund API takes a `charge_id` and an amount (there is no "refund whatever is left" call), and its reason is an enum: a free-text reason maps onto `requested_by_customer`. ## HyperPay @@ -493,7 +497,7 @@ HYPERPAY_SHOPPER_RESULT_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('hyperpay')->createPayment($request); +$session = Paykit::gateway('hyperpay')->createPayment($request); // HyperPay embeds a widget: the session's checkoutUrl is the widget script, // and intentionId is the checkout id your page's form uses. @@ -502,7 +506,7 @@ $session = Tahseel::gateway('hyperpay')->createPayment($request); Three HyperPay details worth knowing: - **The webhook is encrypted, and the encryption is the signature.** Every delivery is AES-256-GCM with the 64-character hex secret you configure on the webhook; the IV and authentication tag arrive in headers. A forged or tampered body fails to decrypt, so verification is `openssl_decrypt` or nothing. Configure the webhook in the back office (Administration -> Webhooks), test it there and activate it. -- **Status comes from result codes, not a status word.** Tahseel maps the documented families: `000.000.*`, `000.100.1**`, `000.3**`, `000.6**` and the `000.400.0**`/`000.400.100` "review manually" codes are success; `000.200.**` and the two async-review groups are pending; everything else fails closed. +- **Status comes from result codes, not a status word.** Paykit maps the documented families: `000.000.*`, `000.100.1**`, `000.3**`, `000.6**` and the `000.400.0**`/`000.400.100` "review manually" codes are success; `000.200.**` and the two async-review groups are pending; everything else fails closed. - **Refunds are backoffice calls.** `POST /v1/payments/{id}` with `paymentType=RF` and an amount; there is no full-refund shortcut. ## Checkout.com @@ -517,16 +521,16 @@ CHECKOUTCOM_SUCCESS_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('checkoutcom')->createPayment($request); +$session = Paykit::gateway('checkoutcom')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` Three Checkout.com details worth knowing: -- **Amounts are integers in the minor unit.** `25000` is 250.00 SAR. Tahseel sends the integer amount directly, so a 19.99 payment never becomes `19.989999`. -- **The signature covers the raw body, byte for byte.** `Cko-Signature` is HMAC-SHA-256 (hex) keyed by the webhook's signature key over the exact bytes received; re-serialising the JSON before verifying breaks every signature. Tahseel verifies the raw body, then parses. -- **A refund is accepted, not completed.** The API answers 202 with an action id; the completion arrives as a `payment_refunded` webhook, so `Tahseel::refund()` reports pending. Event types the driver does not map (disputes, card verification) are refused, never guessed. +- **Amounts are integers in the minor unit.** `25000` is 250.00 SAR. Paykit sends the integer amount directly, so a 19.99 payment never becomes `19.989999`. +- **The signature covers the raw body, byte for byte.** `Cko-Signature` is HMAC-SHA-256 (hex) keyed by the webhook's signature key over the exact bytes received; re-serialising the JSON before verifying breaks every signature. Paykit verifies the raw body, then parses. +- **A refund is accepted, not completed.** The API answers 202 with an action id; the completion arrives as a `payment_refunded` webhook, so `Paykit::refund()` reports pending. Event types the driver does not map (disputes, card verification) are refused, never guessed. ## PayPal @@ -541,19 +545,19 @@ PAYPAL_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('paypal')->createPayment($request); +$session = Paykit::gateway('paypal')->createPayment($request); return redirect()->away($session->checkoutUrl); // PayPal's approve page // On the return URL, capture the approved order (the query's `token` is the order id): -$result = Tahseel::gateway('paypal')->capture(CaptureRequest::forTransaction($request->query('token'))); +$result = Paykit::gateway('paypal')->capture(CaptureRequest::forTransaction($request->query('token'))); ``` Four PayPal details worth knowing: -- **Capture is a second, required call.** An approved order moves no money until you capture it; `CHECKOUT.ORDER.APPROVED` webhooks stay pending in Tahseel for exactly that reason. PayPal captures the full approved amount, so a partial capture is refused rather than silently taking more. +- **Capture is a second, required call.** An approved order moves no money until you capture it; `CHECKOUT.ORDER.APPROVED` webhooks stay pending in Paykit for exactly that reason. PayPal captures the full approved amount, so a partial capture is refused rather than silently taking more. - **PayPal is its own webhook verifier.** There is no local HMAC recipe to get wrong: the five `PAYPAL-TRANSMISSION-*` headers plus the received event go back to PayPal's `verify-webhook-signature` endpoint, and only `SUCCESS` is accepted. The webhook id from the Developer dashboard is part of that check. -- **Amounts are decimal strings, not integers.** `"250.00"` USD. Tahseel formats from minor units, so 19.99 never arrives as `19.989999`. +- **Amounts are decimal strings, not integers.** `"250.00"` USD. Paykit formats from minor units, so 19.99 never arrives as `19.989999`. - **No EGP, no Gulf currencies.** PayPal's supported-currency list is 24 currencies (USD, EUR, GBP and similar); Egyptian and Gulf merchants charge in a supported currency and PayPal converts into the account balance. For local EGP collection the Egyptian drivers remain the answer. A refund addresses the capture id, not the order id; an empty amount refunds whatever is left, an amount is a partial refund. Fixture-tested only, no live PayPal account has run it yet. @@ -569,15 +573,15 @@ STRIPE_SUCCESS_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('stripe')->createPayment($request); +$session = Paykit::gateway('stripe')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` Four Stripe details worth knowing: -- **The signature recipe is public, and Tahseel follows it to the letter.** `Stripe-Signature` carries `t=` plus one or more `v1=` signatures; the expected value is HMAC-SHA-256 of `{t}.{raw body}` keyed by the endpoint's `whsec_` secret, compared in constant time. Other schemes are discarded (v0 is Stripe's documented test-only scheme, so ignoring it is the documented downgrade protection), and a signed timestamp older than five minutes is rejected as a replay. -- **A completed session is not always money.** `checkout.session.completed` fires for async methods before the funds move; Tahseel reads the documented `payment_status` and reports pending unless it is `paid`. +- **The signature recipe is public, and Paykit follows it to the letter.** `Stripe-Signature` carries `t=` plus one or more `v1=` signatures; the expected value is HMAC-SHA-256 of `{t}.{raw body}` keyed by the endpoint's `whsec_` secret, compared in constant time. Other schemes are discarded (v0 is Stripe's documented test-only scheme, so ignoring it is the documented downgrade protection), and a signed timestamp older than five minutes is rejected as a replay. +- **A completed session is not always money.** `checkout.session.completed` fires for async methods before the funds move; Paykit reads the documented `payment_status` and reports pending unless it is `paid`. - **Amounts are minor units again.** `25000` is 250.00 USD, sent as an integer - the same convention as the Egyptian drivers. - **Availability is the real limit.** Stripe merchant accounts are not available in Egypt or most of the Gulf (the UAE is the exception on stripe.com/global). The driver serves the package's international audience; Egyptian merchants keep the local drivers. @@ -594,14 +598,14 @@ PAYSTACK_CALLBACK_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('paystack')->createPayment($request); +$session = Paykit::gateway('paystack')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` Four Paystack details worth knowing: -- **The email is the API's demand, not Tahseel's.** `POST /transaction/initialize` requires the customer's email, so the driver refuses a request without one instead of letting the API reject it. +- **The email is the API's demand, not Paykit's.** `POST /transaction/initialize` requires the customer's email, so the driver refuses a request without one instead of letting the API reject it. - **Two documented signature schemes, both honoured.** The current `Paystack-Signature` header carries `t=` and `v1=` entries; the expected value is HMAC-SHA-512 of `{t}.{raw body}` keyed by the dashboard's `whsec_` signing secret, with the documented 300-second replay tolerance. Webhooks still arriving with the legacy `x-paystack-signature` (plain HMAC-SHA-512 of the raw body under the API secret key) verify against the secret key instead. - **The reference is the handle.** Verification after the redirect is `GET /transaction/verify/{reference}`, exposed as `verifyTransactionStatus()`, and refunds address the same reference. - **A refund is a queue, not a verdict.** `POST /refund` answers 200 with the refund pending; the money settles when a `refund.processed` (or `refund.failed`) webhook lands, so the driver reports Pending and lets the webhook flip the state. @@ -619,15 +623,15 @@ MOYASAR_CALLBACK_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('moyasar')->createPayment($request); +$session = Paykit::gateway('moyasar')->createPayment($request); return redirect()->away($session->checkoutUrl); // the 3DS challenge ``` Five Moyasar details worth knowing: -- **There is no hosted page.** Moyasar's model is embed-the-form or direct API, so a card payment carries the card the customer entered in `extras.card` (name, number, month, year, cvc) - your page's PCI scope, not Tahseel's. When the payment comes back `initiated`, `source.transaction_url` is the documented 3DS challenge; that is the session's checkout url. -- **STC Pay is a source type, not a redirect.** `method: 'stcpay'` with `extras.mobile` (05xxxxxxxx, +9665... or 009665...) creates the payment and the customer completes it by OTP on their phone; there is no checkout url. The OTP proceed step (`POST /stc_pays/{id}/proceed`) is documented but interactive, so Tahseel creates the payment and leaves the OTP step to your UI for now. +- **There is no hosted page.** Moyasar's model is embed-the-form or direct API, so a card payment carries the card the customer entered in `extras.card` (name, number, month, year, cvc) - your page's PCI scope, not Paykit's. When the payment comes back `initiated`, `source.transaction_url` is the documented 3DS challenge; that is the session's checkout url. +- **STC Pay is a source type, not a redirect.** `method: 'stcpay'` with `extras.mobile` (05xxxxxxxx, +9665... or 009665...) creates the payment and the customer completes it by OTP on their phone; there is no checkout url. The OTP proceed step (`POST /stc_pays/{id}/proceed`) is documented but interactive, so Paykit creates the payment and leaves the OTP step to your UI for now. - **You name the payment id.** The documented `given_id` (a UUID you generate) becomes the payment id - Moyasar's built-in idempotency. Pass your own in `extras.given_id` or the driver generates one; your merchant reference always rides in `metadata.reference` and comes back on every response and webhook. - **Webhook verification is a shared token, not a signature.** Moyasar echoes the secret token you registered in each payload's `secret_token` field; the driver compares it in constant time. That is the documented scheme - weaker than an HMAC, so serve the endpoint over HTTPS and keep the token long and random. - **Refunds are synchronous.** `POST /v1/payments/{id}/refund` flips the status to `refunded` in the response; an omitted amount refunds whatever was charged. `fetchPaymentStatus()` is the documented `GET /v1/payments/{id}` check after the callback. @@ -646,7 +650,7 @@ RAZORPAY_CALLBACK_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('razorpay')->createPayment($request); +$session = Paykit::gateway('razorpay')->createPayment($request); return redirect()->away($session->checkoutUrl); // the rzp.io short url ``` @@ -672,7 +676,7 @@ MERCADOPAGO_SUCCESS_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('mercadopago')->createPayment($request); +$session = Paykit::gateway('mercadopago')->createPayment($request); return redirect()->away($session->checkoutUrl); // the init_point ``` @@ -697,7 +701,7 @@ MOLLIE_WEBHOOK_URL=https://your-app.test/webhooks/mollie ``` ```php -$session = Tahseel::gateway('mollie')->createPayment($request); +$session = Paykit::gateway('mollie')->createPayment($request); return redirect()->away($session->checkoutUrl); // the _links.checkout href ``` @@ -723,7 +727,7 @@ ADYEN_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('adyen')->createPayment($request); +$session = Paykit::gateway('adyen')->createPayment($request); return redirect()->away($session->checkoutUrl); // the hosted checkout url ``` @@ -748,7 +752,7 @@ FLUTTERWAVE_PAYMENT_OPTIONS=card, ussd, mobilemoneyghana # optional ``` ```php -$session = Tahseel::gateway('flutterwave')->createPayment($request); +$session = Paykit::gateway('flutterwave')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -770,12 +774,12 @@ PayTabs is the tenth international driver and the Gulf's own processor: licensed PAYTABS_PROFILE_ID=987654 PAYTABS_SERVER_KEY=... # Dashboard -> Developers -> Key management PAYTABS_BASE_URL=https://secure-egypt.paytabs.com # your region's host; the wrong one fails authentication -PAYTABS_CALLBACK_URL=https://your-app.test/tahseel/webhooks/paytabs +PAYTABS_CALLBACK_URL=https://your-app.test/paykit/webhooks/paytabs PAYTABS_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('paytabs')->createPayment($request); +$session = Paykit::gateway('paytabs')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -802,12 +806,12 @@ KLARNA_PURCHASE_COUNTRY=SE KLARNA_LOCALE=en-SE KLARNA_CURRENCY=SEK KLARNA_RETURN_URL=https://your-app.test/checkout/done -KLARNA_CALLBACK_URL=https://your-app.test/tahseel/webhooks/klarna +KLARNA_CALLBACK_URL=https://your-app.test/paykit/webhooks/klarna KLARNA_CALLBACK_TOKEN=... # a long random string you generate ``` ```php -$session = Tahseel::gateway('klarna')->createPayment($request); +$session = Paykit::gateway('klarna')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -831,12 +835,12 @@ SQUARE_ACCESS_TOKEN=... # Developer Console -> SQUARE_LOCATION_ID=L88917AVBK2S5 SQUARE_SQUARE_VERSION=2026-11-18 # the API version you pin SQUARE_SIGNATURE_KEY=... # Webhooks -> your subscription -SQUARE_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/square +SQUARE_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/square SQUARE_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('square')->createPayment($request); +$session = Paykit::gateway('square')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -866,7 +870,7 @@ XENDIT_CANCEL_URL=https://your-app.test/checkout/cancelled ``` ```php -$session = Tahseel::gateway('xendit')->createPayment($request); +$session = Paykit::gateway('xendit')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -896,7 +900,7 @@ TELR_CANCELLED_URL=https://your-app.test/checkout/cancelled ``` ```php -$session = Tahseel::gateway('telr')->createPayment($request); +$session = Paykit::gateway('telr')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -926,7 +930,7 @@ VIVA_REQUEST_LANGUAGE=en-GB ``` ```php -$session = Tahseel::gateway('viva')->createPayment($request); +$session = Paykit::gateway('viva')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -950,14 +954,14 @@ PAYU_CLIENT_ID=... # from the POS in the management pa PAYU_CLIENT_SECRET=... PAYU_POS_ID=145227 PAYU_SECOND_KEY=... # the POS's second key, which signs notifications -PAYU_NOTIFY_URL=https://your-app.test/tahseel/webhooks/payu +PAYU_NOTIFY_URL=https://your-app.test/paykit/webhooks/payu PAYU_CONTINUE_URL=https://your-app.test/checkout/done PAYU_CUSTOMER_IP=127.0.0.1 PAYU_LANGUAGE=en ``` ```php -$session = Tahseel::gateway('payu')->createPayment($request); +$session = Paykit::gateway('payu')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -987,7 +991,7 @@ TABBY_FAILURE_URL=https://your-app.test/checkout/failed ``` ```php -$session = Tahseel::gateway('tabby')->createPayment($request); +$session = Paykit::gateway('tabby')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -1017,7 +1021,7 @@ TAMARA_CANCEL_URL=https://your-app.test/checkout/cancel ``` ```php -$session = Tahseel::gateway('tamara')->createPayment($request); +$session = Paykit::gateway('tamara')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -1033,18 +1037,18 @@ Fixture-tested only, no Tamara account has run it yet. ## Manual payments: Vodafone Cash and InstaPay -Vodafone Cash and InstaPay publish no merchant API, so the honest way to accept them is the way Egyptian shops already do it: the customer transfers to your wallet or InstaPay handle, quotes a reference, and you confirm the money arrived. Tahseel ships that as a driver named `manual`. +Vodafone Cash and InstaPay publish no merchant API, so the honest way to accept them is the way Egyptian shops already do it: the customer transfers to your wallet or InstaPay handle, quotes a reference, and you confirm the money arrived. Paykit ships that as a driver named `manual`. It is not a gateway, and nothing about it is automatic: a human decision settles the payment. What the package does is the boring, dangerous part once: a reference nobody can guess, an amount the customer cannot change, a private place for receipts, and the same `PaymentSucceeded` event the gateways raise. ```dotenv -TAHSEEL_VODAFONE_CASH_NUMBER=01000000000 -TAHSEEL_INSTAPAY_HANDLE=merchant@instapay -TAHSEEL_MANUAL_PANEL_ABILITY=manage-payments +PAYKIT_VODAFONE_CASH_NUMBER=01000000000 +PAYKIT_INSTAPAY_HANDLE=merchant@instapay +PAYKIT_MANUAL_PANEL_ABILITY=manage-payments ``` ```php -$session = Tahseel::createPayment($request->withMethod('vodafone_cash'), 'manual'); +$session = Paykit::createPayment($request->withMethod('vodafone_cash'), 'manual'); $session->paymentReference; // MAN-7F3K9QX2AB, the code the customer quotes $session->raw['account']; // where the money goes @@ -1054,19 +1058,19 @@ $session->raw['instructions']; // one sentence to show the customer as-is The journey: -1. **You open the payment.** `Tahseel::createPayment($request, 'manual')` writes a row and returns the reference, the account and the amount. Show them to the customer. -2. **The customer transfers and says so.** `POST /tahseel/manual/{reference}/proof` takes `transfer_reference` and an optional `proof` upload. The reference is the only credential, so it is unguessable and the route is rate limited. -3. **You decide.** `GET /tahseel/manual/panel` lists what is open, with the receipt behind an authorized link. Approving raises `PaymentSucceeded`; rejecting raises `PaymentFailed`. Both carry the amount stored on the row, never one from the form. +1. **You open the payment.** `Paykit::createPayment($request, 'manual')` writes a row and returns the reference, the account and the amount. Show them to the customer. +2. **The customer transfers and says so.** `POST /paykit/manual/{reference}/proof` takes `transfer_reference` and an optional `proof` upload. The reference is the only credential, so it is unguessable and the route is rate limited. +3. **You decide.** `GET /paykit/manual/panel` lists what is open, with the receipt behind an authorized link. Approving raises `PaymentSucceeded`; rejecting raises `PaymentFailed`. Both carry the amount stored on the row, never one from the form. -Publish the migration and migrate (`tahseel_manual_payments`); the views are publishable if you want to restyle the panel: +Publish the migration and migrate (`paykit_manual_payments`); the views are publishable if you want to restyle the panel: ```bash -php artisan vendor:publish --tag=tahseel-migrations -php artisan vendor:publish --tag=tahseel-views +php artisan vendor:publish --tag=paykit-migrations +php artisan vendor:publish --tag=paykit-views php artisan migrate ``` -**The panel is closed by default.** Its routes are registered only when `tahseel.drivers.manual.panel.ability` names a Gate ability, and every request must be a signed-in user who passes it: +**The panel is closed by default.** Its routes are registered only when `paykit.drivers.manual.panel.ability` names a Gate ability, and every request must be a signed-in user who passes it: ```php Gate::define('manage-payments', fn (User $user) => $user->is_admin); @@ -1085,12 +1089,12 @@ What the driver refuses on purpose: Everything below is off until you turn it on: nothing is on by default. - **Limits.** `methods.{method}.min_minor` and `max_minor` refuse a payment outside the range when it is created. -- **Expiry.** Schedule `php artisan tahseel:manual:expire` (for example every five minutes). Overdue payments become `expired` and raise `PaymentFailed`. A payment already waiting on a human (`awaiting_review`) is left alone unless you turn on `expire_awaiting_review`. +- **Expiry.** Schedule `php artisan paykit:manual:expire` (for example every five minutes). Overdue payments become `expired` and raise `PaymentFailed`. A payment already waiting on a human (`awaiting_review`) is left alone unless you turn on `expire_awaiting_review`. - **One transfer reference, one payment.** A reference already attached to a payment is refused on any other (the proof endpoint answers 409). Run the new migration; it adds a unique index on `transfer_reference`, so clean up duplicate references first if you have them. - **Several accounts.** Give a method `accounts` (a list of numbers) instead of `account`; each new payment goes to the one with the fewest open payments. -- **Audit trail** (`TAHSEEL_MANUAL_AUDIT=true`). An append-only log in `tahseel_manual_events` (opened, proof submitted, approved, rejected, expired) with who did it. The panel serves it at `GET {panel}/{reference}/history`. -- **Review alerts.** The `Tahseel\Events\ManualPaymentAwaitingReview` event fires when the customer sends proof. Listen to it to send a mail, Slack message or notification. Tahseel sends nothing itself. -- **Customer status** (`TAHSEEL_MANUAL_STATUS=true`). `GET /tahseel/manual/{reference}/status` returns `status`, `reference`, `amount` and `expires_at`, so your page can poll. Nothing else: no account, name or phone. +- **Audit trail** (`PAYKIT_MANUAL_AUDIT=true`). An append-only log in `paykit_manual_events` (opened, proof submitted, approved, rejected, expired) with who did it. The panel serves it at `GET {panel}/{reference}/history`. +- **Review alerts.** The `Paykit\Events\ManualPaymentAwaitingReview` event fires when the customer sends proof. Listen to it to send a mail, Slack message or notification. Paykit sends nothing itself. +- **Customer status** (`PAYKIT_MANUAL_STATUS=true`). `GET /paykit/manual/{reference}/status` returns `status`, `reference`, `amount` and `expires_at`, so your page can poll. Nothing else: no account, name or phone. - **Panel extras**, each its own switch: `panel.search` (reference, order, transfer reference, phone, name) and `panel.export` (CSV; cells that start with `=`, `+`, `-` or `@` are neutralised so a customer name cannot run as a formula). The expired filter is always there. - **`InstaPayLink::canonical($link)`** validates a `https://ipn.eg/S/{handle}` link strictly. That format comes from third-party descriptions, not from InstaPay, so compare it with a link your own app makes. An InstaPay link does not carry the amount. @@ -1098,9 +1102,9 @@ Everything below is off until you turn it on: nothing is on by default. ## Wallets, BNPL, Meeza and InstaPay -None of these is a gateway with its own public merchant API. They are payment methods the four gateways above already expose, so Tahseel reaches them the way each gateway documents: an integration ID, an allowed-method string, or whatever your merchant account has enabled. +None of these is a gateway with its own public merchant API. They are payment methods the four gateways above already expose, so Paykit reaches them the way each gateway documents: an integration ID, an allowed-method string, or whatever your merchant account has enabled. -| You want to accept | How Tahseel does it | +| You want to accept | How Paykit does it | | --- | --- | | **Vodafone Cash, Orange Cash, e& money, We Pay, bank wallets** | Paymob: a Mobile Wallet integration ID in `PAYMOB_INTEGRATION_IDS`. Kashier: `KASHIER_ALLOWED_METHODS=card,wallet`. | | **valU, Souhoola, Forsa, Aman Installments, Sympl, TRU** (BNPL) | Paymob: one integration ID per provider, enabled on your account. Kashier: `KASHIER_ALLOWED_METHODS=bnpl[valu]`, the same `method[provider]` syntax as `bank_installments[qnb]`. | @@ -1113,7 +1117,7 @@ Two things worth saying plainly: - **InstaPay has no public merchant API.** It is run by Egyptian Banks Company, onboarding goes through your bank or an acquirer, and the wallet-to-wallet rails are not exposed as a documented HTTP API for third-party merchants. - **Vodafone Cash and the other wallets are the same story at the source.** Access is through an aggregator, a bank or a PSP, not a public developer API. The gateways above are that route. -So Tahseel ships no gateway driver for any of them and will not pretend to. Where you have no gateway account at all, the [manual driver](#manual-payments-vodafone-cash-and-instapay) is the route: a transfer to your own wallet or InstaPay handle, confirmed by a human. If one of these companies publishes a merchant API of its own, a driver is a `Tahseel\Contracts\Gateway` implementation away. +So Paykit ships no gateway driver for any of them and will not pretend to. Where you have no gateway account at all, the [manual driver](#manual-payments-vodafone-cash-and-instapay) is the route: a transfer to your own wallet or InstaPay handle, confirmed by a human. If one of these companies publishes a merchant API of its own, a driver is a `Paykit\Contracts\Gateway` implementation away. ## What is not supported yet @@ -1128,34 +1132,34 @@ Being explicit, so nobody discovers it in production: - **No Viva.com refunds or transaction re-read.** Viva documents refunds elsewhere, and its docs point at the webhook fields (order code, transaction id, status, amount) rather than a re-read, which is what the driver checks. - **No Telr refunds.** Telr documents refunds on a different product surface, so the driver takes payments and reads status only rather than claiming a refund path it has not been grounded in. - **No Xendit payment re-read.** Xendit documents a callback token rather than an HMAC for this flow, and the driver does not fetch the payment afterwards; if you want a second look before fulfilling, call Xendit's own API from your application. -- **No Square capture or voids.** Square's Payments API can complete a delayed capture; Tahseel wraps refunds only, so an `APPROVED` payment stays pending here. -- **No Klarna capture or order reads.** Klarna's Order Management API also captures and reads orders; Tahseel wraps refunds only, and the place-order step is left to `placeOrder()`. -- **Null handling in HMAC is a best guess.** Paymob does not document how it stringifies a `null` field. Tahseel treats `null` as an empty string, the PHP default. If a callback with a null signed field ever fails verification, capture the raw payload and check it against Paymob's HMAC troubleshooter. +- **No Square capture or voids.** Square's Payments API can complete a delayed capture; Paykit wraps refunds only, so an `APPROVED` payment stays pending here. +- **No Klarna capture or order reads.** Klarna's Order Management API also captures and reads orders; Paykit wraps refunds only, and the place-order step is left to `placeOrder()`. +- **Null handling in HMAC is a best guess.** Paymob does not document how it stringifies a `null` field. Paykit treats `null` as an empty string, the PHP default. If a callback with a null signed field ever fails verification, capture the raw payload and check it against Paymob's HMAC troubleshooter. - **No automatic retries.** A timeout surfaces as a `GatewayException` that says the outcome is unknown. Retry a create-payment call with the same idempotency key; do not blind-retry a refund. ## Custom gateways ```php -use Tahseel\Facades\Tahseel; +use Paykit\Facades\Paykit; -Tahseel::extend('fawry', fn ($app) => new FawryGateway($app['config']['tahseel.drivers.fawry'])); +Paykit::extend('fawry', fn ($app) => new FawryGateway($app['config']['paykit.drivers.fawry'])); ``` -A driver implements `Tahseel\Contracts\Gateway`: `name()`, `createPayment()` and `verifyAndParseWebhook()`. +A driver implements `Paykit\Contracts\Gateway`: `name()`, `createPayment()` and `verifyAndParseWebhook()`. -Refunds, voids and captures are separate optional contracts. Implement `SupportsRefunds`, `SupportsVoids` or `SupportsCapture` on your driver and `Tahseel::refund()`, `Tahseel::void()` and `Tahseel::capture()` reach it; a driver that does not implement one keeps raising `UnsupportedOperationException` for it. +Refunds, voids and captures are separate optional contracts. Implement `SupportsRefunds`, `SupportsVoids` or `SupportsCapture` on your driver and `Paykit::refund()`, `Paykit::void()` and `Paykit::capture()` reach it; a driver that does not implement one keeps raising `UnsupportedOperationException` for it. ## Testing -### Testing your own checkout with `Tahseel::fake()` +### Testing your own checkout with `Paykit::fake()` -Your application's tests should not need gateway credentials or a network. `Tahseel::fake()` swaps every driver for a recording stand-in: `createPayment` answers with a session on a clearly fake URL, refunds, voids and captures answer success, and every call is recorded for assertions. +Your application's tests should not need gateway credentials or a network. `Paykit::fake()` swaps every driver for a recording stand-in: `createPayment` answers with a session on a clearly fake URL, refunds, voids and captures answer success, and every call is recorded for assertions. ```php -use Tahseel\Facades\Tahseel; +use Paykit\Facades\Paykit; it('starts a Paymob payment for a new order', function () { - $fake = Tahseel::fake(); + $fake = Paykit::fake(); $this->post('/checkout', ['cart' => 'ORDER-77'])->assertRedirect(); diff --git a/SECURITY.md b/SECURITY.md index 09f1412..9de8c64 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,7 +4,7 @@ Email **ahmed@elbanby.com** with the details. Please do not open a public issue for anything that could put a merchant's payments at risk. Expect an answer within a few days. -## What Tahseel assumes +## What Paykit assumes - Gateway secrets (`secret_key`, `hmac_secret`) stay on the server and out of logs. Only `public_key` is safe in a browser. - A callback is untrusted until its signature verifies. The webhook endpoint verifies before it dispatches anything, and it compares digests in constant time. @@ -14,4 +14,4 @@ Email **ahmed@elbanby.com** with the details. Please do not open a public issue ## Known limits - Replay protection is cache based. If the cache is flushed between two deliveries of the same callback, the transaction is processed twice. Make your listener idempotent as well. -- Tahseel does not rate-limit the webhook endpoint. Put it behind your usual middleware if that matters to you. +- Paykit does not rate-limit the webhook endpoint. Put it behind your usual middleware if that matters to you. diff --git a/composer.json b/composer.json index 626faca..e1bc435 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "elbanbydev/tahseel", - "description": "Tahseel (تحصيل) - a clean, framework-native Laravel package for payment gateways: Paymob, Kashier, Fawry, Geidea, MyFatoorah, Tap, HyperPay, Checkout.com, PayPal, Stripe, Paystack, Moyasar, Razorpay, Mercado Pago, Mollie, Adyen, Flutterwave, PayTabs, Klarna, Square, Xendit, Telr, Viva.com, PayU, Tabby, Tamara and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.", + "name": "elbanbydev/paykit", + "description": "Paykit - a clean, framework-native Laravel package for payment gateways: Paymob, Kashier, Fawry, Geidea, MyFatoorah, Tap, HyperPay, Checkout.com, PayPal, Stripe, Paystack, Moyasar, Razorpay, Mercado Pago, Mollie, Adyen, Flutterwave, PayTabs, Klarna, Square, Xendit, Telr, Viva.com, PayU, Tabby, Tamara and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.", "keywords": [ "laravel", "payments", @@ -18,7 +18,7 @@ "egp", "payment-gateway", "fintech", - "tahseel", + "paykit", "paystack", "moyasar", "stc pay", @@ -92,21 +92,21 @@ }, "autoload": { "psr-4": { - "Tahseel\\": "src/" + "Paykit\\": "src/" } }, "autoload-dev": { "psr-4": { - "Tahseel\\Tests\\": "tests/" + "Paykit\\Tests\\": "tests/" } }, "extra": { "laravel": { "providers": [ - "Tahseel\\TahseelServiceProvider" + "Paykit\\PaykitServiceProvider" ], "aliases": { - "Tahseel": "Tahseel\\Facades\\Tahseel" + "Paykit": "Paykit\\Facades\\Paykit" } } }, diff --git a/config/tahseel.php b/config/paykit.php similarity index 94% rename from config/tahseel.php rename to config/paykit.php index c4be5e5..0a17df8 100644 --- a/config/tahseel.php +++ b/config/paykit.php @@ -9,12 +9,12 @@ | Default gateway |-------------------------------------------------------------------------- | - | The driver used when you call Tahseel::createPayment() or resolve a + | The driver used when you call Paykit::createPayment() or resolve a | gateway without naming one. | */ - 'default' => env('TAHSEEL_GATEWAY', 'paymob'), + 'default' => env('PAYKIT_GATEWAY', 'paymob'), /* |-------------------------------------------------------------------------- @@ -28,9 +28,9 @@ */ 'idempotency' => [ - 'enabled' => env('TAHSEEL_IDEMPOTENCY', true), - 'store' => env('TAHSEEL_IDEMPOTENCY_STORE'), - 'ttl' => (int) env('TAHSEEL_IDEMPOTENCY_TTL', 86400), + 'enabled' => env('PAYKIT_IDEMPOTENCY', true), + 'store' => env('PAYKIT_IDEMPOTENCY_STORE'), + 'ttl' => (int) env('PAYKIT_IDEMPOTENCY_TTL', 86400), ], /* @@ -38,9 +38,9 @@ | Webhooks |-------------------------------------------------------------------------- | - | Tahseel registers POST {path} (default: tahseel/webhooks/{gateway}). + | Paykit registers POST {path} (default: paykit/webhooks/{gateway}). | Point Paymob's notification_url at it, e.g. - | https://your-app.com/tahseel/webhooks/paymob + | https://your-app.com/paykit/webhooks/paymob | | The route is registered on the application's route stack; if you keep | webhook routes inside the `api` middleware group, add that group here. @@ -48,16 +48,16 @@ */ 'webhooks' => [ - 'enabled' => env('TAHSEEL_WEBHOOKS', true), - 'path' => env('TAHSEEL_WEBHOOKS_PATH', 'tahseel/webhooks/{gateway}'), + 'enabled' => env('PAYKIT_WEBHOOKS', true), + 'path' => env('PAYKIT_WEBHOOKS_PATH', 'paykit/webhooks/{gateway}'), 'middleware' => [], - 'deduplicate' => env('TAHSEEL_WEBHOOKS_DEDUPLICATE', true), + 'deduplicate' => env('PAYKIT_WEBHOOKS_DEDUPLICATE', true), // Drop a callback that is older than one already handled for the same // order, so a retried old status never overwrites a newer one. - 'ordering' => env('TAHSEEL_WEBHOOKS_ORDERING', true), - 'store' => env('TAHSEEL_WEBHOOKS_STORE'), - 'dedupe_ttl' => (int) env('TAHSEEL_WEBHOOKS_DEDUPE_TTL', 172800), + 'ordering' => env('PAYKIT_WEBHOOKS_ORDERING', true), + 'store' => env('PAYKIT_WEBHOOKS_STORE'), + 'dedupe_ttl' => (int) env('PAYKIT_WEBHOOKS_DEDUPE_TTL', 172800), ], /* @@ -82,7 +82,7 @@ 'hmac_secret' => env('PAYMOB_HMAC_SECRET'), // Optional. Paymob's refund and void endpoints also accept a - // short-lived auth token in the body; set the API key and Tahseel + // short-lived auth token in the body; set the API key and Paykit // mints one per call. The secret key header is always sent. 'api_key' => env('PAYMOB_API_KEY'), @@ -778,16 +778,16 @@ | null and the panel routes are not registered at all. */ 'manual' => [ - 'enabled' => env('TAHSEEL_MANUAL', true), + 'enabled' => env('PAYKIT_MANUAL', true), - 'default_method' => env('TAHSEEL_MANUAL_METHOD', 'vodafone_cash'), + 'default_method' => env('PAYKIT_MANUAL_METHOD', 'vodafone_cash'), // Where the money lands. "account" is what the customer sees: a // wallet number, an InstaPay handle, a bank account. 'methods' => [ 'vodafone_cash' => [ 'label' => 'Vodafone Cash', - 'account' => env('TAHSEEL_VODAFONE_CASH_NUMBER'), + 'account' => env('PAYKIT_VODAFONE_CASH_NUMBER'), // Or several numbers: the one with the fewest open payments takes the next. // 'accounts' => ['01000000001', '01000000002'], // Optional per-payment limits, in minor units (piasters). @@ -795,52 +795,52 @@ ], 'instapay' => [ 'label' => 'InstaPay', - 'account' => env('TAHSEEL_INSTAPAY_HANDLE'), + 'account' => env('PAYKIT_INSTAPAY_HANDLE'), ], ], - 'currency' => env('TAHSEEL_MANUAL_CURRENCY', 'EGP'), + 'currency' => env('PAYKIT_MANUAL_CURRENCY', 'EGP'), // How long a reference stays valid. An expired payment that never // got a receipt cannot be approved, whatever the panel shows. // A payment whose receipt already arrived can still be decided by // a human after the window; see `expire_awaiting_review` below. - 'expires_after_minutes' => (int) env('TAHSEEL_MANUAL_EXPIRES', 1440), + 'expires_after_minutes' => (int) env('PAYKIT_MANUAL_EXPIRES', 1440), // A payment with a receipt waiting on a human is not expired by // `expireOverdue()` unless you say so. Off by default: the human // can still approve it after the window, when they have read the // receipt. - 'expire_awaiting_review' => (bool) env('TAHSEEL_MANUAL_EXPIRE_REVIEW', false), + 'expire_awaiting_review' => (bool) env('PAYKIT_MANUAL_EXPIRE_REVIEW', false), // Everything below is off until you turn it on. - 'status' => ['enabled' => env('TAHSEEL_MANUAL_STATUS', false)], - 'audit' => ['enabled' => env('TAHSEEL_MANUAL_AUDIT', false)], + 'status' => ['enabled' => env('PAYKIT_MANUAL_STATUS', false)], + 'audit' => ['enabled' => env('PAYKIT_MANUAL_AUDIT', false)], // The customer's proof upload: private disk, served only through // the panel, never from a public URL. 'proof' => [ - 'disk' => env('TAHSEEL_MANUAL_PROOF_DISK', 'local'), - 'max_kb' => (int) env('TAHSEEL_MANUAL_PROOF_MAX_KB', 5120), + 'disk' => env('PAYKIT_MANUAL_PROOF_DISK', 'local'), + 'max_kb' => (int) env('PAYKIT_MANUAL_PROOF_MAX_KB', 5120), 'mimes' => ['jpg', 'jpeg', 'png', 'webp', 'pdf'], ], // POST {path}/{reference}/proof - the customer's side. - 'proof_path' => env('TAHSEEL_MANUAL_PROOF_PATH', 'tahseel/manual'), + 'proof_path' => env('PAYKIT_MANUAL_PROOF_PATH', 'paykit/manual'), 'proof_middleware' => ['web', 'throttle:30,1'], // GET {path} and the two decisions - the merchant's side. 'panel' => [ - 'enabled' => env('TAHSEEL_MANUAL_PANEL', true), - 'path' => env('TAHSEEL_MANUAL_PANEL_PATH', 'tahseel/manual/panel'), + 'enabled' => env('PAYKIT_MANUAL_PANEL', true), + 'path' => env('PAYKIT_MANUAL_PANEL_PATH', 'paykit/manual/panel'), 'middleware' => ['web'], - 'ability' => env('TAHSEEL_MANUAL_PANEL_ABILITY'), + 'ability' => env('PAYKIT_MANUAL_PANEL_ABILITY'), // Extras, each off until you turn it on. - 'search' => env('TAHSEEL_MANUAL_PANEL_SEARCH', false), - 'export' => env('TAHSEEL_MANUAL_PANEL_EXPORT', false), + 'search' => env('PAYKIT_MANUAL_PANEL_SEARCH', false), + 'export' => env('PAYKIT_MANUAL_PANEL_EXPORT', false), // Panel language: null follows the app's locale; set - // TAHSEEL_MANUAL_PANEL_LOCALE=ar for an Arabic (RTL) panel. - 'locale' => env('TAHSEEL_MANUAL_PANEL_LOCALE'), + // PAYKIT_MANUAL_PANEL_LOCALE=ar for an Arabic (RTL) panel. + 'locale' => env('PAYKIT_MANUAL_PANEL_LOCALE'), ], ], diff --git a/database/migrations/2026_11_30_000000_create_tahseel_manual_payments_table.php b/database/migrations/2026_11_30_000000_create_paykit_manual_payments_table.php similarity index 78% rename from database/migrations/2026_11_30_000000_create_tahseel_manual_payments_table.php rename to database/migrations/2026_11_30_000000_create_paykit_manual_payments_table.php index 617f90f..44f0c32 100644 --- a/database/migrations/2026_11_30_000000_create_tahseel_manual_payments_table.php +++ b/database/migrations/2026_11_30_000000_create_paykit_manual_payments_table.php @@ -10,7 +10,14 @@ { public function up(): void { - Schema::create('tahseel_manual_payments', function (Blueprint $table): void { + // Installed under the old Tahseel name: keep the rows, take the new name. + if (Schema::hasTable('tahseel_manual_payments') && ! Schema::hasTable('paykit_manual_payments')) { + Schema::rename('tahseel_manual_payments', 'paykit_manual_payments'); + + return; + } + + Schema::create('paykit_manual_payments', function (Blueprint $table): void { $table->id(); // Our own code, handed to the customer. Unique and unguessable, so @@ -47,6 +54,6 @@ public function up(): void public function down(): void { - Schema::dropIfExists('tahseel_manual_payments'); + Schema::dropIfExists('paykit_manual_payments'); } }; diff --git a/database/migrations/2026_12_01_000000_make_transfer_reference_unique_on_tahseel_manual_payments.php b/database/migrations/2026_12_01_000000_make_transfer_reference_unique_on_paykit_manual_payments.php similarity index 55% rename from database/migrations/2026_12_01_000000_make_transfer_reference_unique_on_tahseel_manual_payments.php rename to database/migrations/2026_12_01_000000_make_transfer_reference_unique_on_paykit_manual_payments.php index 182cc70..bd41191 100644 --- a/database/migrations/2026_12_01_000000_make_transfer_reference_unique_on_tahseel_manual_payments.php +++ b/database/migrations/2026_12_01_000000_make_transfer_reference_unique_on_paykit_manual_payments.php @@ -10,7 +10,14 @@ { public function up(): void { - Schema::table('tahseel_manual_payments', function (Blueprint $table): void { + // A table renamed from the old Tahseel install already has this index. + foreach (Schema::getIndexes('paykit_manual_payments') as $index) { + if ($index['unique'] && $index['columns'] === ['transfer_reference']) { + return; + } + } + + Schema::table('paykit_manual_payments', function (Blueprint $table): void { // One transfer reference settles one payment, so a customer cannot // reuse a single receipt number on two orders. $table->unique('transfer_reference'); @@ -19,7 +26,7 @@ public function up(): void public function down(): void { - Schema::table('tahseel_manual_payments', function (Blueprint $table): void { + Schema::table('paykit_manual_payments', function (Blueprint $table): void { $table->dropUnique(['transfer_reference']); }); } diff --git a/database/migrations/2026_12_02_000000_create_tahseel_manual_events_table.php b/database/migrations/2026_12_02_000000_create_paykit_manual_events_table.php similarity index 62% rename from database/migrations/2026_12_02_000000_create_tahseel_manual_events_table.php rename to database/migrations/2026_12_02_000000_create_paykit_manual_events_table.php index 421a172..c58b9d1 100644 --- a/database/migrations/2026_12_02_000000_create_tahseel_manual_events_table.php +++ b/database/migrations/2026_12_02_000000_create_paykit_manual_events_table.php @@ -10,9 +10,16 @@ { public function up(): void { + // Installed under the old Tahseel name: keep the trail, take the new name. + if (Schema::hasTable('tahseel_manual_events') && ! Schema::hasTable('paykit_manual_events')) { + Schema::rename('tahseel_manual_events', 'paykit_manual_events'); + + return; + } + // An append-only trail of what happened to each manual payment and who // did it. The package only ever inserts into it. - Schema::create('tahseel_manual_events', function (Blueprint $table): void { + Schema::create('paykit_manual_events', function (Blueprint $table): void { $table->id(); $table->string('payment_reference', 40)->index(); $table->string('event', 32)->index(); @@ -24,6 +31,6 @@ public function up(): void public function down(): void { - Schema::dropIfExists('tahseel_manual_events'); + Schema::dropIfExists('paykit_manual_events'); } }; diff --git a/docs/ar/README.md b/docs/ar/README.md index f1633bf..6aee535 100644 --- a/docs/ar/README.md +++ b/docs/ar/README.md @@ -1,4 +1,4 @@ -# تحصيل (Tahseel) +# Paykit باكدج Laravel صغير وواضح لبوابات الدفع، في مصر والخليج وأي مكان. **جديد هنا؟ ابدأ من [البداية السريعة](quickstart.md).** فيه لحد دلوقتي سبعة وعشرين درايفر لبوابات: **Paymob** (Intention API مع Unified Checkout)، **Kashier** (Payment Sessions v3)، **فوري** (أرقام دفع من أي منفذ فوري)، **Geidea** (جلسات دفع على صفحتهم المستضافة)، **MyFatoorah** (روابط دفع الفواتير + webhook v2 موقّع)، **Tap** (صفحة دفع مستضافة + webhook بتوقيع `hashstring`)، **HyperPay** (ودجت COPYandPAY + webhook متشفّر AES-256-GCM)، **Checkout.com** (صفحة دفع مستضافة + webhook بتوقيع `Cko-Signature`)، **PayPal** (Orders v2 + تحقق `verify-webhook-signature`) و**Stripe** (Checkout Sessions + توقيع HMAC الموثّق في `Stripe-Signature`) و**Paystack** (صفحة دفع مستضافة لنيجيريا وغانا وجنوب أفريقيا وكينيا + نظامَي توقيع webhook موثّقين) و**Moyasar** (كروت سعودية ومدى وApple/Samsung Pay وSTC Pay على API واحد + webhooks بتوكن مشترك) و**Razorpay** (روابط دفع مستضافة للهند + HMAC-SHA-256 في كل حاجة) و**Mercado Pago** (صفحات Checkout Pro المستضافة لأمريكا اللاتينية + إشعارات موقّعة بالمانيفست) و**Mollie** (صفحة دفع مستضافة لأوروبا: iDEAL وBancontact وSEPA وKlarna وكروت وأكتر + webhooks مش موقّعة عمد، التحقق فيها بالجلب) و**Adyen** (جلسات Checkout مستضافة للشركات العالمية + webhooks قياسية موقّعة بـ HMAC) و**Flutterwave** (رابط دفع مستضاف في أفريقيا + webhooks بـ `verif-hash` بتتحقق تاني من الـ API) و**PayTabs** (صفحات دفع مستضافة في الخليج + webhooks بتوقيع على البودي الخام) **Klarna** (صفحات دفع مستضافة لأوروبا وأمريكا + callbacks بتوكن لمرة واحدة بتتحقق تاني من الـ API، مع خطوة تثبيت الأوردر الموثّقة) **Square** (روابط دفع مستضافة + إشعارات موقّعة على رابط الإشعار والبودي الخام) **Xendit** (جلسات دفع مستضافة في جنوب شرق آسيا + webhooks بتوكن `x-callback-token`) **Telr** (صفحات دفع مستضافة في الخليج + إشعارات موقّعة بـ SHA1) **Viva.com** (Smart Checkout في أوروبا + webhooks موقّعة بـ HMAC) و**PayU** (منصة PayU الأوروبية + إشعارات موقّعة بـ MD5) **Tabby** (تقسيط في الإمارات والسعودية + capture واسترداد وwebhooks متأمّنة بهيدر) و**Tamara** (تقسيط في السعودية والخليج + إشعارات متأمّنة بـ JWT مع خطوة authorise الموثّقة). ودرايفر الخمسة وعشرين، **manual**، بيغطي الحاجة اللي مفيش محفظة بتنشر API ليها: تحويل على رقم فودافون كاش أو عنوان إنستاباي، وحد من فريقك بيأكده من لوحة صغيرة. الدرايفرات الخليجية وPayPal وStripe وPaystack وMoyasar وRazorpay وMercado Pago وMollie وAdyen وFlutterwave وPayTabs وKlarna وSquare وXendit وTelr وViva.com وPayU وTabby وTamara متجربين على بيانات مسجلة بس لحد دلوقتي، لسه ماتشغلوش على حساب حقيقي. @@ -15,35 +15,39 @@ | البوابة | بدء الدفع | التحقق من الـ webhook | استرداد / إلغاء | capture | ملاحظات | | --- | --- | --- | --- | --- | --- | -| **Paymob** | `Tahseel::gateway('paymob')` — Intention API وUnified Checkout | HMAC-SHA512 على الـ 20 حقل الموقّعين | استرداد وإلغاء | كروت الـ Auth بس | كارت ومحفظة وأي وسيلة تفعّلها كـ integration ID | -| **Kashier** | `Tahseel::gateway('kashier')` — Payment Sessions v3 | HMAC-SHA256 في هيدر `x-kashier-signature` | استرداد وإلغاء | مش موثّق | صفحة دفع مستضافة، كارت ومحفظة | -| **فوري** | `Tahseel::gateway('fawry')` — charge API ورقم دفع من أي منفذ | SHA-256 على `messageSignature` (Notification V2) | استرداد؛ والإلغاء بيلغي أوردر لسه مدفوعش | مش موثّق | أرقام دفع بس؛ الكارت والمحفظة مش مدعومين | -| **Geidea** | `Tahseel::gateway('geidea')` — إنشاء جلسة وصفحة دفع مستضافة | HMAC-SHA256 على كائن الـ `order` الراجع | استرداد بس | مش موثّق | صفحة مستضافة؛ الوسائل اللي حسابك عند Geidea مفعّلها | -| **MyFatoorah** | `Tahseel::gateway('myfatoorah')` — روابط فواتير SendPayment | HMAC-SHA256 (base64) في هيدر `myfatoorah-signature`، webhook v2 | طلب استرداد بيكمّله فريق MyFatoorah المالي | مش موثّق | الكويت والسعودية والخليج؛ متجرب على بيانات مسجلة بس لسه | -| **Tap** | `Tahseel::gateway('tap')` — Charges API وصفحة مستضافة (`src_all`) | HMAC-SHA256 (hex) في هيدر `hashstring`، والمبلغ متنسّق على مقياس العملة | استرداد، والمبلغ مطلوب | مش موثّق | السعودية والكويت والإمارات والخليج؛ متجرب على بيانات مسجلة بس لسه | -| **HyperPay** | `Tahseel::gateway('hyperpay')` — checkout سيرفر-لسيرفر وودجت الدفع | جسم متشفّر AES-256-GCM؛ وسم GCM هو التوقيع | استرداد، والمبلغ مطلوب | مش موثّق | السعودية والخليج؛ مدى والكروت؛ متجرب على بيانات مسجلة بس لسه | -| **Checkout.com** | `Tahseel::gateway('checkoutcom')` — صفحة دفع مستضافة | HMAC-SHA256 (hex) على الجسم الخام في هيدر `Cko-Signature` | استرداد بيتقبّل آسنكرونياً (202) وبيكمّل مع webhook `payment_refunded` | مش موثّق | الشرق الأوسط والعالم؛ متجرب على بيانات مسجلة بس لسه | -| **PayPal** | `Tahseel::gateway('paypal')` — Orders v2 وتحويل على رابط الموافقة | التحقق بيتم عبر endpoint باي بال نفسها `verify-webhook-signature` | استرداد كامل أو جزئي، بيتوجّه بـ capture id | خطوة تانية إجبارية بعد الموافقة، بالمبلغ كامل بس | دولي؛ مش بيدعم الجنيه المصري؛ متجرب على بيانات مسجلة بس لسه | -| **Stripe** | `Tahseel::gateway('stripe')` — صفحة Checkout مستضافة | HMAC-SHA256 على `{t}.{الجسم الخام}` في هيدر `Stripe-Signature`، مقارنة ثابتة الزمن، وسماحية ٥ دقايق ضد الإعادة | استرداد كامل أو جزئي، بيتوجّه بـ payment intent id | مش مدعوم | دولي؛ مفيش حسابات تجار في مصر ولا معظم الخليج؛ متجرب على بيانات مسجلة بس لسه | -| **Paystack** | `Tahseel::gateway('paystack')` — صفحة دفع مستضافة | نظامان موثّقان: `Paystack-Signature` (HMAC-SHA-512 على `{t}.{الجسم الخام}` بسر `whsec_` وسماحية ٣٠٠ ثانية ضد الإعادة) والقديم `x-paystack-signature` (HMAC-SHA-512 على الجسم الخام بمفتاح السر) | استرداد بيتحط في طابور آسنكرونياً، pending لحد webhook `refund.processed` | تحقق من السيرفر بعد الرجوع بـ `verifyTransactionStatus()` | نيجيريا وغانا وجنوب أفريقيا وكينيا؛ NGN/GHS/ZAR/KES/USD؛ متجرب على بيانات مسجلة بس لسه | -| **Moyasar** | `Tahseel::gateway('moyasar')` — دفع بالـ API وتحويل على تحدي 3DS | مفيش توقيع: الـ webhook بيرد التوكن المشترك اللي سجلته، وبيتقارن بمقارنة ثابتة الزمن | استرداد سنكروناس، الرد نفسه بيقول `refunded` | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | السعودية والخليج؛ الريال أولاً، مدى + كروت + STC Pay + سداد؛ متجرب على بيانات مسجلة بس لسه | -| **Razorpay** | `Tahseel::gateway('razorpay')` — روابط دفع مستضافة | HMAC-SHA-256 على الجسم الخام في هيدر `X-Razorpay-Signature` (سر الـ webhook)، مقارنة ثابتة الزمن؛ ولرجوع المتصفح توقيع موثّق لوحده، `verifyCallbackSignature()` | استرداد pending لحد `refund.processed`؛ وبيتبعت هيدر `X-Refund-Idempotency` الموثّق | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | الهند (+ ماليزيا/سنغافورة/أمريكا في الـ API)؛ الروبية أولاً؛ متجرب على بيانات مسجلة بس لسه | -| **Mercado Pago** | `Tahseel::gateway('mercadopago')` — صفحات Checkout Pro مستضافة | HMAC-SHA-256 على المانيفست الموثّق `id:{data.id};request-id:{x-request-id};ts:{ts};` في هيدر `x-signature`، مقارنة ثابتة الزمن، سماحية ٣٠٠ ثانية؛ الإشعار مجرد إشارة، والدرايفر بيجيب الدفع للحقيقة | استرداد كامل (بودي فاضي) أو جزئي، المبلغ بالوحدة الكبرى العشرية؛ وبيتبعت هيدر `X-Idempotency-Key` الموثّق | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | أمريكا اللاتينية (الأرجنتين/البرازيل/المكسيك/تشيلي/كولومبيا/بيرو/أوروجواي)؛ متجرب على بيانات مسجلة بس لسه | -| **Mollie** | `Tahseel::gateway('mollie')` — صفحة دفع مستضافة | مش موقّع عمد: الـ webhook بيحمل بس رقم الدفع، والنموذج الأمني الموثّق هو الجلب الموثّق اللي بييجي بعده، فمكالمة مزيّفة مستحيل تعلّم أي حاجة إنها مدفوعة | استرداد كامل أو جزئي؛ كائن المبلغ مطلوب في كل استرداد | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | أوروبا؛ اليورو أولاً، iDEAL وBancontact وSEPA وKlarna وكروت وأكتر؛ متجرب على بيانات مسجلة بس لسه | -| **Adyen** | `Tahseel::gateway('adyen')` — جلسات Checkout مستضافة | HMAC-SHA-256 على الحمولة الموثّقة المتصلة بنقطتين، بمفتاح HMAC بعد فك ترميزه من hex، base64 في `additionalData.hmacSignature`؛ كل عنصر بيتأكد قبل ما أي عنصر يتقرأ | استرداد آسنكروني: بيتأكد الاستلام، وpending لحد webhook `REFUND`؛ المبلغ مطلوب | مفيش: Adyen بيحسم الحالة بالـ webhook | شركات عالمية؛ المبالغ بأصغر وحدة؛ متجرب على بيانات مسجلة بس لسه | -| **Flutterwave** | `Tahseel::gateway('flutterwave')` — رابط دفع مستضاف (`POST /v3/payments`) | مفيش HMAC: الـ secret hash بتاع الداشبورد بيرجع زي ما هو في `verif-hash` وبيتقارن بزمن ثابت، وبعدين `GET /v3/transactions/{id}/verify` هو اللي بيحسم الحقيقة، فمكالمة مزيّفة مستحيل تعلّم حاجة إنها مدفوعة | استرداد كامل (من غير مبلغ) أو جزئي، بالوحدة الكبرى؛ `completed` يعني بدأ، و`completed-*` بس هي اللي خلصت | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | نيجيريا وغانا وكينيا وجنوب أفريقيا وأكتر من أفريقيا؛ الوحدة الكبرى؛ متجرب على بيانات مسجلة بس لسه | -| **PayTabs** | `Tahseel::gateway('paytabs')` — صفحة دفع مستضافة (`POST /payment/request`) | HMAC-SHA-256 بنظام hex على البودي الخام الكامل للـ callback بمفتاح الـ Server Key بتاع البروفايل، في هيدر `Signature`، مقارنة ثابتة الزمن؛ مجموعة الحالات الموثّقة مقفولة، فأي كود برّاها بيترفض مش بيتخمّن | استرداد بمبلغ مطلوب، برقم `tran_ref` الأصلي؛ و`P` يعني استرداد يدوي لسه pending | تحقق من السيرفر بـ `fetchPaymentStatus()` عن طريق `POST /payment/query` | السعودية والإمارات ومصر وعمان والأردن والكويت وقطر والمغرب والعراق؛ الوحدة الكبرى؛ متجرب على بيانات مسجلة بس لسه | -| **Klarna** | `Tahseel::gateway('klarna')` — جلسة دفع + صفحة مستضافة (`POST /payments/v1/sessions` وبعدها `POST /hpp/v1/sessions`) | مفيش HMAC: التوكن الموثّق لمرة واحدة اللي في رابط `status_update` بيتقارن بزمن ثابت، وبعدها الجلسة بتتجاب تاني من الـ API، فمكالمة مزوّرة عمرها ما تعلّم حاجة مدفوعة | استرداد بمبلغ مطلوب، برقم الأوردر بتاع Klarna نفسه؛ مفيش استرداد كامل افتراضي | `placeOrder()` بعد ما العميل يفوّض: التفويض مش فلوس | أوروبا وأمريكا؛ تقسيط ودفع فوري؛ الوحدة الصغرى؛ متجرب على بيانات مسجلة بس لسه | -| **Square** | `Tahseel::gateway('square')` — رابط دفع مستضاف عند Square (`POST /v2/online-checkout/payment-links`) | HMAC-SHA-256 بترميز base64 على رابط الإشعار وبعده البودي الخام، بمفتاح التوقيع بتاع الاشتراك، في هيدر `x-square-hmacsha256-signature`، مقارنة ثابتة الزمن؛ الإشعار إشارة، وقراءة الدفع الموثّقة هي الحقيقة | استرداد بمبلغ مطلوب، برقم الدفع بتاع Square؛ `PENDING` لحد ما Square توافق | تحقق من السيرفر بـ `fetchPaymentStatus()`؛ الدفعة `APPROVED` مفوّضة مش متحصّلة، فبترجع pending | أمريكا وكندا وبريطانيا وأيرلندا وأستراليا واليابان وفرنسا وإسبانيا؛ الوحدة الصغرى؛ متجرب على بيانات مسجلة بس لسه | -| **Xendit** | `Tahseel::gateway('xendit')` — جلسة دفع بوضع `PAYMENT_LINK` (`POST /sessions`) | مفيش HMAC: توكن الـ callback من الداشبورد بيرجع زي ما هو في هيدر `x-callback-token`، بيتقارن بزمن ثابت، ومجموعة حالات الجلسة الموثّقة مقفولة، فأي حالة برّاها بتترفض مش بتتخمّن | استرداد بمبلغ مطلوب، برقم `payment_id` بتاع Xendit؛ `PENDING` لحد ما webhook الاسترداد يحسمها | مفيش: توكن الـ callback هو التوثيق الموثّق | إندونيسيا والفلبين وماليزيا وتايلاند وفييتنام وسنغافورة؛ المبالغ بأصغر وحدة؛ متجرب على بيانات مسجلة بس لسه | -| **Telr** | `Tahseel::gateway('telr')` — صفحة دفع مستضافة (`POST /gateway/order.json` بالطريقة `create`) | SHA1 على المفتاح السري وبعده حقول العملية الموثّقة، متوصّلة بنقطتين، في `tran_check`، مقارنة ثابتة الزمن؛ والقيم المرمّزة بتتفك قبل الحساب، والحقل الغايب بيساهم بقيمة فاضية، زي ما الوثائق بتقول بالحرف | مش ملفوف: Telr موثّقة الاسترداد على منتج تاني، فالدرايفر مابيدّعيهوش | تحقق من السيرفر بـ `fetchPaymentStatus()` عن طريق الطريقة الموثّقة `check` | الإمارات والسعودية والخليج؛ المبالغ بالوحدة الكبرى كنص عشري؛ و`H` (مفوّض ومعلّق) بترجع pending مش مدفوعة؛ متجرب على بيانات مسجلة بس لسه | -| **Viva.com** | `Tahseel::gateway('viva')` — أمر دفع Smart Checkout (`POST /checkout/v2/orders`) | HMAC-SHA-256 بنظام hex على البودي الخام في `Viva-Signature-256`، و`Viva-Signature` بـ SHA-1 كبديل موثّق، مقارنة ثابتة الزمن؛ ومعرّف الحدث وحالة العملية `StatusId` لازم يتفقوا وإلا الإشعار بيترفض | مش ملفوف: Viva موثّقة الاسترداد على منتج منفصل، فالدرايفر مابيدّعيهوش | مفيش: وثائق Viva بتقول أكّد بـ `OrderCode` و`TransactionId` و`StatusId` و`Amount`، وده اللي الدرايفر بيتحقق منه | أوروبا (Viva.com مُحصّل يوناني بانتشار أوروبي واسع)؛ الوحدة الصغرى؛ `F` منتهية، `A`/`C` معلّقة، `R` مستردة؛ متجرب على بيانات مسجلة بس لسه | -| **PayU** | `Tahseel::gateway('payu')` — أمر PayU Global وتحويل (`POST /api/v2_1/orders`) | MD5 على البودي الخام متوصّل بالمفتاح التاني للـ POS، في `OpenPayu-Signature`، مقارنة ثابتة الزمن؛ وأي خوارزمية الدرايفر ماتأسّسش عليها بتترفض مش بتتخمّن | كامل (من غير مبلغ) أو جزئي، المبلغ بأصغر وحدة، برقم الأمر بتاع PayU؛ وأي حاجة PayU ماتقولهاش صريحة تفضل pending | مفيش: الإشعار الموقّع هو الحالة | أوروبا (PayU Global على secure.payu.com — مش PayU India)؛ المبالغ بأصغر وحدة كنصوص؛ `PENDING` و`WAITING_FOR_CONFIRMATION` معلّقة، وبس `COMPLETED` مدفوعة؛ متجرب على بيانات مسجلة بس لسه | -| **Tabby** | `Tahseel::gateway('tabby')` — جلسة checkout مستضافة (`POST /api/v2/checkout`) | Tabby مابتوقّعش البودي: بتسجّل هيدر باسمك وقيمة من عندك، والدرايفر بيقارنها بزمن ثابت زي ما وثائق Tabby بتقول | كامل أو جزئي، المبلغ مطلوب (Tabby ماعندهاش استرداد كامل من غير مبلغ)، برقم الدفع بتاع Tabby | `POST /api/v2/payments/{id}/captures`؛ وبس الدفعة المتعمولها capture بتبقى `CLOSED` وبتتسوّى | الإمارات والسعودية (base URL حسب المنطقة: api.tabby.ai / api.tabby.sa)؛ المبالغ نصوص عشرية بـ AED أو SAR؛ `AUTHORIZED` معلّقة وبس `CLOSED` مدفوعة؛ متجرب على بيانات مسجلة بس لسه | -| **Tamara** | `Tahseel::gateway('tamara')` — جلسة checkout مستضافة (`POST /checkout`) | JWT بـ HS256 متوقّع بمفتاح الإشعارات بتاعك، وبييجي في `Authorization: Bearer` وكمان في query parameter اسمه `tamaraToken`؛ الدرايفر بيتحقق من التوقيع بنفسه، ويتشيك على الانتهاء، ويرفض أي خوارزمية غير HS256 | كامل أو جزئي، المبلغ مطلوب، برقم `order_id` بتاع Tamara | مش متغلّف: capture عند Tamara نداء موثّق بيطلب أصناف الأمر معاه، فاللي الدرايفر بيعمله هو `authorise()` | السعودية والإمارات والبحرين والكويت وعُمان؛ المبالغ بوحدات رئيسية في `{amount, currency}`؛ `approved` معلّقة و`authorised` مدفوعة؛ `authorise()` هي الخطوة الموثّقة بعد إشعار الموافقة؛ متجرب على بيانات مسجلة بس لسه | -| **يدوي** (فودافون كاش، إنستاباي) | `Tahseel::gateway('manual')` — مرجع، تحويل على محفظتك، وقرار من حد من فريقك | مفيش: التأكيد من اللوحة | مش منطبق | مش منطبق | مفيش API تجار تكلّمه؛ واللوحة مقفولة لحد ما تحدد Gate ability | +| **Paymob** | `Paykit::gateway('paymob')` — Intention API وUnified Checkout | HMAC-SHA512 على الـ 20 حقل الموقّعين | استرداد وإلغاء | كروت الـ Auth بس | كارت ومحفظة وأي وسيلة تفعّلها كـ integration ID | +| **Kashier** | `Paykit::gateway('kashier')` — Payment Sessions v3 | HMAC-SHA256 في هيدر `x-kashier-signature` | استرداد وإلغاء | مش موثّق | صفحة دفع مستضافة، كارت ومحفظة | +| **فوري** | `Paykit::gateway('fawry')` — charge API ورقم دفع من أي منفذ | SHA-256 على `messageSignature` (Notification V2) | استرداد؛ والإلغاء بيلغي أوردر لسه مدفوعش | مش موثّق | أرقام دفع بس؛ الكارت والمحفظة مش مدعومين | +| **Geidea** | `Paykit::gateway('geidea')` — إنشاء جلسة وصفحة دفع مستضافة | HMAC-SHA256 على كائن الـ `order` الراجع | استرداد بس | مش موثّق | صفحة مستضافة؛ الوسائل اللي حسابك عند Geidea مفعّلها | +| **MyFatoorah** | `Paykit::gateway('myfatoorah')` — روابط فواتير SendPayment | HMAC-SHA256 (base64) في هيدر `myfatoorah-signature`، webhook v2 | طلب استرداد بيكمّله فريق MyFatoorah المالي | مش موثّق | الكويت والسعودية والخليج؛ متجرب على بيانات مسجلة بس لسه | +| **Tap** | `Paykit::gateway('tap')` — Charges API وصفحة مستضافة (`src_all`) | HMAC-SHA256 (hex) في هيدر `hashstring`، والمبلغ متنسّق على مقياس العملة | استرداد، والمبلغ مطلوب | مش موثّق | السعودية والكويت والإمارات والخليج؛ متجرب على بيانات مسجلة بس لسه | +| **HyperPay** | `Paykit::gateway('hyperpay')` — checkout سيرفر-لسيرفر وودجت الدفع | جسم متشفّر AES-256-GCM؛ وسم GCM هو التوقيع | استرداد، والمبلغ مطلوب | مش موثّق | السعودية والخليج؛ مدى والكروت؛ متجرب على بيانات مسجلة بس لسه | +| **Checkout.com** | `Paykit::gateway('checkoutcom')` — صفحة دفع مستضافة | HMAC-SHA256 (hex) على الجسم الخام في هيدر `Cko-Signature` | استرداد بيتقبّل آسنكرونياً (202) وبيكمّل مع webhook `payment_refunded` | مش موثّق | الشرق الأوسط والعالم؛ متجرب على بيانات مسجلة بس لسه | +| **PayPal** | `Paykit::gateway('paypal')` — Orders v2 وتحويل على رابط الموافقة | التحقق بيتم عبر endpoint باي بال نفسها `verify-webhook-signature` | استرداد كامل أو جزئي، بيتوجّه بـ capture id | خطوة تانية إجبارية بعد الموافقة، بالمبلغ كامل بس | دولي؛ مش بيدعم الجنيه المصري؛ متجرب على بيانات مسجلة بس لسه | +| **Stripe** | `Paykit::gateway('stripe')` — صفحة Checkout مستضافة | HMAC-SHA256 على `{t}.{الجسم الخام}` في هيدر `Stripe-Signature`، مقارنة ثابتة الزمن، وسماحية ٥ دقايق ضد الإعادة | استرداد كامل أو جزئي، بيتوجّه بـ payment intent id | مش مدعوم | دولي؛ مفيش حسابات تجار في مصر ولا معظم الخليج؛ متجرب على بيانات مسجلة بس لسه | +| **Paystack** | `Paykit::gateway('paystack')` — صفحة دفع مستضافة | نظامان موثّقان: `Paystack-Signature` (HMAC-SHA-512 على `{t}.{الجسم الخام}` بسر `whsec_` وسماحية ٣٠٠ ثانية ضد الإعادة) والقديم `x-paystack-signature` (HMAC-SHA-512 على الجسم الخام بمفتاح السر) | استرداد بيتحط في طابور آسنكرونياً، pending لحد webhook `refund.processed` | تحقق من السيرفر بعد الرجوع بـ `verifyTransactionStatus()` | نيجيريا وغانا وجنوب أفريقيا وكينيا؛ NGN/GHS/ZAR/KES/USD؛ متجرب على بيانات مسجلة بس لسه | +| **Moyasar** | `Paykit::gateway('moyasar')` — دفع بالـ API وتحويل على تحدي 3DS | مفيش توقيع: الـ webhook بيرد التوكن المشترك اللي سجلته، وبيتقارن بمقارنة ثابتة الزمن | استرداد سنكروناس، الرد نفسه بيقول `refunded` | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | السعودية والخليج؛ الريال أولاً، مدى + كروت + STC Pay + سداد؛ متجرب على بيانات مسجلة بس لسه | +| **Razorpay** | `Paykit::gateway('razorpay')` — روابط دفع مستضافة | HMAC-SHA-256 على الجسم الخام في هيدر `X-Razorpay-Signature` (سر الـ webhook)، مقارنة ثابتة الزمن؛ ولرجوع المتصفح توقيع موثّق لوحده، `verifyCallbackSignature()` | استرداد pending لحد `refund.processed`؛ وبيتبعت هيدر `X-Refund-Idempotency` الموثّق | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | الهند (+ ماليزيا/سنغافورة/أمريكا في الـ API)؛ الروبية أولاً؛ متجرب على بيانات مسجلة بس لسه | +| **Mercado Pago** | `Paykit::gateway('mercadopago')` — صفحات Checkout Pro مستضافة | HMAC-SHA-256 على المانيفست الموثّق `id:{data.id};request-id:{x-request-id};ts:{ts};` في هيدر `x-signature`، مقارنة ثابتة الزمن، سماحية ٣٠٠ ثانية؛ الإشعار مجرد إشارة، والدرايفر بيجيب الدفع للحقيقة | استرداد كامل (بودي فاضي) أو جزئي، المبلغ بالوحدة الكبرى العشرية؛ وبيتبعت هيدر `X-Idempotency-Key` الموثّق | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | أمريكا اللاتينية (الأرجنتين/البرازيل/المكسيك/تشيلي/كولومبيا/بيرو/أوروجواي)؛ متجرب على بيانات مسجلة بس لسه | +| **Mollie** | `Paykit::gateway('mollie')` — صفحة دفع مستضافة | مش موقّع عمد: الـ webhook بيحمل بس رقم الدفع، والنموذج الأمني الموثّق هو الجلب الموثّق اللي بييجي بعده، فمكالمة مزيّفة مستحيل تعلّم أي حاجة إنها مدفوعة | استرداد كامل أو جزئي؛ كائن المبلغ مطلوب في كل استرداد | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | أوروبا؛ اليورو أولاً، iDEAL وBancontact وSEPA وKlarna وكروت وأكتر؛ متجرب على بيانات مسجلة بس لسه | +| **Adyen** | `Paykit::gateway('adyen')` — جلسات Checkout مستضافة | HMAC-SHA-256 على الحمولة الموثّقة المتصلة بنقطتين، بمفتاح HMAC بعد فك ترميزه من hex، base64 في `additionalData.hmacSignature`؛ كل عنصر بيتأكد قبل ما أي عنصر يتقرأ | استرداد آسنكروني: بيتأكد الاستلام، وpending لحد webhook `REFUND`؛ المبلغ مطلوب | مفيش: Adyen بيحسم الحالة بالـ webhook | شركات عالمية؛ المبالغ بأصغر وحدة؛ متجرب على بيانات مسجلة بس لسه | +| **Flutterwave** | `Paykit::gateway('flutterwave')` — رابط دفع مستضاف (`POST /v3/payments`) | مفيش HMAC: الـ secret hash بتاع الداشبورد بيرجع زي ما هو في `verif-hash` وبيتقارن بزمن ثابت، وبعدين `GET /v3/transactions/{id}/verify` هو اللي بيحسم الحقيقة، فمكالمة مزيّفة مستحيل تعلّم حاجة إنها مدفوعة | استرداد كامل (من غير مبلغ) أو جزئي، بالوحدة الكبرى؛ `completed` يعني بدأ، و`completed-*` بس هي اللي خلصت | تحقق من السيرفر بعد الرجوع بـ `fetchPaymentStatus()` | نيجيريا وغانا وكينيا وجنوب أفريقيا وأكتر من أفريقيا؛ الوحدة الكبرى؛ متجرب على بيانات مسجلة بس لسه | +| **PayTabs** | `Paykit::gateway('paytabs')` — صفحة دفع مستضافة (`POST /payment/request`) | HMAC-SHA-256 بنظام hex على البودي الخام الكامل للـ callback بمفتاح الـ Server Key بتاع البروفايل، في هيدر `Signature`، مقارنة ثابتة الزمن؛ مجموعة الحالات الموثّقة مقفولة، فأي كود برّاها بيترفض مش بيتخمّن | استرداد بمبلغ مطلوب، برقم `tran_ref` الأصلي؛ و`P` يعني استرداد يدوي لسه pending | تحقق من السيرفر بـ `fetchPaymentStatus()` عن طريق `POST /payment/query` | السعودية والإمارات ومصر وعمان والأردن والكويت وقطر والمغرب والعراق؛ الوحدة الكبرى؛ متجرب على بيانات مسجلة بس لسه | +| **Klarna** | `Paykit::gateway('klarna')` — جلسة دفع + صفحة مستضافة (`POST /payments/v1/sessions` وبعدها `POST /hpp/v1/sessions`) | مفيش HMAC: التوكن الموثّق لمرة واحدة اللي في رابط `status_update` بيتقارن بزمن ثابت، وبعدها الجلسة بتتجاب تاني من الـ API، فمكالمة مزوّرة عمرها ما تعلّم حاجة مدفوعة | استرداد بمبلغ مطلوب، برقم الأوردر بتاع Klarna نفسه؛ مفيش استرداد كامل افتراضي | `placeOrder()` بعد ما العميل يفوّض: التفويض مش فلوس | أوروبا وأمريكا؛ تقسيط ودفع فوري؛ الوحدة الصغرى؛ متجرب على بيانات مسجلة بس لسه | +| **Square** | `Paykit::gateway('square')` — رابط دفع مستضاف عند Square (`POST /v2/online-checkout/payment-links`) | HMAC-SHA-256 بترميز base64 على رابط الإشعار وبعده البودي الخام، بمفتاح التوقيع بتاع الاشتراك، في هيدر `x-square-hmacsha256-signature`، مقارنة ثابتة الزمن؛ الإشعار إشارة، وقراءة الدفع الموثّقة هي الحقيقة | استرداد بمبلغ مطلوب، برقم الدفع بتاع Square؛ `PENDING` لحد ما Square توافق | تحقق من السيرفر بـ `fetchPaymentStatus()`؛ الدفعة `APPROVED` مفوّضة مش متحصّلة، فبترجع pending | أمريكا وكندا وبريطانيا وأيرلندا وأستراليا واليابان وفرنسا وإسبانيا؛ الوحدة الصغرى؛ متجرب على بيانات مسجلة بس لسه | +| **Xendit** | `Paykit::gateway('xendit')` — جلسة دفع بوضع `PAYMENT_LINK` (`POST /sessions`) | مفيش HMAC: توكن الـ callback من الداشبورد بيرجع زي ما هو في هيدر `x-callback-token`، بيتقارن بزمن ثابت، ومجموعة حالات الجلسة الموثّقة مقفولة، فأي حالة برّاها بتترفض مش بتتخمّن | استرداد بمبلغ مطلوب، برقم `payment_id` بتاع Xendit؛ `PENDING` لحد ما webhook الاسترداد يحسمها | مفيش: توكن الـ callback هو التوثيق الموثّق | إندونيسيا والفلبين وماليزيا وتايلاند وفييتنام وسنغافورة؛ المبالغ بأصغر وحدة؛ متجرب على بيانات مسجلة بس لسه | +| **Telr** | `Paykit::gateway('telr')` — صفحة دفع مستضافة (`POST /gateway/order.json` بالطريقة `create`) | SHA1 على المفتاح السري وبعده حقول العملية الموثّقة، متوصّلة بنقطتين، في `tran_check`، مقارنة ثابتة الزمن؛ والقيم المرمّزة بتتفك قبل الحساب، والحقل الغايب بيساهم بقيمة فاضية، زي ما الوثائق بتقول بالحرف | مش ملفوف: Telr موثّقة الاسترداد على منتج تاني، فالدرايفر مابيدّعيهوش | تحقق من السيرفر بـ `fetchPaymentStatus()` عن طريق الطريقة الموثّقة `check` | الإمارات والسعودية والخليج؛ المبالغ بالوحدة الكبرى كنص عشري؛ و`H` (مفوّض ومعلّق) بترجع pending مش مدفوعة؛ متجرب على بيانات مسجلة بس لسه | +| **Viva.com** | `Paykit::gateway('viva')` — أمر دفع Smart Checkout (`POST /checkout/v2/orders`) | HMAC-SHA-256 بنظام hex على البودي الخام في `Viva-Signature-256`، و`Viva-Signature` بـ SHA-1 كبديل موثّق، مقارنة ثابتة الزمن؛ ومعرّف الحدث وحالة العملية `StatusId` لازم يتفقوا وإلا الإشعار بيترفض | مش ملفوف: Viva موثّقة الاسترداد على منتج منفصل، فالدرايفر مابيدّعيهوش | مفيش: وثائق Viva بتقول أكّد بـ `OrderCode` و`TransactionId` و`StatusId` و`Amount`، وده اللي الدرايفر بيتحقق منه | أوروبا (Viva.com مُحصّل يوناني بانتشار أوروبي واسع)؛ الوحدة الصغرى؛ `F` منتهية، `A`/`C` معلّقة، `R` مستردة؛ متجرب على بيانات مسجلة بس لسه | +| **PayU** | `Paykit::gateway('payu')` — أمر PayU Global وتحويل (`POST /api/v2_1/orders`) | MD5 على البودي الخام متوصّل بالمفتاح التاني للـ POS، في `OpenPayu-Signature`، مقارنة ثابتة الزمن؛ وأي خوارزمية الدرايفر ماتأسّسش عليها بتترفض مش بتتخمّن | كامل (من غير مبلغ) أو جزئي، المبلغ بأصغر وحدة، برقم الأمر بتاع PayU؛ وأي حاجة PayU ماتقولهاش صريحة تفضل pending | مفيش: الإشعار الموقّع هو الحالة | أوروبا (PayU Global على secure.payu.com — مش PayU India)؛ المبالغ بأصغر وحدة كنصوص؛ `PENDING` و`WAITING_FOR_CONFIRMATION` معلّقة، وبس `COMPLETED` مدفوعة؛ متجرب على بيانات مسجلة بس لسه | +| **Tabby** | `Paykit::gateway('tabby')` — جلسة checkout مستضافة (`POST /api/v2/checkout`) | Tabby مابتوقّعش البودي: بتسجّل هيدر باسمك وقيمة من عندك، والدرايفر بيقارنها بزمن ثابت زي ما وثائق Tabby بتقول | كامل أو جزئي، المبلغ مطلوب (Tabby ماعندهاش استرداد كامل من غير مبلغ)، برقم الدفع بتاع Tabby | `POST /api/v2/payments/{id}/captures`؛ وبس الدفعة المتعمولها capture بتبقى `CLOSED` وبتتسوّى | الإمارات والسعودية (base URL حسب المنطقة: api.tabby.ai / api.tabby.sa)؛ المبالغ نصوص عشرية بـ AED أو SAR؛ `AUTHORIZED` معلّقة وبس `CLOSED` مدفوعة؛ متجرب على بيانات مسجلة بس لسه | +| **Tamara** | `Paykit::gateway('tamara')` — جلسة checkout مستضافة (`POST /checkout`) | JWT بـ HS256 متوقّع بمفتاح الإشعارات بتاعك، وبييجي في `Authorization: Bearer` وكمان في query parameter اسمه `tamaraToken`؛ الدرايفر بيتحقق من التوقيع بنفسه، ويتشيك على الانتهاء، ويرفض أي خوارزمية غير HS256 | كامل أو جزئي، المبلغ مطلوب، برقم `order_id` بتاع Tamara | مش متغلّف: capture عند Tamara نداء موثّق بيطلب أصناف الأمر معاه، فاللي الدرايفر بيعمله هو `authorise()` | السعودية والإمارات والبحرين والكويت وعُمان؛ المبالغ بوحدات رئيسية في `{amount, currency}`؛ `approved` معلّقة و`authorised` مدفوعة؛ `authorise()` هي الخطوة الموثّقة بعد إشعار الموافقة؛ متجرب على بيانات مسجلة بس لسه | +| **يدوي** (فودافون كاش، إنستاباي) | `Paykit::gateway('manual')` — مرجع، تحويل على محفظتك، وقرار من حد من فريقك | مفيش: التأكيد من اللوحة | مش منطبق | مش منطبق | مفيش API تجار تكلّمه؛ واللوحة مقفولة لحد ما تحدد Gate ability | | **محافظ وتقسيط وميزة وإنستاباي** | عن طريق وسائل Paymob أو Kashier أو Geidea | - | - | - | مفيش API تجار معلن لأي منهم، شوف القسم تحت | +## جاي من Tahseel + +Paykit كان اسمه Tahseel (`elbanbydev/tahseel`) لحد 0.4.x. الانتقال معناه package جديد في composer، والـ namespace `Paykit\`، وملف `config/paykit.php`، ومتغيرات `PAYKIT_*`، وأوامر `paykit:*`، ولينكات الـ webhook بقت `/paykit/webhooks/{gateway}` (اظبط `PAYKIT_WEBHOOKS_PATH=tahseel/webhooks/{gateway}` لو عايز تسيب اللينكات القديمة). جداول التحويل اليدوي بتتغير أسماؤها في مكانها بـ `php artisan migrate`. الخطوات كلها في إدخال 0.5.0 في [CHANGELOG](../../CHANGELOG.md). + ## الفكرة - **طلب واحد، وجلسة واحدة.** المبالغ أعداد صحيحة بالقروش، مش أرقام عشرية. @@ -64,20 +68,20 @@ ```json { "repositories": [ - { "type": "vcs", "url": "https://github.com/elbanbydev/Tahseel" } + { "type": "vcs", "url": "https://github.com/elbanbydev/paykit" } ] } ``` ```bash -composer require elbanbydev/tahseel:dev-main -php artisan vendor:publish --tag=tahseel-config +composer require elbanbydev/paykit:dev-main +php artisan vendor:publish --tag=paykit-config ``` ## الإعداد ```dotenv -TAHSEEL_GATEWAY=paymob +PAYKIT_GATEWAY=paymob PAYMOB_BASE_URL=https://accept.paymob.com PAYMOB_CHECKOUT_URL=https://eg.checkout.paymob.com/ PAYMOB_SECRET_KEY=sk_test_... @@ -85,7 +89,7 @@ PAYMOB_PUBLIC_KEY=pk_test_... PAYMOB_HMAC_SECRET=... PAYMOB_INTEGRATION_IDS=5123456 PAYMOB_API_KEY= # اختياري، للاسترداد والإلغاء والكابتشر بس -PAYMOB_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/paymob +PAYMOB_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/paymob PAYMOB_REDIRECTION_URL=https://your-app.test/checkout/done ``` @@ -104,36 +108,36 @@ PAYMOB_REDIRECTION_URL=https://your-app.test/checkout/done ### اتأكد من الإعداد قبل أول دفعة ```bash -php artisan tahseel:check +php artisan paykit:check ``` بيطبع صف لكل درايفر: `ok`، أو `missing` مع اسم المفتاح والمتغير اللي تظبطه، أو `not configured` للدرايفر اللي مليتهوش أصلاً. الدرايفر اللي مفيهوش ولا مفتاح مش بيفشّل الأمر؛ لكن البوابة الافتراضية لازم تكون كاملة. وبيقول كمان إذا كان راوت الـ webhook شغال وعلى أنهي مسار. ### تتأكد إن مفاتيحك شغالة -`tahseel:check` بيقرأ الإعدادات بس، ومش ممكن يعرف إذا كانت المفاتيح صحيحة ولا لأ. الأمر ده بيعمل عملية دفع حقيقية واحدة من الدرايفر: +`paykit:check` بيقرأ الإعدادات بس، ومش ممكن يعرف إذا كانت المفاتيح صحيحة ولا لأ. الأمر ده بيعمل عملية دفع حقيقية واحدة من الدرايفر: ```bash -php artisan tahseel:smoke -php artisan tahseel:smoke --gateway=kashier --amount=1.00 --method=card +php artisan paykit:smoke +php artisan paykit:smoke --gateway=kashier --amount=1.00 --method=card ``` بيطبع الـ endpoint والـ reference ورقم الجلسة والأوردر ولينك الدفع (أو رقم مرجع فوري)، وبيقولك الـ callback المفروض ييجي على فين. ومفيش أي فلوس بتتحصّل: كل درايفر في الباكدج بيعمل في الخطوة دي مجرد صفحة دفع أو رقم مرجع. المبلغ الافتراضي 1.00 بعملة الدرايفر. لو البوابة رفضت الطلب، الأمر بيرجع بكود فشل وبيطبع رسالة البوابة نفسها، وهي عادةً الرسالة المفيدة ("Invalid API key" أو "merchant not enabled for wallets"). ولو الـ endpoint مش باين إنه تيست، بيحذّرك الأول، لأن Paymob بيخدم حسابات التيست واللايف من نفس الهوست: المفاتيح هي اللي بتحدد، مش اللينك. -ادفع الجلسة دي بكارت تيست وراقب الـ callback وهو بيوصل على `/tahseel/webhooks/{gateway}` عشان تتأكد إن الدورة كلها شغالة، بما فيها التحقق من التوقيع. +ادفع الجلسة دي بكارت تيست وراقب الـ callback وهو بيوصل على `/paykit/webhooks/{gateway}` عشان تتأكد إن الدورة كلها شغالة، بما فيها التحقق من التوقيع. ## بدء عملية دفع ```php -use Tahseel\Data\Customer; -use Tahseel\Data\LineItem; -use Tahseel\Data\Money; -use Tahseel\Data\PaymentRequest; -use Tahseel\Facades\Tahseel; +use Paykit\Data\Customer; +use Paykit\Data\LineItem; +use Paykit\Data\Money; +use Paykit\Data\PaymentRequest; +use Paykit\Facades\Paykit; -$session = Tahseel::createPayment(new PaymentRequest( +$session = Paykit::createPayment(new PaymentRequest( reference: 'ORDER-1042', // بيرجع في merchant_order_id amount: Money::of('250.00', 'EGP'), // بيتخزن 25000 قرش customer: new Customer( @@ -153,7 +157,7 @@ return redirect()->away($session->checkoutUrl); الـ `PaymentSession` فيه `intentionId` و`orderId` و`clientSecret` و`checkoutUrl` ورد البوابة الأصلي في `raw`. خزّن الـ reference ورقم الأوردر، دول اللي الـ callback بيرجعهم. -لو أعدت الطلب بنفس `idempotencyKey` هترجع نفس الجلسة من غير ما Paymob تتنادى تاني. المفاتيح بتتحفظ لمدة `tahseel.idempotency.ttl` (يوم واحد افتراضيًا). +لو أعدت الطلب بنفس `idempotencyKey` هترجع نفس الجلسة من غير ما Paymob تتنادى تاني. المفاتيح بتتحفظ لمدة `paykit.idempotency.ttl` (يوم واحد افتراضيًا). ### لما البوابة متجاوبش @@ -168,7 +172,7 @@ The request may or may not have been processed: check the gateway dashboard befo ## استقبال الـ callback -الباكدج بيسجّل `POST /tahseel/webhooks/{gateway}` (غيّره من `tahseel.webhooks.path`). حط `notification_url` في Paymob على `/tahseel/webhooks/paymob`. +الباكدج بيسجّل `POST /paykit/webhooks/{gateway}` (غيّره من `paykit.webhooks.path`). حط `notification_url` في Paymob على `/paykit/webhooks/paymob`. الكontroler بيعمل الآتي: @@ -178,12 +182,12 @@ The request may or may not have been processed: check the gateway dashboard befo ```php use Illuminate\Support\Facades\Event; -use Tahseel\Events\PaymentSucceeded; +use Paykit\Events\PaymentSucceeded; Event::listen(function (PaymentSucceeded $event) { $event->event->reference; // 'ORDER-1042' $event->event->amount->minor; // 25000 - $event->event->status; // Tahseel\Enums\PaymentStatus + $event->event->status; // Paykit\Enums\PaymentStatus }); ``` @@ -193,17 +197,17 @@ Event::listen(function (PaymentSucceeded $event) { البوابات بتعيد المحاولة. Paymob بيفضل يعيد الـ callback لحد ما ياخد `200`، وKashier وFawry نفس الحكاية، فالعملية الواحدة ممكن توصلك أكتر من مرة. الباكدج بيتعامل مع ده قبل ما يطلق أي حدث: -- **التكرار** — نفس العملية (أو نفس الـ payload لو الـ callback مفيهوش transaction id) بتتطلق مرة واحدة بس. الإعادة بتاخد `{"status":"duplicate"}`. المفاتيح بتتخزن لمدة `tahseel.webhooks.dedupe_ttl` ثانية (يومين افتراضيًا). +- **التكرار** — نفس العملية (أو نفس الـ payload لو الـ callback مفيهوش transaction id) بتتطلق مرة واحدة بس. الإعادة بتاخد `{"status":"duplicate"}`. المفاتيح بتتخزن لمدة `paykit.webhooks.dedupe_ttl` ثانية (يومين افتراضيًا). - **الترتيب المقلوب** — أي callback وقته أقدم من واحد اتعالج قبل كده لنفس الأوردر بيترمى ويرجّع `{"status":"stale"}`. يعني `PENDING` قديم بيوصل بعد `SUCCEEDED` مش هيرجّع الأوردر لورا. والـ callback اللي مفيهوش وقت مقروء عمره ما بيتعامل كـ stale. الاتنين محتاجين cache مشترك لو شغّال على أكتر من سيرفر. ظبّطهم على نفس الـ store: ```php 'webhooks' => [ - 'deduplicate' => env('TAHSEEL_WEBHOOKS_DEDUPLICATE', true), - 'ordering' => env('TAHSEEL_WEBHOOKS_ORDERING', true), - 'store' => env('TAHSEEL_WEBHOOKS_STORE'), // null = الـ cache الافتراضي للتطبيق - 'dedupe_ttl' => (int) env('TAHSEEL_WEBHOOKS_DEDUPE_TTL', 172800), + 'deduplicate' => env('PAYKIT_WEBHOOKS_DEDUPLICATE', true), + 'ordering' => env('PAYKIT_WEBHOOKS_ORDERING', true), + 'store' => env('PAYKIT_WEBHOOKS_STORE'), // null = الـ cache الافتراضي للتطبيق + 'dedupe_ttl' => (int) env('PAYKIT_WEBHOOKS_DEDUPE_TTL', 172800), ], ``` @@ -218,21 +222,21 @@ Event::listen(function (PaymentSucceeded $event) { الاسترداد والإلغاء والكابتشر ليهم كونتراكتات لوحدهم، `SupportsRefunds` و`SupportsVoids` و`SupportsCapture`، فأي درايفر بيدّعي بس اللي بوابته موثّقة فعلاً. ```php -use Tahseel\Data\Money; -use Tahseel\Data\RefundRequest; -use Tahseel\Data\VoidRequest; -use Tahseel\Facades\Tahseel; +use Paykit\Data\Money; +use Paykit\Data\RefundRequest; +use Paykit\Data\VoidRequest; +use Paykit\Facades\Paykit; // استرداد كامل لمعاملة Paymob. الـ id جاي من الـ callback. -$result = Tahseel::refund(RefundRequest::forTransaction('555123456'), 'paymob'); +$result = Paykit::refund(RefundRequest::forTransaction('555123456'), 'paymob'); // استرداد جزئي لأوردر Kashier. -$result = Tahseel::refund(RefundRequest::forOrder($orderId, Money::of('100.00'), 'customer asked'), 'kashier'); +$result = Paykit::refund(RefundRequest::forOrder($orderId, Money::of('100.00'), 'customer asked'), 'kashier'); // إلغاء دفعة قبل ما تتسوّى. -$result = Tahseel::void(VoidRequest::forTransaction('555123456'), 'paymob'); +$result = Paykit::void(VoidRequest::forTransaction('555123456'), 'paymob'); -$result->status; // Tahseel\Enums\PaymentStatus +$result->status; // Paykit\Enums\PaymentStatus $result->succeeded(); ``` @@ -265,7 +269,7 @@ $result->succeeded(); التفاصيل اللي بتوجع: -- **الدرايفر اللي مش قادر بيقول كده.** `Tahseel::refund()` و`Tahseel::void()` بيرموا `UnsupportedOperationException` لو البوابة مش منفّذة الكونتراكت، بدل ما يبعتوا حاجة شكلها معقول. +- **الدرايفر اللي مش قادر بيقول كده.** `Paykit::refund()` و`Paykit::void()` بيرموا `UnsupportedOperationException` لو البوابة مش منفّذة الكونتراكت، بدل ما يبعتوا حاجة شكلها معقول. - **فوري وGeidea محتاجين المبلغ حتى في الاسترداد الكامل.** مفيش عندهم API بمعنى "استرد الباقي"، فابعت `Money` مع الطلب. - **إلغاء فوري هو Cancel Unpaid Order API.** بيشتغل بس والأوردر لسه مدفوعش، وتوقيعه بترتيب مختلف عن الاسترداد: `orderRefNo + merchantAccount + lang + secureKey`. - **Kashier بيخدم عمليات الأوردر من هوست مختلف.** `https://fep.kashier.io` (`https://test-fep.kashier.io` في التيست)، مش هوست الـ payment sessions. غيّرها بـ `KASHIER_OPERATION_BASE_URL`. @@ -276,14 +280,14 @@ $result->succeeded(); الكابتشر هو النص التاني في دورة auth/capture: الـ authorization بيحجز الفلوس على كارت العميل، والكابتشر هو اللي بينقلها لك. Paymob هو الدرايفر الوحيد اللي موثّق الخطوة دي، وللكارت بس. ```php -use Tahseel\Data\CaptureRequest; -use Tahseel\Data\Money; +use Paykit\Data\CaptureRequest; +use Paykit\Data\Money; // تحصيل المبلغ المصرّح به كله. الـ id هو transaction id بتاعة الـ auth. -$result = Tahseel::capture(CaptureRequest::forTransaction('555123456'), 'paymob'); +$result = Paykit::capture(CaptureRequest::forTransaction('555123456'), 'paymob'); // أو تحصيل جزء منه. -$result = Tahseel::capture(CaptureRequest::forTransaction('555123456', Money::of('100.00')), 'paymob'); +$result = Paykit::capture(CaptureRequest::forTransaction('555123456', Money::of('100.00')), 'paymob'); ``` حاجات Paymob مش هيسيبك تعملها: @@ -291,7 +295,7 @@ $result = Tahseel::capture(CaptureRequest::forTransaction('555123456', Money::of - **الكابتشر للكارت وبس، ولمعاملة Auth.** Paymob موثّق الكابتشر لوسيلة الكارت بنوع معاملة Auth، يعني الدفعة لازم تكون اتعملت على integration متظبّط Auth، مش integration بيع عادي. - **الكابتشر لازم يحصل قبل ما الـ authorization تنتهي.** الـ authorization حجز له مدة. لو عدّت، مفيش حاجة تتحصّل، والفلوس بترجع للعميل. - **الكابتشر الجزئي ما يزيدش عن المبلغ المصرّح به.** حصّل الباقي والـ authorization لسه سارية، أو سيب الباقي يروح. -- **أي درايفر تاني بيرفض.** `Tahseel::capture()` بيرمي `UnsupportedOperationException` على Kashier وفوري وGeidea، لأنهم مش موثّقين خطوة كابتشر. +- **أي درايفر تاني بيرفض.** `Paykit::capture()` بيرمي `UnsupportedOperationException` على Kashier وفوري وGeidea، لأنهم مش موثّقين خطوة كابتشر. ## Kashier @@ -301,12 +305,12 @@ KASHIER_SECRET_KEY=ksk_test_... KASHIER_PAYMENT_API_KEY=pk_test_... KASHIER_MERCHANT_ID=MID-1234-567 KASHIER_ALLOWED_METHODS=card,wallet -KASHIER_WEBHOOK_URL=https://your-app.test/tahseel/webhooks/kashier +KASHIER_WEBHOOK_URL=https://your-app.test/paykit/webhooks/kashier KASHIER_REDIRECT_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('kashier')->createPayment($request); +$session = Paykit::gateway('kashier')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -318,10 +322,10 @@ return redirect()->away($session->checkoutUrl); - **الـ redirect موقّع كمان.** كل باراميتر في الـ query ما عدا `signature` و`mode`، بالترتيب اللي وصل بيه: ```php -use Tahseel\Gateways\Kashier\KashierSignature; +use Paykit\Gateways\Kashier\KashierSignature; $query = $request->query(); -$isGenuine = KashierSignature::verifyRedirect($query, $query['signature'] ?? null, config('tahseel.drivers.kashier.api_key')); +$isGenuine = KashierSignature::verifyRedirect($query, $query['signature'] ?? null, config('paykit.drivers.kashier.api_key')); ``` هيدر `api-key` في Kashier هو **Payment API Key**، و`Authorization` بياخد **Secret Key** زي ما هو من غير `Bearer`. الاتنين مش بدل بعض، ولكل مود (Test/Live) مفاتيحه. @@ -337,11 +341,11 @@ FAWRY_MERCHANT_CODE=1tSa6uxz2nTwlaAmt38enA== FAWRY_SECURE_KEY=... FAWRY_PAYMENT_METHOD=PayAtFawry FAWRY_LANGUAGE=en-gb -FAWRY_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/fawry +FAWRY_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/fawry ``` ```php -$session = Tahseel::gateway('fawry')->createPayment($request); +$session = Paykit::gateway('fawry')->createPayment($request); // اعرض دول للعميل. مفيش رابط دفع تحوّله عليه. $session->paymentReference; // "9001234567" @@ -365,13 +369,13 @@ Geidea بتشتغل على خطوتين: تنشئ session، وبعدين تحو GEIDEA_BASE_URL=https://api.merchant.geidea.net # السعودية: https://api.ksamerchant.geidea.net، الإمارات: https://api.geidea.ae GEIDEA_PUBLIC_KEY=... GEIDEA_API_PASSWORD=... -GEIDEA_CALLBACK_URL=https://your-app.test/tahseel/webhooks/geidea +GEIDEA_CALLBACK_URL=https://your-app.test/paykit/webhooks/geidea GEIDEA_RETURN_URL=https://your-app.test/checkout/done GEIDEA_PHONE_COUNTRY_CODE=+20 ``` ```php -$session = Tahseel::gateway('geidea')->createPayment($request); +$session = Paykit::gateway('geidea')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -393,11 +397,11 @@ MYFATOORAH_BASE_URL=https://api.myfatoorah.com # للتجربة: https: MYFATOORAH_API_KEY=... MYFATOORAH_WEBHOOK_SECRET=... MYFATOORAH_CALLBACK_URL=https://your-app.test/checkout/done -MYFATOORAH_WEBHOOK_URL=https://your-app.test/tahseel/webhooks/myfatoorah +MYFATOORAH_WEBHOOK_URL=https://your-app.test/paykit/webhooks/myfatoorah ``` ```php -$session = Tahseel::gateway('myfatoorah')->createPayment($request); +$session = Paykit::gateway('myfatoorah')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -408,7 +412,7 @@ return redirect()->away($session->checkoutUrl); - **كل طلب POST بتوكن Bearer، والأخطاء بتتخبى جوا 200.** MyFatoorah بترجع HTTP 200 حتى في الفشل مع `IsSuccess: false` في الجسم؛ الباكدج بيفحص العلامة دي، مش كود الحالة بس. - **توقيع الـ webhook على قائمة حقول موثّقة.** كل نوع event في v2 بيوقّع قائمة `Key=Value` مرتبة خاصة بيه بسر الـ webhook (HMAC-SHA-256 وبعدين base64) في هيدر `myfatoorah-signature`. الباكدج بيبني النص ده من الـ payload ويتحقق قبل القراءة، وبيرفض أي نوع event أو حالة معاملة مش معروفة بدل ما يخمّن. -الاسترداد عن طريق `Tahseel::refund()` هو **طلب** فريق MyFatoorah المالي بينفذه، فالنتيجة بترجع pending والإتمام بييجي كـ webhook من نوع `REFUND_STATUS_CHANGED`. +الاسترداد عن طريق `Paykit::refund()` هو **طلب** فريق MyFatoorah المالي بينفذه، فالنتيجة بترجع pending والإتمام بييجي كـ webhook من نوع `REFUND_STATUS_CHANGED`. ## Tap @@ -418,11 +422,11 @@ Tap بتغطي السعودية والكويت والإمارات وباقي ا TAP_BASE_URL=https://api.tap.payments # host واحد؛ المفتاح sk_test_... أو sk_live_... هو اللي بيحدد الوضع TAP_SECRET_KEY=sk_test_... TAP_REDIRECT_URL=https://your-app.test/checkout/done -TAP_WEBHOOK_URL=https://your-app.test/tahseel/webhooks/tap +TAP_WEBHOOK_URL=https://your-app.test/paykit/webhooks/tap ``` ```php -$session = Tahseel::gateway('tap')->createPayment($request); +$session = Paykit::gateway('tap')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -446,7 +450,7 @@ HYPERPAY_SHOPPER_RESULT_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('hyperpay')->createPayment($request); +$session = Paykit::gateway('hyperpay')->createPayment($request); // HyperPay بتتضمّن كودجت: الـ checkoutUrl في الجلسة هو سكربت الودجت، // والـ intentionId هو رقم الـ checkout اللي فورم صفحتك بيستخدمه. @@ -470,7 +474,7 @@ CHECKOUTCOM_SUCCESS_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('checkoutcom')->createPayment($request); +$session = Paykit::gateway('checkoutcom')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -479,7 +483,7 @@ return redirect()->away($session->checkoutUrl); - **المبالغ أرقام صحيحة بأصغر وحدة.** `25000` يعني 250.00 ريال. الباكدج بيبعت الرقم الصحيح مباشرة، فدفعة 19.99 ماتبقاش أبداً `19.989999`. - **التوقيع على الجسم الخام بايت ببايت.** هيدر `Cko-Signature` هو HMAC-SHA-256 (hex) بمفتاح توقيع الـ webhook على البايتات اللي وصلت بالظبط؛ إعادة تسلسل الـ JSON قبل التحقق بتكسر كل توقيع. الباكدج بيتحقق من الجسم الخام الأول وبعدين يقرأه. -- **الاسترداد بيتقبّل، مش بيكمّل في الحال.** الـ API بيرد 202 برقم action؛ والإتمام بييجي كـ webhook من نوع `payment_refunded`، فـ `Tahseel::refund()` بترجع pending. أنواع الأحداث اللي الدرايفر مش بيترجمها (المنازعات، تحقق الكروت) بترفض بصوت عالي، مبتتخمّنش. +- **الاسترداد بيتقبّل، مش بيكمّل في الحال.** الـ API بيرد 202 برقم action؛ والإتمام بييجي كـ webhook من نوع `payment_refunded`، فـ `Paykit::refund()` بترجع pending. أنواع الأحداث اللي الدرايفر مش بيترجمها (المنازعات، تحقق الكروت) بترفض بصوت عالي، مبتتخمّنش. ## PayPal @@ -494,12 +498,12 @@ PAYPAL_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('paypal')->createPayment($request); +$session = Paykit::gateway('paypal')->createPayment($request); return redirect()->away($session->checkoutUrl); // صفحة الموافقة بتاعة باي بال // على الـ return URL، اعمل capture للـ order المعتمد (الـ `token` في الـ query هو الـ order id): -$result = Tahseel::gateway('paypal')->capture(CaptureRequest::forTransaction($request->query('token'))); +$result = Paykit::gateway('paypal')->capture(CaptureRequest::forTransaction($request->query('token'))); ``` أربع تفاصيل مهمة في باي بال: @@ -522,7 +526,7 @@ STRIPE_SUCCESS_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('stripe')->createPayment($request); +$session = Paykit::gateway('stripe')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -547,7 +551,7 @@ PAYSTACK_CALLBACK_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('paystack')->createPayment($request); +$session = Paykit::gateway('paystack')->createPayment($request); return redirect()->away($session->checkoutUrl); ``` @@ -572,7 +576,7 @@ MOYASAR_CALLBACK_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('moyasar')->createPayment($request); +$session = Paykit::gateway('moyasar')->createPayment($request); return redirect()->away($session->checkoutUrl); // تحدي الـ 3DS ``` @@ -599,7 +603,7 @@ RAZORPAY_CALLBACK_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('razorpay')->createPayment($request); +$session = Paykit::gateway('razorpay')->createPayment($request); return redirect()->away($session->checkoutUrl); // رابط rzp.io القصير ``` @@ -625,7 +629,7 @@ MERCADOPAGO_SUCCESS_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('mercadopago')->createPayment($request); +$session = Paykit::gateway('mercadopago')->createPayment($request); return redirect()->away($session->checkoutUrl); // الـ init_point ``` @@ -650,7 +654,7 @@ MOLLIE_WEBHOOK_URL=https://your-app.test/webhooks/mollie ``` ```php -$session = Tahseel::gateway('mollie')->createPayment($request); +$session = Paykit::gateway('mollie')->createPayment($request); return redirect()->away($session->checkoutUrl); // رابط _links.checkout ``` @@ -676,7 +680,7 @@ ADYEN_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('adyen')->createPayment($request); +$session = Paykit::gateway('adyen')->createPayment($request); return redirect()->away($session->checkoutUrl); // رابط صفحة الدفع المستضافة ``` @@ -701,7 +705,7 @@ FLUTTERWAVE_PAYMENT_OPTIONS=card, ussd, mobilemoneyghana # اختياري ``` ```php -$session = Tahseel::gateway('flutterwave')->createPayment($request); +$session = Paykit::gateway('flutterwave')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -723,12 +727,12 @@ PayTabs هو عاشر درايفر دولي ومعالج الخليج نفسه: PAYTABS_PROFILE_ID=987654 PAYTABS_SERVER_KEY=... # Dashboard -> Developers -> Key management PAYTABS_BASE_URL=https://secure-egypt.paytabs.com # هوست المنطقة بتاعتك؛ الغلط منه بيفشل التوثيق -PAYTABS_CALLBACK_URL=https://your-app.test/tahseel/webhooks/paytabs +PAYTABS_CALLBACK_URL=https://your-app.test/paykit/webhooks/paytabs PAYTABS_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('paytabs')->createPayment($request); +$session = Paykit::gateway('paytabs')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -755,12 +759,12 @@ KLARNA_PURCHASE_COUNTRY=SE KLARNA_LOCALE=en-SE KLARNA_CURRENCY=SEK KLARNA_RETURN_URL=https://your-app.test/checkout/done -KLARNA_CALLBACK_URL=https://your-app.test/tahseel/webhooks/klarna +KLARNA_CALLBACK_URL=https://your-app.test/paykit/webhooks/klarna KLARNA_CALLBACK_TOKEN=... # نص عشوائي طويل بتولّده انت ``` ```php -$session = Tahseel::gateway('klarna')->createPayment($request); +$session = Paykit::gateway('klarna')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -784,12 +788,12 @@ SQUARE_ACCESS_TOKEN=... # Developer Console -> SQUARE_LOCATION_ID=L88917AVBK2S5 SQUARE_SQUARE_VERSION=2026-11-18 # نسخة الـ API اللي بتثبّتها SQUARE_SIGNATURE_KEY=... # Webhooks -> الاشتراك بتاعك -SQUARE_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/square +SQUARE_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/square SQUARE_RETURN_URL=https://your-app.test/checkout/done ``` ```php -$session = Tahseel::gateway('square')->createPayment($request); +$session = Paykit::gateway('square')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -819,7 +823,7 @@ XENDIT_CANCEL_URL=https://your-app.test/checkout/cancelled ``` ```php -$session = Tahseel::gateway('xendit')->createPayment($request); +$session = Paykit::gateway('xendit')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -849,7 +853,7 @@ TELR_CANCELLED_URL=https://your-app.test/checkout/cancelled ``` ```php -$session = Tahseel::gateway('telr')->createPayment($request); +$session = Paykit::gateway('telr')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -879,7 +883,7 @@ VIVA_REQUEST_LANGUAGE=en-GB ``` ```php -$session = Tahseel::gateway('viva')->createPayment($request); +$session = Paykit::gateway('viva')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -903,14 +907,14 @@ PAYU_CLIENT_ID=... # من الـ POS في لوحة ا PAYU_CLIENT_SECRET=... PAYU_POS_ID=145227 PAYU_SECOND_KEY=... # المفتاح التاني للـ POS اللي بيوقّع الإشعارات -PAYU_NOTIFY_URL=https://your-app.test/tahseel/webhooks/payu +PAYU_NOTIFY_URL=https://your-app.test/paykit/webhooks/payu PAYU_CONTINUE_URL=https://your-app.test/checkout/done PAYU_CUSTOMER_IP=127.0.0.1 PAYU_LANGUAGE=en ``` ```php -$session = Tahseel::gateway('payu')->createPayment($request); +$session = Paykit::gateway('payu')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -940,7 +944,7 @@ TABBY_FAILURE_URL=https://your-app.test/checkout/failed ``` ```php -$session = Tahseel::gateway('tabby')->createPayment($request); +$session = Paykit::gateway('tabby')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -970,7 +974,7 @@ TAMARA_CANCEL_URL=https://your-app.test/checkout/cancel ``` ```php -$session = Tahseel::gateway('tamara')->createPayment($request); +$session = Paykit::gateway('tamara')->createPayment($request); header('Location: '.$session->checkoutUrl); ``` @@ -991,13 +995,13 @@ header('Location: '.$session->checkoutUrl); ده مش بوابة، ومفيش فيه حاجة أوتوماتيك: القرار النهائي لبني آدم. اللي الباكدج بيعمله هو الجزء الممل والخطير مرة واحدة: مرجع محدش يقدر يخمّنه، مبلغ العميل مش قادر يغيّره، مكان خاص لإيصالات التحويل، ونفس حدث `PaymentSucceeded` اللي البوابات بتطلقه. ```dotenv -TAHSEEL_VODAFONE_CASH_NUMBER=01000000000 -TAHSEEL_INSTAPAY_HANDLE=merchant@instapay -TAHSEEL_MANUAL_PANEL_ABILITY=manage-payments +PAYKIT_VODAFONE_CASH_NUMBER=01000000000 +PAYKIT_INSTAPAY_HANDLE=merchant@instapay +PAYKIT_MANUAL_PANEL_ABILITY=manage-payments ``` ```php -$session = Tahseel::createPayment($request->withMethod('vodafone_cash'), 'manual'); +$session = Paykit::createPayment($request->withMethod('vodafone_cash'), 'manual'); $session->paymentReference; // MAN-7F3K9QX2AB، الكود اللي العميل بيقوله $session->raw['account']; // الفلوس بتروح فين @@ -1007,19 +1011,19 @@ $session->raw['instructions']; // جملة واحدة تعرضها للعمي الرحلة: -1. **إنت بتفتح الدفعة.** `Tahseel::createPayment($request, 'manual')` بيكتب صف في الجدول وبيرجّع المرجع والحساب والمبلغ. اعرضهم على العميل. -2. **العميل بيحوّل وبيقول.** `POST /tahseel/manual/{reference}/proof` بياخد `transfer_reference` وملف `proof` اختياري. المرجع هو وسيلة التحقق الوحيدة، فبيتولّد غير قابل للتخمين والراوت عليه rate limit. -3. **إنت بتقرر.** `GET /tahseel/manual/panel` بيعرض اللي لسه مفتوح، والإيصال ورا لينك محمي بالصلاحية. الموافقة بتطلق `PaymentSucceeded` والرفض بيطلق `PaymentFailed`، والاتنين بالمبلغ المخزّن في الصف، مش اللي جاي في الفورم. +1. **إنت بتفتح الدفعة.** `Paykit::createPayment($request, 'manual')` بيكتب صف في الجدول وبيرجّع المرجع والحساب والمبلغ. اعرضهم على العميل. +2. **العميل بيحوّل وبيقول.** `POST /paykit/manual/{reference}/proof` بياخد `transfer_reference` وملف `proof` اختياري. المرجع هو وسيلة التحقق الوحيدة، فبيتولّد غير قابل للتخمين والراوت عليه rate limit. +3. **إنت بتقرر.** `GET /paykit/manual/panel` بيعرض اللي لسه مفتوح، والإيصال ورا لينك محمي بالصلاحية. الموافقة بتطلق `PaymentSucceeded` والرفض بيطلق `PaymentFailed`، والاتنين بالمبلغ المخزّن في الصف، مش اللي جاي في الفورم. -انشر الـ migration واعمل migrate (الجدول `tahseel_manual_payments`)، والـ views قابلة للنشر لو عايز تغيّر شكل اللوحة: +انشر الـ migration واعمل migrate (الجدول `paykit_manual_payments`)، والـ views قابلة للنشر لو عايز تغيّر شكل اللوحة: ```bash -php artisan vendor:publish --tag=tahseel-migrations -php artisan vendor:publish --tag=tahseel-views +php artisan vendor:publish --tag=paykit-migrations +php artisan vendor:publish --tag=paykit-views php artisan migrate ``` -**اللوحة مقفولة افتراضيًا.** راوتسها بتتسجّل بس لما `tahseel.drivers.manual.panel.ability` يحدد اسم Gate ability، وكل طلب لازم يكون من مستخدم مسجّل دخول وبيعدّي الـ ability دي: +**اللوحة مقفولة افتراضيًا.** راوتسها بتتسجّل بس لما `paykit.drivers.manual.panel.ability` يحدد اسم Gate ability، وكل طلب لازم يكون من مستخدم مسجّل دخول وبيعدّي الـ ability دي: ```php Gate::define('manage-payments', fn (User $user) => $user->is_admin); @@ -1038,15 +1042,15 @@ Gate::define('manage-payments', fn (User $user) => $user->is_admin); كل ده مقفول لحد ما تفتحه: مفيش حاجة شغالة افتراضيًا. - **الحدود.** `methods.{method}.min_minor` و`max_minor` بيرفضوا دفعة برّه النطاق وقت إنشائها. -- **الانتهاء.** جدول الأمر `php artisan tahseel:manual:expire` (مثلاً كل 5 دقايق). الدفعات المتأخرة بتبقى `expired` وبتطلق `PaymentFailed`. دفعة مستنية قرار حد (`awaiting_review`) بتتساب لوحدها إلا لو فعّلت `expire_awaiting_review`. +- **الانتهاء.** جدول الأمر `php artisan paykit:manual:expire` (مثلاً كل 5 دقايق). الدفعات المتأخرة بتبقى `expired` وبتطلق `PaymentFailed`. دفعة مستنية قرار حد (`awaiting_review`) بتتساب لوحدها إلا لو فعّلت `expire_awaiting_review`. - **مرجع تحويل واحد لدفعة واحدة.** مرجع اتربط بدفعة بيترفض على غيرها (راوت الإثبات بيرد 409). شغّل الـ migration الجديد؛ بيضيف unique index على `transfer_reference`، فنضّف المراجع المكررة قبله لو عندك. - **أكتر من حساب.** اديّ الطريقة `accounts` (قايمة أرقام) بدل `account`؛ كل دفعة جديدة بتروح للحساب اللي عليه أقل دفعات مفتوحة. -- **سجل المراجعة** (`TAHSEEL_MANUAL_AUDIT=true`). سجل بيتضاف عليه بس في `tahseel_manual_events` (اتفتحت، اتبعت إثبات، اتوافق عليها، اترفضت، انتهت) ومين عمل إيه. اللوحة بتعرضه على `GET {panel}/{reference}/history`. -- **تنبيهات المراجعة.** الحدث `Tahseel\Events\ManualPaymentAwaitingReview` بيتطلق لما العميل يبعت إثبات. اسمعه عشان تبعت إيميل أو رسالة Slack أو إشعار. الباكدج نفسه مبيبعتش حاجة. -- **حالة العميل** (`TAHSEEL_MANUAL_STATUS=true`). `GET /tahseel/manual/{reference}/status` بيرجّع `status` و`reference` و`amount` و`expires_at` عشان صفحتك تعمل polling. مفيش غير كده: لا حساب ولا اسم ولا تليفون. +- **سجل المراجعة** (`PAYKIT_MANUAL_AUDIT=true`). سجل بيتضاف عليه بس في `paykit_manual_events` (اتفتحت، اتبعت إثبات، اتوافق عليها، اترفضت، انتهت) ومين عمل إيه. اللوحة بتعرضه على `GET {panel}/{reference}/history`. +- **تنبيهات المراجعة.** الحدث `Paykit\Events\ManualPaymentAwaitingReview` بيتطلق لما العميل يبعت إثبات. اسمعه عشان تبعت إيميل أو رسالة Slack أو إشعار. الباكدج نفسه مبيبعتش حاجة. +- **حالة العميل** (`PAYKIT_MANUAL_STATUS=true`). `GET /paykit/manual/{reference}/status` بيرجّع `status` و`reference` و`amount` و`expires_at` عشان صفحتك تعمل polling. مفيش غير كده: لا حساب ولا اسم ولا تليفون. - **إضافات اللوحة**، كل واحدة بمفتاح لوحدها: `panel.search` (المرجع، الطلب، مرجع التحويل، التليفون، الاسم) و`panel.export` (CSV؛ الخلايا اللي بتبدأ بـ `=` أو `+` أو `-` أو `@` بتتعطّل عشان اسم عميل ميشتغلش كمعادلة في إكسل). فلتر المنتهي موجود دايمًا. -- **حذف الإيصالات القديمة.** الإيصال بيانات شخصية؛ جدول الأمر `php artisan tahseel:manual:prune-proofs --days=30` عشان يمسح إيصالات الدفعات المتقفولة الأقدم من 30 يوم. الدفعات المفتوحة مابيتلمسش. -- **لغة اللوحة.** اللوحة بتتبع لغة التطبيق؛ حدّد `TAHSEEL_MANUAL_PANEL_LOCALE=ar` لو عايز اللوحة عربي من اليمين للشمال (ومعاها رسايل القرارات) والتطبيق نفسه إنجليزي. اعمل publish للـ `tahseel-lang` لو حابب تعدّل الصياغة. +- **حذف الإيصالات القديمة.** الإيصال بيانات شخصية؛ جدول الأمر `php artisan paykit:manual:prune-proofs --days=30` عشان يمسح إيصالات الدفعات المتقفولة الأقدم من 30 يوم. الدفعات المفتوحة مابيتلمسش. +- **لغة اللوحة.** اللوحة بتتبع لغة التطبيق؛ حدّد `PAYKIT_MANUAL_PANEL_LOCALE=ar` لو عايز اللوحة عربي من اليمين للشمال (ومعاها رسايل القرارات) والتطبيق نفسه إنجليزي. اعمل publish للـ `paykit-lang` لو حابب تعدّل الصياغة. - **`InstaPayLink::canonical($link)`** بتتحقق بصرامة من لينك `https://ipn.eg/S/{handle}`. الصيغة دي جاية من وصف طرف تالت مش من إنستاباي، فقارنها بلينك بيطلعه تطبيقك. ولينك إنستاباي مبيشيلش المبلغ. **مش في الإصدار ده: التأكيد التلقائي من رسايل SMS.** مطابقة رسالة "استلمت فلوس" متحوّلة مع دفعة (endpoint موقّع، ومطابقة، وpatterns اختيارية لرسايل فودافون كاش وبنوك إنستاباي، ومبلغ فريد) اتبنت وبعدين اتشالت من الإصدار لأنها لسه ما اتجرّبتش على رسالة وصلت لموبايل حقيقي. محفوظة في الفرع `feature/sms-ingest` وهترجع بعد ما نجرّبها على رسايل حقيقية. @@ -1068,7 +1072,7 @@ Gate::define('manage-payments', fn (User $user) => $user->is_admin); - **إنستاباي مفيش لها API تجار معلن.** تابعة لشركة المدفوعات الوطنية، والانضمام بيتم عن طريق بنكك أو أكوايرر، ومفيش واجهة HTTP موثّقة للتجار. - **فودافون كاش وباقي المحافظ نفس الحكاية من المصدر.** الوصول عن طريق aggregator أو بنك أو PSP، مش API مطوّرين معلن. البوابات اللي فوق هي الطريق المدعوم. -عشان كده الباكدج مش بيطلّع درايفر بوابة وهمي لأي منهم. ولو معندكش حساب بوابة خالص، [الدرايفر اليدوي](#الدفع-اليدوي-فودافون-كاش-وإنستاباي) هو الطريق: تحويل على محفظتك أو عنوان إنستاباي، وتأكيد من حد من فريقك. ولو أي شركة منهم نشرت API تجار، الدرايفر بيبقى تنفيذ لـ `Tahseel\Contracts\Gateway` وخلاص. +عشان كده الباكدج مش بيطلّع درايفر بوابة وهمي لأي منهم. ولو معندكش حساب بوابة خالص، [الدرايفر اليدوي](#الدفع-اليدوي-فودافون-كاش-وإنستاباي) هو الطريق: تحويل على محفظتك أو عنوان إنستاباي، وتأكيد من حد من فريقك. ولو أي شركة منهم نشرت API تجار، الدرايفر بيبقى تنفيذ لـ `Paykit\Contracts\Gateway` وخلاص. ## اللي مش موجود في 0.1 @@ -1089,24 +1093,24 @@ Gate::define('manage-payments', fn (User $user) => $user->is_admin); ## بوابة جديدة ```php -Tahseel::extend('fawry', fn ($app) => new FawryGateway($app['config']['tahseel.drivers.fawry'])); +Paykit::extend('fawry', fn ($app) => new FawryGateway($app['config']['paykit.drivers.fawry'])); ``` -أي درايفر بينفّذ `Tahseel\Contracts\Gateway`: `name()` و`createPayment()` و`verifyAndParseWebhook()`. +أي درايفر بينفّذ `Paykit\Contracts\Gateway`: `name()` و`createPayment()` و`verifyAndParseWebhook()`. -الاسترداد والإلغاء والكابتشر كونتراكتات اختيارية منفصلة. نفّذ `SupportsRefunds` أو `SupportsVoids` أو `SupportsCapture` على الدرايفر بتاعك، و`Tahseel::refund()` و`Tahseel::void()` و`Tahseel::capture()` هيوصلوا له؛ والدرايفر اللي مش منفّذ واحد منهم هيفضل يرمي `UnsupportedOperationException` عليه. +الاسترداد والإلغاء والكابتشر كونتراكتات اختيارية منفصلة. نفّذ `SupportsRefunds` أو `SupportsVoids` أو `SupportsCapture` على الدرايفر بتاعك، و`Paykit::refund()` و`Paykit::void()` و`Paykit::capture()` هيوصلوا له؛ والدرايفر اللي مش منفّذ واحد منهم هيفضل يرمي `UnsupportedOperationException` عليه. ## الاختبارات -### اختبار الـ checkout بتاعك بـ `Tahseel::fake()` +### اختبار الـ checkout بتاعك بـ `Paykit::fake()` -اختبارات تطبيقك مش محتاجة مفاتيح بوابات ولا شبكة. `Tahseel::fake()` بيستبدل كل درايفر ببديل بيسجّل: `createPayment` بيرد بجلسة على رابط fake واضح، والاسترداد والإلغاء والـ capture بيردّوا نجاح، وكل نداء بيتسجّل عشان التأكيدات. +اختبارات تطبيقك مش محتاجة مفاتيح بوابات ولا شبكة. `Paykit::fake()` بيستبدل كل درايفر ببديل بيسجّل: `createPayment` بيرد بجلسة على رابط fake واضح، والاسترداد والإلغاء والـ capture بيردّوا نجاح، وكل نداء بيتسجّل عشان التأكيدات. ```php -use Tahseel\Facades\Tahseel; +use Paykit\Facades\Paykit; it('starts a Paymob payment for a new order', function () { - $fake = Tahseel::fake(); + $fake = Paykit::fake(); $this->post('/checkout', ['cart' => 'ORDER-77'])->assertRedirect(); diff --git a/docs/ar/quickstart.md b/docs/ar/quickstart.md index 9d97042..71a01eb 100644 --- a/docs/ar/quickstart.md +++ b/docs/ar/quickstart.md @@ -7,8 +7,8 @@ ## 1. التثبيت ```bash -composer require elbanbydev/tahseel -php artisan vendor:publish --tag=tahseel-config +composer require elbanbydev/paykit +php artisan vendor:publish --tag=paykit-config ``` مفيش مفاتيح افتراضية ولا حسابات تجريبية جوه الباكدج. @@ -18,19 +18,19 @@ php artisan vendor:publish --tag=tahseel-config في `.env`، حط بيانات البوابة اللي عندك حساب عليها. مثال Paymob: ```env -TAHSEEL_GATEWAY=paymob +PAYKIT_GATEWAY=paymob PAYMOB_SECRET_KEY=sk_test_... PAYMOB_PUBLIC_KEY=pk_test_... PAYMOB_HMAC_SECRET=... PAYMOB_INTEGRATION_IDS=5123456 -PAYMOB_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/paymob +PAYMOB_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/paymob PAYMOB_REDIRECTION_URL=https://your-app.test/checkout/done ``` -كل بوابة ليها قسم في `config/tahseel.php` بالقيم المطلوبة بالظبط. قبل أول دفعة شغّل: +كل بوابة ليها قسم في `config/paykit.php` بالقيم المطلوبة بالظبط. قبل أول دفعة شغّل: ```bash -php artisan tahseel:check +php artisan paykit:check ``` بيطبع سطر لكل درايفر: `ok`، أو `missing` مع المفتاح الناقص واسم متغير البيئة. @@ -38,12 +38,12 @@ php artisan tahseel:check ## 3. أول دفعة ```php -use Tahseel\Data\Customer; -use Tahseel\Data\Money; -use Tahseel\Data\PaymentRequest; -use Tahseel\Facades\Tahseel; +use Paykit\Data\Customer; +use Paykit\Data\Money; +use Paykit\Data\PaymentRequest; +use Paykit\Facades\Paykit; -$session = Tahseel::createPayment(new PaymentRequest( +$session = Paykit::createPayment(new PaymentRequest( reference: 'ORDER-1042', amount: Money::of('250.00', 'EGP'), // بيتخزن 25000 قرش customer: new Customer( @@ -61,11 +61,11 @@ return redirect()->away($session->checkoutUrl); - `PaymentSession` فيها `orderId` و`checkoutUrl`. خزّن الـ reference والـ order id مع الأوردر، ده اللي بيرجع في الـ callback. - لو أعدت بنفس `idempotencyKey`، هترجع نفس الجلسة والبوابة مش هتتكلم تاني. -عايز تتأكد إن المفاتيح شغالة فعلاً؟ `php artisan tahseel:smoke` بيعمل دفعة حقيقية واحدة على البوابة (بتحجز صفحة دفع بس، مفيش فلوس بتتحرك في الخطوة دي). +عايز تتأكد إن المفاتيح شغالة فعلاً؟ `php artisan paykit:smoke` بيعمل دفعة حقيقية واحدة على البوابة (بتحجز صفحة دفع بس، مفيش فلوس بتتحرك في الخطوة دي). ## 4. الـ callbacks -الباكدج بيسجّل `POST /tahseel/webhooks/{gateway}` لوحده (المسار بيتغير من `tahseel.webhooks.path`). وجّه `notification_url` بتاع البوابة عليه. +الباكدج بيسجّل `POST /paykit/webhooks/{gateway}` لوحده (المسار بيتغير من `paykit.webhooks.path`). وجّه `notification_url` بتاع البوابة عليه. **مفيش callback بيتقرأ قبل ما التوقيع يطابق.** توقيع غلط = رفض، من غير تخمين. والتكرار بيتفلتر: نفس العملية بتتبعت لكودك مرة واحدة. ولو callback أقدم من واحد اتعالج وصل، مش هيرجّع الأوردر لحالة أقدم. @@ -73,7 +73,7 @@ return redirect()->away($session->checkoutUrl); ```php use Illuminate\Support\Facades\Event; -use Tahseel\Events\PaymentSucceeded; +use Paykit\Events\PaymentSucceeded; Event::listen(function (PaymentSucceeded $event) { $event->event->reference; // 'ORDER-1042' @@ -82,8 +82,8 @@ Event::listen(function (PaymentSucceeded $event) { }); ``` -- `Tahseel\Events\PaymentSucceeded` — الدفع نجح. -- `Tahseel\Events\PaymentFailed` — الدفع فشل أو اترفض. +- `Paykit\Events\PaymentSucceeded` — الدفع نجح. +- `Paykit\Events\PaymentFailed` — الدفع فشل أو اترفض. `redirection_url` اللي العميل بيرجع عليها **مش موقّعة** وأي حد يقدر يفتحها: ماتحدّثش حالة الأوردر منها أبدًا، الحالة بتتغير من الـ webhook المتحقق منه بس. @@ -91,14 +91,14 @@ Event::listen(function (PaymentSucceeded $event) { مفيش محفظة مصرية بتنشر API تجار معلن، فالدرايفر ده بيعمل الجزء اليدوي صح: -1. `Tahseel::createPayment($request->withMethod('vodafone_cash'), 'manual')` بيرجع **مرجع** محدش يقدر يخمّنه وحساب التحويل (رقم المحفظة أو عنوان إنستاباي) والمبلغ، تعرضهم للعميل. +1. `Paykit::createPayment($request->withMethod('vodafone_cash'), 'manual')` بيرجع **مرجع** محدش يقدر يخمّنه وحساب التحويل (رقم المحفظة أو عنوان إنستاباي) والمبلغ، تعرضهم للعميل. 2. العميل بيحوّل المبلغ بالظبط وبيرفع صورة الإيصال على راوت الإثبات. -3. حد من فريقك بيراجع من **اللوحة** (`/tahseel/manual/panel`) ويوافق أو يرفض. الموافقة بتطلق نفس `PaymentSucceeded` بتاع البوابات. +3. حد من فريقك بيراجع من **اللوحة** (`/paykit/manual/panel`) ويوافق أو يرفض. الموافقة بتطلق نفس `PaymentSucceeded` بتاع البوابات. الدرايفر ده محتاج migration: ```bash -php artisan vendor:publish --tag=tahseel-migrations +php artisan vendor:publish --tag=paykit-migrations php artisan migrate ``` diff --git a/docs/ar/sandboxes.md b/docs/ar/sandboxes.md index 51ec89e..58e564d 100644 --- a/docs/ar/sandboxes.md +++ b/docs/ar/sandboxes.md @@ -13,7 +13,7 @@ الخلاصة العملية: **Kashier هي الوحيدة اللي مبرمج يقدر يجربها من الأول للآخر دلوقتي بإيميل بس.** Paymob بعدها، بشرط إن التسجيل المجاني يديك تست مود قبل التفعيل (شوف الأسئلة المفتوحة تحت). فوري وGeidea الاتنين بيعدّوك على حد. -## توجيه تحصيل على الساندبوكس +## توجيه Paykit على الساندبوكس ```dotenv # Paymob: نفس الهوست، مفاتيح تست @@ -114,7 +114,7 @@ GEIDEA_API_PASSWORD=... | الخطوة | النتيجة | | --- | --- | -| `tahseel:check` و`tahseel:smoke --gateway=kashier` | اتعملت session وفتحت صفحة الدفع بعلامة وضع التجربة | +| `paykit:check` و`paykit:smoke --gateway=kashier` | اتعملت session وفتحت صفحة الدفع بعلامة وضع التجربة | | دفع ببيانات التجربة بتاعة الصفحة نفسها ومحاكي 3-D Secure | الدفع نجح ورجع بـ `paymentStatus=SUCCESS` | | التحقق من توقيع الـ redirect بـ `KashierSignature::verifyRedirect()` | نجح بعد إصلاح: التوقيع الحقيقي على القيم الخام (النجوم في `maskedCard` مش بتتشفّر) | | استرداد كامل بـ `refund()` | `REFUNDED` والنتيجة `SUCCESS` | @@ -129,12 +129,12 @@ GEIDEA_API_PASSWORD=... | الخطوة | النتيجة | | --- | --- | -| إنشاء intention بمفاتيح الاختبار الحقيقية (`tahseel:smoke --gateway=paymob`) | شغّال. رجع order حقيقي ورابط صفحة دفع. | -| الدفع على صفحة الدفع بكروت الاختبار المنشورة (محاكي 3-D Secure، اختيار `Y`) | **اترفض** في الكروت التلاتة برسالة "Merchant acquirer relationship does not support this Merchant Transaction Frequency". ده حد على حساب التجربة الجديد مش غلط في تحصيل. ماوصلناش لدفع ناجح. | +| إنشاء intention بمفاتيح الاختبار الحقيقية (`paykit:smoke --gateway=paymob`) | شغّال. رجع order حقيقي ورابط صفحة دفع. | +| الدفع على صفحة الدفع بكروت الاختبار المنشورة (محاكي 3-D Secure، اختيار `Y`) | **اترفض** في الكروت التلاتة برسالة "Merchant acquirer relationship does not support this Merchant Transaction Frequency". ده حد على حساب التجربة الجديد مش غلط في Paykit. ماوصلناش لدفع ناجح. | | التحقق من `hmac` في الـ redirect بمفتاح HMAC الحقيقي | **مطابق** لوصفة HMAC-SHA512 على الـ 20 حقل. | | وصول الـ webhook، الاسترداد، الإلغاء، الـ capture | **ماتجربتش على الحقيقي.** مفيش عملية ناجحة ولا رابط callback عام. | -اتصلّح: الـ redirect اللي Paymob بيرجّع بيه العميل query مسطّح (`order` هو رقم الأوردر، والحقول المتداخلة بتيجي `source_data.pan` أو `source_data_pan` بعد ما PHP يقرأها). تحصيل كان بيتحقق من جسم الـ webhook بس. دلوقتي `PaymobSignature::verifyRedirect()` بتتحقق من الـ redirect، ومعاها اختبار انحدار. +اتصلّح: الـ redirect اللي Paymob بيرجّع بيه العميل query مسطّح (`order` هو رقم الأوردر، والحقول المتداخلة بتيجي `source_data.pan` أو `source_data_pan` بعد ما PHP يقرأها). Paykit كان بيتحقق من جسم الـ webhook بس. دلوقتي `PaymobSignature::verifyRedirect()` بتتحقق من الـ redirect، ومعاها اختبار انحدار. ## Geidea وفوري: مش ممكن تجربتهم من غير إنسان (2026-11-30) diff --git a/docs/ar/security-audit.md b/docs/ar/security-audit.md index 9c1b045..ede26d3 100644 --- a/docs/ar/security-audit.md +++ b/docs/ar/security-audit.md @@ -18,7 +18,7 @@ vendor/bin/pest --filter=SecurityAttackTest | F-02 | متوسطة | **حقن URL في روابط الـ redirect والـ callback.** `notificationUrl` و`redirectionUrl` كانوا بيروحوا للبوابة من غير تحقق، فـ `javascript:` أو `file:` أو `data:` ممكن يوصل للبوابة وبعدها لمتصفح العميل باسم البوابة. | بقى يقبل `http` و`https` مطلقين بس، وأي حاجة تانية بترمي `InvalidPaymentRequestException`. | | F-03 | متوسطة | **overflow على مبالغ عبثية.** `Money::of()` كان بيقبل رقم أي طول، فتلاتين ٩ بتعمل overflow للعدد الصحيح والمبلغ يبقى float أو `TypeError` بدل ما يترفض. | أكتر من 12 رقم في الوحدات الكبيرة بيترفض. | | F-04 | منخفضة | **حروف تحكم في مرجع الدفع.** مرجع فيه سطر جديد كان بيتقبل ويدخل في payloads البوابة والتوقيعات واللوجات. | المراجع اللي فيها حروف تحكم بتترفض. | -| F-05 | منخفضة | **اسم بوابة مش معروف بيرجّع 500.** `POST /tahseel/webhooks/not-a-gateway` كان بيسيب `InvalidArgumentException` تطلع، فـ 500 و stack trace في اللوج. | بقى يرجّع 404 بجسم JSON قصير. | +| F-05 | منخفضة | **اسم بوابة مش معروف بيرجّع 500.** `POST /paykit/webhooks/not-a-gateway` كان بيسيب `InvalidArgumentException` تطلع، فـ 500 و stack trace في اللوج. | بقى يرجّع 404 بجسم JSON قصير. | | F-06 | منخفضة | **مفيش طريقة تبدّل الـ idempotency store.** المانجر كان بيبنيها لوحده. | `IdempotencyStore` بقى مربوط في الكونتينر كـ singleton وينفع يتبدّل. | وطلعت كمان تحسين مش باج: الباكدج مش بيخزّن الأوردرات، فمش قادر يقارن مبلغ الـ callback بالأوردر. اللي يقدر يعمله إنه يخلي الشيك سطر واحد، فبقى فيه `WebhookEvent::matchesAmount(Money $expected)` والـ README بيقول لازم تتنادى قبل أي تنفيذ. @@ -31,7 +31,7 @@ vendor/bin/pest --filter=SecurityAttackTest - **mass assignment واللوحة.** الموديل `guarded ['*']`، وبعت `amount_minor` و`currency` و`status` مع الموافقة مبغيّرش حاجة. اللوحة 403 من غير مستخدم و403 من غير الـ ability، وراوتات الكتابة عليها `web` (وفيها CSRF)، ومرجع مش موجود 404، والموافقة مرتين بتنفّذ حدث واحد، والمبلغ المدفوع بعد انتهاء المدة مش بيتوافق عليه، والقرار تحت row lock. - **الملفات.** ملف PHP متنكّر في شكل إيصال بيترفض بالـ MIME، والملف الكبير بالحجم، والاسم UUID، والمجلد باسم مرجع الدفعة، والديسك خاص. والتنزيل من راوت اللوحة بس وبنفس الـ ability، والـ traversal 404. - **ردود البوابة العدائية.** رد مش JSON بيبقى `GatewayException` مش crash، و500 من البوابة بيرجّع الـ claim. -- **الأسرار.** مفيش رسالة استثناء فيها مفتاح أو API password أو التوقيع المتوقع، و`tahseel:check` بيطبع حالة الإعداد مش القيم. +- **الأسرار.** مفيش رسالة استثناء فيها مفتاح أو API password أو التوقيع المتوقع، و`paykit:check` بيطبع حالة الإعداد مش القيم. - **مستوى اللغة.** مفيش `unserialize` ولا `eval` ولا تنفيذ shell في `src/`، وده متأكد منه باختبار بيمشي على الشجرة. - **الاعتماديات.** `composer audit --locked` مفيش عليه تحذيرات. @@ -56,7 +56,7 @@ vendor/bin/pest --filter=SecurityAttackTest | F-07 | وسط | **فحص المرجع المكرر كان بيحصل بعد رفع الإيصال.** المكرر المرفوض كان بيسيب ملفه على الـ disk، فمرجع مكرر متعمد يملّى المساحة. | الفحص بقى قبل تخزين أي ملف. | | F-08 | وسط | **الفحص كان حساس للمسافات والحروف.** `TRX 12` و`trx12` و` TRX12 ` كانت بتعدي كتلات مراجع مختلفة رغم إن الـ unique index ممكن يشوفهم واحد حسب الـ collation. | المرجع بيتوحّد (trim، تقليص المسافات، حروف كبيرة) قبل الفحص وقبل التخزين. | | F-09 | وسط | **سباق على الفحص كان بيطلع خطأ قاعدة بيانات خام.** طلبين في نفس اللحظة يعدّوا الفحص والتاني يضرب في الـ unique index. | الـ `QueryException` بتتقفش وبتتحوّل لـ `DuplicateTransferReferenceException`، نفس رد المكرر العادي. | -| F-10 | وسط | **دفعة منتهية وإيصالها وصل كانت مستحيل تتقرر.** فحص المدة كان بيرفض أي قرار بعد `expires_at`، حتى موافقة بني آدم على إيصال وصل في وقته. وأمر `tahseel:manual:expire` كان بيمسح كمان صفوف `awaiting_review`. | رفض المدة بقى على اللي محدش رد عليه (`pending`) بس. و`expireOverdue()` بيخلّص `pending` بس إلا لو فعّلت إعداد `expire_awaiting_review` الجديد (مقفول افتراضيًا). ده بيغيّر ملاحظة v0.1 إن دفعة منتهية ماتتوافقش أبدًا؛ ده مقصود والـ README بيقول كده. | +| F-10 | وسط | **دفعة منتهية وإيصالها وصل كانت مستحيل تتقرر.** فحص المدة كان بيرفض أي قرار بعد `expires_at`، حتى موافقة بني آدم على إيصال وصل في وقته. وأمر `paykit:manual:expire` كان بيمسح كمان صفوف `awaiting_review`. | رفض المدة بقى على اللي محدش رد عليه (`pending`) بس. و`expireOverdue()` بيخلّص `pending` بس إلا لو فعّلت إعداد `expire_awaiting_review` الجديد (مقفول افتراضيًا). ده بيغيّر ملاحظة v0.1 إن دفعة منتهية ماتتوافقش أبدًا؛ ده مقصود والـ README بيقول كده. | | F-11 | منخفضة | **`_` و`%` في بحث اللوحة كانت wildcards.** البحث عن مرجع فيه `_` كان بيطابق أي حرف. | كلمات البحث بتتعملها escape بـ `ESCAPE '!'` صريح. | | F-12 | منخفضة | **فشل كتابة سطر في سجل المراجعة كان بيكسّر تدفق الدفع.** الإدخال كان في نفس التدفق، فعطلة في جدول السجل كانت هتفشّل موافقة. | كتابة السجل متلفّة بـ `try/catch` وبتتبلّغ لمعالج استثناءات Laravel بدل ما تكسر الدفع. وحدث `ManualPaymentAwaitingReview` بقى بيطلق قبل سطر السجل، فالمستمعين بيسمعوا حتى لو الجدول واقع. | @@ -95,14 +95,14 @@ vendor/bin/pest --filter=SecurityAttackTest ## مراجعة الإضافات بعد v0.2.2 (3 ديسمبر 2026) -مراجعة قصيرة لكل اللي اتضاف بعد v0.2.2 (طلبات الدمج المفتوحة): تعريب اللوحة (RTL)، ترقيم صفحات اللوحة، تحذيرات `tahseel:check`، `Tahseel::fake()`، أمر `tahseel:manual:prune-proofs`، تعديلات الـ CI والمستندات الجديدة. +مراجعة قصيرة لكل اللي اتضاف بعد v0.2.2 (طلبات الدمج المفتوحة): تعريب اللوحة (RTL)، ترقيم صفحات اللوحة، تحذيرات `paykit:check`، `Paykit::fake()`، أمر `paykit:manual:prune-proofs`، تعديلات الـ CI والمستندات الجديدة. النتايج، بصراحة: - **مفيش حدود ثقة جديدة اتضافت.** التعريب بيقرا قيمة من الإعداد على السيرفر؛ الحالات بتتعرض من الـ enum؛ ومتغيرات الترقيم بتعدي من paginator بتاع Laravel وترميز Blade. -- **`tahseel:manual:prune-proofs` بيمسح ملفات بأسماء جاية من `proof_path`.** المسارات دي الباكدج نفسه بيولّدها وقت الرفع، ومابتتاخدش من طلب، فمسار زي `../../` ميقدرش يوصل من راوت الإثبات. الأمر بيشغّله مستخدم الكونسول بس، ومابيلمسش غير الدفعات المقبولة أو المرفوضة. -- **`Tahseel::fake()` خطورته الوحيدة لو اتنده برّه الاختبارات**: بعده، `createPayment` بترجّع جلسات البوابة ماشفتاش. مابيغيّرش حاجة لوحده؛ لازم التاجر يناديه. متوثّق إنه للاختبارات بس. -- **تحذيرات `tahseel:check` بتقرا الإعداد وتطبع**؛ مابتغيّرش حاجة ولسه بتفشل بس على المفاتيح الناقصة زي الأول. +- **`paykit:manual:prune-proofs` بيمسح ملفات بأسماء جاية من `proof_path`.** المسارات دي الباكدج نفسه بيولّدها وقت الرفع، ومابتتاخدش من طلب، فمسار زي `../../` ميقدرش يوصل من راوت الإثبات. الأمر بيشغّله مستخدم الكونسول بس، ومابيلمسش غير الدفعات المقبولة أو المرفوضة. +- **`Paykit::fake()` خطورته الوحيدة لو اتنده برّه الاختبارات**: بعده، `createPayment` بترجّع جلسات البوابة ماشفتاش. مابيغيّرش حاجة لوحده؛ لازم التاجر يناديه. متوثّق إنه للاختبارات بس. +- **تحذيرات `paykit:check` بتقرا الإعداد وتطبع**؛ مابتغيّرش حاجة ولسه بتفشل بس على المفاتيح الناقصة زي الأول. - قوالب الـ issues/PRs الجديدة بينبّهوا ضد لصق الأسرار، بس القوالب مش بتفرض ده. المخاطر الباقية زي ما هي في الأقسام فوق. diff --git a/docs/ar/state-transitions.md b/docs/ar/state-transitions.md index 6dac6f7..ea9ab62 100644 --- a/docs/ar/state-transitions.md +++ b/docs/ar/state-transitions.md @@ -1,6 +1,6 @@ # انتقالات حالة الدفع -كل حالة ممكن تعدي بيها دفعة في تحصيل، لكل بوابة، واللي بيحصل عند الأطراف: أخبار متأخرة أو مكررة أو مقلوبة الترتيب أو متناقضة عن الفلوس. الحالات الموحّدة: `pending` و`succeeded` و`failed` و`refunded` و`voided` (`Tahseel\Enums\PaymentStatus`). +كل حالة ممكن تعدي بيها دفعة في Paykit، لكل بوابة، واللي بيحصل عند الأطراف: أخبار متأخرة أو مكررة أو مقلوبة الترتيب أو متناقضة عن الفلوس. الحالات الموحّدة: `pending` و`succeeded` و`failed` و`refunded` و`voided` (`Paykit\Enums\PaymentStatus`). في حارسين بيشتغلوا قبل ما أي حدث يوصل لكودك (`WebhookGuard`): @@ -44,7 +44,7 @@ `status` الموقّع هو الأساس: `Success` محتاجة `responseCode` بـ `000` وإلا بتبقى failed؛ و`REFUNDED`/`PARTIALLY_REFUNDED` ← refunded؛ و`VOIDED` ← voided؛ وعائلات الفشل والانتظار بالاسم؛ وأي حاجة مجهولة بتترفض. -- في callback الاسترداد Geidea بيسيب `status` الموقّع `Success` وبيحط `Refunded` في `detailedStatus` (على حسب عينات الكولباك بتاعته، مش متأكد منها لايف). و`detailedStatus` **مش** حقل موقّع، فتحصيل بيصدقه بس عشان يحوّل نجاح لاسترداد أو إلغاء، ماشي العكس أبدًا، وده خطر متبقي موثّق: حد معاه callback حقيقي متصيَّد يقدر يعيد إرساله بحقل غير موقّع مقلوب. والترتيب بيستخدم `timeStamp` الموقّع لكل callback، فالإعادة دي على الأقل بترتب بعد النجاح الحقيقي. +- في callback الاسترداد Geidea بيسيب `status` الموقّع `Success` وبيحط `Refunded` في `detailedStatus` (على حسب عينات الكولباك بتاعته، مش متأكد منها لايف). و`detailedStatus` **مش** حقل موقّع، فـPaykit بيصدقه بس عشان يحوّل نجاح لاسترداد أو إلغاء، ماشي العكس أبدًا، وده خطر متبقي موثّق: حد معاه callback حقيقي متصيَّد يقدر يعيد إرساله بحقل غير موقّع مقلوب. والترتيب بيستخدم `timeStamp` الموقّع لكل callback، فالإعادة دي على الأقل بترتب بعد النجاح الحقيقي. ## اليدوي (فودافون كاش، إنستاباي) @@ -53,7 +53,7 @@ - المبلغ والعملة بيتقروا من الصف وقت القرار؛ مفيش حاجة في الطلب تقدر تغيّرهم. - القرار بيمسك قفل الصف، فضغطتين ميقدروش يحسموا مرتين، ودفعة اتحسمت بترفض أي قرار بعد كده. نفس القرار مرتين بيبقى بدون تأثير ومن غير حدث تاني. - إرسال الإيصال بيمسك القفل برضه: انتهاء أو قرار بني آدم يحصل والصورة بتترفع هو اللي يكسب، والملف المرفوض بيتمسح من الـ disk. -- دفعة إيصالها وصل خلاص ممكن تتقرر بعد مدتها؛ أما اللي محدش رد عليها بيقفلها `tahseel:manual:expire`. +- دفعة إيصالها وصل خلاص ممكن تتقرر بعد مدتها؛ أما اللي محدش رد عليها بيقفلها `paykit:manual:expire`. - إيصال متعاد إرساله بيستبدل القديم، والقديم بيتمسح. - مبلغ محوّل ناقص أو غلط هو قرار بني آدم: الباكدج مابيقارنش مبلغ التحويل أبدًا، لأنه مش شايف التحويل. اللوحة بتعرض المبلغ المتوقع جنب الإيصال. - **إعادة الفتح هي طريق الإصلاح.** دفعة مرفوضة أو منتهية يقدر بني آدم يرجّعها (`ManualPayments::reopen` أو زرار Reopen في اللوحة): اللي معاها إيصال بترجع `awaiting_review`، واللي من غير بتاخد مهلة جديدة، والسجل بيسجّلها (`reopened`)، والتطبيق بيسمع `PaymentPending` عشان يلغي فشل الأوردر. **المقبولة نهائية**: الفلوس اتأكدت، والرجوع في ده هو استرداد، والدرايفر اليدوي مابيعملش استرداد. diff --git a/docs/ar/troubleshooting.md b/docs/ar/troubleshooting.md index a9744e2..f0dbb0c 100644 --- a/docs/ar/troubleshooting.md +++ b/docs/ar/troubleshooting.md @@ -7,7 +7,7 @@ **البوابة بتقول إنها بعتت الإشعار، بس الطلب ماتسجلش مدفوع.** - لو إنت على v0.2.1 أو أقدم، حدّث: النسخ دي كانت بتعتبر *تغيّر الحالة* على نفس رقم العملية "تكرار"، فإشعار النجاح لفوري وجيديا وبايموب كاش/محافظ كان بيترمي. اتصلّح في v0.2.2. -- اتأكد إن `tahseel.webhooks.enabled` شغالة، وإن لوحة البوابة بتوجّه على `https://your-domain/tahseel/webhooks/{gateway}` (أو المسار اللي إنت ظبطّه). +- اتأكد إن `paykit.webhooks.enabled` شغالة، وإن لوحة البوابة بتوجّه على `https://your-domain/paykit/webhooks/{gateway}` (أو المسار اللي إنت ظبطّه). - دوّر في اللوجز على 401 من راوت الـ webhook: ده معناه إن التوقيع فشل، وده تقريبًا دايمًا سر غلط (`PAYMOB_HMAC_SECRET`، `KASHIER_SECRET_KEY`، `FAWRY_SECURE_KEY`، `GEIDEA_API_PASSWORD`)، مش payload غلط. - رد 400 برسالة "unknown status" من Kashier معناه إن Kashier بعت حالة موقّعة الباكدج مش عارفاها؛ افتح issue باسم الحالة (مش الـ payload كله). @@ -19,7 +19,7 @@ **كل كروت التجربة بترفض في ساندبوكس بايموب.** -الحسابات التجريبية الجديدة عند بايموب ساعات ميبقاش وراها بنك استحواذ، فالدفع بيترفض قبل ما يوصل لأي كود في تحصيل. أكّد مع دعم بايموب إن حسابك التجريبي يقدر يستقبل مدفوعات. التجربة الحية بتاعتنا وقعت في نفس المشكلة (docs/sandboxes.md). +الحسابات التجريبية الجديدة عند بايموب ساعات ميبقاش وراها بنك استحواذ، فالدفع بيترفض قبل ما يوصل لأي كود في Paykit. أكّد مع دعم بايموب إن حسابك التجريبي يقدر يستقبل مدفوعات. التجربة الحية بتاعتنا وقعت في نفس المشكلة (docs/sandboxes.md). **فحص الـ HMAC بيفشل على التحويل الحقيقي بس بيشتغل على الـ fixtures.** @@ -41,7 +41,7 @@ Kashier بيوقّع الـ query بتاعة التحويل، مش الـ body. **اللوحة بترد 404 أو الراوتات مش موجودة.** -اللوحة مابتسجّلش أي راوت لحد ما `TAHSEEL_MANUAL_PANEL_ABILITY` يسمّي صلاحية Gate، ولازم الـ Gate يعرّف الصلاحية دي. ده مقصود: لوحة من غير حماية ممكن تحرّك فلوس. +اللوحة مابتسجّلش أي راوت لحد ما `PAYKIT_MANUAL_PANEL_ABILITY` يسمّي صلاحية Gate، ولازم الـ Gate يعرّف الصلاحية دي. ده مقصود: لوحة من غير حماية ممكن تحرّك فلوس. **عميل دفع بس الدفعة انتهت قبل ما حد يراجعها.** @@ -53,13 +53,13 @@ Kashier بيوقّع الـ query بتاعة التحويل، مش الـ body. **الإيصالات مينفعش تكون متاحة علنيًا.** -خلّي `TAHSEEL_MANUAL_PROOF_DISK` على disk خاص (الافتراضي `local`). `tahseel:check` بينبّه لو متحطوط `public`. +خلّي `PAYKIT_MANUAL_PROOF_DISK` على disk خاص (الافتراضي `local`). `paykit:check` بينبّه لو متحطوط `public`. ## منع التكرار (Idempotency) **طلب معاد أنشأ دفعة تانية عند البوابة.** -مخزن الـ idempotency هو cache store؛ على درايفر `array` أو `null` بينسى المفاتيح بين الطلبات. وجّه `TAHSEEL_IDEMPOTENCY_STORE` لمخزن دائم (redis أو database أو file). `tahseel:check` بينبّه على كده. +مخزن الـ idempotency هو cache store؛ على درايفر `array` أو `null` بينسى المفاتيح بين الطلبات. وجّه `PAYKIT_IDEMPOTENCY_STORE` لمخزن دائم (redis أو database أو file). `paykit:check` بينبّه على كده. ## التحديث diff --git a/docs/quickstart.md b/docs/quickstart.md index d329f54..a4ffb54 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -7,8 +7,8 @@ A short guide from zero to a first payment. Full details live in the [README](.. ## 1. Install ```bash -composer require elbanbydev/tahseel -php artisan vendor:publish --tag=tahseel-config +composer require elbanbydev/paykit +php artisan vendor:publish --tag=paykit-config ``` The package ships no default keys and no test accounts. @@ -18,19 +18,19 @@ The package ships no default keys and no test accounts. In `.env`, fill in the gateway you have an account with. Paymob example: ```env -TAHSEEL_GATEWAY=paymob +PAYKIT_GATEWAY=paymob PAYMOB_SECRET_KEY=sk_test_... PAYMOB_PUBLIC_KEY=pk_test_... PAYMOB_HMAC_SECRET=... PAYMOB_INTEGRATION_IDS=5123456 -PAYMOB_NOTIFICATION_URL=https://your-app.test/tahseel/webhooks/paymob +PAYMOB_NOTIFICATION_URL=https://your-app.test/paykit/webhooks/paymob PAYMOB_REDIRECTION_URL=https://your-app.test/checkout/done ``` -Each gateway has its own section in `config/tahseel.php` with exactly what it needs. Before the first payment, run: +Each gateway has its own section in `config/paykit.php` with exactly what it needs. Before the first payment, run: ```bash -php artisan tahseel:check +php artisan paykit:check ``` It prints one line per driver: `ok`, or `missing` with the key and its environment variable. It also warns about unsafe setups (plain-HTTP URLs, a volatile idempotency cache store, receipts on a public disk). @@ -38,12 +38,12 @@ It prints one line per driver: `ok`, or `missing` with the key and its environme ## 3. First payment ```php -use Tahseel\Data\Customer; -use Tahseel\Data\Money; -use Tahseel\Data\PaymentRequest; -use Tahseel\Facades\Tahseel; +use Paykit\Data\Customer; +use Paykit\Data\Money; +use Paykit\Data\PaymentRequest; +use Paykit\Facades\Paykit; -$session = Tahseel::createPayment(new PaymentRequest( +$session = Paykit::createPayment(new PaymentRequest( reference: 'ORDER-1042', amount: Money::of('250.00', 'EGP'), // stored as 25000 piastres customer: new Customer( @@ -61,11 +61,11 @@ return redirect()->away($session->checkoutUrl); - `PaymentSession` carries `orderId` and `checkoutUrl`. Store the reference and the order id with your order; they come back in the callback. - Retrying with the same `idempotencyKey` returns the same session; the gateway is not called twice. -Want proof your keys really work? `php artisan tahseel:smoke` starts one real payment on the gateway (it only reserves a payment page; no money moves at this step). +Want proof your keys really work? `php artisan paykit:smoke` starts one real payment on the gateway (it only reserves a payment page; no money moves at this step). ## 4. Callbacks -The package registers `POST /tahseel/webhooks/{gateway}` itself (the path is configurable via `tahseel.webhooks.path`). Point the gateway's `notification_url` at it. +The package registers `POST /paykit/webhooks/{gateway}` itself (the path is configurable via `paykit.webhooks.path`). Point the gateway's `notification_url` at it. **No callback is read before its signature checks out.** A wrong signature is refused, not guessed. Duplicates are filtered: one transaction reaches your code once. And a callback older than one already processed will not move the order backwards. @@ -73,7 +73,7 @@ Listen for the result through events: ```php use Illuminate\Support\Facades\Event; -use Tahseel\Events\PaymentSucceeded; +use Paykit\Events\PaymentSucceeded; Event::listen(function (PaymentSucceeded $event) { $event->event->reference; // 'ORDER-1042' @@ -82,8 +82,8 @@ Event::listen(function (PaymentSucceeded $event) { }); ``` -- `Tahseel\Events\PaymentSucceeded` - the payment succeeded. -- `Tahseel\Events\PaymentFailed` - the payment failed or was rejected. +- `Paykit\Events\PaymentSucceeded` - the payment succeeded. +- `Paykit\Events\PaymentFailed` - the payment failed or was rejected. The `redirection_url` the customer lands on is **not signed** and anyone can open it: never update an order from it; state changes come only from the verified webhook. @@ -91,14 +91,14 @@ The `redirection_url` the customer lands on is **not signed** and anyone can ope No Egyptian wallet publishes a merchant API, so this driver does the manual part properly: -1. `Tahseel::createPayment($request->withMethod('vodafone_cash'), 'manual')` returns a **reference** nobody can guess, the receiving account (wallet number or InstaPay handle) and the amount; show them to the customer. +1. `Paykit::createPayment($request->withMethod('vodafone_cash'), 'manual')` returns a **reference** nobody can guess, the receiving account (wallet number or InstaPay handle) and the amount; show them to the customer. 2. The customer transfers the exact amount and uploads a receipt photo to the proof route. -3. Someone on your team reviews in the **panel** (`/tahseel/manual/panel`) and approves or rejects. Approval raises the same `PaymentSucceeded` the gateways raise. +3. Someone on your team reviews in the **panel** (`/paykit/manual/panel`) and approves or rejects. Approval raises the same `PaymentSucceeded` the gateways raise. This driver needs a migration: ```bash -php artisan vendor:publish --tag=tahseel-migrations +php artisan vendor:publish --tag=paykit-migrations php artisan migrate ``` diff --git a/docs/sandboxes.md b/docs/sandboxes.md index 6c8312a..9c257e4 100644 --- a/docs/sandboxes.md +++ b/docs/sandboxes.md @@ -13,7 +13,7 @@ The mock in `mock/gateway.php` proves the drivers agree with each other. Only a Practical reading: **Kashier is the only one a developer can test end to end today with nothing but an email address.** Paymob is next, assuming the free signup gives test mode before activation (see the open questions below). Fawry and Geidea both route you through a human. -## Pointing Tahseel at a sandbox +## Pointing Paykit at a sandbox ```dotenv # Paymob: same host, test keys @@ -114,7 +114,7 @@ Run with a free Kashier account in Test Mode, host `https://test-api.kashier.io` | Step | Result | | --- | --- | -| `tahseel:check` and `tahseel:smoke --gateway=kashier` | Session created, hosted page opened with the test-mode badge | +| `paykit:check` and `paykit:smoke --gateway=kashier` | Session created, hosted page opened with the test-mode badge | | Pay with the page's own "use testing data" card and the 3-D Secure emulator | Paid, redirected back with `paymentStatus=SUCCESS` | | Verify the signed redirect with `KashierSignature::verifyRedirect()` | Passed after a fix: the real signature is over raw values (the `******` in `maskedCard` is not encoded) | | Full refund through `refund()` | `REFUNDED`, result `SUCCESS` | @@ -129,12 +129,12 @@ A free Paymob account (phone + SMS code, no documents) gives test mode, test API | Step | Result | | --- | --- | -| Create an intention with the live test keys (`tahseel:smoke --gateway=paymob`) | Works. Real order and hosted checkout URL returned. | -| Pay on the hosted checkout with the published test cards (3-D Secure emulator, answer `Y`) | **Declined** for all three cards with "Merchant acquirer relationship does not support this Merchant Transaction Frequency". This is a limit on the fresh test merchant, not a Tahseel fault. No successful payment was reached. | +| Create an intention with the live test keys (`paykit:smoke --gateway=paymob`) | Works. Real order and hosted checkout URL returned. | +| Pay on the hosted checkout with the published test cards (3-D Secure emulator, answer `Y`) | **Declined** for all three cards with "Merchant acquirer relationship does not support this Merchant Transaction Frequency". This is a limit on the fresh test merchant, not a Paykit fault. No successful payment was reached. | | Verify the signed redirect `hmac` with the real HMAC key | **Matches** the 20-field HMAC-SHA512 recipe. | | Webhook delivery, refund, void, capture | **Not tested live.** No successful transaction, and no public callback URL. | -Found and fixed: the redirect Paymob sends the customer back to is a flat query (`order` is the order id, nested fields arrive as `source_data.pan`, or `source_data_pan` after PHP parses it). Tahseel could only verify the nested webhook body. `PaymobSignature::verifyRedirect()` now verifies the redirect, with a regression test. +Found and fixed: the redirect Paymob sends the customer back to is a flat query (`order` is the order id, nested fields arrive as `source_data.pan`, or `source_data_pan` after PHP parses it). Paykit could only verify the nested webhook body. `PaymobSignature::verifyRedirect()` now verifies the redirect, with a regression test. ## Geidea and Fawry: not testable without a human (2026-11-30) diff --git a/docs/security-audit.md b/docs/security-audit.md index a1b7609..3cde431 100644 --- a/docs/security-audit.md +++ b/docs/security-audit.md @@ -18,8 +18,8 @@ Six things were wrong. All six are fixed, each with a test that fails if the fix | F-02 | Medium | **URL injection through redirect and callback URLs.** `notificationUrl` and `redirectionUrl` were passed to the gateway unvalidated, so a `javascript:`, `file:` or `data:` URL could be handed to the gateway and then to the customer's browser wearing the gateway's name. | Only absolute `http` and `https` URLs are accepted now; anything else throws `InvalidPaymentRequestException`. | | F-03 | Medium | **Integer overflow on absurd amounts.** `Money::of()` accepted a numeric string of any length, so 30 nines overflowed the minor-unit integer and the amount became a float (or a `TypeError`), not a rejection. | More than 12 digits of major units is refused. 999,999,999,999.99 is far past any real payment and still fits in 64 bits. | | F-04 | Low | **Control characters in a payment reference.** A reference with a newline was accepted and went into gateway payloads, signatures and logs. | References containing control characters are refused. | -| F-05 | Low | **Unknown gateway name returned 500.** `POST /tahseel/webhooks/not-a-gateway` let Laravel's `InvalidArgumentException` escape, producing a 500 and a stack trace in the log. | It answers 404 with a short JSON body. | -| F-06 | Low | **The idempotency store could not be replaced.** The manager built it privately, so an application with a Redis-backed queue or a custom store had no way in. | `Tahseel\Contracts\IdempotencyStore` is bound in the container as a singleton and can be swapped. | +| F-05 | Low | **Unknown gateway name returned 500.** `POST /paykit/webhooks/not-a-gateway` let Laravel's `InvalidArgumentException` escape, producing a 500 and a stack trace in the log. | It answers 404 with a short JSON body. | +| F-06 | Low | **The idempotency store could not be replaced.** The manager built it privately, so an application with a Redis-backed queue or a custom store had no way in. | `Paykit\Contracts\IdempotencyStore` is bound in the container as a singleton and can be swapped. | One improvement came out of the amount-tampering attack rather than a bug: the package cannot compare a callback's amount with the order, because it does not store orders. What it can do is make the check one line, so `WebhookEvent::matchesAmount(Money $expected)` now exists and the README says to call it before fulfilling anything. @@ -39,7 +39,7 @@ Each line is a test that would fail if the protection disappeared. **Hostile gateway responses.** A response that is not JSON becomes a `GatewayException` rather than a crash. A 500 from the gateway becomes a `GatewayException` and releases the idempotency claim. -**Secrets.** No exception message contains a secret key, an API password or the expected signature. `tahseel:check` prints configuration state, never values. +**Secrets.** No exception message contains a secret key, an API password or the expected signature. `paykit:check` prints configuration state, never values. **Language level.** No `unserialize`, `eval`, `shell_exec`, `passthru`, `proc_open` or `popen` anywhere in `src/`, asserted by a test that scans the tree. @@ -68,7 +68,7 @@ A separate review of the v0.2.1 additions (audit trail, customer status endpoint | F-07 | Medium | **The duplicate-reference check ran after the proof upload.** A refused duplicate left its uploaded file on the disk, so repeated junk references filled storage. | The check now runs before any file is stored. | | F-08 | Medium | **The duplicate check was case- and space-sensitive.** `TRX 12`, `trx12` and ` TRX12 ` passed the check as three different references even though the unique index on `transfer_reference` may see them as one, depending on the database collation. | References are normalised (trimmed, inner whitespace collapsed, uppercased) before the check and before storage. | | F-09 | Medium | **A race past the duplicate check surfaced as a raw database error.** Two requests in the same instant both passed the check and the second hit the unique index. | The `QueryException` from the unique index is caught and re-thrown as `DuplicateTransferReferenceException`, the same answer a normal duplicate gets. | -| F-10 | Medium | **An expired payment with a receipt in hand could never be decided.** The window check refused every decision after `expires_at`, including a human approving a receipt that arrived in time. `tahseel:manual:expire` also swept `awaiting_review` rows, deleting payments a human was looking at. | The window refusal now applies only to payments nobody answered (`pending`). `expireOverdue()` expires only `pending` rows unless the new `expire_awaiting_review` config (off by default) is turned on. This reverses the v0.1 note that an expired payment can never be approved; it is deliberate, and the README says so. | +| F-10 | Medium | **An expired payment with a receipt in hand could never be decided.** The window check refused every decision after `expires_at`, including a human approving a receipt that arrived in time. `paykit:manual:expire` also swept `awaiting_review` rows, deleting payments a human was looking at. | The window refusal now applies only to payments nobody answered (`pending`). `expireOverdue()` expires only `pending` rows unless the new `expire_awaiting_review` config (off by default) is turned on. This reverses the v0.1 note that an expired payment can never be approved; it is deliberate, and the README says so. | | F-11 | Low | **`_` and `%` in panel search were LIKE wildcards.** Searching for a transfer reference containing `_` matched everything one character wide. | Search terms are escaped with an explicit `ESCAPE '!'` clause. | | F-12 | Low | **A failed audit write broke the payment flow.** The audit insert ran in-line, so a database hiccup on the log table could fail an approval. | Audit writes are wrapped in `try/catch` and reported through Laravel's exception handler instead. The `ManualPaymentAwaitingReview` event now fires before the audit row, so listeners hear about a payment even if the audit table is down. | @@ -107,14 +107,14 @@ Residual risk this pass added or restated, plainly: ## Post-v0.2.2 additions review (Dec 3, 2026) -A short pass over everything added after v0.2.2 (the open pull requests): the Arabic/RTL panel localization, panel pagination, `tahseel:check` warnings, `Tahseel::fake()`, `tahseel:manual:prune-proofs`, the CI changes and the new docs. +A short pass over everything added after v0.2.2 (the open pull requests): the Arabic/RTL panel localization, panel pagination, `paykit:check` warnings, `Paykit::fake()`, `paykit:manual:prune-proofs`, the CI changes and the new docs. Findings, plainly: - **No new trust boundary was added.** The localization reads a server-side config value; statuses render through the enum; pagination parameters pass through Laravel's paginator and Blade escaping. -- **`tahseel:manual:prune-proofs` deletes files named by `proof_path`.** Those paths are generated by the package itself on upload (`Storage::putFile` style server-side names), never taken from a request, so a path like `../../` cannot arrive through the proof route. Only console users can run the command, and only rows whose status is approved or rejected are touched. -- **`Tahseel::fake()` is a loaded foot-gun only if called outside tests**: after it runs, `createPayment` returns sessions no gateway ever saw. It swaps nothing on its own; a merchant has to call it. Documented as test-only. -- **The `tahseel:check` warnings read config and print**; they change nothing and keep failing only on missing keys, as before. +- **`paykit:manual:prune-proofs` deletes files named by `proof_path`.** Those paths are generated by the package itself on upload (`Storage::putFile` style server-side names), never taken from a request, so a path like `../../` cannot arrive through the proof route. Only console users can run the command, and only rows whose status is approved or rejected are touched. +- **`Paykit::fake()` is a loaded foot-gun only if called outside tests**: after it runs, `createPayment` returns sessions no gateway ever saw. It swaps nothing on its own; a merchant has to call it. Documented as test-only. +- **The `paykit:check` warnings read config and print**; they change nothing and keep failing only on missing keys, as before. - The new GitHub issue/PR templates warn against pasting secrets, but templates cannot enforce that. Residual risk unchanged from the sections above. diff --git a/docs/state-transitions.md b/docs/state-transitions.md index 4140ee4..85c5c43 100644 --- a/docs/state-transitions.md +++ b/docs/state-transitions.md @@ -1,6 +1,6 @@ # Payment state transitions -Every state a payment can pass through in Tahseel, per driver, and what the package does at the edges: late, repeated, out-of-order and contradictory news about money. The normalised states are `pending`, `succeeded`, `failed`, `refunded`, `voided` (`Tahseel\Enums\PaymentStatus`). +Every state a payment can pass through in Paykit, per driver, and what the package does at the edges: late, repeated, out-of-order and contradictory news about money. The normalised states are `pending`, `succeeded`, `failed`, `refunded`, `voided` (`Paykit\Enums\PaymentStatus`). Two guards run before any event reaches your code (`WebhookGuard`): @@ -44,7 +44,7 @@ States come from four boolean flags on the transaction object: `is_refunded` → The signed `status` decides first: `Success` needs `responseCode` `000` or it is failed; `REFUNDED`/`PARTIALLY_REFUNDED` → refunded; `VOIDED` → voided; the failed and pending families map by name; anything unknown is refused. -- On a refund callback Geidea keeps the signed `status` at `Success` and puts `Refunded` in `detailedStatus` (per its sample callbacks, not verified live). `detailedStatus` is NOT a signed field, so Tahseel trusts it only to turn a success into a refund or void, never the other way, and this is a documented residual risk: someone holding a captured genuine callback could replay it with a flipped unsigned field. Ordering uses the signed per-callback `timeStamp`, so such a replay is at least ordered after the real success. +- On a refund callback Geidea keeps the signed `status` at `Success` and puts `Refunded` in `detailedStatus` (per its sample callbacks, not verified live). `detailedStatus` is NOT a signed field, so Paykit trusts it only to turn a success into a refund or void, never the other way, and this is a documented residual risk: someone holding a captured genuine callback could replay it with a flipped unsigned field. Ordering uses the signed per-callback `timeStamp`, so such a replay is at least ordered after the real success. ## Manual (Vodafone Cash, InstaPay) @@ -53,7 +53,7 @@ The signed `status` decides first: `Success` needs `responseCode` `000` or it is - The amount and currency are read from the row at decision time; nothing in a request can change them. - A decision holds a row lock, so two clicks cannot both settle, and a settled payment refuses every later decision. A second identical decision is a no-op with no second event. - Proof submission locks the row too: an expiry or a human decision that lands while the screenshot uploads wins, and the refused upload is deleted from the disk. -- A payment whose proof already arrived can be decided after its window; one nobody answered is closed by `tahseel:manual:expire`. +- A payment whose proof already arrived can be decided after its window; one nobody answered is closed by `paykit:manual:expire`. - A resubmitted screenshot replaces the old file, which is deleted. - A partial or wrong transfer amount is a human decision: the package never compares the transferred amount, because it cannot see the transfer. The panel shows the expected amount next to the receipt. - **Reopen is the recovery path.** A rejected or expired payment can be reopened by a human (`ManualPayments::reopen`, or the panel's Reopen button): one with proof goes back to `awaiting_review`, one without starts a fresh window, the trail records it (`reopened`), and the application hears `PaymentPending` so it can un-fail the order. **Approved is final**: the money was confirmed, and reversing that is a refund, which the manual driver does not do. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index b9f8e39..769ba11 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -7,7 +7,7 @@ Real problems this package has met, and what to do about each. If yours is not h **The gateway says it delivered, but my order never became paid.** - On v0.2.1 or earlier, upgrade: those versions dropped a *status change* on an already-seen transaction id as a "duplicate", so the success callback for Fawry, Geidea and Paymob cash/wallet payments was swallowed. Fixed in v0.2.2. -- Check that `tahseel.webhooks.enabled` is on and the gateway's dashboard points at `https://your-domain/tahseel/webhooks/{gateway}` (or your configured path). +- Check that `paykit.webhooks.enabled` is on and the gateway's dashboard points at `https://your-domain/paykit/webhooks/{gateway}` (or your configured path). - Check your logs for a 401 from the webhook route: that means the signature failed, which almost always means a wrong secret (`PAYMOB_HMAC_SECRET`, `KASHIER_SECRET_KEY`, `FAWRY_SECURE_KEY`, `GEIDEA_API_PASSWORD`), not a wrong payload. - A 400 with "unknown status" from Kashier means Kashier sent a signed status the package does not know; open an issue with the status name (not the whole payload). @@ -19,7 +19,7 @@ Handled since v0.2.2 per gateway: Paymob is ordered by its signed timestamps, Fa **Every test card is declined in the Paymob sandbox.** -Fresh Paymob test merchants sometimes have no acquiring bank behind them; the payment is declined before it reaches any Tahseel code. Confirm with Paymob support that your test merchant can take payments. Tahseel's own live run hit exactly this (docs/sandboxes.md). +Fresh Paymob test merchants sometimes have no acquiring bank behind them; the payment is declined before it reaches any Paykit code. Confirm with Paymob support that your test merchant can take payments. Paykit's own live run hit exactly this (docs/sandboxes.md). **The HMAC check fails on the real redirect but works on fixtures.** @@ -41,7 +41,7 @@ On purpose: the driver implements pay-at-outlet reference numbers only. Card and **The panel answers 404 or the routes do not exist.** -The panel registers nothing until `TAHSEEL_MANUAL_PANEL_ABILITY` names a Gate ability, and the Gate must define that ability. This is deliberate: an unguarded panel could move money. +The panel registers nothing until `PAYKIT_MANUAL_PANEL_ABILITY` names a Gate ability, and the Gate must define that ability. This is deliberate: an unguarded panel could move money. **A customer paid but the payment expired before anyone reviewed it.** @@ -53,13 +53,13 @@ A second payment quotes a reference already attached to another one. References **Receipts must not be publicly reachable.** -Keep `TAHSEEL_MANUAL_PROOF_DISK` on a private disk (default `local`). `tahseel:check` warns if it is set to `public`. +Keep `PAYKIT_MANUAL_PROOF_DISK` on a private disk (default `local`). `paykit:check` warns if it is set to `public`. ## Idempotency **A retried request created a second payment at the gateway.** -The idempotency store is a cache store; on the `array` or `null` driver it forgets keys between requests. Point `TAHSEEL_IDEMPOTENCY_STORE` at a persistent store (redis, database, file). `tahseel:check` warns about this. +The idempotency store is a cache store; on the `array` or `null` driver it forgets keys between requests. Point `PAYKIT_IDEMPOTENCY_STORE` at a persistent store (redis, database, file). `paykit:check` warns about this. ## Upgrading diff --git a/mock/gateway.php b/mock/gateway.php index b9531b6..38a1d6e 100644 --- a/mock/gateway.php +++ b/mock/gateway.php @@ -35,19 +35,19 @@ * GEIDEA_BASE_URL=http://127.0.0.1:8099 * GEIDEA_PUBLIC_KEY=pk_test_geidea_public * GEIDEA_API_PASSWORD=mock-geidea-api-password - * GEIDEA_CALLBACK_URL=http://127.0.0.1:8000/tahseel/webhooks/geidea + * GEIDEA_CALLBACK_URL=http://127.0.0.1:8000/paykit/webhooks/geidea * * Then open http://127.0.0.1:8099/ for a page that starts a payment and pays it. */ -use Tahseel\Gateways\Fawry\FawrySignature; -use Tahseel\Gateways\Geidea\GeideaSignature; -use Tahseel\Gateways\Kashier\KashierSignature; -use Tahseel\Gateways\Paymob\PaymobSignature; +use Paykit\Gateways\Fawry\FawrySignature; +use Paykit\Gateways\Geidea\GeideaSignature; +use Paykit\Gateways\Kashier\KashierSignature; +use Paykit\Gateways\Paymob\PaymobSignature; require __DIR__.'/../vendor/autoload.php'; -$stateDir = sys_get_temp_dir().'/tahseel-mock'; +$stateDir = sys_get_temp_dir().'/paykit-mock'; if (! is_dir($stateDir)) { mkdir($stateDir, 0770, true); @@ -316,7 +316,7 @@ .'Reference: '.htmlspecialchars((string) $payment['reference'], ENT_QUOTES).'
' .'Amount: '.number_format($payment['amount_cents'] / 100, 2).' '.htmlspecialchars((string) $payment['currency'], ENT_QUOTES).'

' .'
' - .'

' + .'

' .'' .'' .'
'); @@ -434,7 +434,7 @@ // --------------------------------------------------------------------------- if ($method === 'GET' && $path === '/') { - $page('Tahseel mock gateway', '

Tahseel mock gateway

' + $page('Paykit mock gateway', '

Paykit mock gateway

' .'

Point a driver at '.$base.' and pay through the page it sends you to. ' .'The mock signs its callbacks with the secrets below; keep them in the application .env.

' .'