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

- **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.
- **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.
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-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.
Tahseel gives you one clean API for starting a payment, verifying the gateway's callback, and getting a normalised result. Twenty-four 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) and **Viva.com** (Smart Checkout across Europe + HMAC-signed 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 and Viva.com 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 @@ -46,6 +46,7 @@ Tahseel gives you one clean API for starting a payment, verifying the gateway's
| **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 |
| **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 @@ -903,6 +904,36 @@ Four Telr details worth knowing:

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.

## Viva.com

Viva.com is the fifteenth international driver: a Greek acquirer with a wide European footprint, on Smart Checkout. You create a payment order, send the customer to the checkout page it belongs to, and Viva tells you what happened with a signed webhook.

```dotenv
VIVA_BASE_URL=https://api.vivapayments.com # demo: https://demo-api.vivapayments.com
VIVA_ACCOUNTS_URL=https://accounts.vivapayments.com # demo: https://demo-accounts.vivapayments.com
VIVA_CLIENT_ID=... # Smart Checkout client credentials
VIVA_CLIENT_SECRET=...
VIVA_SOURCE_CODE=8362 # the 4-digit payment source from the Viva app
VIVA_WEBHOOK_SECRET=... # the webhook signing secret
VIVA_CHECKOUT_URL=https://www.vivapayments.com/web/checkout
VIVA_REQUEST_LANGUAGE=en-GB
```

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

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

Four Viva.com details worth knowing:

- **Two hosts and an OAuth2 token.** Orders go to the API host, the token to the accounts host: client credentials, `grant_type=client_credentials`, the client id and secret as Basic auth. The driver fetches the token once per instance and reuses it.
- **The order code is a 16-digit string.** Viva's docs are explicit that it must be handled as a string, because a JavaScript number cannot hold it. The driver keeps it a string everywhere and builds the documented checkout url (`?ref={OrderCode}`) from it.
- **Webhooks are signed over the raw body.** `Viva-Signature-256` is the hex HMAC-SHA-256 of the body under the webhook secret, `Viva-Signature` the SHA-1 equivalent; the driver prefers the 256 one, falls back to the 1 one, compares in constant time, and refuses a body whose raw bytes it cannot see. It then reads only the documented events (1796 payment created, 1797 reversal created, 1798 payment failed, 4865 order updated) and requires the event and the transaction's own `StatusId` to agree - a notification that claims success for a failed transaction is refused, not believed.
- **`F` is finished, and only `F` is money.** The documented statuses are `F` finished, `A` active, `C` captured, `E` error, `R` refunded, `X` cancelled: `F` is paid, `A` and `C` come through pending, `R` refunded, `E` and `X` failed, and anything else is refused. Amounts arrive in minor units with the currency as an ISO numeric code (`978` is EUR), which the driver maps before building `Money`.

Refunds are not wrapped: Viva documents them on a separate product surface that this driver has not been grounded in. Fixture-tested only, no Viva 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 @@ -997,6 +1028,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 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.
Expand Down
7 changes: 5 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 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 and manual transfers (Vodafone Cash, InstaPay) behind one gateway contract with signed webhook verification. Experimental.",
"keywords": [
"laravel",
"payments",
Expand Down Expand Up @@ -62,7 +62,10 @@
"idr",
"southeast asia",
"telr",
"aed"
"aed",
"viva",
"vivawallet",
"smart checkout"
],
"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),
],

'viva' => [
// Production: https://api.vivapayments.com. Demo:
// https://demo-api.vivapayments.com.
'base_url' => env('VIVA_BASE_URL', 'https://api.vivapayments.com'),

// Production: https://accounts.vivapayments.com. Demo:
// https://demo-accounts.vivapayments.com.
'accounts_url' => env('VIVA_ACCOUNTS_URL', 'https://accounts.vivapayments.com'),

// Smart Checkout client credentials.
'client_id' => env('VIVA_CLIENT_ID'),
'client_secret' => env('VIVA_CLIENT_SECRET'),

// The 4-digit payment source code from the Viva banking app.
'source_code' => env('VIVA_SOURCE_CODE'),

// The webhook signing secret, and the checkout page host.
'webhook_secret' => env('VIVA_WEBHOOK_SECRET'),
'checkout_url' => env('VIVA_CHECKOUT_URL', 'https://www.vivapayments.com/web/checkout'),

'request_language' => env('VIVA_REQUEST_LANGUAGE'),
'payment_timeout' => (int) env('VIVA_PAYMENT_TIMEOUT', 0),
'currency' => env('VIVA_CURRENCY', 'EUR'),

'timeout' => (int) env('VIVA_TIMEOUT', 30),
'idempotency_ttl' => (int) env('VIVA_IDEMPOTENCY_TTL', 86400),
],

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

Expand Down
Loading
Loading