Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to Tahseel are documented here. This project follows [Semant

### Added

- **Tabby driver** (`Tahseel::gateway('tabby')`), the seventeenth international driver and the first buy-now-pay-later one, for the UAE and Saudi Arabia: hosted checkout session via `POST /api/v2/checkout` with decimal-string amounts, buyer, shipping address and order items, redirecting to the hosted page url from `configuration.available_products`; a `rejected` pre-scoring answer reported as a refusal rather than a fake checkout page; webhooks authenticated the only way Tabby documents it - the custom header you register, compared in constant time, with no body signature claimed; lowercase webhook statuses and uppercase retrieve statuses both read, the documented status set closed; `AUTHORIZED` reported pending and only captured (`CLOSED`) payments paid, with capture implemented; refunds requiring their amount because Tabby has no amount-less full refund; region-pinned base URL, config + `TABBY_*` env vars, and 14 fixture tests. Fixture-tested only, no live account has run it yet.
- **PayU driver** (`Tahseel::gateway('payu')`), the sixteenth international driver, on the European PayU Global platform (secure.payu.com - explicitly not PayU India): OAuth2 client-credentials token as a form post to `/pl/standard/user/oauth/authorize`, `POST /api/v2_1/orders` with lowest-unit string amounts, the merchant reference as `extOrderId`, notify and continue urls, and the `redirectUri` returned as the checkout url; notifications verified as documented - MD5 of the raw body concatenated with the POS's second key, parsed out of `OpenPayu-Signature`, constant-time, a body without raw bytes refused, and an algorithm the docs do not show refused rather than approximated; the closed status set honoured (`COMPLETED` paid, `PENDING`/`WAITING_FOR_CONFIRMATION` pending, `CANCELED` failed, anything else refused); refunds through `POST /api/v2_1/orders/{orderId}/refunds` with the amount omitted for a full refund as documented, reporting pending unless PayU says the refund is final; config + `PAYU_*` env vars, and 15 fixture tests. Fixture-tested only, no live account has run it yet.
- **Viva.com driver** (`Tahseel::gateway('viva')`), the fifteenth international driver (a Greek acquirer with a wide European footprint), on Smart Checkout: OAuth2 client-credentials token from the accounts host, `POST /checkout/v2/orders` on the API host with MINOR-unit amounts and the 4-digit payment source, the 16-digit order code kept as a string and turned into the documented `?ref={OrderCode}` checkout url; webhooks verified over the raw body - hex HMAC-SHA-256 in `Viva-Signature-256` with the documented SHA-1 `Viva-Signature` as fallback, constant-time, a body without raw bytes refused - reading only the documented events (1796, 1797, 1798, 4865) and requiring the event and the transaction's own `StatusId` to agree, with the closed status set honoured (`F` paid, `A`/`C` pending, `R` refunded, `E`/`X` failed, anything else refused) and the ISO numeric currency code mapped before Money; config + `VIVA_*` env vars, and 13 fixture tests. Refunds are not wrapped and there is no transaction re-read; the docs say both. Fixture-tested only, no live account has run it yet.
- **Telr driver** (`Tahseel::gateway('telr')`), the fourteenth international driver and a Gulf acquirer (UAE, Saudi Arabia and the wider region), on the hosted payment page: `POST /gateway/order.json` with method `create`, store id and auth key in the body as documented, MAJOR-unit decimal-string amounts, the `order.ref` + `order.url` pair returned as the checkout url; transaction advice verified exactly as Telr documents it - SHA1 of the secret key followed by the fourteen transaction fields colon-joined in order, percent-encoded values decoded first, a missing field contributing an empty value, compared in constant time - with the documented status set honoured (`A` paid, `H` authorised-but-held pending, `D`/`C`/`E` failed, anything else refused); `fetchPaymentStatus()` through the documented `check` method with the status text matched and an unrecognised one refused; config + `TELR_*` env vars, and 16 fixture tests. Refunds are not wrapped and the docs say so. Fixture-tested only, no live account has run it yet.
Expand Down
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-five 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) and **PayU** (the European PayU platform + MD5-signed notifications). 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 and PayU are fixture-tested only, no live account has run them yet.
Tahseel gives you one clean API for starting a payment, verifying the gateway's callback, and getting a normalised result. Twenty-six 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) and **Tabby** (BNPL checkout across the UAE and Saudi Arabia + capture, refunds and header-authenticated webhooks). 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 and Tabby are fixture-tested only, no live account has run them yet.

> **Status: v0.3.0, EXPERIMENTAL pre-release. Do not take real money through it yet.**
>
Expand Down Expand Up @@ -48,6 +48,7 @@ Tahseel gives you one clean API for starting a payment, verifying the gateway's
| **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 |
| **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 |
| **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) |

Expand Down Expand Up @@ -301,6 +302,7 @@ $result->succeeded(); // true, false, or false while pending
| Square | full or partial, MINOR-unit amount required; `PENDING` until Square approves it | not implemented | the Square payment id |
| Xendit | full or partial, smallest-unit amount required; `PENDING` until the refund webhook settles it | not implemented | Xendit's `payment_id`, which the session webhook carries |
| PayU | full (no amount, as documented) or partial, lowest-unit amount | not implemented | the PayU order id |
| Tabby | full or partial, amount required | not implemented | Tabby's payment id |

The details that bite:

Expand Down Expand Up @@ -967,6 +969,36 @@ Four PayU details worth knowing:

Fixture-tested only, no PayU account has run it yet.

## Tabby

Tabby is the seventeenth international driver and the first buy-now-pay-later one: the customer is redirected to Tabby's hosted checkout, approved or declined there, and you capture the payment afterwards. Tabby operates in the UAE and Saudi Arabia, and its docs say every call has to go to the base URL of your own region.

```dotenv
TABBY_BASE_URL=https://api.tabby.ai # Saudi Arabia: https://api.tabby.sa
TABBY_SECRET_KEY=sk_test_... # or sk_... in production
TABBY_MERCHANT_CODE=merchant-ae
TABBY_WEBHOOK_AUTH_HEADER=X-Auth-Key
TABBY_WEBHOOK_AUTH_VALUE=... # the value you registered with Tabby
TABBY_SUCCESS_URL=https://your-app.test/checkout/done
TABBY_CANCEL_URL=https://your-app.test/checkout/cancel
TABBY_FAILURE_URL=https://your-app.test/checkout/failed
```

```php
$session = Tahseel::gateway('tabby')->createPayment($request);

header('Location: '.$session->checkoutUrl);
```

Four Tabby details worth knowing:

- **Tabby does not sign its webhooks, and the driver does not pretend otherwise.** Tabby's documented check is a custom header you choose when you register the webhook (`X-Auth-Key` with your own value). The driver compares that header with the configured value in constant time and refuses anything else. That is the whole documented authentication, so nothing stronger is claimed.
- **`AUTHORIZED` is not money.** Tabby authorises, and only a captured payment becomes `CLOSED` and settles to you. The driver reports `AUTHORIZED` as pending, implements capture (`POST /api/v2/payments/{id}/captures`) and reports `CLOSED` as paid. Tabby may auto-capture after 21 days, which is a reason to capture, not a reason to skip it.
- **Statuses arrive in two spellings.** Webhooks send lowercase (`authorized`), the retrieve endpoint answers uppercase (`AUTHORIZED`). Both are read. The documented set is closed - `CREATED`, `AUTHORIZED`, `CLOSED`, `REJECTED`, `EXPIRED` - and anything else is refused.
- **Amounts are decimal strings, not minor units.** `"340.00"` is 340 dirhams, and the documented currencies are `AED` and `SAR`. A refund always carries its amount: Tabby has no amount-less full refund, so a refund request without one is refused before a request is made.

Fixture-tested only, no Tabby 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`.
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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 and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.",
"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 and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.",
"keywords": [
"laravel",
"payments",
Expand Down Expand Up @@ -68,7 +68,8 @@
"smart checkout",
"payu",
"poland",
"pln"
"pln",
"tabby"
],
"license": "MIT",
"require": {
Expand Down
36 changes: 36 additions & 0 deletions config/tahseel.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,42 @@
'idempotency_ttl' => (int) env('PAYTABS_IDEMPOTENCY_TTL', 86400),
],

'tabby' => [
// Tabby's region decides the base URL: https://api.tabby.ai for
// the UAE, https://api.tabby.sa for Saudi Arabia. Tabby's docs
// warn that a cross-region call can answer 404 or 403.
'base_url' => env('TABBY_BASE_URL', 'https://api.tabby.ai'),

// The secret key from the Tabby merchant dashboard.
'secret_key' => env('TABBY_SECRET_KEY'),

// The merchant code Tabby gave you.
'merchant_code' => env('TABBY_MERCHANT_CODE'),

// Tabby has no webhook signature: you register a header of your
// own with a value you choose, and that header is the whole
// documented check. Set both here.
'webhook_auth_header' => env('TABBY_WEBHOOK_AUTH_HEADER', 'X-Auth-Key'),
'webhook_auth_value' => env('TABBY_WEBHOOK_AUTH_VALUE'),

'lang' => env('TABBY_LANG', 'en'),
'currency' => env('TABBY_CURRENCY', 'AED'),
'item_category' => env('TABBY_ITEM_CATEGORY', 'General'),

'success_url' => env('TABBY_SUCCESS_URL'),
'cancel_url' => env('TABBY_CANCEL_URL'),
'failure_url' => env('TABBY_FAILURE_URL'),

'shipping_city' => env('TABBY_SHIPPING_CITY'),
'shipping_address' => env('TABBY_SHIPPING_ADDRESS'),
'shipping_zip' => env('TABBY_SHIPPING_ZIP'),
'buyer_registered_since' => env('TABBY_BUYER_REGISTERED_SINCE'),
'buyer_loyalty_level' => (int) env('TABBY_BUYER_LOYALTY_LEVEL', 0),

'timeout' => (int) env('TABBY_TIMEOUT', 30),
'idempotency_ttl' => (int) env('TABBY_IDEMPOTENCY_TTL', 86400),
],

'payu' => [
// PayU Global (Europe): https://secure.payu.com. Sandbox:
// https://secure.snd.payu.com.
Expand Down
Loading
Loading