Skip to content

Commit acbd399

Browse files
authored
Merge pull request #5043 from Shopify/add-support-moto
Add support for MOTO in credit card payments extension schema
2 parents ed55fc7 + cf2bc94 commit acbd399

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.test.ts

+42
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const config: CreditCardPaymentsAppExtensionConfigType = {
2121
supported_countries: ['CA'],
2222
supported_payment_methods: ['PAYMENT_METHOD'],
2323
supported_buyer_contexts: [{currency: 'USD'}, {currency: 'CAD'}],
24+
supports_moto: true,
2425
supports_3ds: false,
2526
test_mode_available: true,
2627
supports_deferred_payments: false,
@@ -172,6 +173,46 @@ describe('CreditCardPaymentsAppExtensionSchema', () => {
172173
]),
173174
)
174175
})
176+
177+
test('returns an error if supports_moto is not a boolean', async () => {
178+
// When/Then
179+
expect(() =>
180+
CreditCardPaymentsAppExtensionSchema.parse({
181+
...config,
182+
supports_moto: 'true',
183+
}),
184+
).toThrowError(
185+
new zod.ZodError([
186+
{
187+
code: 'invalid_type',
188+
expected: 'boolean',
189+
received: 'string',
190+
path: ['supports_moto'],
191+
message: 'Value must be Boolean',
192+
},
193+
]),
194+
)
195+
})
196+
197+
test('returns an error if supports_moto is not present', async () => {
198+
// When/Then
199+
expect(() =>
200+
CreditCardPaymentsAppExtensionSchema.parse({
201+
...config,
202+
supports_moto: undefined,
203+
}),
204+
).toThrowError(
205+
new zod.ZodError([
206+
{
207+
code: 'invalid_type',
208+
expected: 'boolean',
209+
received: 'undefined',
210+
path: ['supports_moto'],
211+
message: 'supports_moto is required',
212+
},
213+
]),
214+
)
215+
})
175216
})
176217

177218
describe('creditCardPaymentsAppExtensionDeployConfig', () => {
@@ -194,6 +235,7 @@ describe('creditCardPaymentsAppExtensionDeployConfig', () => {
194235
supported_payment_methods: config.supported_payment_methods,
195236
supported_buyer_contexts: config.supported_buyer_contexts,
196237
test_mode_available: config.test_mode_available,
238+
supports_moto: config.supports_moto,
197239
supports_3ds: config.supports_3ds,
198240
supports_deferred_payments: config.supports_deferred_payments,
199241
supports_installments: config.supports_installments,

packages/app/src/cli/models/extensions/specifications/payments_app_extension_schemas/credit_card_payments_app_extension_schema.ts

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export const CreditCardPaymentsAppExtensionSchema = BasePaymentsAppExtensionSche
2929
targeting: zod.array(zod.object({target: zod.literal(CREDIT_CARD_TARGET)})).length(1),
3030
verification_session_url: zod.string().url().optional(),
3131
ui_extension_handle: zod.string().optional(),
32+
supports_moto: zod.boolean({
33+
required_error: 'supports_moto is required',
34+
invalid_type_error: 'Value must be Boolean',
35+
}),
3236
encryption_certificate_fingerprint: zod
3337
.string()
3438
.min(1, {message: "Encryption certificate fingerprint can't be blank"}),
@@ -72,6 +76,7 @@ export interface CreditCardPaymentsAppExtensionDeployConfigType extends BasePaym
7276
supports_3ds: boolean
7377

7478
// CreditCard-specific fields
79+
supports_moto: boolean
7580
start_verification_session_url?: string
7681
ui_extension_registration_uuid?: string
7782
ui_extension_handle?: string
@@ -106,6 +111,7 @@ export function creditCardDeployConfigToCLIConfig(
106111
supported_buyer_contexts: config.supported_buyer_contexts,
107112
test_mode_available: config.test_mode_available,
108113
supports_3ds: config.supports_3ds,
114+
supports_moto: config.supports_moto,
109115
supports_deferred_payments: config.supports_deferred_payments,
110116
supports_installments: config.supports_installments,
111117
verification_session_url: config.start_verification_session_url,
@@ -132,6 +138,7 @@ export async function creditCardPaymentsAppExtensionDeployConfig(
132138
supported_buyer_contexts: config.supported_buyer_contexts,
133139
test_mode_available: config.test_mode_available,
134140
supports_3ds: config.supports_3ds,
141+
supports_moto: config.supports_moto,
135142
supports_deferred_payments: config.supports_deferred_payments,
136143
encryption_certificate_fingerprint: config.encryption_certificate_fingerprint,
137144
supports_installments: config.supports_installments,

0 commit comments

Comments
 (0)