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

Use STPAPIClient.shared by default #1469

Merged
merged 13 commits into from
Jan 22, 2020

Conversation

yuki-stripe
Copy link
Collaborator

@yuki-stripe yuki-stripe commented Jan 2, 2020

Summary

Make STPPaymentContext, STPCustomerContext, STPPinManagementService, STPPushProvisioningContext, STPAddCardViewController:

  1. Use an explicit APIClient property to make API requests
  2. Expose that property publicly
  3. Default that property value to STPAPIClient.shared

Previously, they used various APIClient instances, leading to inconsistent and unclear configurations of APIClient properties like stripeAccount.

Motivation

https://paper.dropbox.com/doc/psyduck-why-iOS-SDK-API-Configuration-LTvIMxj6CBy1Mw4ntaU0l#:uid=436909486618175148450143&h2=Proposal

https://jira.corp.stripe.com/browse/IOS-1437

Testing

Manually test basic integration app and make sure customer things work.

…new one. This means its api client has the same configuration as the shared one. This gets us closer to "By default, the Stripe SDK uses the STPAPIClient.shared to make API calls."
Stripe/STPAPIClient.m Outdated Show resolved Hide resolved
@yuki-stripe
Copy link
Collaborator Author

@csabol-stripe Ready for another pass. I discovered 2 more classes that make API requests, both using ephemeral keys. I think it makes sense that they use sharedClient too.

Manually tested Basic Integration again.

@yuki-stripe yuki-stripe changed the title STPCustomerContext uses STPAPIClient.shared Use STPAPIClient.shared by default Jan 10, 2020
@yuki-stripe
Copy link
Collaborator Author

Expanded scope of PR after discussion, see revised summary.

Copy link
Contributor

@csabol-stripe csabol-stripe left a comment

Choose a reason for hiding this comment

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

👍🏻on changing from class to instance methods. i think that makes the behavior much more clear

Stripe/STPAPIRequest.h Outdated Show resolved Hide resolved
@@ -91,7 +90,7 @@ - (void)commonInitWithConfiguration:(STPPaymentConfiguration *)configuration {
_configuration = configuration;
_shippingAddress = nil;
_hasUsedShippingAddress = NO;
_apiClient = [[STPAPIClient alloc] initWithConfiguration:configuration];
_apiClient = [STPAPIClient sharedClient];
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, these changes are the most concerning to me. If stripeAccount (and other STPAPIClient configurations) is still a property on STPPaymentConfiguration this should probably respect those. Is the plan to deprecate on STPPaymentConfiguration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, plan is to kill PaymentConfiguration.{stripeAccount, publishableKey} in a follow-up PR

Copy link
Contributor

Choose a reason for hiding this comment

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

mind putting up that patch in parallel with this one so I can review both together?

…ugh they don't make network requests themselves, they initialize others that do.

Here's a graph:
PaymentContext
  - PaymentOptionsVC
    - PaymentOptionsInternalVC
      - AddCardVC
      - BankSelectionVC
    - AddCardVC

APIClient configuration needs to flow from every node to leaf.
@yuki-stripe yuki-stripe merged commit 47a13b2 into master Jan 22, 2020
@yuki-stripe yuki-stripe deleted the yuki/customercontext-use-shared-apiclient branch January 23, 2020 18:16
davidme-stripe added a commit that referenced this pull request Oct 14, 2022
[23] Project files and iOS 13 changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants