fix: use testmode boolean parameter for Mollie payments

Changed from mode: 'test' | 'live' to testmode: boolean as per Mollie
API requirements. The testmode parameter is set to true when the API
key starts with 'test_', false otherwise.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-05 15:12:09 +01:00
parent 291ce255b4
commit 1eb9d282b3
2 changed files with 7 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@xtr-dev/payload-billing", "name": "@xtr-dev/payload-billing",
"version": "0.1.25", "version": "0.1.26",
"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",

View File

@@ -18,10 +18,10 @@ 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 * Determine if testmode should be enabled based on API key prefix
*/ */
function getMollieMode(apiKey: string): 'test' | 'live' { function isTestMode(apiKey: string): boolean {
return apiKey.startsWith('test_') ? 'test' : 'live' return apiKey.startsWith('test_')
} }
/** /**
@@ -168,8 +168,8 @@ 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_) // Determine testmode from API key (test_ prefix = true)
const mode = getMollieMode(mollieConfig.apiKey) const testmode = isTestMode(mollieConfig.apiKey)
const molliePayment = await singleton.get(payload).payments.create({ const molliePayment = await singleton.get(payload).payments.create({
amount: { amount: {
@@ -179,7 +179,7 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
description: payment.description || '', description: payment.description || '',
redirectUrl, redirectUrl,
webhookUrl, webhookUrl,
mode, testmode,
} as any); } 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)