mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 19:03:23 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 20030b435c |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-billing",
|
"name": "@xtr-dev/payload-billing",
|
||||||
"version": "0.1.26",
|
"version": "0.1.27",
|
||||||
"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,13 +17,6 @@ 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 if testmode should be enabled based on API key prefix
|
|
||||||
*/
|
|
||||||
function isTestMode(apiKey: string): boolean {
|
|
||||||
return apiKey.startsWith('test_')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-safe mapping of Mollie payment status to internal status
|
* Type-safe mapping of Mollie payment status to internal status
|
||||||
*/
|
*/
|
||||||
@@ -168,9 +161,6 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
|
|||||||
validateProductionUrl(redirectUrl, 'Redirect')
|
validateProductionUrl(redirectUrl, 'Redirect')
|
||||||
validateProductionUrl(webhookUrl, 'Webhook')
|
validateProductionUrl(webhookUrl, 'Webhook')
|
||||||
|
|
||||||
// Determine testmode from API key (test_ prefix = true)
|
|
||||||
const testmode = isTestMode(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),
|
||||||
@@ -179,8 +169,7 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
|
|||||||
description: payment.description || '',
|
description: payment.description || '',
|
||||||
redirectUrl,
|
redirectUrl,
|
||||||
webhookUrl,
|
webhookUrl,
|
||||||
testmode,
|
});
|
||||||
} 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