mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 10:53:23 +00:00
Compare commits
17 Commits
claude/iss
...
v0.1.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b8c89a0a2 | ||
| d651e8199c | |||
| f77719716f | |||
|
|
c6e51892e6 | ||
|
|
38c8c3677d | ||
|
|
e74a2410e6 | ||
|
|
27b86132e9 | ||
| ec635fb707 | |||
| cabe6eda96 | |||
| a3108a0f49 | |||
|
|
113a0d36c0 | ||
| 8ac328e14f | |||
| 7a3d6ec26e | |||
| 534b0e440f | |||
| bfa214aed6 | |||
| c083ae183c | |||
| d09fe3054a |
7
.github/workflows/claude-code-review.yml
vendored
7
.github/workflows/claude-code-review.yml
vendored
@@ -12,11 +12,8 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
claude-review:
|
claude-review:
|
||||||
# Optional: Filter by PR author
|
# Only allow bvdaakster to trigger reviews
|
||||||
# if: |
|
if: github.event.pull_request.user.login == 'bvdaakster'
|
||||||
# github.event.pull_request.user.login == 'external-contributor' ||
|
|
||||||
# github.event.pull_request.user.login == 'new-developer' ||
|
|
||||||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
96
README.md
96
README.md
@@ -1,17 +1,19 @@
|
|||||||
# @xtr-dev/payload-billing
|
# @xtr-dev/payload-billing
|
||||||
|
|
||||||
A billing and payment provider plugin for PayloadCMS 3.x. Supports Stripe, Mollie, and local testing with comprehensive tracking.
|
A billing and payment provider plugin for PayloadCMS 3.x. Supports Stripe, Mollie, and local testing with comprehensive tracking and flexible customer data management.
|
||||||
|
|
||||||
⚠️ **Pre-release Warning**: This package is currently in active development (v0.0.x). Breaking changes may occur before v1.0.0. Not recommended for production use.
|
⚠️ **Pre-release Warning**: This package is currently in active development (v0.1.x). Breaking changes may occur before v1.0.0. Not recommended for production use.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 💳 Multiple payment providers (Stripe, Mollie, Test)
|
- 💳 Multiple payment providers (Stripe, Mollie, Test)
|
||||||
- 🧾 Invoice generation and management
|
- 🧾 Invoice generation and management with embedded customer info
|
||||||
|
- 👥 Flexible customer data management with relationship support
|
||||||
- 📊 Complete payment tracking and history
|
- 📊 Complete payment tracking and history
|
||||||
- 🪝 Secure webhook processing for all providers
|
- 🪝 Secure webhook processing for all providers
|
||||||
- 🧪 Built-in test provider for local development
|
- 🧪 Built-in test provider for local development
|
||||||
- 📱 Payment management in PayloadCMS admin
|
- 📱 Payment management in PayloadCMS admin
|
||||||
|
- 🔄 Callback-based customer data syncing
|
||||||
- 🔒 Full TypeScript support
|
- 🔒 Full TypeScript support
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -42,6 +44,8 @@ pnpm add @mollie/api-client
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
|
### Basic Configuration
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { buildConfig } from 'payload'
|
import { buildConfig } from 'payload'
|
||||||
import { billingPlugin, stripeProvider, mollieProvider } from '@xtr-dev/payload-billing'
|
import { billingPlugin, stripeProvider, mollieProvider } from '@xtr-dev/payload-billing'
|
||||||
@@ -70,6 +74,68 @@ export default buildConfig({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### With Customer Management
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { billingPlugin, CustomerInfoExtractor } from '@xtr-dev/payload-billing'
|
||||||
|
|
||||||
|
// Define how to extract customer info from your customer collection
|
||||||
|
const customerExtractor: CustomerInfoExtractor = (customer) => ({
|
||||||
|
name: customer.name,
|
||||||
|
email: customer.email,
|
||||||
|
phone: customer.phone,
|
||||||
|
company: customer.company,
|
||||||
|
taxId: customer.taxId,
|
||||||
|
billingAddress: {
|
||||||
|
line1: customer.address.line1,
|
||||||
|
line2: customer.address.line2,
|
||||||
|
city: customer.address.city,
|
||||||
|
state: customer.address.state,
|
||||||
|
postalCode: customer.address.postalCode,
|
||||||
|
country: customer.address.country,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
billingPlugin({
|
||||||
|
// ... providers
|
||||||
|
collections: {
|
||||||
|
payments: 'payments',
|
||||||
|
invoices: 'invoices',
|
||||||
|
refunds: 'refunds',
|
||||||
|
},
|
||||||
|
customerRelationSlug: 'customers', // Enable customer relationships
|
||||||
|
customerInfoExtractor: customerExtractor, // Auto-sync customer data
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Customer Data Extraction
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { CustomerInfoExtractor } from '@xtr-dev/payload-billing'
|
||||||
|
|
||||||
|
const customExtractor: CustomerInfoExtractor = (customer) => ({
|
||||||
|
name: customer.fullName,
|
||||||
|
email: customer.contactEmail,
|
||||||
|
phone: customer.phoneNumber,
|
||||||
|
company: customer.companyName,
|
||||||
|
taxId: customer.vatNumber,
|
||||||
|
billingAddress: {
|
||||||
|
line1: customer.billing.street,
|
||||||
|
line2: customer.billing.apartment,
|
||||||
|
city: customer.billing.city,
|
||||||
|
state: customer.billing.state,
|
||||||
|
postalCode: customer.billing.zip,
|
||||||
|
country: customer.billing.countryCode,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
billingPlugin({
|
||||||
|
// ... other config
|
||||||
|
customerRelationSlug: 'clients',
|
||||||
|
customerInfoExtractor: customExtractor,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Imports
|
## Imports
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@@ -80,7 +146,17 @@ import { billingPlugin } from '@xtr-dev/payload-billing'
|
|||||||
import { stripeProvider, mollieProvider } from '@xtr-dev/payload-billing'
|
import { stripeProvider, mollieProvider } from '@xtr-dev/payload-billing'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import type { PaymentProvider, Payment, Invoice, Refund } from '@xtr-dev/payload-billing'
|
import type {
|
||||||
|
PaymentProvider,
|
||||||
|
Payment,
|
||||||
|
Invoice,
|
||||||
|
Refund,
|
||||||
|
BillingPluginConfig,
|
||||||
|
CustomerInfoExtractor,
|
||||||
|
MollieProviderConfig,
|
||||||
|
StripeProviderConfig,
|
||||||
|
ProviderData
|
||||||
|
} from '@xtr-dev/payload-billing'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Provider Types
|
## Provider Types
|
||||||
@@ -99,9 +175,19 @@ Local development testing with configurable scenarios, automatic completion, deb
|
|||||||
The plugin adds these collections:
|
The plugin adds these collections:
|
||||||
|
|
||||||
- **payments** - Payment transactions with status and provider data
|
- **payments** - Payment transactions with status and provider data
|
||||||
- **invoices** - Invoice generation with line items and PDF support
|
- **invoices** - Invoice generation with line items and embedded customer info
|
||||||
- **refunds** - Refund tracking and management
|
- **refunds** - Refund tracking and management
|
||||||
|
|
||||||
|
### Customer Data Management
|
||||||
|
|
||||||
|
The plugin supports flexible customer data handling:
|
||||||
|
|
||||||
|
1. **With Customer Relationship + Extractor**: Customer relationship required, customer info auto-populated and read-only, syncs automatically when customer changes
|
||||||
|
|
||||||
|
2. **With Customer Relationship (no extractor)**: Customer relationship optional, customer info manually editable, either relationship OR customer info required
|
||||||
|
|
||||||
|
3. **No Customer Collection**: Customer info fields always required and editable, no relationship field available
|
||||||
|
|
||||||
## Webhook Endpoints
|
## Webhook Endpoints
|
||||||
|
|
||||||
Automatic webhook endpoints are created for configured providers:
|
Automatic webhook endpoints are created for configured providers:
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export interface Payment {
|
|||||||
/**
|
/**
|
||||||
* The payment ID from the payment provider
|
* The payment ID from the payment provider
|
||||||
*/
|
*/
|
||||||
providerId: string;
|
providerId?: string | null;
|
||||||
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'refunded' | 'partially_refunded';
|
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'refunded' | 'partially_refunded';
|
||||||
/**
|
/**
|
||||||
* Amount in cents (e.g., 2000 = $20.00)
|
* Amount in cents (e.g., 2000 = $20.00)
|
||||||
@@ -198,6 +198,7 @@ export interface Payment {
|
|||||||
| boolean
|
| boolean
|
||||||
| null;
|
| null;
|
||||||
refunds?: (number | Refund)[] | null;
|
refunds?: (number | Refund)[] | null;
|
||||||
|
version?: number | null;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
@@ -499,6 +500,7 @@ export interface PaymentsSelect<T extends boolean = true> {
|
|||||||
metadata?: T;
|
metadata?: T;
|
||||||
providerData?: T;
|
providerData?: T;
|
||||||
refunds?: T;
|
refunds?: T;
|
||||||
|
version?: T;
|
||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-billing",
|
"name": "@xtr-dev/payload-billing",
|
||||||
"version": "0.1.5",
|
"version": "0.1.7",
|
||||||
"description": "PayloadCMS plugin for billing and payment provider integrations with tracking and local testing",
|
"description": "PayloadCMS plugin for billing and payment provider integrations with tracking and local testing",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
Reference in New Issue
Block a user