Skip to content

feat: added react wrapper for payment methods management#8

Merged
ArushKapoorJuspay merged 5 commits intomainfrom
pmm-changes
Jan 14, 2026
Merged

feat: added react wrapper for payment methods management#8
ArushKapoorJuspay merged 5 commits intomainfrom
pmm-changes

Conversation

@sakksham7
Copy link
Contributor

@sakksham7 sakksham7 commented Jan 12, 2026

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Made the changes for Exposing ConfirmTokenization callback for Payment Methods Management

Old Approach (Not used now)

  • Previously we were exposing the same useHyper hook from the react wrapper for PMM as well which leads to exposing of default Payments Switch context from the wrapper, So we were not able to get the PMM Context during Integration and always getting the default switch instance of payments.
  • Added new useHyperManagement hook to expose the PMM Context on the merchant side and fixed the HyperManagementMethods switch instance to expose all the methods correctly

New approach

  • Exposed all the switch instance context which was there for Payment Element into payment method management element as well with additional new callback

How did you test it?

tested via generating the build of the wrapper and putting in local react demo app for consuming it.
reference video -

Screen.Recording.2026-01-12.at.5.49.40.PM.mov

V1 Test -

Screen.Recording.2026-01-12.at.6.27.16.PM.mov

Usage Notes

New entry point added for Payment methods management react integration

Version Update

  • I have bumped the package version in package.json following semantic versioning:
    • x.x.x for major changes (breaking).
    • 1.3.4 for minor changes (new feature, no breaking changes).
    • x.x.x for patch changes (bug fixes, minor improvements).

Checklist

  • I ran npm run re:build and verified the build artifacts.
  • I reviewed the code for style, readability, and consistency.
  • I verified the changes are backward compatible (if applicable).
  • I tested this change in a real or simulated consuming project.
  • I updated documentation, README, or usage examples if necessary.

Screenshots or Logs

Added Screen Recording

@sakksham7 sakksham7 self-assigned this Jan 12, 2026
@sakksham7 sakksham7 added the enhancement New feature or request label Jan 12, 2026

module PaymentMethodsManagementSwitchContextProvider = {
let make = React.Context.provider(paymentMethodsManagementSwitchContext)
let make = React.Context.provider(switchContext)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let defaultPaymentMethodsManagementSwitchContext = {
  ephemeralKey: "",
  paymentRequest,
}

do we need to add ephemeralKey: "" in defaultSwitchContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and tested this so we do not need the switch context to have this value since its not needed and used
cc: @ArushKapoorJuspay

Comment on lines +22 to +30
let switchValClone: Context.switchContextType = {
confirmPayment: switchInstance.confirmPayment,
confirmCardPayment: switchInstance.confirmCardPayment,
retrievePaymentIntent: switchInstance.retrievePaymentIntent,
clientSecret: "",
paymentRequest: switchInstance.paymentRequest,
ephemeralKey: paymentMethodsManagementElementOptions.ephemeralKey,
completeUpdateIntent: switchInstance.completeUpdateIntent,
initiateUpdateIntent: switchInstance.initiateUpdateIntent,
confirmTokenization: switchInstance.confirmTokenization,
Copy link

@aritro2002 aritro2002 Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ephemeralKey support will be needed for paymentMethodsManagement, right?

Image Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On testing this i found out that even though we have client secret value but its not needed or consumed anywhere since its provided in element options and not from the switch context, so we do not need to add the ephemeral key here since its not needed
cc: @ArushKapoorJuspay

src/Context.res Outdated
paymentRequest,
completeUpdateIntent: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
initiateUpdateIntent: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
confirmTokenization: confirmTokenizationFn,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
confirmTokenization: confirmTokenizationFn,
confirmTokenization: _ => Promise.resolve(Dict.make()->JSON.Encode.object),

@ArushKapoorJuspay ArushKapoorJuspay merged commit 8bcc3b0 into main Jan 14, 2026
6 checks passed
@ArushKapoorJuspay ArushKapoorJuspay deleted the pmm-changes branch January 14, 2026 14:41
@github-actions github-actions bot removed the enhancement New feature or request label Jan 14, 2026
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.

4 participants