Download the PHP package aqsaahsan301/laravel-payments without Composer

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

Laravel Payments

Packagist PHP from Packagist Laravel versions GitHub Workflow Status (main) Total Downloads

Gateway-agnostic payment and subscription billing for Laravel.

Installation

You can install the package via Composer:

You may publish all of the package's resources at once:

Or, you may publish each resource individually:

Publishing the Configuration File

Why gateway-agnostic

Laravel Cashier is excellent, but it's Stripe-only by design — it owns a subscriptions table, a Billable Eloquent trait, and a whole persistence layer built around Stripe's model. For clients who need a local gateway instead (Billplz, ToyyibPay, Curlec/Razorpay — common where FPX, GrabPay, or TnG matter), that coupling means starting over.

This package takes a different shape:

Design principle: Interface Segregation (SOLID)

The PaymentGateway / SupportsSubscriptions split (shipped in v1.1.0) is a direct application of the Interface Segregation Principle — "no client should be forced to depend on methods it does not use." Before the split, PaymentGateway carried checkout(), cancelSubscription(), and currentPlan() as required methods, which meant a one-time/invoice-only gateway (FPX, Billplz, ToyyibPay) had no honest way to implement it — it would have to either throw NotSupportedException from three methods or fake a subscription concept it doesn't have. Both are ISP violations: the interface was shaped around one client's needs (Stripe) and imposed on every implementer.

Splitting the fat interface into a lean base contract (charge(), handleWebhook() — what every gateway can do) plus a segregated, opt-in contract (SupportsSubscriptions — what only some gateways can do) means:

Configuration

Map your app's plan slugs to each gateway's own price/plan ids in config/laravel-payments.php:

The package registers its webhook route automatically at laravel-payments/webhook (or wherever webhook_path points). Exclude it from CSRF verification in your host app's bootstrap/app.php — the gateway calls it directly and can't supply a token:

Then point your gateway's dashboard (Stripe's webhook settings, for example) at https://your-app.test/laravel-payments/webhook, and copy the signing secret it gives you into STRIPE_WEBHOOK_SECRET.

Usage

A one-time payment (every gateway supports this)

Starting a subscription checkout (only for drivers that support it)

Type-hinting SupportsSubscriptions (rather than PaymentGateway) means the container throws immediately with a clear message if PAYMENT_GATEWAY is ever pointed at a driver that doesn't support subscriptions — instead of failing later with a "method does not exist" error. If your app needs to conditionally show recurring-billing UI only when it's available, resolve PaymentGateway and check instanceof SupportsSubscriptions instead of hard-depending on it.

Both charge() and checkout() return a URL to redirect the browser to — for hosted-checkout gateways like Stripe, that has to be a real top-level navigation (redirect()->away(...) in a controller, or window.location.href = ... from an SPA/Inertia frontend), not an XHR-driven route visit, since the response goes off-site.

Reacting to webhook events

Available events: PaymentSucceeded, PaymentFailed, SubscriptionCancelled, SubscriptionUpdated. Each carries plain scalars (providerCustomerId, providerSubscriptionId, amounts, currency, status) plus a raw array with the full webhook payload for anything not modeled explicitly.

Checking the current plan / cancelling

Adding a new driver

Every driver is a class implementing Aqsaahsan301\LaravelPayments\Contracts\PaymentGateway (and SupportsSubscriptions too, only if the gateway genuinely has recurring billing) — StripeDriver (src/Drivers/StripeDriver.php) is the reference implementation to copy the shape of. To add, say, a Billplz driver (one-time/invoice-only, no subscriptions):

  1. Write the driver. src/Drivers/BillplzDriver.php implements PaymentGateway. It's the only class allowed to import anything from Billplz's SDK/API client — everything else in the package (and in host apps) depends on the contract, never on your driver directly. Implement charge() and handleWebhook(); skip SupportsSubscriptions entirely if the gateway has no subscription concept — that's the whole point of the split.
  2. Translate provider events into this package's own events. In your handleWebhook(), map Billplz's webhook payload fields onto PaymentSucceeded/PaymentFailed (and SubscriptionCancelled/SubscriptionUpdated too, if you implemented SupportsSubscriptions) and dispatch those — don't invent new event classes per driver, or host app listeners have to know which gateway is active, defeating the point.
  3. Register it. Either add a createBillplzDriver() method to PaymentManager (the built-in, Laravel Manager-style way — see createStripeDriver()), or call $manager->extendDriver('billplz', BillplzDriver::class) from your own service provider if you're shipping the driver as a separate package.
  4. Test it the same way StripeDriverTest/StripeWebhookEventsTest do: install a fake HTTP client for your provider's SDK (or bind a mock client in the container) so tests never hit the network, then assert on charge()'s returned ChargeResult, on which events handleWebhook() dispatches for which payloads, and that an invalid signature is rejected.
  5. Nothing in PaymentGateway, SupportsSubscriptions, PaymentManager, the routes file, the events, or any host app code should need to change. If it does, that's a sign the new driver needs something the contract doesn't offer yet — widen the contract, not a driver-specific escape hatch.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Laravel Payments! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Laravel Payments is open-sourced software licensed under the MIT license.


All versions of laravel-payments with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^12.0||^13.0
stripe/stripe-php Version ^17.4||^18.0||^19.0||^20.0||^21.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 aqsaahsan301/laravel-payments contains the following files

Loading the files please wait ...