@salesforce/b2c-cli 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dev.js +8 -8
- package/bin/run.js +5 -7
- package/content/guidance/b2c/b2c-business-manager-extensions/SKILL.md +361 -0
- package/content/guidance/b2c/b2c-business-manager-extensions/references/EXTENSIONS-XML.md +458 -0
- package/content/guidance/b2c/b2c-controllers/SKILL.md +301 -0
- package/content/guidance/b2c/b2c-controllers/references/CLASSIC-PATTERNS.md +335 -0
- package/content/guidance/b2c/b2c-controllers/references/SFRA-PATTERNS.md +400 -0
- package/content/guidance/b2c/b2c-custom-api-development/SKILL.md +281 -0
- package/content/guidance/b2c/b2c-custom-api-development/references/CONTRACT.md +142 -0
- package/content/guidance/b2c/b2c-custom-api-development/references/IMPLEMENTATION.md +153 -0
- package/content/guidance/b2c/b2c-custom-api-development/references/TESTING.md +118 -0
- package/content/guidance/b2c/b2c-custom-caches/SKILL.md +279 -0
- package/content/guidance/b2c/b2c-custom-job-steps/SKILL.md +520 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/CHUNK-ORIENTED.md +377 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/JOBS-XML.md +212 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/STEPTYPES-JSON.md +373 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/TASK-ORIENTED.md +344 -0
- package/content/guidance/b2c/b2c-custom-objects/SKILL.md +327 -0
- package/content/guidance/b2c/b2c-custom-objects/references/OCAPI-SEARCH.md +298 -0
- package/content/guidance/b2c/b2c-forms/SKILL.md +242 -0
- package/content/guidance/b2c/b2c-forms/references/FORM-XML.md +409 -0
- package/content/guidance/b2c/b2c-hooks/SKILL.md +500 -0
- package/content/guidance/b2c/b2c-hooks/references/OCAPI-SCAPI-HOOKS.md +403 -0
- package/content/guidance/b2c/b2c-hooks/references/ORDER-HOOK-LIFECYCLE.md +169 -0
- package/content/guidance/b2c/b2c-hooks/references/SYSTEM-HOOKS.md +433 -0
- package/content/guidance/b2c/b2c-isml/SKILL.md +320 -0
- package/content/guidance/b2c/b2c-isml/references/EXPRESSIONS.md +366 -0
- package/content/guidance/b2c/b2c-isml/references/TAGS.md +443 -0
- package/content/guidance/b2c/b2c-localization/SKILL.md +344 -0
- package/content/guidance/b2c/b2c-localization/references/PATTERNS.md +407 -0
- package/content/guidance/b2c/b2c-logging/SKILL.md +352 -0
- package/content/guidance/b2c/b2c-logging/references/LOG-FILES.md +282 -0
- package/content/guidance/b2c/b2c-metadata/SKILL.md +406 -0
- package/content/guidance/b2c/b2c-metadata/references/SYSTEM-OBJECTS.md +320 -0
- package/content/guidance/b2c/b2c-metadata/references/XML-EXAMPLES.md +366 -0
- package/content/guidance/b2c/b2c-onboarding/SKILL.md +154 -0
- package/content/guidance/b2c/b2c-ordering/SKILL.md +391 -0
- package/content/guidance/b2c/b2c-page-designer/SKILL.md +410 -0
- package/content/guidance/b2c/b2c-page-designer/references/ATTRIBUTE-TYPES.md +436 -0
- package/content/guidance/b2c/b2c-page-designer/references/META-DEFINITIONS.md +340 -0
- package/content/guidance/b2c/b2c-querying-data/SKILL.md +289 -0
- package/content/guidance/b2c/b2c-querying-data/references/PERFORMANCE-APIS.md +74 -0
- package/content/guidance/b2c/b2c-scapi-admin/SKILL.md +53 -0
- package/content/guidance/b2c/b2c-scapi-admin/references/CLIENT-EXAMPLES.md +440 -0
- package/content/guidance/b2c/b2c-scapi-admin/references/INTEGRATION-PATTERNS.md +518 -0
- package/content/guidance/b2c/b2c-scapi-admin/references/OAUTH-SCOPES.md +337 -0
- package/content/guidance/b2c/b2c-scapi-shopper/SKILL.md +56 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/CHECKOUT-FLOW.md +466 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/CLIENT-EXAMPLES.md +351 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/COMMON-PATTERNS.md +390 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/SCOPES.md +290 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/SKILL.md +420 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/references/PASSKEYS.md +126 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/references/SESSION-BRIDGE.md +267 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/references/TOKEN-LIFECYCLE.md +367 -0
- package/content/guidance/b2c/b2c-webservices/SKILL.md +318 -0
- package/content/guidance/b2c/b2c-webservices/references/FTP-SERVICES.md +524 -0
- package/content/guidance/b2c/b2c-webservices/references/HTTP-SERVICES.md +578 -0
- package/content/guidance/b2c/b2c-webservices/references/SERVICES-XML.md +351 -0
- package/content/guidance/b2c/b2c-webservices/references/SOAP-SERVICES.md +587 -0
- package/content/guidance/b2c-cli/b2c-am/SKILL.md +277 -0
- package/content/guidance/b2c-cli/b2c-bm-users-roles/SKILL.md +210 -0
- package/content/guidance/b2c-cli/b2c-cap/SKILL.md +131 -0
- package/content/guidance/b2c-cli/b2c-cip/SKILL.md +116 -0
- package/content/guidance/b2c-cli/b2c-cip/references/KNOWN_TABLES.md +105 -0
- package/content/guidance/b2c-cli/b2c-cip/references/SALES_ANALYSIS.md +50 -0
- package/content/guidance/b2c-cli/b2c-cip/references/STARTER_QUERIES.md +147 -0
- package/content/guidance/b2c-cli/b2c-code/SKILL.md +146 -0
- package/content/guidance/b2c-cli/b2c-config/SKILL.md +462 -0
- package/content/guidance/b2c-cli/b2c-content/SKILL.md +176 -0
- package/content/guidance/b2c-cli/b2c-debug/SKILL.md +138 -0
- package/content/guidance/b2c-cli/b2c-docs/SKILL.md +301 -0
- package/content/guidance/b2c-cli/b2c-ecdn/SKILL.md +135 -0
- package/content/guidance/b2c-cli/b2c-ecdn/references/ADVANCED.md +97 -0
- package/content/guidance/b2c-cli/b2c-ecdn/references/SECURITY.md +75 -0
- package/content/guidance/b2c-cli/b2c-import-set-migrations/SKILL.md +265 -0
- package/content/guidance/b2c-cli/b2c-job/SKILL.md +64 -0
- package/content/guidance/b2c-cli/b2c-job/references/EXPORT.md +121 -0
- package/content/guidance/b2c-cli/b2c-job/references/IMPORT.md +55 -0
- package/content/guidance/b2c-cli/b2c-job/references/RUN-AND-MONITOR.md +119 -0
- package/content/guidance/b2c-cli/b2c-logs/SKILL.md +249 -0
- package/content/guidance/b2c-cli/b2c-metrics/SKILL.md +315 -0
- package/content/guidance/b2c-cli/b2c-mrt/SKILL.md +207 -0
- package/content/guidance/b2c-cli/b2c-mrt/references/BUNDLE-COMMANDS.md +203 -0
- package/content/guidance/b2c-cli/b2c-mrt/references/ENVIRONMENT-COMMANDS.md +218 -0
- package/content/guidance/b2c-cli/b2c-mrt/references/PROJECT-COMMANDS.md +154 -0
- package/content/guidance/b2c-cli/b2c-sandbox/SKILL.md +112 -0
- package/content/guidance/b2c-cli/b2c-scapi-custom/SKILL.md +126 -0
- package/content/guidance/b2c-cli/b2c-scapi-schemas/SKILL.md +66 -0
- package/content/guidance/b2c-cli/b2c-scapi-schemas/references/CLI-EXAMPLES.md +108 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/SKILL.md +57 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/references/IMPORT-OPTIONS.md +118 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/references/METADATA-XML.md +381 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/references/WORKFLOWS.md +182 -0
- package/content/guidance/b2c-cli/b2c-sites/SKILL.md +112 -0
- package/content/guidance/b2c-cli/b2c-slas/SKILL.md +182 -0
- package/content/guidance/b2c-cli/b2c-webdav/SKILL.md +186 -0
- package/content/guidance/b2c-ops/b2c-checkout-triage/SKILL.md +68 -0
- package/content/guidance/b2c-ops/b2c-job-health/SKILL.md +75 -0
- package/content/guidance/b2c-ops/b2c-job-health/references/job-logs.md +21 -0
- package/content/guidance/b2c-ops/b2c-order-failure-triage/SKILL.md +66 -0
- package/content/guidance/b2c-ops/b2c-order-failure-triage/references/order-evidence.md +87 -0
- package/content/guidance/b2c-ops/b2c-production-triage/SKILL.md +87 -0
- package/content/guidance/b2c-ops/b2c-production-triage/references/escalation.md +57 -0
- package/content/guidance/index.json +1949 -0
- package/content/guidance/storefront-next/sfnext-accessibility/SKILL.md +103 -0
- package/content/guidance/storefront-next/sfnext-accessibility/references/checklist.md +64 -0
- package/content/guidance/storefront-next/sfnext-analytics-consent/SKILL.md +91 -0
- package/content/guidance/storefront-next/sfnext-analytics-consent/references/CUSTOM-ADAPTER.md +49 -0
- package/content/guidance/storefront-next/sfnext-authentication/SKILL.md +127 -0
- package/content/guidance/storefront-next/sfnext-authentication/references/COOKIES.md +39 -0
- package/content/guidance/storefront-next/sfnext-authentication/references/LOGIN-FLOWS.md +59 -0
- package/content/guidance/storefront-next/sfnext-commerce-features/SKILL.md +67 -0
- package/content/guidance/storefront-next/sfnext-commerce-features/references/FEATURE-PREREQUISITES.md +37 -0
- package/content/guidance/storefront-next/sfnext-components/SKILL.md +153 -0
- package/content/guidance/storefront-next/sfnext-components/references/COMPONENT-AUTHORING.md +118 -0
- package/content/guidance/storefront-next/sfnext-components/references/SHAPE-TOKENS.md +51 -0
- package/content/guidance/storefront-next/sfnext-components/references/STORYBOOK.md +54 -0
- package/content/guidance/storefront-next/sfnext-components/references/TOKEN-SYSTEM.md +53 -0
- package/content/guidance/storefront-next/sfnext-components/references/TROUBLESHOOTING.md +19 -0
- package/content/guidance/storefront-next/sfnext-configuration/SKILL.md +163 -0
- package/content/guidance/storefront-next/sfnext-configuration/references/ENV-VARIABLES.md +55 -0
- package/content/guidance/storefront-next/sfnext-configuration/references/MULTI-SITE-URLS.md +137 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/SKILL.md +140 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/ACTIONS.md +53 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/API-CLIENTS.md +34 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/LOADERS.md +73 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/SCAPI-FETCHER.md +39 -0
- package/content/guidance/storefront-next/sfnext-deployment/SKILL.md +127 -0
- package/content/guidance/storefront-next/sfnext-deployment/references/MRT-DEPLOYMENT.md +59 -0
- package/content/guidance/storefront-next/sfnext-extensions/SKILL.md +118 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/ACTION-HOOKS.md +57 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/BASE-AUDIT.md +68 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/CLI-AND-INSTALL.md +58 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/EXTENSION-EXAMPLES.md +79 -0
- package/content/guidance/storefront-next/sfnext-hybrid-storefronts/SKILL.md +93 -0
- package/content/guidance/storefront-next/sfnext-hybrid-storefronts/references/HYBRID-PROXY-CONFIG.md +86 -0
- package/content/guidance/storefront-next/sfnext-i18n/SKILL.md +152 -0
- package/content/guidance/storefront-next/sfnext-i18n/references/locale-config.md +35 -0
- package/content/guidance/storefront-next/sfnext-overview/SKILL.md +101 -0
- package/content/guidance/storefront-next/sfnext-page-designer/SKILL.md +202 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/BUSINESS-MANAGER.md +46 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/COMPONENT-REGISTRY.md +111 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/DECORATOR-PATTERNS.md +168 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/REVIEW-CHECKLIST.md +83 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/TROUBLESHOOTING.md +35 -0
- package/content/guidance/storefront-next/sfnext-performance/SKILL.md +102 -0
- package/content/guidance/storefront-next/sfnext-performance/references/PERFORMANCE-REVIEW-CHECKLIST.md +85 -0
- package/content/guidance/storefront-next/sfnext-performance/references/SUSPENSE-AND-STREAMING.md +58 -0
- package/content/guidance/storefront-next/sfnext-project-setup/SKILL.md +147 -0
- package/content/guidance/storefront-next/sfnext-project-setup/references/PROJECT-STRUCTURE.md +61 -0
- package/content/guidance/storefront-next/sfnext-project-setup/references/SCRIPTS.md +47 -0
- package/content/guidance/storefront-next/sfnext-project-setup/references/SFNEXT-CLI.md +63 -0
- package/content/guidance/storefront-next/sfnext-quality-gates/SKILL.md +70 -0
- package/content/guidance/storefront-next/sfnext-quality-gates/references/lint-and-budgets.md +39 -0
- package/content/guidance/storefront-next/sfnext-revalidation/SKILL.md +121 -0
- package/content/guidance/storefront-next/sfnext-revalidation/references/POLICIES-AND-TAGS.md +55 -0
- package/content/guidance/storefront-next/sfnext-routing/SKILL.md +123 -0
- package/content/guidance/storefront-next/sfnext-routing/references/ROUTE-CONVENTIONS.md +65 -0
- package/content/guidance/storefront-next/sfnext-routing/references/URLS-AND-SEO-ROUTES.md +22 -0
- package/content/guidance/storefront-next/sfnext-scapi/SKILL.md +126 -0
- package/content/guidance/storefront-next/sfnext-scapi/references/WORKED-EXAMPLE.md +39 -0
- package/content/guidance/storefront-next/sfnext-security/SKILL.md +129 -0
- package/content/guidance/storefront-next/sfnext-security/references/COOKIE-DOMAIN.md +39 -0
- package/content/guidance/storefront-next/sfnext-security/references/TURNSTILE.md +43 -0
- package/content/guidance/storefront-next/sfnext-seo/SKILL.md +95 -0
- package/content/guidance/storefront-next/sfnext-seo/references/MULTI-DOMAIN-BASE-PATH.md +17 -0
- package/content/guidance/storefront-next/sfnext-seo/references/SEO-ROUTES.md +31 -0
- package/content/guidance/storefront-next/sfnext-state-management/SKILL.md +114 -0
- package/content/guidance/storefront-next/sfnext-state-management/references/PATTERNS.md +45 -0
- package/content/guidance/storefront-next/sfnext-testing/SKILL.md +151 -0
- package/content/guidance/storefront-next/sfnext-testing/references/E2E.md +38 -0
- package/content/guidance/storefront-next/sfnext-testing/references/STORYBOOK-PATTERNS.md +97 -0
- package/content/guidance/storefront-next/sfnext-testing/references/UNIT-AND-ROUTE-TESTS.md +60 -0
- package/content/guidance/storefront-next/sfnext-theming/SKILL.md +104 -0
- package/content/guidance/storefront-next/sfnext-theming/references/REBRAND-CHECKLIST.md +29 -0
- package/dist/commands/cap/install.d.ts +1 -0
- package/dist/commands/cap/list.d.ts +1 -0
- package/dist/commands/cap/pull.d.ts +1 -0
- package/dist/commands/cap/tasks.d.ts +1 -0
- package/dist/commands/cap/uninstall.d.ts +1 -0
- package/dist/commands/cip/describe.d.ts +1 -0
- package/dist/commands/cip/query.d.ts +1 -0
- package/dist/commands/cip/report/bot-traffic-share.d.ts +1 -0
- package/dist/commands/cip/report/checkout-funnel-dropoff.d.ts +1 -0
- package/dist/commands/cip/report/controller-error-rate-trend.d.ts +1 -0
- package/dist/commands/cip/report/controller-health-scorecard.d.ts +1 -0
- package/dist/commands/cip/report/customer-registration-trends.d.ts +1 -0
- package/dist/commands/cip/report/discount-depth-breakdown.d.ts +1 -0
- package/dist/commands/cip/report/inventory-stockout-by-location.d.ts +1 -0
- package/dist/commands/cip/report/new-vs-returning-buyer-revenue.d.ts +1 -0
- package/dist/commands/cip/report/ocapi-client-usage.d.ts +1 -0
- package/dist/commands/cip/report/ocapi-requests.d.ts +1 -0
- package/dist/commands/cip/report/payment-method-performance.d.ts +1 -0
- package/dist/commands/cip/report/product-co-purchase-analysis.d.ts +1 -0
- package/dist/commands/cip/report/promotion-discount-analysis.d.ts +1 -0
- package/dist/commands/cip/report/promotion-roi-leaderboard.d.ts +1 -0
- package/dist/commands/cip/report/recommender-effectiveness.d.ts +1 -0
- package/dist/commands/cip/report/remote-include-performance.d.ts +1 -0
- package/dist/commands/cip/report/revenue-by-channel.d.ts +1 -0
- package/dist/commands/cip/report/sales-analytics.d.ts +1 -0
- package/dist/commands/cip/report/sales-summary.d.ts +1 -0
- package/dist/commands/cip/report/scapi-cache-hit-ratio.d.ts +1 -0
- package/dist/commands/cip/report/scapi-error-rate-by-status.d.ts +1 -0
- package/dist/commands/cip/report/scapi-latency-distribution.d.ts +1 -0
- package/dist/commands/cip/report/scapi-traffic-latency.d.ts +1 -0
- package/dist/commands/cip/report/search-query-performance.d.ts +1 -0
- package/dist/commands/cip/report/top-referrers.d.ts +1 -0
- package/dist/commands/cip/report/top-selling-products.d.ts +1 -0
- package/dist/commands/cip/report/zero-result-searches.d.ts +1 -0
- package/dist/commands/cip/tables.d.ts +1 -0
- package/dist/commands/code/activate.d.ts +1 -0
- package/dist/commands/code/delete.d.ts +1 -0
- package/dist/commands/code/deploy.d.ts +1 -0
- package/dist/commands/code/download.d.ts +1 -0
- package/dist/commands/code/watch.d.ts +1 -0
- package/dist/commands/commands/search.d.ts +35 -0
- package/dist/commands/commands/search.js +85 -0
- package/dist/commands/commands/search.js.map +1 -0
- package/dist/commands/content/export.d.ts +1 -0
- package/dist/commands/content/list.d.ts +1 -0
- package/dist/commands/content/validate.d.ts +1 -0
- package/dist/commands/debug/cli.d.ts +1 -0
- package/dist/commands/debug/index.d.ts +1 -0
- package/dist/commands/docs/cache.d.ts +1 -0
- package/dist/commands/docs/download.d.ts +1 -0
- package/dist/commands/docs/read.d.ts +1 -0
- package/dist/commands/docs/schema.d.ts +1 -0
- package/dist/commands/docs/search.d.ts +1 -0
- package/dist/commands/docs/skill.d.ts +41 -0
- package/dist/commands/docs/skill.js +183 -0
- package/dist/commands/docs/skill.js.map +1 -0
- package/dist/commands/ecdn/cache/purge.d.ts +1 -0
- package/dist/commands/ecdn/certificates/add.d.ts +1 -0
- package/dist/commands/ecdn/certificates/delete.d.ts +1 -0
- package/dist/commands/ecdn/certificates/list.d.ts +1 -0
- package/dist/commands/ecdn/certificates/update.d.ts +1 -0
- package/dist/commands/ecdn/certificates/validate.d.ts +1 -0
- package/dist/commands/ecdn/cipher-suites/get.d.ts +1 -0
- package/dist/commands/ecdn/cipher-suites/update.d.ts +1 -0
- package/dist/commands/ecdn/firewall/create.d.ts +1 -0
- package/dist/commands/ecdn/firewall/delete.d.ts +1 -0
- package/dist/commands/ecdn/firewall/get.d.ts +1 -0
- package/dist/commands/ecdn/firewall/list.d.ts +1 -0
- package/dist/commands/ecdn/firewall/reorder.d.ts +1 -0
- package/dist/commands/ecdn/firewall/update.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/create.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/delete.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/get.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/list.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/update.d.ts +1 -0
- package/dist/commands/ecdn/logpush/ownership.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/create.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/delete.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/get.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/rules/delete.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/rules/update.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/update.d.ts +1 -0
- package/dist/commands/ecdn/mtls/create.d.ts +1 -0
- package/dist/commands/ecdn/mtls/delete.d.ts +1 -0
- package/dist/commands/ecdn/mtls/get.d.ts +1 -0
- package/dist/commands/ecdn/mtls/issue.d.ts +1 -0
- package/dist/commands/ecdn/mtls/list.d.ts +1 -0
- package/dist/commands/ecdn/mtls/setup.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/delete.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/get.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/set.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/create.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/delete.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/list.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/create.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/delete.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/get.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/list.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/update.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/scripts/get.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/scripts/list.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/create.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/delete.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/get.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/list.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/update.d.ts +1 -0
- package/dist/commands/ecdn/security/get.d.ts +1 -0
- package/dist/commands/ecdn/security/update.d.ts +1 -0
- package/dist/commands/ecdn/speed/get.d.ts +1 -0
- package/dist/commands/ecdn/speed/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/groups/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/groups/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/managed-rules/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/managed-rules/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/migrate.d.ts +1 -0
- package/dist/commands/ecdn/waf/owasp/get.d.ts +1 -0
- package/dist/commands/ecdn/waf/owasp/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/get.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/rulesets/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/rulesets/update.d.ts +1 -0
- package/dist/commands/ecdn/zones/create.d.ts +1 -0
- package/dist/commands/ecdn/zones/list.d.ts +1 -0
- package/dist/commands/job/execution/delete.d.ts +1 -0
- package/dist/commands/job/export.d.ts +1 -0
- package/dist/commands/job/import-set.d.ts +1 -0
- package/dist/commands/job/import.d.ts +1 -0
- package/dist/commands/job/log.d.ts +1 -0
- package/dist/commands/job/run.d.ts +1 -0
- package/dist/commands/job/search.d.ts +1 -0
- package/dist/commands/job/wait.d.ts +1 -0
- package/dist/commands/logs/get.d.ts +1 -0
- package/dist/commands/logs/list.d.ts +1 -0
- package/dist/commands/logs/tail.d.ts +1 -0
- package/dist/commands/metrics/controller.d.ts +1 -0
- package/dist/commands/metrics/ecdn.d.ts +1 -0
- package/dist/commands/metrics/mrt.d.ts +1 -0
- package/dist/commands/metrics/ocapi.d.ts +1 -0
- package/dist/commands/metrics/overall.d.ts +1 -0
- package/dist/commands/metrics/sales.d.ts +1 -0
- package/dist/commands/metrics/scapi-hooks.d.ts +1 -0
- package/dist/commands/metrics/scapi.d.ts +1 -0
- package/dist/commands/metrics/third-party.d.ts +1 -0
- package/dist/commands/mrt/bundle/delete.d.ts +1 -0
- package/dist/commands/mrt/bundle/deploy.d.ts +1 -0
- package/dist/commands/mrt/bundle/download.d.ts +1 -0
- package/dist/commands/mrt/bundle/history.d.ts +1 -0
- package/dist/commands/mrt/bundle/list.d.ts +1 -0
- package/dist/commands/mrt/bundle/save.d.ts +1 -0
- package/dist/commands/mrt/bundle/upload-v2.d.ts +1 -0
- package/dist/commands/mrt/env/access-control/list.d.ts +1 -0
- package/dist/commands/mrt/env/b2c.d.ts +1 -0
- package/dist/commands/mrt/env/clone.d.ts +1 -0
- package/dist/commands/mrt/env/create.d.ts +1 -0
- package/dist/commands/mrt/env/delete.d.ts +1 -0
- package/dist/commands/mrt/env/get.d.ts +1 -0
- package/dist/commands/mrt/env/invalidate.d.ts +1 -0
- package/dist/commands/mrt/env/list.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/clone.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/create.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/delete.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/list.d.ts +1 -0
- package/dist/commands/mrt/env/update.d.ts +1 -0
- package/dist/commands/mrt/env/var/delete.d.ts +1 -0
- package/dist/commands/mrt/env/var/list.d.ts +1 -0
- package/dist/commands/mrt/env/var/push.d.ts +1 -0
- package/dist/commands/mrt/env/var/set.d.ts +1 -0
- package/dist/commands/mrt/org/b2c.d.ts +1 -0
- package/dist/commands/mrt/org/cert/create.d.ts +1 -0
- package/dist/commands/mrt/org/cert/delete.d.ts +1 -0
- package/dist/commands/mrt/org/cert/get.d.ts +1 -0
- package/dist/commands/mrt/org/cert/list.d.ts +1 -0
- package/dist/commands/mrt/org/cert/restart-validation.d.ts +1 -0
- package/dist/commands/mrt/org/list.d.ts +1 -0
- package/dist/commands/mrt/org/member/add.d.ts +1 -0
- package/dist/commands/mrt/org/member/get.d.ts +1 -0
- package/dist/commands/mrt/org/member/list.d.ts +1 -0
- package/dist/commands/mrt/org/member/remove.d.ts +1 -0
- package/dist/commands/mrt/org/member/update.d.ts +1 -0
- package/dist/commands/mrt/project/create.d.ts +1 -0
- package/dist/commands/mrt/project/delete.d.ts +1 -0
- package/dist/commands/mrt/project/get.d.ts +1 -0
- package/dist/commands/mrt/project/list.d.ts +1 -0
- package/dist/commands/mrt/project/member/add.d.ts +1 -0
- package/dist/commands/mrt/project/member/get.d.ts +1 -0
- package/dist/commands/mrt/project/member/list.d.ts +1 -0
- package/dist/commands/mrt/project/member/remove.d.ts +1 -0
- package/dist/commands/mrt/project/member/update.d.ts +1 -0
- package/dist/commands/mrt/project/notification/delete.d.ts +1 -0
- package/dist/commands/mrt/project/notification/get.d.ts +1 -0
- package/dist/commands/mrt/project/update.d.ts +1 -0
- package/dist/commands/mrt/save-credentials.d.ts +1 -0
- package/dist/commands/mrt/tail-logs.d.ts +1 -0
- package/dist/commands/mrt/user/api-key.d.ts +1 -0
- package/dist/commands/mrt/user/email-prefs.d.ts +1 -0
- package/dist/commands/mrt/user/profile.d.ts +1 -0
- package/dist/commands/scaffold/init.js +2 -1
- package/dist/commands/scaffold/init.js.map +1 -1
- package/dist/commands/scapi/custom/status.d.ts +1 -0
- package/dist/commands/scapi/schemas/get.d.ts +1 -0
- package/dist/commands/scapi/schemas/list.d.ts +1 -0
- package/dist/commands/setup/ide/tsserver-plugin.d.ts +1 -0
- package/dist/commands/setup/ide/vscode-types.d.ts +1 -0
- package/dist/commands/setup/index.js +4 -3
- package/dist/commands/setup/index.js.map +1 -1
- package/dist/commands/setup/inspect.d.ts +1 -0
- package/dist/commands/setup/inspect.js +17 -2
- package/dist/commands/setup/inspect.js.map +1 -1
- package/dist/commands/setup/instance/create.d.ts +1 -0
- package/dist/commands/setup/instance/list.d.ts +1 -0
- package/dist/commands/setup/instance/remove.d.ts +1 -0
- package/dist/commands/setup/instance/set-active.d.ts +1 -0
- package/dist/commands/setup/openshell.d.ts +1 -0
- package/dist/commands/setup/skills.d.ts +1 -0
- package/dist/commands/slas/client/create.d.ts +1 -0
- package/dist/commands/slas/client/delete.d.ts +1 -0
- package/dist/commands/slas/client/get.d.ts +1 -0
- package/dist/commands/slas/client/list.d.ts +1 -0
- package/dist/commands/slas/client/open.d.ts +1 -0
- package/dist/commands/slas/client/update.d.ts +1 -0
- package/dist/commands/slas/token.d.ts +1 -0
- package/dist/commands/slas/token.js +2 -1
- package/dist/commands/slas/token.js.map +1 -1
- package/dist/commands/webdav/get.d.ts +1 -0
- package/dist/commands/webdav/rm.d.ts +1 -0
- package/dist/help.d.ts +25 -0
- package/dist/help.js +96 -0
- package/dist/help.js.map +1 -0
- package/dist/lib/scaffold/generate-helper.js +3 -2
- package/dist/lib/scaffold/generate-helper.js.map +1 -1
- package/dist/lib/skills.d.ts +19 -0
- package/dist/lib/skills.js +75 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/utils/cip/command.d.ts +1 -0
- package/dist/utils/ecdn/zone-command.d.ts +1 -0
- package/dist/utils/slas/client.d.ts +1 -0
- package/oclif.manifest.json +21814 -18473
- package/package.json +11 -5
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: b2c-hooks
|
|
3
|
+
description: >-
|
|
4
|
+
Register and implement B2C Commerce platform hooks declared in hooks.json and invoked by HookMgr during OCAPI/SCAPI requests or system events. Use for hooks.json, HookMgr.callHook(), dw.system.Status, dw.ocapi.shop.* before/after/modifyResponse hooks, dw.order.payment.authorize/authorizeCreditCard, dw.order.calculate, app.payment.processor.*, SCAPI order-payment authorization and placement, rollback semantics, and request.custom transport. Do not use for external Node.js webhooks, SFRA controller middleware or prepend/append chains, scheduled job steps in steptypes.json, or Git/CI hooks.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# B2C Commerce Hooks
|
|
8
|
+
|
|
9
|
+
Hooks are extension points that allow you to customize business logic by registering scripts. B2C Commerce supports two types of hooks:
|
|
10
|
+
|
|
11
|
+
1. **OCAPI/SCAPI Hooks** - Extend API resources with before, after, and modifyResponse hooks
|
|
12
|
+
2. **System Hooks** - Custom extension points for order calculation, payment, and other core functionality
|
|
13
|
+
|
|
14
|
+
## Hook Types Overview
|
|
15
|
+
|
|
16
|
+
| Type | Purpose | Examples |
|
|
17
|
+
|------|---------|----------|
|
|
18
|
+
| OCAPI/SCAPI | Extend API behavior | `dw.ocapi.shop.basket.afterPOST` |
|
|
19
|
+
| System | Core business logic | `dw.order.calculate` |
|
|
20
|
+
| Custom | Your own extension points | `app.checkout.validate` |
|
|
21
|
+
|
|
22
|
+
## Hook Registration
|
|
23
|
+
|
|
24
|
+
### File Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
my_cartridge/
|
|
28
|
+
├── package.json # References hooks.json
|
|
29
|
+
└── cartridge/
|
|
30
|
+
└── scripts/
|
|
31
|
+
├── hooks.json # Hook registrations
|
|
32
|
+
└── hooks/ # Hook implementations
|
|
33
|
+
├── basket.js
|
|
34
|
+
└── order.js
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### package.json
|
|
38
|
+
|
|
39
|
+
Reference the hooks configuration file:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"name": "my_cartridge",
|
|
44
|
+
"hooks": "./cartridge/scripts/hooks.json"
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### hooks.json
|
|
49
|
+
|
|
50
|
+
Register hooks with their implementing scripts:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"hooks": [
|
|
55
|
+
{
|
|
56
|
+
"name": "dw.ocapi.shop.basket.afterPOST",
|
|
57
|
+
"script": "./hooks/basket.js"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "dw.ocapi.shop.basket.modifyPOSTResponse",
|
|
61
|
+
"script": "./hooks/basket.js"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "dw.order.calculate",
|
|
65
|
+
"script": "./hooks/order.js"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Hook Script
|
|
72
|
+
|
|
73
|
+
Export functions matching the hook method name (without package prefix):
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
// hooks/basket.js
|
|
77
|
+
var Status = require('dw/system/Status');
|
|
78
|
+
|
|
79
|
+
exports.afterPOST = function(basket) {
|
|
80
|
+
// Called after basket creation
|
|
81
|
+
// Returning a value would skip system implementation
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.modifyPOSTResponse = function(basket, basketResponse) {
|
|
85
|
+
// Modify the API response
|
|
86
|
+
basketResponse.c_customField = 'value';
|
|
87
|
+
};
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## HookMgr API
|
|
91
|
+
|
|
92
|
+
Use `dw.system.HookMgr` to call hooks programmatically:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
var HookMgr = require('dw/system/HookMgr');
|
|
96
|
+
|
|
97
|
+
// Check if hook exists
|
|
98
|
+
if (HookMgr.hasHook('dw.order.calculate')) {
|
|
99
|
+
// Call the hook
|
|
100
|
+
var result = HookMgr.callHook('dw.order.calculate', 'calculate', basket);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Method | Description |
|
|
105
|
+
|--------|-------------|
|
|
106
|
+
| `hasHook(extensionPoint)` | Returns true if hook is registered or has default implementation |
|
|
107
|
+
| `callHook(extensionPoint, functionName, args...)` | Calls the hook, returns result or undefined |
|
|
108
|
+
|
|
109
|
+
## Status Object
|
|
110
|
+
|
|
111
|
+
Hooks return `dw.system.Status` to indicate success or failure:
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
var Status = require('dw/system/Status');
|
|
115
|
+
|
|
116
|
+
// Success - continue processing
|
|
117
|
+
return new Status(Status.OK);
|
|
118
|
+
|
|
119
|
+
// Error - stop processing, rollback transaction
|
|
120
|
+
var status = new Status(Status.ERROR);
|
|
121
|
+
status.addDetail('error_code', 'INVALID_ADDRESS');
|
|
122
|
+
status.addDetail('message', 'Address validation failed');
|
|
123
|
+
return status;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Status | HTTP Response | Behavior |
|
|
127
|
+
|--------|---------------|----------|
|
|
128
|
+
| `Status.OK` | Continues | Hook execution continues |
|
|
129
|
+
| `Status.ERROR` | 400 Bad Request | Transaction rolled back, processing stops |
|
|
130
|
+
| Uncaught exception | 500 Internal Error | Transaction rolled back |
|
|
131
|
+
|
|
132
|
+
## Return Value Behavior (Important)
|
|
133
|
+
|
|
134
|
+
**OCAPI/SCAPI hooks that return ANY value will SKIP the system implementation and all subsequent registered hooks for that extension point.**
|
|
135
|
+
|
|
136
|
+
This is a common source of bugs. For example, if a hook returns `Status.OK`, the system's `dw.order.calculate` implementation won't run, causing cart totals to be incorrect.
|
|
137
|
+
|
|
138
|
+
### When to Return a Value
|
|
139
|
+
|
|
140
|
+
Return a `Status` object **only** when you want to:
|
|
141
|
+
- **Stop processing** with an error (`Status.ERROR`)
|
|
142
|
+
- **Skip the system implementation** intentionally
|
|
143
|
+
|
|
144
|
+
### When NOT to Return a Value
|
|
145
|
+
|
|
146
|
+
To ensure system implementations run (like cart calculation), **return nothing**:
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
// Returning Status.OK skips system implementation
|
|
150
|
+
exports.afterPOST = function(basket) {
|
|
151
|
+
doSomething(basket);
|
|
152
|
+
return new Status(Status.OK); // Skips dw.order.calculate
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// No return value - system implementation runs
|
|
156
|
+
exports.afterPOST = function(basket) {
|
|
157
|
+
doSomething(basket);
|
|
158
|
+
// No return, or explicit: return;
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Summary
|
|
163
|
+
|
|
164
|
+
| Return Value | OCAPI/SCAPI Behavior | Custom Hook Behavior |
|
|
165
|
+
|-------------|---------------------|---------------------|
|
|
166
|
+
| `undefined` (no return) | System implementation runs, subsequent hooks run | All hooks run |
|
|
167
|
+
| `Status.OK` | **Skips** system implementation and subsequent hooks | All hooks run |
|
|
168
|
+
| `Status.ERROR` | Stops processing, returns error | All hooks run |
|
|
169
|
+
|
|
170
|
+
**Debugging tip**: If cart totals are wrong or hooks aren't firing, check if an earlier hook is returning a value.
|
|
171
|
+
|
|
172
|
+
## OCAPI/SCAPI Hooks
|
|
173
|
+
|
|
174
|
+
OCAPI and SCAPI share the same hooks. Enable in Business Manager:
|
|
175
|
+
**Administration > Global Preferences > Feature Switches > Enable Salesforce Commerce Cloud API hook execution**
|
|
176
|
+
|
|
177
|
+
### Hook Types
|
|
178
|
+
|
|
179
|
+
| Hook | When Called | Use Case |
|
|
180
|
+
|------|-------------|----------|
|
|
181
|
+
| `before<METHOD>` | Before processing | Validation, access control |
|
|
182
|
+
| `after<METHOD>` | After processing (in transaction) | Data modification, external calls |
|
|
183
|
+
| `modify<METHOD>Response` | Before response sent | Add/modify response properties |
|
|
184
|
+
|
|
185
|
+
### Common Hook Patterns
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
// Validation in beforePUT
|
|
189
|
+
exports.beforePUT = function(basket, addressDoc) {
|
|
190
|
+
if (!isValidAddress(addressDoc)) {
|
|
191
|
+
var status = new Status(Status.ERROR);
|
|
192
|
+
status.addDetail('validation_error', 'Invalid address');
|
|
193
|
+
return status;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// External call in afterPOST (within transaction)
|
|
198
|
+
exports.afterPOST = function(basket, paymentDoc) {
|
|
199
|
+
var result = callPaymentService(paymentDoc);
|
|
200
|
+
request.custom.paymentResult = result; // Pass to modifyResponse
|
|
201
|
+
// Returning a Status would skip system implementation
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// Modify response
|
|
205
|
+
exports.modifyPOSTResponse = function(basket, basketResponse, paymentDoc) {
|
|
206
|
+
basketResponse.c_paymentStatus = request.custom.paymentResult.status;
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Passing Data Between Hooks
|
|
211
|
+
|
|
212
|
+
Use `request.custom` to pass data between hooks in the same request:
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
// In afterPOST
|
|
216
|
+
exports.afterPOST = function(basket, doc) {
|
|
217
|
+
request.custom.externalId = callExternalService();
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// In modifyPOSTResponse
|
|
221
|
+
exports.modifyPOSTResponse = function(basket, response, doc) {
|
|
222
|
+
response.c_externalId = request.custom.externalId;
|
|
223
|
+
};
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Detect SCAPI vs OCAPI
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
exports.afterPOST = function(basket) {
|
|
230
|
+
if (request.isSCAPI()) {
|
|
231
|
+
// SCAPI-specific logic
|
|
232
|
+
} else {
|
|
233
|
+
// OCAPI-specific logic
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Headless Order Payment: Use the Order-PI Authorization Seam
|
|
239
|
+
|
|
240
|
+
Lead with the documented Shopper Orders lifecycle. Do not authorize payment in
|
|
241
|
+
`dw.ocapi.shop.order.afterPOST` by default:
|
|
242
|
+
|
|
243
|
+
```text
|
|
244
|
+
POST /orders
|
|
245
|
+
-> order persists in CREATED
|
|
246
|
+
PATCH /orders/{orderNo}/payment-instruments/{paymentInstrumentId}
|
|
247
|
+
-> platform updates the order PI
|
|
248
|
+
-> dw.order.payment.authorizeCreditCard or dw.order.payment.authorize
|
|
249
|
+
-> order.payment_instrument.afterPATCH(..., successfullyAuthorized)
|
|
250
|
+
-> default afterPATCH places the order when authorized coverage >= order total
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
This separates order creation from the gateway call, preserves a durable order number for recovery,
|
|
254
|
+
uses the same authorization extension points as the standard Commerce implementation and payment
|
|
255
|
+
extensions, and lets the platform own final coverage-based placement.
|
|
256
|
+
|
|
257
|
+
### Authorization Semantics
|
|
258
|
+
|
|
259
|
+
The order-PI `PATCH` chooses the payment hook as follows:
|
|
260
|
+
|
|
261
|
+
- Require the selected payment method to be active and applicable to the order. For
|
|
262
|
+
`CREDIT_CARD`, include `paymentCard` in the request.
|
|
263
|
+
- Call `dw.order.payment.authorizeCreditCard` when the request includes `paymentCard` or the order PI
|
|
264
|
+
contains a credit-card type.
|
|
265
|
+
- Otherwise call `dw.order.payment.authorize`.
|
|
266
|
+
- For a saved payment method, pass the documented customer payment-instrument ID (called
|
|
267
|
+
`customer_payment_instrument_id` in the OCAPI documentation; generated SCAPI clients can expose a
|
|
268
|
+
camel-case property). Commerce resolves it from the order customer's payment instruments and
|
|
269
|
+
copies that PI for authorization; an unknown ID throws. Amount and card security code from the
|
|
270
|
+
request are still propagated to `authorizeCreditCard`.
|
|
271
|
+
- Without a customer PI reference, the authorization input is populated from request data such as
|
|
272
|
+
`paymentCard` or bank-account information. Do not assume the `paymentDetails` argument is the same
|
|
273
|
+
object instance as the persistent PI already attached to `order`; resolve and validate the
|
|
274
|
+
persistent instrument when provider state was stored there.
|
|
275
|
+
- Do not accept a client-supplied reusable payment token as an ownership substitute.
|
|
276
|
+
- Set the payment transaction's processor, amount, type, and provider transaction identifiers in the
|
|
277
|
+
authorization implementation. Return `Status.OK` only for a successful authorization and
|
|
278
|
+
`Status.ERROR` otherwise.
|
|
279
|
+
|
|
280
|
+
Register `dw.order.payment.authorizeCreditCard`, `dw.order.payment.authorize`, and the order-PI
|
|
281
|
+
`beforePATCH`/`afterPATCH` hooks. In `beforePATCH`, validate the untrusted request against persistent
|
|
282
|
+
order state before any gateway call: PI count, method, applicable processor, server-owned tender
|
|
283
|
+
allocation, amount, ownership/token provenance, and integration state. A single-PI checkout can
|
|
284
|
+
require the requested amount to equal the order total; validate each server-owned allocation for
|
|
285
|
+
split tender.
|
|
286
|
+
|
|
287
|
+
Use all four documented `afterPATCH` parameters. The platform reduces the payment authorization
|
|
288
|
+
`Status` to `successfullyAuthorized`; preserve a richer processor outcome in `request.custom` only
|
|
289
|
+
when the distinction is needed within this same request:
|
|
290
|
+
|
|
291
|
+
```javascript
|
|
292
|
+
var Status = require('dw/system/Status');
|
|
293
|
+
|
|
294
|
+
exports.afterPATCH = function (order, paymentInstrument, newPaymentInstrument, successfullyAuthorized) {
|
|
295
|
+
if (!successfullyAuthorized) {
|
|
296
|
+
if (request.custom.deterministicPaymentDecline === true) {
|
|
297
|
+
return new Status(Status.ERROR, 'PAYMENT_DECLINED');
|
|
298
|
+
}
|
|
299
|
+
return; // Preserve indeterminate/review state for reconciliation.
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
var validation = validateAuthorizedInstrument(order, paymentInstrument);
|
|
303
|
+
if (validation) { return validation; }
|
|
304
|
+
// Return undefined so the default placement implementation still runs.
|
|
305
|
+
};
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
`successfullyAuthorized === true` applies to the payment instrument just processed; it does not by
|
|
309
|
+
itself prove that a multi-instrument order is fully covered. Let the default implementation place the
|
|
310
|
+
still-`CREATED` order only when authorized payment coverage equals or exceeds the order total. The
|
|
311
|
+
result changes the order to `NEW` and prepares it for export.
|
|
312
|
+
|
|
313
|
+
### Storefront/BFF Outcome Handling
|
|
314
|
+
|
|
315
|
+
Treat the returned order status as the authoritative placement result:
|
|
316
|
+
|
|
317
|
+
- `NEW`: placement succeeded.
|
|
318
|
+
- `CREATED`: the order was not placed. This can be expected while authorizing multiple instruments,
|
|
319
|
+
or it can represent decline/review/unknown state.
|
|
320
|
+
- Deterministic authorization failure: call Shopper Orders
|
|
321
|
+
`POST /orders/{orderNo}/actions/fail?reopenBasket=true` with reason code
|
|
322
|
+
`payment_auth_failure` so Commerce persists the failed order and restores the basket.
|
|
323
|
+
- Indeterminate gateway result: do not automatically retry or reopen the basket. Preserve the
|
|
324
|
+
`CREATED` order for reconciliation to avoid duplicate authorization.
|
|
325
|
+
|
|
326
|
+
In this recommended flow, use the Shopper Orders fail action for the durable state transition rather
|
|
327
|
+
than coordinating failure across the order POST hooks.
|
|
328
|
+
|
|
329
|
+
### Alternative: Authorize and Place in `order.afterPOST`
|
|
330
|
+
|
|
331
|
+
Use `dw.ocapi.shop.order.afterPOST` when a checkout deliberately needs one server-side phase that
|
|
332
|
+
creates the order, authorizes every PI, and performs the Commerce-side place-or-fail transition in
|
|
333
|
+
the order-creation transaction, or when a processor cannot participate in the order-PI authorization
|
|
334
|
+
endpoints. This keeps the storefront orchestration simple. The external gateway side effect is not
|
|
335
|
+
rolled back with the Commerce transaction, so balance that benefit against these tradeoffs:
|
|
336
|
+
|
|
337
|
+
- The external payment call runs inside order creation's platform transaction and consumes the
|
|
338
|
+
order-POST timeout budget.
|
|
339
|
+
- Returning `Status.ERROR` rolls back order creation, so the caller can lose both the order and the
|
|
340
|
+
original basket reference.
|
|
341
|
+
- The implementation must manually authorize every PI, verify total coverage, call
|
|
342
|
+
`OrderMgr.placeOrder`/`failOrder`, and preserve any later platform or cartridge behavior.
|
|
343
|
+
- Do not add `Transaction.wrap()` around `OrderMgr.placeOrder()` or `OrderMgr.failOrder()` inside
|
|
344
|
+
`afterPOST`; it already runs in a platform transaction.
|
|
345
|
+
|
|
346
|
+
If choosing this option, see
|
|
347
|
+
[Order Hook Lifecycle](references/ORDER-HOOK-LIFECYCLE.md) for transaction semantics and the
|
|
348
|
+
two-hook variant that persists a failed order while returning an HTTP error.
|
|
349
|
+
|
|
350
|
+
### `request.custom` for Inter-Hook Data Passing
|
|
351
|
+
|
|
352
|
+
Use `request.custom` only as request-scoped transport between hook phases. Do not add persistent
|
|
353
|
+
metadata solely to carry a richer outcome from `authorize*` to `afterPATCH` in the same request.
|
|
354
|
+
|
|
355
|
+
## System Hooks
|
|
356
|
+
|
|
357
|
+
### Calculate Hooks
|
|
358
|
+
|
|
359
|
+
| Extension Point | Function | Purpose |
|
|
360
|
+
|-----------------|----------|---------|
|
|
361
|
+
| `dw.order.calculate` | `calculate` | Full basket/order calculation |
|
|
362
|
+
| `dw.order.calculateShipping` | `calculateShipping` | Shipping calculation |
|
|
363
|
+
| `dw.order.calculateTax` | `calculateTax` | Tax calculation |
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
// hooks/calculate.js
|
|
367
|
+
var Status = require('dw/system/Status');
|
|
368
|
+
var HookMgr = require('dw/system/HookMgr');
|
|
369
|
+
|
|
370
|
+
exports.calculate = function(lineItemCtnr) {
|
|
371
|
+
// Calculate shipping
|
|
372
|
+
HookMgr.callHook('dw.order.calculateShipping', 'calculateShipping', lineItemCtnr);
|
|
373
|
+
|
|
374
|
+
// Calculate promotions, totals...
|
|
375
|
+
|
|
376
|
+
// Calculate tax
|
|
377
|
+
HookMgr.callHook('dw.order.calculateTax', 'calculateTax', lineItemCtnr);
|
|
378
|
+
|
|
379
|
+
return new Status(Status.OK);
|
|
380
|
+
};
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Payment Hooks
|
|
384
|
+
|
|
385
|
+
| Extension Point | Function | Purpose |
|
|
386
|
+
|-----------------|----------|---------|
|
|
387
|
+
| `dw.order.payment.authorize` | `authorize` | Payment authorization |
|
|
388
|
+
| `dw.order.payment.authorizeCreditCard` | `authorizeCreditCard` | Credit-card authorization invoked by order-PI POST/PATCH |
|
|
389
|
+
| `dw.order.payment.capture` | `capture` | Capture authorized payment |
|
|
390
|
+
| `dw.order.payment.refund` | `refund` | Refund payment |
|
|
391
|
+
| `dw.order.payment.validateAuthorization` | `validateAuthorization` | Check authorization validity |
|
|
392
|
+
| `dw.order.payment.reauthorize` | `reauthorize` | Re-authorize expired auth |
|
|
393
|
+
|
|
394
|
+
### Order Hooks
|
|
395
|
+
|
|
396
|
+
| Extension Point | Function | Purpose |
|
|
397
|
+
|-----------------|----------|---------|
|
|
398
|
+
| `dw.order.createOrderNo` | `createOrderNo` | Custom order number generation |
|
|
399
|
+
|
|
400
|
+
```javascript
|
|
401
|
+
var OrderMgr = require('dw/order/OrderMgr');
|
|
402
|
+
var Site = require('dw/system/Site');
|
|
403
|
+
|
|
404
|
+
exports.createOrderNo = function() {
|
|
405
|
+
var seqNo = OrderMgr.createOrderSequenceNo();
|
|
406
|
+
var prefix = Site.current.ID;
|
|
407
|
+
return prefix + '-' + seqNo;
|
|
408
|
+
};
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Custom Hooks
|
|
412
|
+
|
|
413
|
+
Create your own extension points:
|
|
414
|
+
|
|
415
|
+
```javascript
|
|
416
|
+
// Define custom hook
|
|
417
|
+
var HookMgr = require('dw/system/HookMgr');
|
|
418
|
+
|
|
419
|
+
function processCheckout(basket) {
|
|
420
|
+
// Call custom hook if registered
|
|
421
|
+
if (HookMgr.hasHook('app.checkout.validate')) {
|
|
422
|
+
var status = HookMgr.callHook('app.checkout.validate', 'validate', basket);
|
|
423
|
+
if (status && status.error) {
|
|
424
|
+
return status;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// Continue processing...
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Register in hooks.json:
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"hooks": [
|
|
436
|
+
{
|
|
437
|
+
"name": "app.checkout.validate",
|
|
438
|
+
"script": "./hooks/checkout.js"
|
|
439
|
+
}
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Custom hooks always execute all registered implementations regardless of return value.
|
|
445
|
+
|
|
446
|
+
## Remote Includes in Hooks
|
|
447
|
+
|
|
448
|
+
Enhance API responses with data from other SCAPI endpoints:
|
|
449
|
+
|
|
450
|
+
```javascript
|
|
451
|
+
var RESTResponseMgr = require('dw/system/RESTResponseMgr');
|
|
452
|
+
|
|
453
|
+
exports.modifyGETResponse = function(product, doc) {
|
|
454
|
+
// Include Custom API response
|
|
455
|
+
var include = RESTResponseMgr.createScapiRemoteInclude(
|
|
456
|
+
'custom', // API family
|
|
457
|
+
'my-api', // API name
|
|
458
|
+
'v1', // Version
|
|
459
|
+
'endpoint' // Endpoint
|
|
460
|
+
);
|
|
461
|
+
doc.c_additionalData = { value: [include] };
|
|
462
|
+
};
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
## Best Practices
|
|
466
|
+
|
|
467
|
+
- Return `undefined` (no return) from OCAPI/SCAPI hooks to ensure system implementations run
|
|
468
|
+
- Only return `Status.ERROR` when you need to stop processing
|
|
469
|
+
- Returning `Status.OK` skips system implementation and subsequent hooks
|
|
470
|
+
- Use `request.custom` to pass data between hooks
|
|
471
|
+
- Check `request.isSCAPI()` when supporting both APIs
|
|
472
|
+
- Keep hooks focused and performant
|
|
473
|
+
- Use custom properties (`c_` prefix) in modifyResponse
|
|
474
|
+
- Avoid transactions in calculate hooks (breaks SCAPI)
|
|
475
|
+
- Avoid slow external calls in beforeGET (affects caching)
|
|
476
|
+
|
|
477
|
+
## Error Handling
|
|
478
|
+
|
|
479
|
+
### Circuit Breaker
|
|
480
|
+
|
|
481
|
+
Too many hook errors triggers circuit breaker (HTTP 503):
|
|
482
|
+
|
|
483
|
+
```json
|
|
484
|
+
{
|
|
485
|
+
"title": "Hook Circuit Breaker",
|
|
486
|
+
"type": "https://api.commercecloud.salesforce.com/.../hook-circuit-breaker",
|
|
487
|
+
"detail": "Failure rate above threshold of '50%'",
|
|
488
|
+
"extensionPointName": "dw.ocapi.shop.basket.afterPOST"
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Timeout
|
|
493
|
+
|
|
494
|
+
Hooks must complete within the SCAPI timeout (HTTP 504 on timeout).
|
|
495
|
+
|
|
496
|
+
## Detailed References
|
|
497
|
+
|
|
498
|
+
- [OCAPI/SCAPI Hooks](references/OCAPI-SCAPI-HOOKS.md) - API hook patterns and available hooks
|
|
499
|
+
- [System Hooks](references/SYSTEM-HOOKS.md) - Calculate, payment, and order hooks
|
|
500
|
+
- [Order Hook Lifecycle](references/ORDER-HOOK-LIFECYCLE.md) - Lifecycle phases, rollback semantics, and the two-hook pattern
|