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",
"version": "0.1.25",
"version": "0.1.26",
"description": "PayloadCMS plugin for billing and payment provider integrations with tracking and local testing",
"license": "MIT",
"type": "module",

View File

@@ -18,10 +18,10 @@ const symbol = Symbol.for('@xtr-dev/payload-billing/mollie')
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' {
return apiKey.startsWith('test_') ? 'test' : 'live'
function isTestMode(apiKey: string): boolean {
return apiKey.startsWith('test_')
}
/**
@@ -168,8 +168,8 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
validateProductionUrl(redirectUrl, 'Redirect')
validateProductionUrl(webhookUrl, 'Webhook')
// Determine mode from API key (test_ or live_)
const mode = getMollieMode(mollieConfig.apiKey)
// Determine testmode from API key (test_ prefix = true)
const testmode = isTestMode(mollieConfig.apiKey)
const molliePayment = await singleton.get(payload).payments.create({
amount: {
@@ -179,7 +179,7 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
description: payment.description || '',
redirectUrl,
webhookUrl,
mode,
testmode,
} as any);
payment.providerId = molliePayment.id
// Use toPlainObject if available, otherwise spread the object (for compatibility with different Mollie client versions)