Repository navigation
[COMMEX-2267] Forward configured checkout payment methods - #1541
Conversation
🦋 Changeset detectedLatest commit: c627605 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
pbennett1-godaddy
left a comment
There was a problem hiding this comment.
Three blocking issues are in the inline comments. They have one cause: what paymentMethods() accepts doesn't match what createCheckoutSession needs to succeed.
Non-blocking:
- A configured method that the API drops goes undetected. After the session is created, promotion codes, tax and shipping are each checked against the response, but the configured payment methods aren't. If Google Pay is configured and the API returns only card, checkout works with no Google Pay and nothing is logged. A per-method check would match how the other flags are handled. It could also replace the card-only check in blocking comment 1.
- Invalid config falls back silently. One bad entry, such as a typo like
googlepayor an extra field, makespaymentMethods()returnundefinedand discards the whole map with no signal. Logging a warning with the reason would make it much easier to see why Google Pay is missing. - Values aren't trimmed before they're sent.
processorandcheckoutTypesuse.trim()only to check for empty values, and the original strings are forwarded. So" godaddy "passes validation and goes upstream with the spaces. Either return trimmed copies or reject padded values.
| ) | ||
| return undefined; | ||
| } | ||
| return value as CheckoutSessionPaymentMethodsInput; |
There was a problem hiding this comment.
Blocking: some configs that pass this validator make every checkout throw.
The validator follows the API, where every method including card is optional and nullable. So { googlePay: {...} } and { card: null, googlePay: {...} } are accepted. But create-checkout-session.ts:312 still does this after the session is created:
if (!session.paymentMethods?.card?.processor) {
throw new UpstreamError('Checkout session did not configure payment methods.');
}That check was safe when the server always sent the card default. With configurable methods, a card-less config creates the session upstream and then throws, for every cart, Buy Now and non-catalog checkout. Each attempt also leaves an unused upstream session behind.
Since the API allows card-less sessions, I'd relax that check: throw only when none of the configured non-null methods comes back with a processor. If card-less checkout isn't meant to be supported, require a non-null card here and document that instead.
| if (!isRecord(value) || Object.keys(value).length === 0) return undefined; | ||
| for (const [name, method] of Object.entries(value)) { | ||
| if (!PAYMENT_METHOD_NAMES.has(name as keyof CheckoutSessionPaymentMethodsInput)) return undefined; | ||
| if (method === null) continue; |
There was a problem hiding this comment.
Blocking: a map where every method is null passes as valid.
Because of this continue, { card: null } or { card: null, googlePay: null } is returned as a valid config instead of falling back to DEFAULT_CHECKOUT_PAYMENT_METHODS. Checkout then sends a session with no payment methods, which is the silent failure the default exists to prevent. The README says invalid payment settings fall back to standard card, but an all-null map doesn't.
Suggested fix: after the loop, require at least one non-null method and return undefined otherwise.
| currencyCode: configCurrencyCode, | ||
| } = readReadyCommerceConfig(configuration); | ||
| const checkoutConfiguration = readReadyCheckoutConfig(configuration); | ||
| const paymentMethods = checkoutConfiguration.paymentMethods ?? DEFAULT_CHECKOUT_PAYMENT_METHODS; |
There was a problem hiding this comment.
Blocking: payment methods from a host's readCheckout() reach the Checkout API without validation.
Only undefined falls back to the default through ??. A host that returns paymentMethods: {} or a malformed map replaces the safe card default, and every checkout fails (see the comment on checkout-config.ts).
The README does say hosts supplying readCheckout() must validate their own values. But paymentMethods() already exists, so running host values through it here is a small change. An empty or invalid map would then fall back the same way the env path does. If you'd rather keep this as the host's job, consider at least treating {} as missing.
pbennett1-godaddy
left a comment
There was a problem hiding this comment.
Approving. 802dde3f fixes all three blocking issues:
- Card-less configs: the check after the session is created now passes when any configured method comes back with the processor that was requested.
- All-null maps: these now fall back to the card default.
- Host
readCheckout()values: these now go through the same validator as environment configuration.
Padded values are rejected too. Typecheck, tests and lint pass on this commit.
Non-blocking follow-up: invalid payment config still falls back with no log. One bad entry, such as a typo like googlepay or an extra field, makes parseCheckoutPaymentMethods return undefined, and the whole map is replaced by the card default. This now covers host readCheckout() values too. The result is that a builder can configure Google Pay, see card-only checkout and have nothing to explain why. A warning through the configured logger with the reason (unknown method name, extra field, invalid processor or checkoutTypes, no enabled methods) would make this easy to diagnose. The same logging would help when a configured method is dropped from the returned session but another one survives.
sbolinger-godaddy
left a comment
There was a problem hiding this comment.
Nothing major found, approving. One item you may want to address, but it's not a blocker:
- Invalid
paymentMethodsconfig (e.g. agooglepaytypo or an extra field) falls back to card-only with no log, same as Patrick noted. A warning through the configured logger would make missing Google Pay much easier to diagnose.
Verified: traced configured methods through cart, Buy Now, and non-catalog inputs and the response check; ran typecheck, lint, and tests for @godaddy/gd-commerce-server on Node 24 (383 passed). Did not exercise a live Checkout API or Google Pay flow.
Summary
The server currently replaces managed
paymentMethodswith a hard-coded card configuration, preventing Airo apps from enabling Google Pay in standard hosted checkout. Read and validate the optional methods fromGODADDY_CHECKOUT_CONFIGURATION, then forward them for cart, Buy Now, and trusted non-catalog sessions.For Google Pay, both methods require the explicit Checkout API fields:
{ "card": { "processor": "godaddy", "checkoutTypes": ["standard"] }, "googlePay": { "processor": "godaddy", "checkoutTypes": ["standard"] } }Missing, empty, all-null, or malformed optional methods retain standard card checkout without resetting valid shipping, tax, or promotion flags. Environment settings and custom host
readCheckout()values use the same payment validation. Padded processor and checkout-type strings are rejected. Valid cardless configurations are supported: the returned session must retain at least one configured method with its requested processor.Invalid payment maps emit one
invalid_checkout_payment_methodswarning per checkout attempt through the configured logger, with astandard_godaddy_cardfallback marker and no configuration values. Missing or valid settings do not warn. Existing error-only loggers remain compatible, usingconsole.warnwhen no warning handler is available or it fails.Payment methods remain server-owned; browser checkout inputs cannot override them. Forwarding a provider does not initialize its frontend SDK. This integration enables Google Pay through GoDaddy Payments; other providers still require their SDK configuration in hosted checkout. Apple Pay is outside this change.
Jira: COMMEX-2267, related to COMMEX-2168.
Changeset
@godaddy/gd-commerce-server.Publish the fixed package before releasing the AAB dependency update. Existing apps need a resolved dependency and lockfile update, configuration refresh, rebuild, and redeploy; configuration delivery alone cannot upgrade bundled code.
Companion configuration bridge and Customer Care recovery: gdcorp-partners/airo-app-builder#14581, kept as a draft pending the package release.
Test Plan
pnpm --filter @godaddy/gd-commerce-server test: 389 tests passed.processorandcheckoutTypesare required. Real preview cart and Buy Now requests returned HTTP 200 with checkout sessions using the corrected configuration.Bug-fix details
Configured wallet methods were ignored, so shoppers could not use Google Pay through the packaged checkout integration. An empty wallet object also fails Checkout API input validation; the parser rejects incomplete method settings before forwarding them. Shared validation prevents invalid custom host settings from bypassing the safe card fallback, and the response check accepts configured methods without requiring card.