Skip to content

Commit

Permalink
Merge pull request #5043 from Shopify/add-support-moto
Browse files Browse the repository at this point in the history
Add support for MOTO in credit card payments extension schema
  • Loading branch information
buzuloiu authored Jan 10, 2025
2 parents ed55fc7 + cf2bc94 commit acbd399
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
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

0 comments on commit acbd399

Please sign in to comment.