PHPackages                             hamedov/omnipay-moyasar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. hamedov/omnipay-moyasar

ActiveLibrary[Payment Processing](/categories/payments)

hamedov/omnipay-moyasar
=======================

Omnipay moyasar payment gateway

1.0.1(5y ago)54502[2 PRs](https://github.com/hamedov93/omnipay-moyasar/pulls)MITPHP

Since Apr 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/hamedov93/omnipay-moyasar)[ Packagist](https://packagist.org/packages/hamedov/omnipay-moyasar)[ Docs](https://github.com/hamedov93/omnipay-moyasar)[ RSS](/packages/hamedov-omnipay-moyasar/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (5)Used By (0)

Moyasar gateway extension for Omnipay package
---------------------------------------------

[](#moyasar-gateway-extension-for-omnipay-package)

This package makes it easy to process payments using moyasar gateway for credit card, sadad, apple pay and mada payments. For more information about different payment methods refer to Moyasar documentation.

Installation
------------

[](#installation)

`composer require hamedov/omnipay-moyasar`

Usage
-----

[](#usage)

### Initialize the gateway with api key

[](#initialize-the-gateway-with-api-key)

You can use test or live api key here.

```
use Omnipay\Omnipay;

$moyasar = Omnipay::create('Moyasar');

$moyasar->setApiKey('You test or live api key');

```

### Initiate new payment

[](#initiate-new-payment)

```
$request = $moyasar->purchase([
  'amount' => 50,
  'currency' => 'SAR',
  'description' => 'Payment description',
  'callbackUrl' => 'http://example.com/payments',
  'source' => [
    'type' => 'creditcard',
    'name' => 'Mohamed Hamed',
    'number' => '4111111111111111',
    'cvc' => 785,
    'month' => 11,
    'year' => 2021,
    '3ds' => true,
  ],
]);

$payment = $request->send();

```

### Initiate new manual payment

[](#initiate-new-manual-payment)

To only authorize the payment and let it be captured manually by the merchant, use the authorize method. If the payment is not captured within 7 days, the authorization is canceled and funds released.

```
$request = $moyasar->authorize([
  'amount' => 50,
  'currency' => 'SAR',
  'description' => 'Payment description',
  'callbackUrl' => 'http://example.com/payments',
  'source' => [
    'type' => 'creditcard',
    'name' => 'Mohamed Hamed',
    'number' => '4111111111111111',
    'cvc' => 785,
    'month' => 11,
    'year' => 2021,
    '3ds' => true,
  ],
]);

$payment = $request->send();

```

### Handle payment response

[](#handle-payment-response)

You will need to check the payment status to decide whether there will be a redirect to complete payment or not. You will also need to save reference to the payment for future reference such as refunding and voiding payments.

```
if ($payment->isSuccessful())
{
  // Payment is successful no redirect requird
  $transactionId = $payment->getTransactionReference();
}
elseif ($payment->isAuthorized())
{
  // Payment is authorized and waiting to be capture by the merchant
  $transactionId = $payment->getTransactionReference();
}
elseif ($payment->isFailed())
{
  // Payment failed
  $error = $payment->getMessage();

}

```

For Redirect response You can call the `redirect()` method to redirect the user automatically to complete payment, or you can get the transaction url using `$payment->getRedirectUrl()` and handle the redirect yourself or return it in a json api response.

```
if ($payment->isRedirect())
{
  $payment->redirect();
}

```

After the user is redirected back to your website you can fetch the payment using the id provided in the url to check payment status and process it as required. You will get the same response format as returned in the payment request.

```
$moyasar = Omnipay::create('Moyasar');
$moyasar->setApiKey('You test or live api key');

$payment = $moyasar->fetch($_GET['id'])->send();
if ($payment->isSuccessful())
{
  // Payment successful
  $transactionId = $payment->getTransactionReference();
}
elseif ($payment->isFailed())
{
  // Payment failed
  $error = $payment->getMessage();
}

```

### Capture a previously authorized payment

[](#capture-a-previously-authorized-payment)

You can provide the amount to be captured, it can be less than or equal to original amount provided during payment creation. The remaining amount will be automatically released. The request will fail if the payment has any status other than `authorized`

```
$moyasar = Omnipay::create('Moyasar');
$moyasar->setApiKey('You test or live api key');

$payment = $moyasar->capture([
  'id' => $transactionId,
  'amount' => $amount, // Optional, defaults to total amount
])->send();

if ($payment->isCaptured())
{
  // Success

}
elseif ($payment->hasError())
{
  $error = $payment->getMessage();
}

```

### Void a payment

[](#void-a-payment)

- You can cancel/void an authorized payment which has not been captured yet.
- You can cancel/void captured or successful payments which have not yet settled in the customers bank account. Or you will need to send a refund request.

```
$moyasar = Omnipay::create('Moyasar');
$moyasar->setApiKey('You test or live api key');

$payment = $moyasar->void([
  'id' => $transactionId,
])->send();

if ($payment->isVoided())
{
  // Success

}
elseif ($payment->hasError())
{
  $error = $payment->getMessage();
  // You can fallback to the refund request here
}

```

### Refund a payment

[](#refund-a-payment)

```
$moyasar = Omnipay::create('Moyasar');
$moyasar->setApiKey('You test or live api key');

$payment = $moyasar->refund([
  'id' => $transactionId,
  'amount' => $amount, // Optional
])->send();

if ($payment->isRefunded())
{
  // Success

}
elseif ($payment->hasError())
{
  // Payment cannot be refunded
  $error = $payment->getMessage();
}

```

TODO
----

[](#todo)

- Add update payment request.
- Add list payments request.

License
-------

[](#license)

Released under the Mit license, see [LICENSE](https://github.com/hamedov93/omnipay-moyasar/blob/master/LICENSE)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~226 days

Total

2

Last Release

1984d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82c37e59c90c4c4b24cdb4e1dc98084ea2acd19e8cc1e8f7e928af64d39c05f2?d=identicon)[hamedov](/maintainers/hamedov)

---

Top Contributors

[![hamedov93](https://avatars.githubusercontent.com/u/13410895?v=4)](https://github.com/hamedov93 "hamedov93 (4 commits)")

---

Tags

paymentgatewaypayomnipayMoyasar

### Embed Badge

![Health badge](/badges/hamedov-omnipay-moyasar/health.svg)

```
[![Health](https://phpackages.com/badges/hamedov-omnipay-moyasar/health.svg)](https://phpackages.com/packages/hamedov-omnipay-moyasar)
```

###  Alternatives

[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)[sudiptpa/omnipay-nabtransact

National Australia Bank (NAB) Transact driver for the Omnipay payment processing library.

1017.2k](/packages/sudiptpa-omnipay-nabtransact)[lucassmacedo/omnipay-mercadopago

MercadoPago gateway for OmniPay

154.6k](/packages/lucassmacedo-omnipay-mercadopago)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
