mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 19:03:23 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6de405d07f | |||
| 7c0b42e35d | |||
| 25b340d818 | |||
| 46bec6bd2e |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-billing",
|
"name": "@xtr-dev/payload-billing",
|
||||||
"version": "0.1.16",
|
"version": "0.1.18",
|
||||||
"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",
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ export const initProviderPayment = async (payload: Payload, payment: Partial<Pay
|
|||||||
|
|
||||||
if (!billing) {
|
if (!billing) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Billing plugin not initialized. Make sure the billingPlugin is properly configured in your Payload config and that Payload has finished initializing.'
|
'Billing plugin not initialized. Make sure the billingPlugin is properly configured in your Payload config and that Payload has finished initializing. ' +
|
||||||
|
'If you are calling this from a Next.js API route or Server Component, ensure you are using getPayload() with the same config instance used in your Payload configuration.'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,18 @@ export function createPaymentsCollection(pluginConfig: BillingPluginConfig): Col
|
|||||||
useAsTitle: 'id',
|
useAsTitle: 'id',
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
|
defaultPopulate: {
|
||||||
|
id: true,
|
||||||
|
provider: true,
|
||||||
|
status: true,
|
||||||
|
amount: true,
|
||||||
|
currency: true,
|
||||||
|
description: true,
|
||||||
|
checkoutUrl: true,
|
||||||
|
providerId: true,
|
||||||
|
metadata: true,
|
||||||
|
providerData: true,
|
||||||
|
},
|
||||||
hooks: {
|
hooks: {
|
||||||
afterChange: [
|
afterChange: [
|
||||||
async ({ doc, operation, req, previousDoc }) => {
|
async ({ doc, operation, req, previousDoc }) => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { Config, Payload } from 'payload'
|
|||||||
import { createSingleton } from './singleton'
|
import { createSingleton } from './singleton'
|
||||||
import type { PaymentProvider } from '../providers/index'
|
import type { PaymentProvider } from '../providers/index'
|
||||||
|
|
||||||
const singleton = createSingleton(Symbol('billingPlugin'))
|
const singleton = createSingleton(Symbol.for('@xtr-dev/payload-billing'))
|
||||||
|
|
||||||
type BillingPlugin = {
|
type BillingPlugin = {
|
||||||
config: BillingPluginConfig
|
config: BillingPluginConfig
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
import { formatAmountForProvider, isValidAmount, isValidCurrencyCode } from './currency'
|
import { formatAmountForProvider, isValidAmount, isValidCurrencyCode } from './currency'
|
||||||
import { createContextLogger } from '../utils/logger'
|
import { createContextLogger } from '../utils/logger'
|
||||||
|
|
||||||
const symbol = Symbol('mollie')
|
const symbol = Symbol.for('@xtr-dev/payload-billing/mollie')
|
||||||
export type MollieProviderConfig = Parameters<typeof createMollieClient>[0]
|
export type MollieProviderConfig = Parameters<typeof createMollieClient>[0]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
import { isValidAmount, isValidCurrencyCode } from './currency'
|
import { isValidAmount, isValidCurrencyCode } from './currency'
|
||||||
import { createContextLogger } from '../utils/logger'
|
import { createContextLogger } from '../utils/logger'
|
||||||
|
|
||||||
const symbol = Symbol('stripe')
|
const symbol = Symbol.for('@xtr-dev/payload-billing/stripe')
|
||||||
|
|
||||||
export interface StripeProviderConfig {
|
export interface StripeProviderConfig {
|
||||||
secretKey: string
|
secretKey: string
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { handleWebhookError, logWebhookEvent } from './utils'
|
|||||||
import { isValidAmount, isValidCurrencyCode } from './currency'
|
import { isValidAmount, isValidCurrencyCode } from './currency'
|
||||||
import { createContextLogger } from '../utils/logger'
|
import { createContextLogger } from '../utils/logger'
|
||||||
|
|
||||||
const TestModeWarningSymbol = Symbol('TestModeWarning')
|
const TestModeWarningSymbol = Symbol.for('@xtr-dev/payload-billing/test-mode-warning')
|
||||||
const hasGivenTestModeWarning = () => TestModeWarningSymbol in globalThis
|
const hasGivenTestModeWarning = () => TestModeWarningSymbol in globalThis
|
||||||
const setTestModeWarning = () => ((<any>globalThis)[TestModeWarningSymbol] = true)
|
const setTestModeWarning = () => ((<any>globalThis)[TestModeWarningSymbol] = true)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user