@@ -35,7 +35,7 @@ public static RequestOptions getDefault() {
3535 return new RequestOptionsBuilder ().build ();
3636 }
3737
38- protected RequestOptions (
38+ private RequestOptions (
3939 Authenticator authenticator ,
4040 String clientId ,
4141 String idempotencyKey ,
@@ -64,6 +64,23 @@ protected RequestOptions(
6464 this .proxyCredential = proxyCredential ;
6565 }
6666
67+ RequestOptions (RequestOptionsBuilder builder ) {
68+ this (
69+ builder .authenticator ,
70+ normalizeClientId (builder .clientId ),
71+ normalizeIdempotencyKey (builder .idempotencyKey ),
72+ builder .stripeContext ,
73+ builder .stripeRequestTrigger ,
74+ normalizeStripeAccount (builder .stripeAccount ),
75+ normalizeStripeVersion (builder .stripeVersionOverride ),
76+ normalizeBaseUrl (builder .baseUrl ),
77+ builder .connectTimeout ,
78+ builder .readTimeout ,
79+ builder .maxNetworkRetries ,
80+ builder .connectionProxy ,
81+ builder .proxyCredential );
82+ }
83+
6784 public Authenticator getAuthenticator () {
6885 return this .authenticator ;
6986 }
@@ -383,20 +400,7 @@ public RequestOptionsBuilder setBaseUrl(final String baseUrl) {
383400
384401 /** Constructs a {@link RequestOptions} with the specified values. */
385402 public RequestOptions build () {
386- return new RequestOptions (
387- this .authenticator ,
388- normalizeClientId (this .clientId ),
389- normalizeIdempotencyKey (this .idempotencyKey ),
390- stripeContext ,
391- stripeRequestTrigger ,
392- normalizeStripeAccount (this .stripeAccount ),
393- normalizeStripeVersion (this .stripeVersionOverride ),
394- normalizeBaseUrl (this .baseUrl ),
395- connectTimeout ,
396- readTimeout ,
397- maxNetworkRetries ,
398- connectionProxy ,
399- proxyCredential );
403+ return new RequestOptions (this );
400404 }
401405 }
402406
@@ -513,34 +517,46 @@ static RequestOptions merge(StripeResponseGetterOptions clientOptions, RequestOp
513517 } else {
514518 stripeContext = clientOptions .getStripeContext ();
515519 }
516- return new RequestOptions (
517- options .getAuthenticator () != null
518- ? options .getAuthenticator ()
519- : clientOptions .getAuthenticator (),
520- options .getClientId () != null ? options .getClientId () : clientOptions .getClientId (),
521- options .getIdempotencyKey (),
522- stripeContext ,
523- options .getStripeRequestTrigger (),
524- options .getStripeAccount () != null
525- ? options .getStripeAccount ()
526- : clientOptions .getStripeAccount (),
527- RequestOptions .unsafeGetStripeVersionOverride (options ),
528- options .getBaseUrl (),
529- options .getConnectTimeout () != null
530- ? options .getConnectTimeout ()
531- : clientOptions .getConnectTimeout (),
532- options .getReadTimeout () != null
533- ? options .getReadTimeout ()
534- : clientOptions .getReadTimeout (),
535- options .getMaxNetworkRetries () != null
536- ? options .getMaxNetworkRetries ()
537- : clientOptions .getMaxNetworkRetries (),
538- options .getConnectionProxy () != null
539- ? options .getConnectionProxy ()
540- : clientOptions .getConnectionProxy (),
541- options .getProxyCredential () != null
542- ? options .getProxyCredential ()
543- : clientOptions .getProxyCredential ());
520+
521+ return RequestOptionsBuilder .unsafeSetStripeVersionOverride (
522+ new RequestOptionsBuilder ()
523+ .setAuthenticator (
524+ options .getAuthenticator () != null
525+ ? options .getAuthenticator ()
526+ : clientOptions .getAuthenticator ())
527+ .setClientId (
528+ options .getClientId () != null
529+ ? options .getClientId ()
530+ : clientOptions .getClientId ())
531+ .setIdempotencyKey (options .getIdempotencyKey ())
532+ .setStripeContext (stripeContext )
533+ .setStripeRequestTrigger (options .getStripeRequestTrigger ())
534+ .setStripeAccount (
535+ options .getStripeAccount () != null
536+ ? options .getStripeAccount ()
537+ : clientOptions .getStripeAccount ())
538+ .setConnectTimeout (
539+ options .getConnectTimeout () != null
540+ ? options .getConnectTimeout ()
541+ : clientOptions .getConnectTimeout ())
542+ .setReadTimeout (
543+ options .getReadTimeout () != null
544+ ? options .getReadTimeout ()
545+ : clientOptions .getReadTimeout ())
546+ .setMaxNetworkRetries (
547+ options .getMaxNetworkRetries () != null
548+ ? options .getMaxNetworkRetries ()
549+ : clientOptions .getMaxNetworkRetries ())
550+ .setConnectionProxy (
551+ options .getConnectionProxy () != null
552+ ? options .getConnectionProxy ()
553+ : clientOptions .getConnectionProxy ())
554+ .setProxyCredential (
555+ options .getProxyCredential () != null
556+ ? options .getProxyCredential ()
557+ : clientOptions .getProxyCredential ()),
558+ RequestOptions .unsafeGetStripeVersionOverride (options ))
559+ .build ();
544560 }
545561
546562 public static class InvalidRequestOptionsException extends RuntimeException {
0 commit comments