Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MOTO in credit card payments extension schema #5043

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading