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

Regarding ability to override stripe api url per API request #1181

Closed
devansh-dalal opened this issue Feb 7, 2021 · 2 comments
Closed

Regarding ability to override stripe api url per API request #1181

devansh-dalal opened this issue Feb 7, 2021 · 2 comments
Assignees
Labels

Comments

@devansh-dalal
Copy link

Hi

We are using stripe-mock for our e2e tests requiring stripe API calls. There we required to change the stripe api base url per request as:

public PaymentMethod createPaymentMethod(Card card) {
      var paymentMethodParams =
          PaymentMethodCreateParams.builder()
              .setType(Type.CARD)
              .setCard(
                  CardDetails.builder()
                      .setNumber(card.getNumber())
                      .setExpMonth((long) card.getExpiryMonth())
                      .setExpYear((long) card.getExpiryYear())
                      .setCvc(card.getCvv())
                      .build())
              .build();
      var response = testMode? "Make API call to mock stripe with params" : PaymentMethod.create(paymentMethodParams);
      return response;
  }

This could be done globally via static method as

Stripe.overrideApiBase();

but this changes the url of stripe api globally, It could have been usable if I could have overridden the api url per request, maybe via RequestOptions. Please do let if know if there are any problems, this should be easy, or not?

@remi-stripe remi-stripe self-assigned this Feb 7, 2021
@remi-stripe
Copy link
Contributor

@devansh-dalal Thanks for the report! We'll track this internally but I think it will only happen once we ship support for the client/services infrastructure we're working on!

richardm-stripe added a commit that referenced this issue Dec 29, 2022
#1476)

* Solution For "Regarding ability to override stripe api url per API request #1181".
#1181

* normalizeApiBase method added

* Replace ReflectionCheckingTypeAdapterFactory with a ReflectionAccessFilter (#1496)

* Replace ReflectionCheckingTypeAdapterFactory with a Filter

* Add test

* API Updates (#1497)

* Codegen for openapi v216

* Bump version to 22.4.0

* Actually release (#1499)

* Deprecate ApiResource.classUrl, etc.

* Tweak RequestOptions and ApiResource

* Format

* Codegen

* Overridden methods

* Update src/main/java/com/stripe/net/ApiResource.java

Co-authored-by: pakrym-stripe <[email protected]>

* Revert "Update src/main/java/com/stripe/net/ApiResource.java"

This reverts commit c263ce0.

Co-authored-by: Yasir Shabbir <[email protected]>
Co-authored-by: Richard Marmorstein <[email protected]>
Co-authored-by: Richard Marmorstein <[email protected]>
Co-authored-by: anniel-stripe <[email protected]>
Co-authored-by: pakrym-stripe <[email protected]>
@richardm-stripe
Copy link
Contributor

This was made possible in #1476 and was released in https://github.com/stripe/stripe-java/releases/tag/v22.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants