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

- **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.
- **Xendit driver** (`Tahseel::gateway('xendit')`), the thirteenth international driver and the South-East Asia specialist (Indonesia, the Philippines, Malaysia, Thailand, Vietnam, Singapore), on Payment Sessions in `PAYMENT_LINK` mode rather than the legacy Invoice API: `POST /sessions` with Basic auth (secret key as username, empty password) and the documented `api-version` header, smallest-unit amounts, the hosted `payment_link_url` returned as the checkout url; webhooks authenticated the way Xendit documents them - the dashboard's token echoed verbatim in `x-callback-token`, compared in constant time, no HMAC - and only the documented `payment_session.completed` / `payment_session.expired` events read, with a completed event re-checked against the session's own status so a session that is not `COMPLETED` comes through pending, and the closed status set honoured with anything else refused; refunds through `POST /refunds` keyed by Xendit's `payment_id`, amount required, reason mapped to the documented enum (`REQUESTED_BY_CUSTOMER` unless a documented code is passed), `SUCCEEDED`/`PENDING`/`FAILED` mapped and pending refunds left to their own webhook; config + `XENDIT_*` env vars, and 16 fixture tests. No fetch-on-callback, stated plainly. Fixture-tested only, no live account has run it yet.
- **Square driver** (`Tahseel::gateway('square')`), the twelfth international driver (US, Canada, UK, Ireland, Australia, Japan, France, Spain), on the hosted Checkout product: `POST /v2/online-checkout/payment-links` with a pinned `Square-Version` header, MINOR-unit amounts, the merchant reference carried back as the payment `note`; notifications verified exactly as Square documents them - HMAC-SHA-256 of the notification URL followed by the raw body under the subscription's signature key, base64, in `x-square-hmacsha256-signature`, constant-time, and the docs' own published example vector as a fixture test - then the authenticated `GET /v2/payments/{id}` read decides the status, a body without raw bytes is refused rather than reconstructed, and the documented `APPROVED`/`PENDING`/`COMPLETED`/`CANCELED`/`FAILED` set is honoured with `APPROVED` (authorised, not captured) coming through as pending; refund notifications parsed (`APPROVED` refunded, `PENDING` pending, `REJECTED`/`FAILED` failed); refunds through `POST /v2/refunds` with the required amount, addressed by the Square payment id, idempotency key kept inside Square's 45-character limit; `fetchPaymentStatus()`, config + `SQUARE_*` env vars, and 18 fixture tests. Fixture-tested only, no live account has run it yet.
- **Klarna driver** (`Tahseel::gateway('klarna')`), the eleventh international driver and the BNPL specialist (Sweden and the Nordics, most of Europe, the UK, the US), on the documented hosted payment page product: `POST /payments/v1/sessions` for the purchase session, then `POST /hpp/v1/sessions` for the page the customer pays on, MINOR-unit amounts, and the third step Klarna documents made explicit instead of hidden - `placeOrder($authorizationToken, $request)` creates the order that is actually paid, returns the Klarna `order_id`, and maps the fraud assessment (`REJECTED` fails, `PENDING` stays pending); callbacks carry no HMAC, so the documented one-time token in the `status_update` url is compared in constant time and the session is then re-read through the authenticated API, a post without the token is refused before any API call, and the session's closed status set is honoured with anything else refused rather than guessed; refunds with the required `refunded_amount` and the documented `Klarna-Idempotency-Key` header, addressed by Klarna's own order id; the `{{session_id}}` / `{{authorization_token}}` placeholders are sent literally as Klarna documents them rather than percent-encoded; config + `KLARNA_*` env vars, and 16 fixture tests. No `fetchPaymentStatus()`, and the callback carries no amount, so amounts are compared from `placeOrder()`. 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-two 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) and **Xendit** (hosted Payment Sessions across South-East Asia + `x-callback-token` 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 and Xendit 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-three 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) and **Telr** (hosted payment pages across the Gulf + SHA1-signed transaction advice). 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 and Telr 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 @@ -45,6 +45,7 @@ Tahseel gives you one clean API for starting a payment, verifying the gateway's
| **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 |
| **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 @@ -872,6 +873,36 @@ Four Xendit details worth knowing:

Amounts are the currency's smallest unit, the same convention as most drivers here. Fixture-tested only, no Xendit account has run it yet.

