Skip to content

fix(payment-methods): pass on the Hyperswitch vault's refusal instead of reporting ready - #107

Open
Pradeep-kumar1202 wants to merge 1 commit into
mainfrom
fix/pm-vault-refusal
Open

Pradeep-kumar1202 wants to merge 1 commit into
mainfrom
fix/pm-vault-refusal

Conversation

@Pradeep-kumar1202

Copy link
Copy Markdown
Contributor

What

The Hyperswitch adapter of the payment-methods SDK now passes on the vault's refusal instead of reporting the form ready.

The vault's card fields are native only (#104 Android, #105 iOS). Where they cannot run, for example an app built without them, an over-the-air update onto an older build, or a form that stops, the vault's CardForm draws no field and calls onError with unsupported_configuration. Before this change, the adapter passed the vault no onError and reported ready whenever the form's ref existed. The merchant got an empty form, "ready", and no error until a save.

Changes

  • providers/hyperswitch/adapter.tsx: passes the vault's error on to onError, with its code and message, and doesn't report ready when the vault refused.
  • core/formSession.ts:
    • Every later tokenize() keeps unsupported_configuration. Any other failure stays tokenization_failed.
    • A save in flight when the form fails keeps its own result, unknown_outcome included, and the form stays failed instead of going back to ready.

Tests

  • Session: the kept code, no other code carried through, and a save in flight during a failure.
  • Adapter, with a refusing vault stand-in: onError fires once, ready never fires, and a later save gives the same code and message.
  • Adapter, with a running vault stand-in: ready fires and no error.

Jest: 220 passed, 3 skipped. tsc and ESLint are clean.

Release

This takes effect with the vault release that has the native-only card fields. Older vault versions never call onError, so nothing changes with them.

… of reporting ready

The vault's card fields are native only. Where they cannot run (an app built without them, an
over-the-air update onto an older build, a form that stops), the vault's CardForm draws no field
and calls onError with unsupported_configuration. The Hyperswitch adapter passed the vault no
onError and reported ready whenever the form's ref existed, so the merchant got an empty form,
"ready", and no error until a save.

- The adapter passes the vault's error on to onError, with its code and message, and does not
  report ready when the vault refused. Fields report ready only after the form, so they stay quiet.
- The form session keeps unsupported_configuration on every later tokenize(); any other failure
  stays tokenization_failed.
- A save in flight when the form fails keeps its own result (unknown_outcome included), and the
  form stays failed instead of going back to ready.

Tests: the session (the kept code, no other code carried through, a save in flight during a
failure); the adapter with a refusing vault stand-in (onError once, never ready, a later save gives
the same code and message) and with a running one (ready, no error).

Takes effect with the vault release that has the native-only card fields; older vault versions
never call onError, so nothing changes with them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant