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

- **Tamara driver** (`Tahseel::gateway('tamara')`), the eighteenth international driver and the second buy-now-pay-later one, for Saudi Arabia, the UAE, Bahrain, Kuwait and Oman: hosted checkout session via `POST /checkout` with major-unit `{amount, currency}` objects, consumer, items, risk assessment and the three merchant redirect urls; notifications authenticated the way Tamara documents it - an HS256 JWT signed with the merchant's notification token, arriving both as `Authorization: Bearer` and as the `tamaraToken` query parameter, verified in the driver with a constant-time compare, an expiry check and a refusal of any other algorithm; the documented event set mapped and an unknown event refused; `approved` reported pending and `authorised` paid, with the documented `authorise()` call exposed as `authorise()`; refunds through `/payments/simplified-refund/{orderId}` requiring their amount; config + `TAMARA_*` env vars, and 16 fixture tests. Capture is not wrapped, and the README says why. Fixture-tested only, no live account has run it yet.
- **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.
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-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.
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.

> **Status: v0.3.0, EXPERIMENTAL pre-release. Do not take real money through it yet.**
>
Expand Down Expand Up @@ -49,6 +49,7 @@ Tahseel gives you one clean API for starting a payment, verifying the gateway's
| **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 |
| **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 @@ -303,6 +304,7 @@ $result->succeeded(); // true, false, or false while pending
| 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 |
| Tamara | full or partial, amount required | not implemented | Tamara's order id |

The details that bite:

Expand Down Expand Up @@ -999,6 +1001,36 @@ Four Tabby details worth knowing:

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

## Tamara

Tamara is the eighteenth international driver and the second buy-now-pay-later one, for Saudi Arabia, the UAE, Bahrain, Kuwait and Oman. Its checkout is hosted, but its flow has one step Tabby's does not: after Tamara approves an order you have to confirm it before it counts as paid.

```dotenv
TAMARA_BASE_URL=https://api.tamara.co # sandbox: https://api-sandbox.tamara.co
TAMARA_API_TOKEN=...
TAMARA_NOTIFICATION_TOKEN=... # the HS256 secret Tamara signs webhooks with
TAMARA_COUNTRY_CODE=SA
TAMARA_LOCALE=en_US
TAMARA_SUCCESS_URL=https://your-app.test/checkout/done
TAMARA_FAILURE_URL=https://your-app.test/checkout/failed
TAMARA_CANCEL_URL=https://your-app.test/checkout/cancel
```

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

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

Four Tamara details worth knowing:

- **Notifications are a JWT, not a body signature.** Tamara sends `tamaraToken` both as `Authorization: Bearer` and as the `tamaraToken` query parameter. It is an HS256 JWT signed with your notification token. The driver verifies that signature with `hash_hmac` and a constant-time compare, checks the expiry, and refuses any other algorithm rather than accepting an unsigned token.
- **`approved` is not paid.** Tamara's docs are explicit that the order becomes paid at `authorised`, and that you call `POST /orders/{order_id}/authorise` after the approved notification (unless Tamara's auto-authorisation is on for your account). The driver reports `approved` as pending and exposes that call as `authorise()`, so nothing is fulfilled before it is made.
- **Amounts are major units in an object.** `{"amount": 300, "currency": "SAR"}`, with 2 decimals by default and 3 for BHD, KWD and OMR. The currencies are the ones Tamara operates in, and `country_code` is one of `SA`, `AE`, `BH`, `KW`, `OM`.
- **Capture is not wrapped.** Tamara's capture call wants the order's items sent back with it. That is a bigger surface than this driver claims, so it is left to your own call against the documented API and the README says so rather than pretending otherwise. Refunds need their amount: Tamara has no amount-less full refund.

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`.
Expand Down
6 changes: 4 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, Tabby 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, Tamara and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.",
"keywords": [
"laravel",
"payments",
Expand Down Expand Up @@ -69,7 +69,9 @@
"payu",
"poland",
"pln",
"tabby"
"tabby",
"tamara",
"saudi-arabia"
],
"license": "MIT",
"require": {
Expand Down
34 changes: 34 additions & 0 deletions config/tahseel.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,40 @@
'idempotency_ttl' => (int) env('PAYTABS_IDEMPOTENCY_TTL', 86400),
],

'tamara' => [
// Tamara's sandbox is https://api-sandbox.tamara.co and its
// production API https://api.tamara.co.
'base_url' => env('TAMARA_BASE_URL', 'https://api.tamara.co'),

// The API token from Tamara's partner portal.
'api_token' => env('TAMARA_API_TOKEN'),

// The notification token, which is the HS256 secret Tamara signs
// its webhook JWTs with.
'notification_token' => env('TAMARA_NOTIFICATION_TOKEN'),

// Tamara operates in SA, AE, BH, KW and OM.
'country_code' => env('TAMARA_COUNTRY_CODE', 'SA'),
'locale' => env('TAMARA_LOCALE', 'en_US'),
'platform' => env('TAMARA_PLATFORM', 'web'),
'currency' => env('TAMARA_CURRENCY', 'SAR'),
'item_type' => env('TAMARA_ITEM_TYPE', 'Physical'),

'success_url' => env('TAMARA_SUCCESS_URL'),
'failure_url' => env('TAMARA_FAILURE_URL'),
'cancel_url' => env('TAMARA_CANCEL_URL'),

'shipping_line1' => env('TAMARA_SHIPPING_LINE1'),
'shipping_region' => env('TAMARA_SHIPPING_REGION'),
'shipping_city' => env('TAMARA_SHIPPING_CITY'),
'account_creation_date' => env('TAMARA_ACCOUNT_CREATION_DATE'),
'total_order_count' => (int) env('TAMARA_TOTAL_ORDER_COUNT', 0),

'timeout' => (int) env('TAMARA_TIMEOUT', 30),
'webhook_tolerance' => (int) env('TAMARA_WEBHOOK_TOLERANCE', 300),
'idempotency_ttl' => (int) env('TAMARA_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
Expand Down
Loading
Loading