Overview
The FastSpring integration is a webhook server that handles the complete license lifecycle: creation, renewal, suspension, and deletion based on FastSpring events. It supports both one-time purchases and subscriptions, including bundles and add-ons. Key capabilities:- Create licenses for orders and subscriptions
- Renew licenses on successful subscription charges
- Suspend licenses when payments are overdue
- Delete licenses when subscriptions are deactivated
- Support for bundles and subscription add-ons
- Quantity-based license creation
Supported Webhook Events
The integration handles four FastSpring webhook event types:order.completed
order.completed
Triggered when an order is successfully completed (both one-time and subscription orders).Actions:
- Creates a user in Cryptlex based on customer email
- Creates licenses for all items in the order
- Handles bundles (products with
driver.type: bundle) - Handles add-ons (products with
driver.type: addonandparentSubscription) - Supports quantity mapping to either license count or allowed activations
- Stores subscription ID or order ID in license metadata
subscription_idfor subscription-based licensesorder_idfor one-time purchasesdriverfor bundles and add-ons (e.g.,bundle_ProductName,addon_ProductName)
subscription.charge.completed
subscription.charge.completed
Triggered when a subscription charge is successfully processed.Actions:
- Finds all licenses with matching subscription ID
- Renews each license to extend expiry date
- Unsuspends licenses if they were previously suspended
subscription.payment.overdue
subscription.payment.overdue
Triggered when a subscription payment becomes overdue.Actions:
- Finds all licenses with matching subscription ID
- Suspends each license to prevent usage
subscription.deactivated
subscription.deactivated
Triggered when a subscription is deactivated (canceled, expired, or failed).Actions:
- Finds all licenses with matching subscription ID
- Permanently deletes each license from Cryptlex
Environment Variables
Set these environment variables in your hosting environment:| Variable | Required | Description |
|---|---|---|
FASTSPRING_WEBHOOK_SECRET | Yes | Your FastSpring webhook secret for HMAC signature verification |
CRYPTLEX_ACCESS_TOKEN | Yes | Cryptlex API access token with license:read, license:write, user:read, user:write, and licenseTemplate:read (for add-ons) permissions |
CRYPTLEX_WEB_API_BASE_URL | Yes | Base URL of the Cryptlex Web API |
The
licenseTemplate:read permission is only required if you plan to support subscription add-ons.Setup Instructions
1. Deploy the Integration
Choose your deployment method: AWS Lambda: Review the providedaws.yml GitHub Actions workflow for automated deployments.
Node.js / Docker:
Use the provided Dockerfile to run in any containerized environment.
2. Configure FastSpring Webhook
- Log in to your FastSpring account
- Go to Integrations > Webhooks
- Click Add Webhook URL
- Set the URL to your deployed endpoint:
https://your-domain.com/v1 - Generate a Secret and save it as
FASTSPRING_WEBHOOK_SECRET - Select the following events:
order.completedsubscription.charge.completedsubscription.payment.overduesubscription.deactivated
- Save the webhook configuration
3. Configure Product Custom Attributes
For each FastSpring product, add custom attributes to map to Cryptlex: Required attributes:cryptlex_product_id- Your Cryptlex Product IDcryptlex_license_template_id- License template to usecryptlex_license_subscription_interval- Subscription interval (e.g.,P1Mfor monthly,P1Yfor yearly, or empty string for perpetual)
cryptlex_mappings_quantity- Set toallowedActivationsto map quantity to activations, orlicenseCountto create multiple licensescryptlex_is_bundle- Set totruefor bundle products (the bundle product itself won’t create a license)
Subscription intervals use ISO 8601 duration format:
P1M (1 month), P1Y (1 year), P3M (3 months), etc.4. Set Environment Variables
Configure all required environment variables:Webhook Signature Verification
FastSpring signs webhooks using HMAC-SHA256. The integration verifies every request:- FastSpring computes HMAC-SHA256 of the raw request body using your secret
- The signature is sent in the
x-fs-signatureheader - The integration computes the signature independently and compares
- Only matching signatures are processed
Example Workflows
One-Time Purchase
When a customer purchases a product:- Event:
order.completed - Handler:
handleOrderCreated - Actions:
- Create user from customer email and name
- Extract product attributes (product ID, template ID)
- Create license(s) based on quantity
- Store order ID in metadata
- Result: Customer receives perpetual license(s)
Subscription Order
When a customer starts a subscription:- Event:
order.completed - Handler:
handleOrderCreated - Actions:
- Create user
- Create license with subscription interval
- Store subscription ID in metadata
- Result: Time-limited license that auto-renews
Subscription Renewal
When a subscription charge succeeds:- Event:
subscription.charge.completed - Handler:
handleSubscriptionChargeCompleted - Actions:
- Find licenses by subscription ID
- Renew each license
- Unsuspend if previously suspended
- Result: License expiry extended
Payment Overdue
When a subscription payment fails:- Event:
subscription.payment.overdue - Handler:
handleSubscriptionPaymentOverdue - Actions:
- Find licenses by subscription ID
- Suspend each license
- Result: License usage blocked until payment
Subscription Canceled
When a subscription is deactivated:- Event:
subscription.deactivated - Handler:
handleSubscriptionDeactivated - Actions:
- Find licenses by subscription ID
- Delete each license permanently
- Result: Licenses removed from Cryptlex
Advanced Features
Bundle Support
Bundles allow selling multiple products together:Add-on Support
Add-ons inherit subscription properties from parent:Quantity Mapping
Control how product quantity maps to licenses: License count mode (default):- Quantity of 5 creates 5 separate licenses
- Quantity of 5 creates 1 license with 5 allowed activations
FAQ
What happens if order.completed fails partially?
What happens if order.completed fails partially?
The handler creates users and licenses sequentially. If an error occurs, the error message includes which user ID was created and which license IDs were created before failure, helping you recover manually.
Can I prevent license deletion on subscription.deactivated?
Can I prevent license deletion on subscription.deactivated?
Yes, modify
handleSubscriptionDeactivated to suspend licenses instead of deleting them. Replace the DELETE call with a PATCH setting suspended: true.How do I handle refunds?
How do I handle refunds?
FastSpring doesn’t have a specific refund webhook event. You’ll need to manually delete or suspend licenses when processing refunds, or set up a custom workflow.
Can I test webhooks before going live?
Can I test webhooks before going live?
Yes! FastSpring provides a test mode. You can also use tools like ngrok to tunnel webhooks to your local development environment.
What if a subscription has multiple products?
What if a subscription has multiple products?
The integration handles this automatically. Each product in the subscription creates its own license, all sharing the same subscription ID in metadata.
Error Handling
All errors include context about what succeeded before failure:- Identify which step failed
- Recover partial progress manually
- Debug issues faster