mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 02:43:24 +00:00
fix: handle missing toPlainObject in Mollie client responses
Add fallback for Mollie API responses that may not have toPlainObject method depending on client version or response type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user