Download the PHP package serenity_technologies/cashier-gumroad without Composer

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

Laravel Cashier for Gumroad - Complete Documentation

Table of Contents

  1. Overview
  2. Installation & Setup
  3. Configuration
  4. Database Schema
  5. Core Concepts
  6. Checkout Flows
  7. Subscription Management
  8. Webhook Handling
  9. License Management
  10. Offer Codes & Discounts
  11. Sales Tracking
  12. Revenue Analytics
  13. Console Commands
  14. Events & Listeners
  15. Security Best Practices
  16. Common Patterns & Examples
  17. API Limitations
  18. Troubleshooting

Overview

Laravel Cashier for Gumroad provides a fluent, expressive interface to Gumroad's subscription billing and payment services. It handles almost all of the boilerplate code needed for subscription management, including:

Package Architecture


Installation & Setup

Prerequisites

Step 1: Install Package

Step 2: Add Billable Trait to User Model

The Billable trait provides subscription management methods to your user model:

What the Billable trait provides:

Step 3: Publish Configuration

This creates config/cashier-gumroad.php with all configuration options.

Step 4: Publish & Run Migrations

This creates 6 database tables (with configured prefix, default gumroad_cashier_):

  1. gumroad_cashier_subscriptions - Local subscription records
  2. gumroad_cashier_subscription_items - Subscription line items
  3. gumroad_cashier_sales - Sale records
  4. gumroad_cashier_licenses - License key records
  5. gumroad_cashier_offer_codes - Discount code records
  6. gumroad_cashier_webhook_calls - Webhook call tracking

Step 5: Configure Webhook Route (CSRF Exclusion)

CRITICAL: The webhook endpoint must be excluded from CSRF protection.

Step 6: Configure Gumroad API Access Token

The package uses the serenity_technologies/gumroad package for API calls. Configure your access token:

Get your access token from: Gumroad Dashboard → Settings → Advanced → Generate access token


Configuration

Environment Variables

Configuration File Breakdown

Custom Table Prefix Example


Database Schema

1. Subscriptions Table

Purpose: Tracks subscription lifecycle for each user.

Key Fields:

Indexes:

2. Subscription Items Table

Purpose: Line items within a subscription (for multi-product subscriptions).

Key Fields:

3. Sales Table

Purpose: Records all sales (one-time and recurring).

Key Fields:

Foreign Keys:

4. Licenses Table

Purpose: Track license keys for software products.

Key Fields:

5. Offer Codes Table

Purpose: Local cache of Gumroad discount codes.

Key Fields:

Unique: (gumroad_product_id, name)

6. Webhook Calls Table

Purpose: Track and idempotent webhook processing.

Key Fields:


Core Concepts

Billable Model

The billable model (typically User) is the entity that can have subscriptions. Add the Billable trait:

Services

The package provides several services (auto-injected via dependency injection):

Models

All models use ULIDs and configurable table names:

Cashier Static Helper

The Cashier class provides static helper methods:


Checkout Flows

The package supports two primary checkout methods.

1. New Window Checkout (Recommended)

Opens the Gumroad checkout page in a new browser tab. This is now the default behavior for all generated buttons.

Using Blade Directives:

This generates a standard anchor tag with target="_blank" and rel="noopener noreferrer".

Dedicated Checkout Route:

You can link directly to a hosted launcher:

2. Embed Checkout

Embeds the full product page in an iframe.

Getting Products


Subscription Management

Checking Subscription Status

Subscription Model Methods

Syncing Subscribers from Gumroad

Sync subscribers from Gumroad API to local database:

Programmatic sync:

Subscription Lifecycle States


Webhook Handling

Before your application can receive webhook events, you must first subscribe to the specific resources you want to listen to. Use the provided artisan commands to manage these subscriptions.

Available Artisan Commands for Webhook Subscriptions:

Supported Resources: sale, refund, dispute, dispute_won, cancellation, subscription_updated, subscription_ended, subscription_restarted.

Supported Events

