fix: add sdk authorization support in initpaymentsession, cvc widget flow and add cvc prop validation#1487
Open
aritro2002 wants to merge 1 commit intomainfrom
Open
fix: add sdk authorization support in initpaymentsession, cvc widget flow and add cvc prop validation#1487aritro2002 wants to merge 1 commit intomainfrom
aritro2002 wants to merge 1 commit intomainfrom
Conversation
…flow and add cvc prop validation
Contributor
🚫 Missing Linked IssueHi 👋 This pull request does not appear to be linked to any open issue yet. Linking your PR to an issue helps keep the project tidy and ensures the issue is closed automatically. ✔️ How to fix this
Once linked, this check will pass automatically on your next push or when you re-run the workflow. Thanks for helping maintainers! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…flow and add cvc prop validation
Type of Change
Description
Added
sdkAuthorizationsupport in theinitPaymentSessionflow, the CVC widget confirm flow, and added CVC prop validation for headless mode.1.
sdkAuthorizationininitPaymentSessionMirrored the existing
sdkAuthorizationsupport from theelements()flow intoinitPaymentSession. WhensdkAuthorization(a base64-encoded token containingpublishable_key,client_secret,customer_id, andprofile_id) is provided in the payment session options:Utils.getSdkAuthorizationDataandclientSecretis extracted from the token (with fallback to the explicitclientSecretoption)Authorizationheader instead ofapi-keyclient_secretis omitted from request bodiesPaymentSession->PaymentSessionMethods->PaymentHelpersto all payment intent, customer payment method list, and session fetch calls2.
sdkAuthorizationin CVC Widget FlowFixed a pre-existing gap in
CardCVCElement.reswheresdkAuthorizationfrom Recoil state (keys.sdkAuthorization) was not being passed topaymentIntentForPaymentSession. This ensures the CVC widget confirm flow also uses theAuthorizationheader whensdkAuthorizationis available.3. CVC Prop Validation
Added validation for the
cvcprop passed directly by the user in headless mode (PaymentSessionMethods.res):onlyDigitsutilityhandleFailureResponsewith message"The CVC must be a 3 to 4 digit string."and error typecvc_validationif invalidChanges Summary
Modified Files:
src/hyper-loader/Hyper.res— UpdatedinitPaymentSessionto extract and decodesdkAuthorizationfrom options, set the ref, and pass it toPaymentSession.makesrc/hyper-loader/PaymentSession.res— Added~sdkAuthorizationparameter, forwarded togetCustomerSavedPaymentMethodssrc/hyper-loader/PaymentSessionMethods.res— Added~sdkAuthorizationparameter, converted to option, passed to allpaymentIntentForPaymentSession,fetchCustomerPaymentMethodList, andfetchSessionscalls; added CVC digit-only sanitization and 3-4 digit length validationsrc/Utilities/PaymentHelpers.res— Added~sdkAuthorization=Nonedefault parameter topaymentIntentForPaymentSession, conditionally usesAuthorizationheader vsapi-key, conditionally omitsclient_secretfrom body, passessdkAuthorizationtointentCallsrc/CardCVCElement.res— Passed~sdkAuthorization=keys.sdkAuthorizationtopaymentIntentForPaymentSessionHow did you test it?
case 1: sdkauthorization passed, cvc: "123"
https://github.com/user-attachments/assets/fe1e3c83-7cd5-4832-81fe-7419460ce8c7
case 2: sdkauthorization passed, cvc: 123

case 3: sdkauthorization passed, cvc: ""

case 4: sdkauthentication passed, cvc not passed

Screen.Recording.2026-04-07.at.5.16.52.pm.mov
Checklist
npm run re:build