Download the PHP package iabduul7/laravel-moyasar without Composer

On this page you can find all versions of the php package iabduul7/laravel-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 laravel-moyasar

Laravel Moyasar

Tests PHPStan Latest Version

A modern, opinionated Laravel package for the Moyasar payment gateway. Built for Saudi Arabian e-commerce: mada, Visa, Mastercard, Apple Pay, Google Pay, Samsung Pay, and STC Pay.

Status: v0.2.0-dev — Adds Tokens, Payouts, the Money value object, a specialised exception hierarchy, the Sadad source type, and MoyasarTestCards. v0.1.0 covered Payments, Invoices, Webhooks, Events, and an Eloquent trait.

Why this package?

Other Moyasar Laravel packages exist. This one is the only one that:

This package roduankd/laravel-moyasar ahmedebead/moyasar-laravel
Webhooks + signature verification
Typed event per Moyasar event type 8 events 1 generic
Eloquent trait + auto-sync partial
Readonly DTOs + enums
Idempotency support
Retry on 5xx (not 4xx)
Card number / CVC log masking
Pest 4 + Http::fake() test suite 109 tests Pest 1 PHPUnit + Mockery
Laravel 11/12/13 support Laravel 8 Laravel 9
Active maintenance abandoned Oct 2023 last push Sept 2024
License MIT MIT GPL-3.0

Requirements

Installation

Publish the config and migration:

Configuration

Add your keys to .env:

Get test keys from your Moyasar Dashboard → Settings → API keys.

All values, including the webhook route, retry behaviour, logging, and replay-cache TTL, live in config/moyasar.php.

Quick start

Payments

Idempotency

Moyasar supports an idempotency key called given_id on payment creation. Pass a UUID v4 to safely retry the same request:

Errors

All non-2xx responses raise an Iabduul7\Moyasar\Exceptions\ApiException that carries statusCode, type, errors, and the full decoded payload:

5xx responses and connection errors are automatically retried (count + delay are configurable). 4xx responses are never retried.

Typed exception hierarchy

ApiException::fromResponse() returns the most specific subclass available so callers can catch by intent:

Card-level exceptions win over generic status mapping. Each carries sourceMessage and sourceResponseCode as readonly properties for forensic logging.

Money

Use the Money value object to convert between major-unit decimals and Moyasar's smallest-unit integers — the #1 source of integration bugs:

Invoices

Tokens

Server-side tokenisation for trusted-environment flows (admin tools, card-on-file migrations). For browser tokenisation, use Moyasar's JS SDK with your publishable key — the PAN never touches your server that way.

Payouts

Bulk payouts and payout-account endpoints aren't wrapped yet — open an issue if you need them.

Testing helpers

Webhooks

The package registers a POST /moyasar/webhook route automatically (configurable). Add the URL to your Moyasar dashboard with the same secret you set in MOYASAR_WEBHOOK_SECRET. Moyasar embeds that secret as secret_token inside the webhook body — the package verifies it in constant time and rejects any mismatch with a 401.

Replay protection caches each event id for MOYASAR_WEBHOOK_REPLAY_TTL seconds (default 24h). A redelivered event returns 200 but is not dispatched a second time.

Events

Listen for the events you care about:

All eight Moyasar event types are mapped:

Moyasar event Laravel event class
payment_paid Iabduul7\Moyasar\Events\PaymentPaid
payment_failed Iabduul7\Moyasar\Events\PaymentFailed
payment_authorized Iabduul7\Moyasar\Events\PaymentAuthorized
payment_captured Iabduul7\Moyasar\Events\PaymentCaptured
payment_refunded Iabduul7\Moyasar\Events\PaymentRefunded
payment_voided Iabduul7\Moyasar\Events\PaymentVoided
payment_abandoned Iabduul7\Moyasar\Events\PaymentAbandoned
payment_verified Iabduul7\Moyasar\Events\PaymentVerified

Eloquent integration

Add the HasMoyasarPayments trait to any model that needs to track payments:

When webhooks arrive, the package automatically updates any existing moyasar_payments row keyed by moyasar_id — your local copy stays in sync without any wiring. Disable via MOYASAR_WEBHOOK_SYNC_ELOQUENT=false.

MoyasarPaymentCast

Cast a payment-ID column to a live PaymentData DTO (lazy fetch + per-instance cache):

Reading the attribute calls the Moyasar API. Use sparingly to avoid N+1.

Testing your integration

Downstream apps should fake the Moyasar HTTP API the same way the package's own suite does:

For webhook tests, post a JSON body that includes a matching secret_token and assert against the dispatched event with Event::fake([PaymentPaid::class, ...]).

Saudi-specific notes

Configuration reference

Contributing

Pull requests welcome. Before submitting:

Run the full check locally:

Security

Found a security issue? Email [email protected] rather than opening a public issue.

License

MIT — see LICENSE.


All versions of laravel-moyasar with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.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 iabduul7/laravel-moyasar contains the following files

Loading the files please wait ...