The package handles all 8 Gumroad webhook events: ... Gumroad Event Local Action Events Dispatched
sale Create sale record, create subscription PaymentReceived, SubscriptionCreated
refund Update sale, cancel subscription PaymentRefunded, SubscriptionCancelled
cancellation Cancel subscription SubscriptionCancelled
subscription_updated Update subscription details SubscriptionUpdated
subscription_ended End subscription SubscriptionEnded
subscription_restarted Reactivate subscription SubscriptionRestarted
dispute Log dispute DisputeCreated
dispute_won Log dispute outcome DisputeWon

How Webhooks Work

  1. Gumroad sends POST to your webhook endpoint (/cashier/gumroad/webhook)
  2. Middleware verifies the request (secret token, IP whitelist)
  3. Controller validates payload (50+ fields validated)
  4. Idempotency check prevents duplicate processing
  5. Event type determined from payload (never trust headers)
  6. Webhook call recorded in database
  7. Job dispatched to queue (or processed synchronously)
  8. Handler processes the webhook in a database transaction
  9. Events dispatched after transaction commits

Webhook Security

Three layers of protection:

  1. Secret Token Verification (optional):

  2. IP Whitelisting (optional):

  3. Rate Limiting (default: 60 req/min):

Idempotency

Webhooks are protected against duplicate processing using SHA-256 idempotency keys:

Event Type Detection

The package determines event type from payload fields (never trusts client headers):

Webhook Payload Validation

All incoming webhooks are validated with 50+ field rules:

Payload Sanitization

Sensitive fields are removed before storage:


License Management

License keys are used to verify software purchases.

Verify License Middleware

Protect routes with license verification:

Or apply globally:

How it works:

  1. Checks for X-License-Key header or license_key query parameter
  2. Verifies with Gumroad API (cached for 1 hour)
  3. Updates local license record
  4. Throws AccessDeniedHttpException if invalid

License Service Methods

License Model Methods


Offer Codes & Discounts

Creating Offer Codes

Syncing Offer Codes

Offer Code Model Methods

Checkout with Offer Code


Sales Tracking

Sale Model Methods

Syncing Sales


Revenue Analytics

The package provides comprehensive revenue analytics.

Key Metrics

How MRR is Calculated

MRR normalizes different recurrence periods to monthly:

LTV Calculation

Caching

All analytics queries are cached (default: 1 hour) using prefixed keys:


Console Commands

1. Sync Subscribers

Syncs subscribers from Gumroad API to local database.

Options:

2. Sync Sales

Syncs sales from Gumroad API to local database.

Options:

3. Webhook Subscriptions

Manage real-time notifications by subscribing to Gumroad resources (Ping/Webhooks).

Supported Resources: sale, refund, dispute, dispute_won, cancellation, subscription_updated, subscription_ended, subscription_restarted.

Setting Up Cron Jobs

For automatic syncing, add to your server's crontab:


Events & Listeners

Available Events

Event When Dispatched Parameters
GumroadWebhookReceived Every webhook received $eventType, $payload, $saleId, $subscriptionId
PaymentReceived Sale completed $payload, $saleId, $subscriptionId
PaymentRefunded Refund processed $payload, $saleId
SubscriptionCreated New subscription created $subscription, $payload
SubscriptionCancelled Subscription cancelled $subscription, $payload, $cancelledByAdmin, $cancelledByBuyer, $cancelledBySeller, $cancelledDueToRefund
SubscriptionUpdated Subscription details updated $subscription, $payload, $updateType
SubscriptionEnded Subscription ended $subscription, $payload, $endedReason
SubscriptionRestarted Subscription reactivated $subscription, $payload
DisputeCreated Dispute raised $payload, $saleId
DisputeWon Dispute resolved in buyer's favor $payload, $saleId

Registering Event Listeners

Method 1: EventServiceProvider

Method 2: Event Subscribers

Example Listener


Security Best Practices

1. Exclude Webhook from CSRF

CRITICAL: This is required for webhooks to work.

2. Enable Webhook Verification

Generate a strong secret:

3. IP Whitelisting (Optional)

If Gumroad provides static IPs, whitelist them:

4. Use Queue for Webhooks

Queue webhook processing to ensure fast response times:

Configure queue worker:

5. Rate Limiting

Default rate limiting is 60 requests per minute. Adjust as needed:

6. Protect Sensitive Data

The package automatically sanitizes webhook payloads before storage. Do not store:

