Download the PHP package ahmedlaggoun/moyasar without Composer

On this page you can find all versions of the php package ahmedlaggoun/moyasar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package moyasar

Moyasar for Laravel

Moyasar payment gateway integration for Laravel, built with the security constraints of card payments as the design driver rather than a section at the end. PHP 8.2+, Laravel 10/11/12.

tests

The constraint that shapes everything

Moyasar's terms state that sending cardholder data to your backend is prohibited and grounds for terminating your agreement. Cards are collected in the browser or the mobile SDK, against the publishable key, and never reach your server.

So this package offers no way to do it. There is no method anywhere that accepts a PAN, CVC or expiry — not a discouraged one, not a commented-out one. The only payment-creation path exposed server-side is charging an existing token, which contains no card data. If you find yourself wanting a createPayment($cardNumber, ...), the integration has gone wrong upstream.

Install

Package discovery registers the provider. The webhook route registers itself only when MOYASAR_WEBHOOK_SECRET is set — an unauthenticated payment webhook is worse than no webhook.

The one flow that matters

The customer pays in the browser and is redirected back to your callback_url with query parameters appended:

Take the id. Discard status and message. They are in the address bar. A customer can change status=failed to status=paid before your route ever sees the request, so any check that reads them is checking a value the attacker supplied.

verify() fetches the payment with your secret key and asserts status, amount and currency together, then throws rather than returning false — a missed return value should not become a free order. Checking status alone lets someone pay SAR 1.00 for a SAR 1,000.00 order, because the amount is set in the browser-side form config.

Note the order id comes from the session, not the query string. Otherwise one valid payment can be replayed against a different order.

Render the form with the only key that may leave your server:

Amounts

Every amount is an integer in the currency's minor unit, wrapped in Money. There is no fromFloat(), deliberately — 0.1 + 0.2 is not 0.3 in binary floating point, and a one-halala drift is a reconciliation failure.

Currency is part of equality, so a USD 100.00 payment can never satisfy a SAR 100.00 order.

Webhooks

Understand what Moyasar's webhook authentication does and does not prove. There is no HMAC signature. Moyasar echoes a shared secret inside the request body. A valid secret_token proves the sender knows the secret — it does not prove the body is unmodified, because nothing signs it, and the same secret rides on every event to every endpoint you register.

The package therefore:

Even with a verified event, call assertMatches() against your own order total. Knowing a payment is paid is not knowing it paid for this order.

Register the endpoint in the Moyasar dashboard pointing at https://yourapp.com/webhooks/moyasar, with the same shared secret you put in MOYASAR_WEBHOOK_SECRET.

Refunds, captures and voids

These are never retried automatically. A retried refund is a second refund, and an HTTP client that cannot tell a refund from a fetch will eventually issue one. get() retries; post() does not. On an ambiguous failure the gateway re-reads the payment and returns it if the operation had in fact landed — the recovery flow Moyasar documents — and otherwise rethrows.

Prefer void over refund inside the window: it releases the hold instantly and avoids processing fees. Authorized holds are voidable for about 14 days on mada; a paid or captured charge for roughly two hours.

Charging a saved card

The idempotency key maps to Moyasar's given_id and becomes the payment id. It must be derived from the thing being paid for and identical across retries — an invoice id, a subscription period. A fresh UUID per attempt turns the guarantee off, which is exactly the failure it exists to prevent. This is what makes a timeout safe to retry: you either get the original payment back or it is created once.

Delete the token the moment a customer removes the payment method:

Structure

Dependencies point inward, and this is enforced rather than aspirational: Domain imports nothing from Application or Infrastructure, Application imports nothing from Infrastructure, and only Infrastructure knows that Moyasar exists.

Two honest caveats the folder names would otherwise paper over. Domain is free of the Laravel framework but uses Illuminate\Support\Collection as a return type; that ships in illuminate/collections, a standalone library, so the layer still runs outside Laravel — it is not zero-dependency. And Application uses the queue and event traits, so it is Laravel-bound by design: ProcessMoyasarWebhook exists precisely to move slow work onto a queue, which is a framework concern.

WebhookVerifier sits in Infrastructure/Contracts, not Domain/Contracts, for a concrete reason: its method signature takes an Illuminate\Http\Request. An interface that names an HTTP request object is not a domain concept, and putting it in Domain would make the layer boundary decorative. The two ports the domain does own — PaymentGateway and TokenGateway — are the ones a second payment provider would implement.

Configuration safety

The provider refuses to boot on:

All at boot, loudly, rather than at the first live charge.

Other security notes

Documentation quirks handled

Testing

Every dependency is a narrow interface, so a fake transport replaces HTTP entirely. The suite covers the tamper cases specifically: wrong amount, wrong currency, unsettled status, forged webhook secret, wrong environment, and path traversal in a resource id.

Changelog

See CHANGELOG.md. Semantic versioning: a breaking change to any interface in src/Domain/Contracts/ is a major bump.

License

MIT. See LICENSE.


All versions of moyasar with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
illuminate/bus Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/queue Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ahmedlaggoun/moyasar contains the following files

Loading the files please wait ...