Skip to content
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

Add CPM toggle to playground #4633

Merged
merged 2 commits into from
Mar 5, 2025
Merged

Add CPM toggle to playground #4633

merged 2 commits into from
Mar 5, 2025

Conversation

porter-stripe
Copy link
Collaborator

Summary

  • Adds a toggle to the playground to let us test CPMs
  • This currently doesn't do anything

Motivation

  • CPMs!

Testing

  • Manual

Changelog

N/A

@porter-stripe porter-stripe marked this pull request as ready for review March 5, 2025 18:26
@porter-stripe porter-stripe requested review from a team as code owners March 5, 2025 18:26
Comment on lines +48 to +50
if playgroundController.settings.merchantCountryCode == .US {
SettingView(setting: $playgroundController.settings.customPaymentMethods)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like it's possible to turn this on while in US mode, then switch to another country and the setting will still be activated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it could! It would no-op internally, but better to not set it, updated this.

switch settings.customPaymentMethods {
case .on:
// Obtained from https://dashboard.stripe.com/settings/custom_payment_methods
let customPaymentMethodType = PaymentSheet.CustomPaymentMethodConfiguration.CustomPaymentMethodType(id: "cpmt_1QpId5Lu5o3P18ZpLwSqMXws",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we have this vended from our merchant backend, and we add a parameter so we can test 1 or many custom payment methods? (e.g. the setting for customPaymentMethods is a value between 0-3 rather than a boolean)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, it feels needlessly complex tbh. Even if we needed multiple CPMs I'd rather have them defined client-side, this is more consistent with how merchants will integrate as well. Although nothing stopping them from using a backend to vend them as you suggested.

_ billingDetails: STPPaymentMethodBillingDetails
) async -> PaymentSheetResult {
return await withCheckedContinuation { continuation in
handleExternalPaymentMethod(type: customPaymentMethodType.id, billingDetails: billingDetails) { result in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will handling custom payment methods always be the same as handling external payment methods? Or will it eventually differ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Handling confirmation of CPMs and EPMs will be the same. The merchant is responsible for handling the confirmation, then returning back to us the final result.

@porter-stripe porter-stripe merged commit 934574c into master Mar 5, 2025
6 checks passed
@porter-stripe porter-stripe deleted the porter/cpm-playground branch March 5, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants