Skip to content

Commit c5c239a

Browse files
authored
handle 3DS success = false scenario for CardFields (#98)
* 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
1 parent 3602eb8 commit c5c239a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/three-domain-secure/component.jsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,18 @@ export function getThreeDomainSecureComponent(): TDSComponent {
115115
onSuccess: {
116116
type: "function",
117117
alias: "onContingencyResult",
118-
decorate: ({ value, onError }) => {
118+
decorate: ({ props, value, onError }) => {
119119
return (err, result) => {
120-
if (err || (result && !result.success)) {
120+
const isCardFieldFlow = props?.userType === "UNBRANDED_GUEST";
121+
122+
// HostedFields ONLY rejects when the err object is not null. The below implementation ensures that CardFields follows the same pattern.
123+
124+
const hasError = isCardFieldFlow
125+
? Boolean(err)
126+
: // $FlowFixMe[incompatible-use]
127+
Boolean(err) || result?.success === false;
128+
129+
if (hasError) {
121130
return onError(err);
122131
}
123132

0 commit comments

Comments
 (0)