## Telr

Telr is the fourteenth international driver and a Gulf acquirer: the UAE, Saudi Arabia and the wider region, on the hosted payment page. One endpoint does the work - `POST /gateway/order.json` - with a `method` of `create` for the page and `check` for a status read.

```dotenv
TELR_BASE_URL=https://secure.telr.com/gateway
TELR_STORE=1234 # Merchant Administration System -> store id
TELR_AUTH_KEY=... # the API auth key
TELR_SECRET_KEY=... # the secret key the advice hash is keyed by
TELR_TEST_MODE=0 # 1 puts the payment page in test mode
TELR_AUTHORISED_URL=https://your-app.test/checkout/done
TELR_DECLINED_URL=https://your-app.test/checkout/declined
TELR_CANCELLED_URL=https://your-app.test/checkout/cancelled
```

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

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

Four Telr details worth knowing:

- **The advice hash is SHA1 over a fixed field list.** Telr documents it as the secret key followed by fourteen transaction fields - store, type, class, test flag, ref, previous ref, first ref, currency, amount, cart id, description, status, auth code, auth message - joined with colons in that order, with percent-encoded characters decoded first and a missing field contributing an empty value. The driver builds exactly that string and compares in constant time. `card_check`, `bill_check` and `acquirer_check` exist for the other sections; the transaction hash is the one that decides a payment.
- **`H` is not paid.** The documented statuses are `A` authorised, `H` authorised but placed on hold for manual inspection, `D` declined, `C` cancelled and `E` error. Only `A` comes through as paid, `H` as pending, and a status outside the set is refused rather than guessed.
- **Amounts are major units as decimal strings.** `95.00`, not `9500`, the same convention as Kashier and PayTap; the driver formats from your `Money` so nothing rounds through a float.
- **The store id and auth key travel in the body, not a header.** That is how Telr documents the call, and it is configuration here, never a constant.

Refunds are not wrapped: Telr documents them through a different product surface, and this driver does not claim what it has not been grounded in. Fixture-tested only, no Telr 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 Expand Up @@ -966,6 +997,7 @@ Being explicit, so nobody discovers it in production:
- **No capture on Kashier.** Refund and void are wrapped; capture is not.
- **No Fawry card or wallet payments.** Reference numbers only, for the reasons above.
- **No Geidea voids or saved cards.** Refund is wrapped; Geidea documents a void only for pre-authorised, uncaptured payments and publishes no endpoint recipe for it, so it is not guessed.
- **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()`.
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 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 and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.",
"keywords": [
"laravel",
"payments",
Expand Down Expand Up @@ -60,7 +60,9 @@
"xendit",
"indonesia",
"idr",
"southeast asia"
"southeast asia",
"telr",
"aed"
],
"license": "MIT",
"require": {
Expand Down
28 changes: 28 additions & 0 deletions config/tahseel.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,34 @@
'idempotency_ttl' => (int) env('PAYTABS_IDEMPOTENCY_TTL', 86400),
],

'telr' => [
'base_url' => env('TELR_BASE_URL', 'https://secure.telr.com/gateway'),

// Merchant Administration System -> your store id and the API
// auth key. Both travel in the request body, not a header.
'store' => env('TELR_STORE'),
'auth_key' => env('TELR_AUTH_KEY'),

// The secret key used to sign transaction advice messages.
'secret_key' => env('TELR_SECRET_KEY'),

// 1 puts the payment page in test mode.
'test_mode' => (int) env('TELR_TEST_MODE', 0),

'transaction_type' => env('TELR_TRANSACTION_TYPE', 'sale'),
'framed' => (int) env('TELR_FRAMED', 0),

// Where Telr sends the shopper back, per outcome.
'authorised_url' => env('TELR_AUTHORISED_URL'),
'declined_url' => env('TELR_DECLINED_URL'),
'cancelled_url' => env('TELR_CANCELLED_URL'),

'currency' => env('TELR_CURRENCY', 'AED'),

'timeout' => (int) env('TELR_TIMEOUT', 30),
'idempotency_ttl' => (int) env('TELR_IDEMPOTENCY_TTL', 86400),
],

'xendit' => [
'base_url' => env('XENDIT_BASE_URL', 'https://api.xendit.co'),

Expand Down
Loading
Loading