mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 10:53:23 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 291ce255b4 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-billing",
|
"name": "@xtr-dev/payload-billing",
|
||||||
"version": "0.1.24",
|
"version": "0.1.25",
|
||||||
"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",
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ import { createContextLogger } from '../utils/logger'
|
|||||||
const symbol = Symbol.for('@xtr-dev/payload-billing/mollie')
|
const symbol = Symbol.for('@xtr-dev/payload-billing/mollie')
|
||||||
export type MollieProviderConfig = Parameters<typeof createMollieClient>[0]
|
export type MollieProviderConfig = Parameters<typeof createMollieClient>[0]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the Mollie mode based on API key prefix
|
||||||
|
*/
|
||||||
|
function getMollieMode(apiKey: string): 'test' | 'live' {
|
||||||
|
return apiKey.startsWith('test_') ? 'test' : 'live'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-safe mapping of Mollie payment status to internal status
|
* Type-safe mapping of Mollie payment status to internal status
|
||||||
*/
|
*/
|
||||||
@@ -161,6 +168,9 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
|
|||||||
validateProductionUrl(redirectUrl, 'Redirect')
|
validateProductionUrl(redirectUrl, 'Redirect')
|
||||||
validateProductionUrl(webhookUrl, 'Webhook')
|
validateProductionUrl(webhookUrl, 'Webhook')
|
||||||
|
|
||||||
|
// Determine mode from API key (test_ or live_)
|
||||||
|
const mode = getMollieMode(mollieConfig.apiKey)
|
||||||
|
|
||||||
const molliePayment = await singleton.get(payload).payments.create({
|
const molliePayment = await singleton.get(payload).payments.create({
|
||||||
amount: {
|
amount: {
|
||||||
value: formatAmountForProvider(payment.amount, payment.currency),
|
value: formatAmountForProvider(payment.amount, payment.currency),
|
||||||
@@ -169,7 +179,8 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
|
|||||||
description: payment.description || '',
|
description: payment.description || '',
|
||||||
redirectUrl,
|
redirectUrl,
|
||||||
webhookUrl,
|
webhookUrl,
|
||||||
});
|
mode,
|
||||||
|
} as any);
|
||||||
payment.providerId = molliePayment.id
|
payment.providerId = molliePayment.id
|
||||||
// Use toPlainObject if available, otherwise spread the object (for compatibility with different Mollie client versions)
|
// Use toPlainObject if available, otherwise spread the object (for compatibility with different Mollie client versions)
|
||||||
payment.providerData = typeof molliePayment.toPlainObject === 'function'
|
payment.providerData = typeof molliePayment.toPlainObject === 'function'
|
||||||
|
|||||||
Reference in New Issue
Block a user