7. Use HTTPS in Production

Always use HTTPS for webhook endpoints in production.

8. Monitor Failed Webhooks

Check for failed webhook processing:


Common Patterns & Examples

1. Product Checkout Page

2. Access Control Middleware

3. Pricing Page with Multiple Plans

4. Subscription Status Page

5. Event Listener for Welcome Email

6. Admin Dashboard Analytics

7. License-Protected API Route

Client request:

8. Formatting Currency


API Limitations

Gumroad's API has several limitations to be aware of:

What Gumroad Does NOT Support:

  1. Direct Checkout on Your Site

    • Cannot process payments directly
    • Must use overlay widget or redirect to Gumroad
  2. Payment Method Updates

    • Cannot update payment methods via API
    • Users must manage via Gumroad dashboard
  3. Proration Calculations

    • No API support for proration on plan changes
    • Gumroad handles this internally
  4. Subscription Cancellation via API

    • Cannot cancel subscriptions via API
    • Must be done via Gumroad dashboard or by user
  5. Custom Checkout CSS

    • Cannot customize checkout appearance
    • Limited to overlay widget styling
  6. Price Retrieval for Subscribers
    • Subscriber API doesn't return pricing info
    • Must track locally or query sales API

Workarounds:


Troubleshooting

Issue: Webhook Returns 403 (Invalid Webhook Secret)

Cause: The HMAC signature validation failed. This usually means:

  1. The CASHIER_GUMROAD_WEBHOOK_SECRET in your .env does not match the one used during subscription.
  2. The URL signature was generated with a different secret or event type.

Solution:

  1. Verify CASHIER_GUMROAD_WEBHOOK_SECRET is identical in your environment.
  2. Re-subscribe to your resources using the cashier-gumroad:subscribe --url=https://yourdomain.com command to regenerate valid URLs with the correct resource-specific signatures.
  3. If using TestWebhookCommand, it automatically uses the correct logic, but verify your .env configuration matches.

Issue: Webhook Returns 419 (CSRF Token Mismatch)

Solution: Exclude webhook route from CSRF protection.

Issue: generateCheckoutUrl Returns 404

Cause: The URL was being constructed manually without fetching from Gumroad.

Solution: The method now:

  1. Accepts product ID (not permalink)
  2. Fetches product from Gumroad API
  3. Uses the actual short_url from API response

Issue: Duplicate Webhook Processing

Solution: Idempotency is handled automatically using SHA-256 keys. If duplicates still occur, check:

Issue: Subscriber Sync Fails

Common causes:

  1. User not found - Email in Gumroad doesn't match local user
  2. Invalid subscriber ID - Check subscriber ID format

Solution: Ensure users have matching emails:

Issue: Queue Jobs Failing

Check:

Ensure queue worker is running:

Issue: License Verification Failing

Common causes:

  1. Product ID not provided - Set default in config
  2. Invalid license key - Check key format
  3. API rate limit - Verification is cached for 1 hour

Solution:

Issue: Analytics Showing Zero

Check:

  1. Sales are being synced: Sale::count()
  2. Webhooks are processing: WebhookCall::unprocessed()->count()
  3. Cache is not stale: Clear analytics cache

Issue: Currency Formatting Incorrect

Solution: Configure locale:


Additional Resources

Recommended Queue Configuration

For production, use Redis or database queue driver:

Supervisor configuration for queue worker:

Database Indexes

All necessary indexes are created in migrations. If adding custom queries, consider:

Testing Webhooks Locally

Use ngrok or similar to expose local server:

Update Gumroad webhook URL to: https://your-ngrok-url.ngrok.io/cashier/gumroad/webhook

Package Updates

When updating the package:


Changelog Highlights

Recent Improvements


Support & Contributing

For issues, suggestions, or contributions, please refer to the project repository.

License

This package is open-sourced software licensed under the MIT license.


All versions of cashier-gumroad with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-intl Version *
guzzlehttp/guzzle Version ^7.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
laravel/framework Version ^9.0|^10.0|^11.0|^12.0|^13.0
moneyphp/money Version ^4.0
serenity_technologies/gumroad Version ^1.2
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 serenity_technologies/cashier-gumroad contains the following files

Loading the files please wait ...