fix: add better error handling for uninitialized billing plugin

- Fix TypeError when accessing providerConfig on undefined billing plugin
- Add proper type safety: useBillingPlugin now returns BillingPlugin | undefined
- Add clear error message when plugin hasn't been initialized
- Update README quickstart with concise provider response examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-18 22:31:51 +01:00
parent 1867bb2f96
commit a37757ffa1
4 changed files with 16 additions and 6 deletions

View File

@@ -100,18 +100,21 @@ export default buildConfig({
const payment = await payload.create({
collection: 'payments',
data: {
provider: 'stripe',
provider: 'stripe', // or 'mollie' or 'test'
amount: 5000, // $50.00 in cents
currency: 'USD',
description: 'Product purchase',
status: 'pending',
}
})
// Payment is automatically initialized with Stripe
console.log(payment.providerId) // Stripe PaymentIntent ID
```
**What you get back:**
- **Stripe**: `providerId` = PaymentIntent ID, `providerData.raw.client_secret` for Stripe.js
- **Mollie**: `providerId` = Transaction ID, `providerData.raw._links.checkout.href` for redirect URL
- **Test**: `providerId` = Test payment ID, `providerData.raw.paymentUrl` for interactive test UI
## Payment Providers
### Stripe