-
Notifications
You must be signed in to change notification settings - Fork 103
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
payment apps: add support for supported buyer contexts #3875
Conversation
50a4dd7
to
ffb0902
Compare
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success1655 tests passing in 767 suites. Report generated by 🧪jest coverage report action from 894b551 |
c6404ab
to
216f81a
Compare
216f81a
to
c597bc1
Compare
We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset. |
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.
LGTM overall !
It would be great to also spin 🌀 test the pnpm shopify app import-extensions
flow ensuring that we are also importing extensions appropriately.
You could also include some tests here: packages/app/src/cli/services/payments/extension-to-toml.test.ts
@punkstar something to also keep in mind is that the minimum required CLI version for payments app extension support is |
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.
little context on CLI, but it does seem to make sense overall 👍
@@ -12,6 +12,7 @@ export interface BasePaymentsAppExtensionDeployConfigType { | |||
merchant_label: string | |||
supported_countries: string[] | |||
supported_payment_methods: string[] | |||
supported_buyer_contexts?: {currency: string; countries?: [string, ...string[]]}[] |
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.
Am I understanding correctly that this type definition enforces the non-empty condition? (countries?: [string, ...string[]]
versus a simpler string[]
)
If so, do we also need the nonempty()
check at line 70? I guess it doesn't hurt either 🤷
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.
If we want to make supported_buyer_contexts
required at some point later, are we able to do so or is making it nullable today forcing lifetime support of a nullable 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.
Am I understanding correctly that this type definition enforces the non-empty condition? (
countries?: [string, ...string[]]
versus a simplerstring[]
)
Correct!
If so, do we also need the
nonempty()
check at line 70? I guess it doesn't hurt either 🤷
We need both. SupportedBuyerContextsSchema
is the schema definition that will validate and parse input (by calling #parse
on it). BasePaymentsAppExtensionDeployConfigType
is just the type definition and the output of the schema. We can compute one from the type from the schema (type SchemaType = zod.infer<typeof Schema>
) but there must be a reason we don't!
If we want to make
supported_buyer_contexts
required at some point later, are we able to do so or is making it nullable today forcing lifetime support of a nullable value?
I don't think we have the concept of config schema versions right now, so we'd likely have to introduce a new pattern to support this. It may already be used by other parts of the CLI but we're not making an irreversible decision.
@@ -150,6 +155,7 @@ describe('customCreditCardPaymentsAppExtensionDeployConfig', () => { | |||
supports_3ds: config.supports_3ds, | |||
supported_countries: config.supported_countries, | |||
supported_payment_methods: config.supported_payment_methods, | |||
supported_buyer_contexts: config.supported_buyer_contexts, |
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.
Should we also test the mapping for customCreditCardDeployConfigToCLIConfig
?
Thanks for the feedback @marklevi! I've added some tests around the TOML generation to cover the new field and I've top hatted the import extension command. All looks fine! |
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.
💪
WHY are these changes introduced?
To provide configuration to support future payment app extension features.
WHAT is this pull request doing?
Introduces new configuration for payment app extensions called
supported_buyer_contexts
. These are small objects with acurrency
member and an optionalcountries
array.How to test your changes?
pnpm shopify app generate extension
pnpm shopify app deploy
Test Cases
✅ Backwards Compatibility
supported_buyer_contexts
configuration in the app extension configuration.AppDeploy
payload contains nosupported_buyer_contexts
:✅ Valid Configuration
Configuration:
AppDeploy
payload contains expectedsupported_buyer_contexts
value:✅ Invalid Configuration
Configuration:
✅ Extension Import (where supported buyer contexts exist)
shopify app import-extensions
to import the extension.Command runs successfully:
Configuration is correctly generated:
✅ Extension Import (where supported buyer contexts does not exist)
shopify app import-extensions
to import the extension.extensions.supported_buyer_context
entries.Command runs successfully:
Configuration is correctly generated:
Post-release steps
No post-release action required. Documentation changes will be introduced in the future.
Measuring impact
How do we know this change was effective? Please choose one:
Checklist
dev
ordeploy
have been reflected in the internal flowchart.