Fixes ApiRequestorAdapter requests with BaseAddress other than Api #3007
+229
−56
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.
Why?
v46 of the SDK introduced a service accessors into
StripeClient
and a internal ApiRequestor classes for implementing the actual request issuing and response parsing logic used by the service classes. TheApiRequestorAdapter
class is used to support older-style SDK usage patterns, e.g.and also to support any custom implementations of
IStripeClient
. When a service is created directly like this, Stripe.net wraps theStripeConfiguration.StripeClient
client object with this adapter to adapt the client to an ApiRequestor.A user reported a problem with using the OAuthTokenService service with the pattern described above (#3006) where the SDK was not using the correct API base address. The root issue appears to be that BaseAddress specified by the OAuthTokenService.Create method is getting replaced with the API base address when it passes through the ApiRequestorAdapter, because the IStripeClient
RequestAsync
method does not accept a BaseAddress argument. To fix this would introduce a breaking change inIStripeClient
; this PR implements a backwards compatible fix by utilizing theRequestOption.BaseUrl
property.What?
ApiRequestorAdapter
to set theRequestOptions.BaseUrl
if thebaseAddress
argument is anything other than APILiveApiRequestor
MakeStripeRequest
to use theBaseUrl
to overridebaseAddress
, if BaseUrl is specifiedChangelog