Download the PHP package squareboat/razorpay-cashier without Composer

On this page you can find all versions of the php package squareboat/razorpay-cashier. 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 razorpay-cashier

Razorpay Cashier for Laravel

A Laravel package that provides an expressive, fluent interface to integrate Razorpay payment gateway, inspired by Laravel Cashier. This package simplifies handling one-time charges and subscriptions for Laravel applications, tailored for the Indian market with support for INR and 100+ payment methods.

Features

Installation

Step 1: Install via Composer

Step 2: Publish Configuration

Publish the configuration file to customize settings:

This creates config/razorpay.php in your project.

Step 3: Configure Environment

Add your Razorpay API keys to your .env file. You can get these from the Razorpay Dashboard:

Step 4: Run Migrations

If your application uses subscriptions, run the migration to create the necessary tables:

This sets up a subscriptions table to track user subscriptions.

Configuration

The config/razorpay.php file contains default settings:

Adjust these as needed (e.g., change currency for multi-currency support, if implemented).

Usage

Adding the Billable Trait

Add the Billable trait to your User model (or any model you want to bill):

One-Time Charges

Charge a user a specific amount (e.g., 100 INR):

Frontend: Use Razorpay's checkout.js to collect payment details.

Creating Subscriptions

Subscribe a user to a Razorpay plan:

Replace plan_id_from_razorpay with a plan ID created in your Razorpay Dashboard. $paymentMethodId is the razorpay_payment_id returned from the frontend.

Frontend Integration

Use Razorpay's checkout.js to initiate payments:

Backend Route (e.g., routes/web.php):

Trial Periods

The package supports trial periods for subscriptions, allowing users to access a plan for a specified number of days before billing begins. This feature integrates with Razorpay's start_at parameter to delay the initial payment and uses a local trial_ends_at column in the subscriptions table to track the trial end date.

Setup

  1. Migration:

    • Ensure the subscriptions table includes the trial_ends_at column. The package provides a migration to add this column:

    • The migration (2025_04_08_000001_add_trial_ends_at_to_subscriptions.php) adds a nullable trial_ends_at timestamp. If you haven't run it yet, apply it with the above command.
  2. Model:
    • The Subscription model (Squareboat\RazorpayCashier\Models\Subscription) is pre-configured to handle trial_ends_at as a date field and includes helper methods to check trial status.

Usage

To create a subscription with a trial period, use the trialDays() method on the SubscriptionBuilder instance returned by newSubscription():

Behavior:

Checking Trial Status

The Subscription model provides methods to check the trial status:

Example:

Syncing with Razorpay

To keep the local subscription status in sync with Razorpay after the trial, use the syncTrialStatus method:

Notes

Troubleshooting

Subscription Management

The squareboat/razorpay-cashier package provides methods to manage subscriptions, including pausing, resuming, canceling, and swapping plans.

Usage

Use the following methods on a Billable model (e.g., User):

Notes

Troubleshooting

Invoicing

The squareboat/razorpay-cashier package integrates with Razorpay's official invoicing feature and syncs details to a local invoices table for hybrid management.

Setup

Usage

Use the following methods on a Billable model (e.g., User):

Notes

Troubleshooting

Upcoming Features

  1. Webhook Handling:

    • Process Razorpay webhook events (e.g., subscription.charged, payment.failed, subscription.cancelled).
    • Store events in a razorpay_events table for idempotency and debugging.
  2. Payment Method Management:

    • Store and manage customer payment methods (e.g., cards) using Razorpay's Customer API.
    • Allow updating or deleting payment methods.
  3. Multi-Currency Support:

    • Support payments and subscriptions in multiple currencies (e.g., INR, USD).
    • Configure currency dynamically via options or config.
  4. Retries for Failed Payments:

    • Automatically retry failed subscription charges with configurable rules.
    • Queue retries using Laravel's job system.
  5. Grace Periods:

    • Allow a grace period after subscription cancellation or payment failure before deactivating services.
    • Track ends_at for grace period logic.
  6. Coupons/Discounts:

    • Apply Razorpay coupons to subscriptions or one-time charges.
    • Store discount details locally.
  7. Refunds:

    • Process refunds for one-time charges or subscription payments.
    • Update local records accordingly.
  8. Subscription Quantity:

    • Support variable quantities for subscriptions (e.g., 5 users on a plan).
    • Adjust billing via Razorpay's quantity parameter.
  9. Tax Handling:

    • Apply taxes to charges and subscriptions using Razorpay's tax features.
    • Store tax details in invoices.
  10. Customer Management:

    • Link Razorpay customers to Laravel users for recurring payments.
    • Sync customer data (e.g., email, phone) with Razorpay.
  11. Payment Receipts:

    • Send email receipts for successful payments via Razorpay's email system or Laravel's mail.
  12. Frontend Integration Enhancements:
    • Add prebuilt Blade components or JavaScript helpers for easier checkout integration.

Testing

Use Razorpay's test mode with these sample card details:

Check the Razorpay Test Cards for more options.

Requirements

Troubleshooting

Contributing

Feel free to submit issues or pull requests on GitHub.

License

This package is open-sourced software.

Support

For questions or issues, open a ticket on the GitHub Issues page.


All versions of razorpay-cashier with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0
razorpay/razorpay Version ^2.8
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 squareboat/razorpay-cashier contains the following files

Loading the files please wait ...