diff --git a/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.test.ts b/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.test.ts index b5f5e5867b3..c8d4fd47f9b 100644 --- a/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.test.ts +++ b/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.test.ts @@ -21,6 +21,7 @@ const config: CreditCardPaymentsAppExtensionConfigType = { supported_countries: ['CA'], supported_payment_methods: ['PAYMENT_METHOD'], supported_buyer_contexts: [{currency: 'USD'}, {currency: 'CAD'}], + supports_moto: true, supports_3ds: false, test_mode_available: true, supports_deferred_payments: false, @@ -172,6 +173,46 @@ describe('CreditCardPaymentsAppExtensionSchema', () => { ]), ) }) + + test('returns an error if supports_moto is not a boolean', async () => { + // When/Then + expect(() => + CreditCardPaymentsAppExtensionSchema.parse({ + ...config, + supports_moto: 'true', + }), + ).toThrowError( + new zod.ZodError([ + { + code: 'invalid_type', + expected: 'boolean', + received: 'string', + path: ['supports_moto'], + message: 'Value must be Boolean', + }, + ]), + ) + }) + + test('returns an error if supports_moto is not present', async () => { + // When/Then + expect(() => + CreditCardPaymentsAppExtensionSchema.parse({ + ...config, + supports_moto: undefined, + }), + ).toThrowError( + new zod.ZodError([ + { + code: 'invalid_type', + expected: 'boolean', + received: 'undefined', + path: ['supports_moto'], + message: 'supports_moto is required', + }, + ]), + ) + }) }) describe('creditCardPaymentsAppExtensionDeployConfig', () => { @@ -194,6 +235,7 @@ describe('creditCardPaymentsAppExtensionDeployConfig', () => { supported_payment_methods: config.supported_payment_methods, supported_buyer_contexts: config.supported_buyer_contexts, test_mode_available: config.test_mode_available, + supports_moto: config.supports_moto, supports_3ds: config.supports_3ds, supports_deferred_payments: config.supports_deferred_payments, supports_installments: config.supports_installments, diff --git a/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.ts b/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.ts index e4f65957dc0..b6515040426 100644 --- a/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.ts +++ b/packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.ts @@ -29,6 +29,10 @@ export const CreditCardPaymentsAppExtensionSchema = BasePaymentsAppExtensionSche targeting: zod.array(zod.object({target: zod.literal(CREDIT_CARD_TARGET)})).length(1), verification_session_url: zod.string().url().optional(), ui_extension_handle: zod.string().optional(), + supports_moto: zod.boolean({ + required_error: 'supports_moto is required', + invalid_type_error: 'Value must be Boolean', + }), encryption_certificate_fingerprint: zod .string() .min(1, {message: "Encryption certificate fingerprint can't be blank"}), @@ -72,6 +76,7 @@ export interface CreditCardPaymentsAppExtensionDeployConfigType extends BasePaym supports_3ds: boolean // CreditCard-specific fields + supports_moto: boolean start_verification_session_url?: string ui_extension_registration_uuid?: string ui_extension_handle?: string @@ -106,6 +111,7 @@ export function creditCardDeployConfigToCLIConfig( supported_buyer_contexts: config.supported_buyer_contexts, test_mode_available: config.test_mode_available, supports_3ds: config.supports_3ds, + supports_moto: config.supports_moto, supports_deferred_payments: config.supports_deferred_payments, supports_installments: config.supports_installments, verification_session_url: config.start_verification_session_url, @@ -132,6 +138,7 @@ export async function creditCardPaymentsAppExtensionDeployConfig( supported_buyer_contexts: config.supported_buyer_contexts, test_mode_available: config.test_mode_available, supports_3ds: config.supports_3ds, + supports_moto: config.supports_moto, supports_deferred_payments: config.supports_deferred_payments, encryption_certificate_fingerprint: config.encryption_certificate_fingerprint, supports_installments: config.supports_installments,