diff --git a/package.json b/package.json index a4d2798..ef6c34a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xtr-dev/payload-billing", - "version": "0.1.22", + "version": "0.1.23", "description": "PayloadCMS plugin for billing and payment provider integrations with tracking and local testing", "license": "MIT", "type": "module", diff --git a/src/providers/mollie.ts b/src/providers/mollie.ts index 9f39f75..43073bf 100644 --- a/src/providers/mollie.ts +++ b/src/providers/mollie.ts @@ -85,11 +85,15 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & { const status = mapMollieStatusToPaymentStatus(molliePayment.status) // Update the payment status and provider data + // Use toPlainObject if available, otherwise spread the object + const providerData = typeof molliePayment.toPlainObject === 'function' + ? molliePayment.toPlainObject() + : { ...molliePayment } const updateSuccess = await updatePaymentStatus( payload, payment.id, status, - molliePayment.toPlainObject(), + providerData, pluginConfig ) @@ -167,7 +171,10 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & { webhookUrl, }); payment.providerId = molliePayment.id - payment.providerData = molliePayment.toPlainObject() + // Use toPlainObject if available, otherwise spread the object (for compatibility with different Mollie client versions) + payment.providerData = typeof molliePayment.toPlainObject === 'function' + ? molliePayment.toPlainObject() + : { ...molliePayment } payment.checkoutUrl = molliePayment._links?.checkout?.href || null return payment },