Skip to content

Added static client_attribution_metadata fields to API requests on payment method tokenization #5177

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

Open
wants to merge 45 commits into
base: master
Choose a base branch
from

Conversation

joyceqin-stripe
Copy link
Collaborator

@joyceqin-stripe joyceqin-stripe commented Jul 18, 2025

Summary

Added client attribution metadata with fields client_session_id, merchant_integration_source, merchant_integration_subtype, and merchant_integration_version

Under payment_method_data[client_attribution_metadata] in API calls for confirmPaymentIntent, confirmSetupIntent.
Top-level under client_attribution_metadata for createPaymentMethod
Under payment_method_options[client_attribution_metadata] for sharePaymentDetails.

More client_attribution_metadata fields to come, but I thought I'd just get this one out first for less complexity.

A lot of files changed, but they're almost all network stubs

Motivation

MOBILESDK-3759
For more context, here are all the notes I have at the moment: https://docs.google.com/document/d/1NNTf3TKRJ6Ftgk6PYtDjPMSAYU-RMUezUjGndJr81Eg/edit?usp=sharing

Testing

Network stubs, manually inspected requests
confirmPaymentIntent request: https://admin.corp.stripe.com/request-log/req_3jspitgU8NcFUm
confirmSetupIntent request: https://admin.corp.stripe.com/request-log/req_E3hihx6DTYAYhy
createPaymentMethod request: https://admin.corp.stripe.com/request-log/req_gwBYjtzWxvCqPx
sharePaymentDetails request: https://admin.corp.stripe.com/request-log/req_OHbC2Nv9lfc2ot
createPaymentMethod request from ApplePay: https://admin.corp.stripe.com/request-log/req_0qmm7pYZxY1R72

Changelog

N/A

Copy link

⚠️ Public API changes detected:

StripePaymentSheet

- case flatWithDisclosure
+ case flatWithChevron
- public var disclosure: StripePaymentSheet.PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Disclosure
- public var chevron: StripePaymentSheet.PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Chevron
- public struct Disclosure : Swift.Equatable {
- public struct Chevron : Swift.Equatable {
- public static func == (a: StripePaymentSheet.PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Disclosure, b: StripePaymentSheet.PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Disclosure) -> Swift.Bool
- public static func == (a: StripePaymentSheet.PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Chevron, b: StripePaymentSheet.PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Chevron) -> Swift.Bool

If you are adding a new public API consider the following:

  • Do these APIs need to be public or can they be protected with @_spi(STP)?
  • If these APIs need to be public, assess whether they require an API review.

If you are modifying or removing a public API:

  • Does this require a breaking version change?
  • Do these changes require API review?

If you confirm these APIs need to be added/updated and have undergone necessary review, add the label modifies public API to this PR to acknowledge and bypass this check.

ℹ️ If this comment appears to be left in error, make sure your branch is up-to-date with master.

@joyceqin-stripe joyceqin-stripe marked this pull request as ready for review July 21, 2025 16:07
@joyceqin-stripe joyceqin-stripe requested review from a team as code owners July 21, 2025 16:07
@joyceqin-stripe joyceqin-stripe changed the title Added mobile session id to API requests on payment method creation and intent confirmation Added client_attribution_metadata to API requests on payment method tokenization Jul 25, 2025
@joyceqin-stripe joyceqin-stripe changed the title Added client_attribution_metadata to API requests on payment method tokenization Added static client_attribution_metadata fields to API requests on payment method tokenization Jul 25, 2025
AnalyticsHelper.shared.clearSessionID()
AnalyticsHelper.shared.generateSessionID()
Copy link
Collaborator

Choose a reason for hiding this comment

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

👀 huh this is like, doing the opposite now - why'd we make this change? Seems like it'd make sense to clear the session ID before every network test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I originally added the clearSessionID there when I was adding mobile_session_id to the API call to retrieve an ElementsSession so that network tests wouldn't hit the live network unless I explicitly generated a session ID. However, all of those network tests that would have been affected have had their stubs changed in this PR, and now that I've edited the paramsAddingClientAttributionMetadata to not include client_session_id in the request unless it's non-nil, it feels like it would make more sense to always generate a session ID and include client_attribution_metadata[client_session_id] in all the stubs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually not all of those original network tests that would have been affected are affected here, I can revert to clearing the session ID but I'll have to rerecord these tests

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.

2 participants