PHPackages                             masterpuffin/payment-gateways - 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. masterpuffin/payment-gateways

ActiveLibrary[Payment Processing](/categories/payments)

masterpuffin/payment-gateways
=============================

2.1.0(2mo ago)0101MITPHPPHP &gt;=8.1

Since Apr 13Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MasterPuffin/PaymentGateways)[ Packagist](https://packagist.org/packages/masterpuffin/payment-gateways)[ RSS](/packages/masterpuffin-payment-gateways/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

Payment Gateways
================

[](#payment-gateways)

Integrate payments with just a few lines of code.

Why does this exist?
--------------------

[](#why-does-this-exist)

There are two main reasons which no other payment library offered which made me write this library:

1. I want a unified approach to process payments from different payment providers. This means I want to always call the same function in the same order regardless of the process of the payment provider. This rules out using the libraries of the payment providers on their own. This also rules out (Omnipay)\[\].
2. It should be simple to use and shouldn't require a framework like Laravel or Symfony. This rules out (Payum)\[\]

What does it do?
----------------

[](#what-does-it-do)

It creates the payment and returns the redirection url to the payment provider. After the payment provider redirects back to your site, this will verify the payment has been made. It will also handle incoming webhooks, verify them and return the payment status.

What does it not do?
--------------------

[](#what-does-it-not-do)

Saving the payments. You have to save the payment before redirecting to the payment provider and retrieve it to verify the payment.

Which gateways are supported?
-----------------------------

[](#which-gateways-are-supported)

Currently Stripe Checkout and PayPal REST.

Can you give me an example?
---------------------------

[](#can-you-give-me-an-example)

Sure!

First create a payment and set its data

```
$payment = new Payment();
$payment->setAmount(123.45);
$payment->setCurrencyCode('EUR');
$payment->setDescription('Test payment');
$payment->getCustomer()->setName('John Doe');
$payment->getCustomer()->setEmail('john@doe.com');

```

Then make a gateway. Some gateways require additional data. If not supplied, this library will throw an exception.

```
$gateway = new PaymentGateway(Provider::Stripe, ['secret_key' => 'abc'], ['payment_method_types' => ['card']]);
$gateway->setSuccessUrl('https://www.example.com/success');
$gateway->setCancelUrl('https://www.example.com/success');

```

Now create the gateway for the payment. This will return the redirection url to the payment provider.

```
$redirectUrl = $gateway->create($payment);

```

Also save the payment somewhere, for example to a database. Creating the gateway also updated the providerId of the payment which will be needed later to verify the payment. Then redirect to the redirectUrl.

After the user has been redirected back to your site, execute/capture and verify the payment.

```
$gateway = new PaymentGateway(Provider::Stripe, ['secret_key' => 'abc'], ['payment_method_types' => ['card']]);
$result = $gateway->execute($payment);

```

You can now use the result (which can be different eg. succeeded, pending or failed). It is best practice to check if the cart has been modified during the checkout process, by comparing $payment-&gt;getAmount() with the amount of the cart.

**Important!**Some Stripe Payment methods don't allow asynchronous capture (eg. SEPA debit). This library tries to use asynchronous capture, whenever possible. Where not possible, that payment will be created and captured on `create`. The best way to handle this, is either avoiding payment methods which can't be captured asynchronously or to call `$paymentGateway->cancel($payment)` which cancels the payment. This however only works, if the payment state is pending.
See the [Stripe Docs](https://docs.stripe.com/payments/payment-methods/payment-method-support) for more info.

Should I use this?
------------------

[](#should-i-use-this)

If you just want to integrate payments, then yes. If you need any more functionality, like subscriptions or more gateways I would suggest taking a look at [Payum](https://github.com/Payum/Payum).

Known issues
------------

[](#known-issues)

### The library uses the outdated PayPal

[](#the-library-uses-the-outdated-paypal)

This is correct, however the new [Server SDK](https://github.com/paypal/PayPal-PHP-Server-SDK) is still in beta and does not support all required methods.

### Disputes via PayPal webhooks are not supported

[](#disputes-via-paypal-webhooks-are-not-supported)

This library won't act on disputes via webhooks from PayPal. The issue is that incoming PayPal webhooks can't be securely verified without preventing MITM attacks. To mitigate this, the library will request the payment from PayPal on an incoming webhook request. The payment object however does not contains if the payment is disputed. A possible workaround would be to request the disputes via the dispute API and check if there is a match. This is however not implemented yet.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance87

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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 ~163 days

Total

3

Last Release

64d ago

Major Versions

1.0.0 → 2.0.02025-09-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/b9e368edc72d68e2e2e5348ba7d72bfaadd506358beca84b02b1397466ff8f48?d=identicon)[MasterPuffin](/maintainers/MasterPuffin)

---

Top Contributors

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

---

Tags

payment-gatewayspaymentspaypalstripe

### Embed Badge

![Health badge](/badges/masterpuffin-payment-gateways/health.svg)

```
[![Health](https://phpackages.com/badges/masterpuffin-payment-gateways/health.svg)](https://phpackages.com/packages/masterpuffin-payment-gateways)
```

###  Alternatives

[duncanmcclean/simple-commerce

A simple, yet powerful e-commerce addon for Statamic.

16313.2k2](/packages/duncanmcclean-simple-commerce)[tomatophp/filament-payments

Manage your payments inside FilamentPHP app with multi payment gateway integration

542.3k](/packages/tomatophp-filament-payments)[flux-se/sylius-stripe-plugin

Sylius Stripe plugin using Payment Request

1029.3k](/packages/flux-se-sylius-stripe-plugin)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

322.8k](/packages/duncanmcclean-statamic-cargo)[gilbitron/spark-create-stripe-plans

A simple Laravel artisan command to create Spark plans in Stripe

1810.7k](/packages/gilbitron-spark-create-stripe-plans)

PHPackages © 2026

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