Skip to content

Commit

Permalink
handle 3DS success = false scenario for CardFields (#98)
Browse files Browse the repository at this point in the history
* remove onError call when success is false

* fix: ensure cardfield flow rejects only when err is not null

* fix: flow type issue

* handle missing props use case

* temporary console logs for alpha release test

* eslint disables for alpha testing

* remove console logs and coerce hasError to boolean
  • Loading branch information
mchoun authored May 24, 2024
1 parent 3602eb8 commit c5c239a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/three-domain-secure/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,18 @@ export function getThreeDomainSecureComponent(): TDSComponent {
onSuccess: {
type: "function",
alias: "onContingencyResult",
decorate: ({ value, onError }) => {
decorate: ({ props, value, onError }) => {
return (err, result) => {
if (err || (result && !result.success)) {
const isCardFieldFlow = props?.userType === "UNBRANDED_GUEST";

// HostedFields ONLY rejects when the err object is not null. The below implementation ensures that CardFields follows the same pattern.

const hasError = isCardFieldFlow
? Boolean(err)
: // $FlowFixMe[incompatible-use]
Boolean(err) || result?.success === false;

if (hasError) {
return onError(err);
}

Expand Down

0 comments on commit c5c239a

Please sign in to comment.