Skip to content

feat: added sdk authorization support in pmm#1415

Open
sakksham7 wants to merge 6 commits intomainfrom
sdk-auth-pmm
Open

feat: added sdk authorization support in pmm#1415
sakksham7 wants to merge 6 commits intomainfrom
sdk-auth-pmm

Conversation

@sakksham7
Copy link
Copy Markdown
Contributor

Type of Change

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

Description

This PR adds support for SDK Authorization in the Hyperswitch Web SDK for Payment Methods Management flow to enable platform-connected merchant flows.

Added Support for sdkAuthorization header in Payment Methods Management Flow
After this support, From merchant integration - we will not need to collect pmSessionId, pmClientSecret and profileId
Merchant will only need to pass sdkAuthorization and we will extract pmSessionId from it, Only pmSessionId is needed as It is a path parameter for all the API endpoints

Previous Authorization Headers

[
    ("x-profile-id", `${profileId}`),
    ("Authorization", `publishable-key=${publishableKey},client-secret=${pmClientSecret}`),
]

New Authorization Headers

[("Authorization", `${sdkAuthorization}`)]

Major Changes -

  • We are removing support for older integration as its Payment Methods Management flow
  • Removed appending client secret in query params after confirm or update

How did you test it?

Tested via Checking the SDK authorization integration flow
Created Intent using this body

{
          customer_id: "12345_cus_019c7051de7572b289d9318f4ff82ad8",
          storage_type: "persistent",
          billing: {
            address: {
              first_name: "hellow",
              last_name: "world",
            },
            email: "example@example.com",
          },
}

Headers

{
          "x-profile-id": "pro_...",
          "x-connected-merchant-id": "merchant_...",
          "Content-Type": "application/json",
          Authorization:
            "api-key=snd_...",
        }

Passed the sdkAuthorization to SDK

Payment Methods Management Flow

Screen.Recording.2026-03-11.at.2.07.06.PM.mov

Checklist

  • I ran npm run re:build
  • I reviewed submitted code
  • I added unit tests for my changes where possible

@semanticdiff-com
Copy link
Copy Markdown

Review changes with  SemanticDiff

@sakksham7 sakksham7 linked an issue Mar 11, 2026 that may be closed by this pull request
@sakksham7 sakksham7 added the Ready for Review PR with label Ready for Review should only be reviewed. label Mar 11, 2026
aritro2002
aritro2002 previously approved these changes Mar 23, 2026
aritro2002
aritro2002 previously approved these changes Mar 23, 2026
~pmSessionId=keys.pmSessionId->Option.getOr(""),
~logger,
~customPodUri,
~sdkAuthorization=keys.sdkAuthorization->Option.getOr(""),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extract sdkAuthorization from keys at line no. 17

~pmSessionId=keys.pmSessionId->Option.getOr(""),
~logger,
~customPodUri,
~sdkAuthorization=keys.sdkAuthorization->Option.getOr(""),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

pmManagementOptionsDict
->Option.forEach(x => x->Dict.set("launchTime", Date.now()->JSON.Encode.float))
->ignore
let sdkAuthorizationId = pmManagementOptionsDict->getStringFromDict("sdkAuthorization", "")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to make this new variable sdkAuthorizationId
assign value directly to sdkAuthorization and use

]
switch keys.pmSessionId {
| Some(pmSessionId) =>
let headers = [("Authorization", `${keys.sdkAuthorization->Option.getOr("")}`)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to use template literal here

]
switch keys.pmSessionId {
| Some(pmSessionId) =>
let headers = [("Authorization", `${keys.sdkAuthorization->Option.getOr("")}`)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extract and use values from key at line no. 371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Review PR with label Ready for Review should only be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sdkAuthorization support in PMM

3 participants