-
Notifications
You must be signed in to change notification settings - Fork 143
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
Conversation
Coverage report
Show files with reduced coverage 🔻
Test suite run success1998 tests passing in 903 suites. Report generated by 🧪jest coverage report action from cf2bc94 |
b7ec4c1
to
704c99d
Compare
We detected some changes at packages/*/src and there are no updates in the .changeset. |
@@ -29,6 +29,7 @@ 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(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this is not optional, it will break any existing extension that doesn't have it. Is this an accepted outcome? should it have a default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that the CLI will be used when partners want to update/create extensions. At this point we want them to supply a value. Default value will be used in core when existing extensions are loaded in Core (https://github.com/Shopify/shopify/pull/559538). Are there other scenarios where CLI is used to manage/load extensions that I am missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I say existing extensions, i mean at the moment of updating them via CLI, it will fail until they provide this value.
Simple case:
- You have an automated deploy in CI, if we release this, that deploy will start failing until you provide this value.
Is this the expected behaviour? If it is, then OK; just wanted to confirm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think it's worth it to provide default values similar to what is done in core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we had some team discussion and decided it might be better to fail deploys on releasing this to force the new param instead of offering a default. I added some better error messaging in cf2bc94, and the unit tests I wrote for it work, but I'm having trouble tophatting this.
When I run pnpm shopify app dev
for my extension in spin, I get
╭─ error ──────────────────────────────────────────────────────────────────────╮
│ │
│ App configuration is not valid │
│ Validation errors in ../cli-apps/empowered-marketplace-app/extensions/cred │
│ it-card/shopify.extension.toml: │
│ │
│ • []: Invalid input │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
instead of the error message I defined for either the wrong type or the value being missing altogether.
@isaacroldan is this the right kind of validation to introduce here? Is there a better way to define this? I'm not sure I have enough cli context to understand why this isn't working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think this has something to do with how we're defining/loading the schema for this?
Lines 19 to 28 in cf2bc94
export const CreditCardPaymentsAppExtensionSchema = BasePaymentsAppExtensionSchema.merge(DeferredPaymentsSchema) | |
.merge(ConfirmationSchema) | |
.merge(MultipleCaptureSchema) | |
.merge(SupportedBuyerContextsSchema) | |
.required({ | |
refund_session_url: true, | |
capture_session_url: true, | |
void_session_url: true, | |
}) | |
.extend({ |
I added some debug code to the loader here
parsed.errors.forEach((error) => console.log(error))
output of `pnpm shopify app dev --path=../cli-apps/test`
{
code: 'invalid_union',
unionErrors: [
ZodError: [
{
"received": "payments.credit-card.render",
"code": "invalid_literal",
"expected": "payments.offsite.render",
"path": [
"targeting",
0,
"target"
],
"message": "Invalid literal value, expected \"payments.offsite.render\""
}
]
at file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:56
at Array.map (<anonymous>)
at ZodUnion._parse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:40)
at ZodUnion._parseSync (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:624:29)
at ZodUnion.safeParse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:654:29)
at Object.parseConfigurationObject (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/extensions/specification.js:61:47)
at parseConfigurationObjectAgainstSpecification (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:90:25)
at AppLoader.createExtensionInstance (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:284:31)
at file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:355:33
at Array.map (<anonymous>) {
issues: [Array],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [Array]
},
ZodError: [
{
"received": "payments.credit-card.render",
"code": "invalid_literal",
"expected": "payments.redeemable.render",
"path": [
"targeting",
0,
"target"
],
"message": "Invalid literal value, expected \"payments.redeemable.render\""
},
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"balance_url"
],
"message": "Required"
}
]
at file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:56
at Array.map (<anonymous>)
at ZodUnion._parse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:40)
at ZodUnion._parseSync (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:624:29)
at ZodUnion.safeParse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:654:29)
at Object.parseConfigurationObject (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/extensions/specification.js:61:47)
at parseConfigurationObjectAgainstSpecification (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:90:25)
at AppLoader.createExtensionInstance (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:284:31)
at file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:355:33
at Array.map (<anonymous>) {
issues: [Array],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [Array]
},
ZodError: [
{
"received": "payments.credit-card.render",
"code": "invalid_literal",
"expected": "payments.custom-onsite.render",
"path": [
"targeting",
0,
"target"
],
"message": "Invalid literal value, expected \"payments.custom-onsite.render\""
}
]
at file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:56
at Array.map (<anonymous>)
at ZodUnion._parse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:40)
at ZodUnion._parseSync (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:624:29)
at ZodUnion.safeParse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:654:29)
at Object.parseConfigurationObject (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/extensions/specification.js:61:47)
at parseConfigurationObjectAgainstSpecification (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:90:25)
at AppLoader.createExtensionInstance (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:284:31)
at file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:355:33
at Array.map (<anonymous>) {
issues: [Array],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [Array]
},
ZodError: [
{
"received": "payments.credit-card.render",
"code": "invalid_literal",
"expected": "payments.custom-credit-card.render",
"path": [
"targeting",
0,
"target"
],
"message": "Invalid literal value, expected \"payments.custom-credit-card.render\""
}
]
at file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:56
at Array.map (<anonymous>)
at ZodUnion._parse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:40)
at ZodUnion._parseSync (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:624:29)
at ZodUnion.safeParse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:654:29)
at Object.parseConfigurationObject (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/extensions/specification.js:61:47)
at parseConfigurationObjectAgainstSpecification (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:90:25)
at AppLoader.createExtensionInstance (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:284:31)
at file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:355:33
at Array.map (<anonymous>) {
issues: [Array],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [Array]
},
ZodError: [
{
"code": "invalid_type",
"expected": "boolean",
"received": "string",
"path": [
"supports_moto"
],
"message": "Value must be Boolean"
}
]
at file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:56
at Array.map (<anonymous>)
at ZodUnion._parse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:2589:40)
at ZodUnion._parseSync (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:624:29)
at ZodUnion.safeParse (file:///home/spin/src/github.com/Shopify/cli/node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs:654:29)
at Object.parseConfigurationObject (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/extensions/specification.js:61:47)
at parseConfigurationObjectAgainstSpecification (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:90:25)
at AppLoader.createExtensionInstance (file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:284:31)
at file:///home/spin/src/github.com/Shopify/cli/packages/app/dist/cli/models/app/loader.js:355:33
at Array.map (<anonymous>) {
issues: [Array],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [Array]
}
],
path: [],
message: 'Invalid input'
}
╭─ error ──────────────────────────────────────────────────────────────────────╮
│ │
│ App configuration is not valid │
│ Validation errors in │
│ ../cli-apps/test/extensions/credit-card/shopify.extension.toml: │
│ │
│ • []: Invalid input │
│ │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
I'm not too familiar with Zod, but is what's happening here that it's not managing to resolve it to a credit card payment extension? Which is why the error is there and the specific schema tests pass, but then when we try to do it all together it fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good from my perspective, but I'm not very familiar with the CLI code, it's not impossible that I've missed something.
I suggest you to wait to have another review from someone more familiar with it before shipping.
91cd6e9
to
2269a79
Compare
6b2b548
to
cf2bc94
Compare
WHY are these changes introduced?
Story https://github.com/Shopify/payments-platform/issues/7130
Figma docs
PR 3 of 5
We want to allow payment partners to indicate if they support Mail Order/Telephone Order (MOTO) payment in their credit card payment extension config so as to gate the ability of merchants to manually enter credit card details in draft orders or order edit flows.
WHAT is this pull request doing?
Introduces new configuration for payment app extensions called
supports_moto
which is a boolean value that indicates whether the payment app supports MOTO payments.How to test your changes?
supports_moto
flag to create extensionpartner_certificate_use_cases
model in partners database.Post-release steps
Documentation shipped in https://github.com/Shopify/shopify-dev/pull/51330
Measuring impact
How do we know this change was effective? Please choose one:
Checklist