feat: use outcome property in api requests#237
Open
jakubjasinsky wants to merge 2 commits intomasterfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrate API response handling from the legacy
success: booleanproperty to the newoutcomeproperty ("success" | "failed" | "pending"), with backward-compatible fallback. This adds support for the pending payment state across all Dynamic Checkout payment flows.Changes
Core
resolveOutcome()utility (src/processout/outcome.ts) that readsdata.outcomewhen present, falling back todata.successboolean for backward compatibility!data.successchecks inprocessout.tswithresolveOutcome(data) === OUTCOME.Failedpendingcallback parameter tomakeCardPaymentandhandleCardActions, threaded through recursive 3DS callspendingcallback is provided, fall back tosuccesscallback for backward compatibilityDynamic Checkout - Payment Methods
PAYMENT_PENDINGevent dispatches (previously fired beforemakeCardPayment, meaning "in progress") —PAYMENT_PENDINGnow only fires when the API returnsoutcome: "pending"apm.tshandleApmPaymentWithSaveForFuturedirectapiRequestcall (previously had no error handling on the response)handleDeletePaymentMethodin payment methods viewresourceIDargument inhandleCardActions3DS1 recursive call (was silently passed as 9th arg, now correctly passespending)Views & Locales
DynamicCheckoutPaymentPendingViewfor displaying pending state to userspayment-pending-messagetranslation to all 9 locales (en, de, es, fr, it, ja, ko, pl, pt)pt.tstranslations from Brazilian Portuguese (pt-BR) to European Portuguese (pt-PT)Impact
outcome, behavior is identical to before (falls back tosuccessboolean)makeCardPaymentAPI —pendingis an optional trailing parameterPAYMENT_PENDINGcustom DOM event now fires only on actual pending outcomes, not as a "payment in progress" signal. Consumers relying on the old timing should migrate toPAYMENT_SUBMITTEDTesting Plan
outcome: "success"behave identically to previoussuccess: trueoutcomefield fall back tosuccessboolean correctlyoutcome: "pending"trigger pending callback and showDynamicCheckoutPaymentPendingViewoutcome: "failed"behave identically to previoussuccess: falsePAYMENT_PENDINGevent only fires on pending outcome, not beforemakeCardPaymentshowStatusMessage: trueand does not render withshowStatusMessage: false