-
Notifications
You must be signed in to change notification settings - Fork 165
feat: add support for sdkData API field #3511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 10c117d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for adyen-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @m1aw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request implements support for a new sdkData API field, designed to centralize and transmit crucial analytics and risk-related information within payment requests. The sdkData is generated as a base64-encoded JSON blob, containing a schema version, checkout attempt ID, and client risk data. This ensures a standardized and secure way to pass this information for both session-based and advanced payment flows.
Highlights
- New API Field
sdkData: Introduces support for a newsdkDataAPI field, which will be an encrypted blob containing analytics and risk information. - Data Encapsulation: The
sdkDatafield consolidatesanalytics(specificallycheckoutAttemptId) andriskData(specificallyclientData) into a single, base64-encoded JSON object. - Integration into Payment Flows: This new field is integrated into the
.data()method ofBaseElement, ensuring its inclusion in payment requests for both sessions and advanced flows when relevant data is available. - Utility Function: A new utility
createSdkDatais added to handle the construction and encoding of thesdkDataobject.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for a new sdkData API field, which encapsulates analytics and risk data into a single base64-encoded JSON string. The changes look good overall. I've added a couple of comments: one to prevent sending a 'failed' state value in the sdkData payload, and another to improve maintainability by using a constant for the schema version.
packages/lib/src/components/internal/BaseElement/BaseElement.ts
Outdated
Show resolved
Hide resolved
size-limit report 📦
|
c2aa44b to
9e987e7
Compare
9f6fe0a to
943e76b
Compare
|
943e76b to
14b2719
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for a new sdkData API field, which will be part of payment requests. The changes look good overall, adding a utility to create the sdkData blob and integrating it into the BaseElement. However, I've found a couple of issues. There's a significant type mismatch that would cause incorrect serialization of the risk data within sdkData. Additionally, there's a missed edge case where a failed checkoutAttemptId could be used, leading to invalid analytics data. I've provided suggestions to fix these issues and also a minor one to improve type safety.
|
| return false; | ||
| } | ||
|
|
||
| get dataUnencoded(): object | false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan here of returning either an object or false from the same function. We could make it more singular purpose by just retuning null as the negative case
| get dataUnencoded(): object | false { | |
| get dataUnencoded(): Record<string | any> | null { |
| return { version: RISK_DATA_VERSION, ...this.state.data }; | ||
| } | ||
|
|
||
| return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return false; | |
| return null; |
| * @param clientData - The client data from risk module | ||
| * @returns Base64 encoded JSON string of the SDK data object | ||
| */ | ||
| export function createSdkData(checkoutAttemptId: string, clientData: object): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function createSdkData(checkoutAttemptId: string, clientData: object): string { | |
| export function createSdkData(checkoutAttemptId: string, clientData: Record<string, any>): string { |
Object is also not the most easy to work with in typescript. I propose using Record<> instead



Summary
Add support for a new API field sdkData. Please check internal ticket for the full details. This PR adds sdkData as an encrypted blob in the
.data(), this is used both on sessions and advanced flow payment requests.Tested scenarios
Fixed issue:
COSDK-514