stripe / stripe-java

Java library for the Stripe API.

Home Page:https://stripe.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating PaymentSource Caused by: java.net.UnknownHostException: api.stripe.comnull

barrychapman opened this issue · comments

Describe the bug

When creating a source, the following occurs:

PaymentSource paymentSource = paymentSourceCollection.create(createParams);

Line #52 in PaymentSourceCollection.java

  /**
   * When you create a new credit card, you must specify a customer or recipient on which to create
   * it.
   *
   * <p>If the card’s owner has no default card, then the new card will become the default. However,
   * if the owner already has a default, then it will not change. To change the default, you should
   * <a href="https://stripe.com/docs/api#update_customer">update the customer</a> to have a new
   * <code>default_source</code>.
   */
  public PaymentSource create(PaymentSourceCollectionCreateParams params) throws StripeException {
    return create(params, (RequestOptions) null);
  }

Then calls line #65 in the same file (PaymentSourceCollection.java)

  public PaymentSource create(PaymentSourceCollectionCreateParams params, RequestOptions options)
      throws StripeException {
    String url = ApiResource.fullUrl(Stripe.getApiBase(), options, this.getUrl());
    return ApiResource.request(
        ApiResource.RequestMethod.POST, url, params, PaymentSource.class, options);
  }

This is generating a URL of api.stripe.comnull - there is no parameter I can pass to correct this behavior.

To Reproduce

Create PaymentSource - returns an invalid host error

Expected behavior

Connect as expected and create payment source

Code snippets

No response

OS

Windows 11 / CentOS

Java version

Java 17

stripe-java version

v22.13.0

API version

2022-11-15

Additional context

No response

@barrychapman this looks like a similar question as your previous issue. Please work closely with our support team or get help from developers on Discord instead who can help you figure out what is wrong with your integration.