PrimeIPTV Plus v2.1.0版本的 MD5 值为:44f247a9048d0121c6011174ea55496e
以下内容为反编译后的 StripeApiHandler.java 源代码,内容仅作参考
package com.stripe.android;
import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import com.stripe.android.ErrorParser;
import com.stripe.android.StripeNetworkUtils;
import com.stripe.android.exception.APIConnectionException;
import com.stripe.android.exception.APIException;
import com.stripe.android.exception.AuthenticationException;
import com.stripe.android.exception.CardException;
import com.stripe.android.exception.InvalidRequestException;
import com.stripe.android.exception.PermissionException;
import com.stripe.android.exception.RateLimitException;
import com.stripe.android.exception.StripeException;
import com.stripe.android.model.Customer;
import com.stripe.android.model.ShippingInformation;
import com.stripe.android.model.Source;
import com.stripe.android.model.SourceParams;
import com.stripe.android.model.Token;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.Security;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Scanner;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
class StripeApiHandler {
private static final String CHARSET = "UTF-8";
private static final String CUSTOMERS = "customers";
private static final String DNS_CACHE_TTL_PROPERTY_NAME = "networkaddress.cache.ttl";
private static final String LIVE_API_BASE = "https://api.stripe.com";
private static final String LIVE_LOGGING_BASE = "https://q.stripe.com";
private static final String LOGGING_ENDPOINT = "https://m.stripe.com/4";
private static final String SOURCES = "sources";
private static final SSLSocketFactory SSL_SOCKET_FACTORY = new StripeSSLSocketFactory();
private static final String TOKENS = "tokens";
public interface LoggingResponseListener {
void onLoggingResponse(StripeResponse stripeResponse);
void onStripeException(StripeException stripeException);
boolean shouldLogTest();
}
public static final class Parameter {
public final String key;
public final String value;
Parameter(String str, String str2) {
this.key = str;
this.value = str2;
}
}
public interface StripeResponseListener {
void onStripeResponse(StripeResponse stripeResponse);
}
StripeApiHandler() {
}
@Nullable
public static Customer a(@Nullable Context context, @NonNull String str, @NonNull String str2, @NonNull List<String> list, @NonNull ShippingInformation shippingInformation, @NonNull String str3, @Nullable LoggingResponseListener loggingResponseListener) throws InvalidRequestException, APIConnectionException, APIException, AuthenticationException, CardException {
HashMap hashMap = new HashMap();
hashMap.put("shipping", shippingInformation.toMap());
if (context != null) {
a(LoggingUtils.a(context, list, null, null, str2, "set_shipping_info"), RequestOptions.builder(str2).b("2017-06-05").build(), loggingResponseListener);
}
StripeResponse stripeResponse = getStripeResponse("POST", b(str), hashMap, RequestOptions.builder(str3).b("2017-06-05").build());
a(stripeResponse);
return Customer.fromString(stripeResponse.b());
}
@Nullable
public static Customer a(@NonNull String str, @NonNull String str2) throws InvalidRequestException, APIConnectionException, APIException, AuthenticationException, CardException {
StripeResponse stripeResponse = getStripeResponse("GET", b(str), null, RequestOptions.builder(str2).b("2017-06-05").build());
a(stripeResponse);
return Customer.fromString(stripeResponse.b());
}
@Nullable
public static Source a(@Nullable Context context, @NonNull String str, @NonNull String str2, @NonNull List<String> list, @NonNull String str3, @NonNull String str4, @Nullable LoggingResponseListener loggingResponseListener) throws InvalidRequestException, APIConnectionException, APIException, AuthenticationException, CardException {
HashMap hashMap = new HashMap();
if (context != null) {
a(LoggingUtils.a(context, list, str2), RequestOptions.builder(str2).b("2017-06-05").build(), loggingResponseListener);
}
StripeResponse stripeResponse = getStripeResponse("DELETE", b(str, str3), hashMap, RequestOptions.builder(str4).b("2017-06-05").build());
a(stripeResponse);
return Source.fromString(stripeResponse.b());
}
@Nullable
public static Source a(@Nullable Context context, @NonNull String str, @NonNull String str2, @NonNull List<String> list, @NonNull String str3, @NonNull String str4, @NonNull String str5, @Nullable LoggingResponseListener loggingResponseListener) throws InvalidRequestException, APIConnectionException, APIException, AuthenticationException, CardException {
HashMap hashMap = new HashMap();
hashMap.put(RequestOptions.TYPE_QUERY, str3);
if (context != null) {
a(LoggingUtils.c(context, list, str2, str4), RequestOptions.builder(str2).b("2017-06-05").build(), loggingResponseListener);
}
StripeResponse stripeResponse = getStripeResponse("POST", a(str), hashMap, RequestOptions.builder(str5).b("2017-06-05").build());
a(stripeResponse);
return Source.fromString(stripeResponse.b());
}
@Nullable
public static Source a(@Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String str, @Nullable String str2, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
return a(uidProvider, context, sourceParams, str, str2, loggingResponseListener, (StripeResponseListener) null);
}
@VisibleForTesting
@Nullable
static Source a(@Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String str, @Nullable String str2, @Nullable LoggingResponseListener loggingResponseListener, @Nullable StripeResponseListener stripeResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
Map<String, Object> paramMap = sourceParams.toParamMap();
StripeNetworkUtils.a(uidProvider, context, paramMap);
RequestOptions build = RequestOptions.builder(str, str2, RequestOptions.TYPE_QUERY).build();
try {
String d = build.d();
if (StripeTextUtils.isBlank(d)) {
return null;
}
setTelemetryData(context, loggingResponseListener);
a(LoggingUtils.b(context, null, d, sourceParams.getType()), RequestOptions.builder(str).build(), loggingResponseListener);
StripeResponse requestData = requestData("POST", b(), paramMap, build);
if (stripeResponseListener != null) {
stripeResponseListener.onStripeResponse(requestData);
}
return Source.fromString(requestData.b());
} catch (CardException e) {
throw new APIException(e.getMessage(), e.getRequestId(), e.getStatusCode(), e);
}
}
@Nullable
public static Source a(@NonNull String str, @NonNull String str2, @NonNull String str3) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
try {
return Source.fromString(requestData("GET", c(str), SourceParams.createRetrieveSourceParams(str2), RequestOptions.builder(str3).build()).b());
} catch (CardException e) {
throw new APIException(e.getMessage(), e.getRequestId(), e.getStatusCode(), e);
}
}
@Nullable
public static Token a(@NonNull Context context, @NonNull Map<String, Object> map, @NonNull RequestOptions requestOptions, @NonNull String str, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
String d;
try {
d = requestOptions.d();
} catch (ClassCastException unused) {
map.remove("product_usage");
}
if (StripeTextUtils.isBlank(d)) {
return null;
}
map.remove("product_usage");
setTelemetryData(context, loggingResponseListener);
a(LoggingUtils.a(context, (List) map.get("product_usage"), d, str), requestOptions, loggingResponseListener);
return requestToken("POST", a(), map, requestOptions);
}
@VisibleForTesting
static String a() {
return String.format(Locale.ENGLISH, "%s/v1/%s", LIVE_API_BASE, TOKENS);
}
@VisibleForTesting
static String a(@NonNull String str) {
return String.format(Locale.ENGLISH, "%s/%s", b(str), SOURCES);
}
static String a(Map<String, Object> map) throws UnsupportedEncodingException, InvalidRequestException {
StringBuilder sb = new StringBuilder();
for (Parameter parameter : flattenParams(map)) {
if (sb.length() > 0) {
sb.append("&");
}
sb.append(urlEncodePair(parameter.key, parameter.value));
}
return sb.toString();
}
static Map<String, String> a(RequestOptions requestOptions) {
HashMap hashMap = new HashMap();
hashMap.put("Accept-Charset", "UTF-8");
hashMap.put("Accept", "application/json");
hashMap.put("User-Agent", String.format("Stripe/v1 AndroidBindings/%s", BuildConfig.VERSION_NAME));
if (requestOptions != null) {
hashMap.put("Authorization", String.format(Locale.ENGLISH, "Bearer %s", requestOptions.d()));
}
HashMap hashMap2 = new HashMap();
hashMap2.put("java.version", System.getProperty("java.version"));
hashMap2.put("os.name", "android");
hashMap2.put("os.version", String.valueOf(Build.VERSION.SDK_INT));
hashMap2.put("bindings.version", BuildConfig.VERSION_NAME);
hashMap2.put("lang", "Java");
hashMap2.put("publisher", "Stripe");
hashMap.put("X-Stripe-Client-User-Agent", new JSONObject(hashMap2).toString());
if (requestOptions != null && requestOptions.a() != null) {
hashMap.put("Stripe-Version", requestOptions.a());
}
if (requestOptions != null && requestOptions.f() != null) {
hashMap.put("Stripe-Account", requestOptions.f());
}
if (requestOptions != null && requestOptions.c() != null) {
hashMap.put("Idempotency-Key", requestOptions.c());
}
return hashMap;
}
static void a(StripeResponse stripeResponse) throws InvalidRequestException, APIConnectionException, APIException, AuthenticationException, CardException {
int a = stripeResponse.a();
String b = stripeResponse.b();
Map<String, List<String>> c = stripeResponse.c();
String str = null;
List<String> list = c == null ? null : c.get("Request-Id");
if (list != null && list.size() > 0) {
str = list.get(0);
}
if (a < 200 || a >= 300) {
handleAPIError(b, a, str);
}
}
public static void a(@NonNull Map<String, Object> map, @Nullable RequestOptions requestOptions, @Nullable LoggingResponseListener loggingResponseListener) {
String d;
if (requestOptions == null) {
return;
}
if ((loggingResponseListener != null && !loggingResponseListener.shouldLogTest()) || (d = requestOptions.d()) == null || d.trim().isEmpty()) {
return;
}
fireAndForgetApiCall(map, LIVE_LOGGING_BASE, "GET", requestOptions, loggingResponseListener);
}
private static void attachPseudoCookie(@NonNull HttpURLConnection httpURLConnection, @NonNull RequestOptions requestOptions) {
if (requestOptions.b() == null || TextUtils.isEmpty(requestOptions.b())) {
return;
}
httpURLConnection.setRequestProperty("Cookie", "m=" + requestOptions.b());
}
@Nullable
public static Customer b(@Nullable Context context, @NonNull String str, @NonNull String str2, @NonNull List<String> list, @NonNull String str3, @NonNull String str4, @NonNull String str5, @Nullable LoggingResponseListener loggingResponseListener) throws InvalidRequestException, APIConnectionException, APIException, AuthenticationException, CardException {
HashMap hashMap = new HashMap();
hashMap.put("default_source", str3);
if (context != null) {
a(LoggingUtils.a(context, list, str4, null, str2, "default_source"), RequestOptions.builder(str2).b("2017-06-05").build(), loggingResponseListener);
}
StripeResponse stripeResponse = getStripeResponse("POST", b(str), hashMap, RequestOptions.builder(str5).b("2017-06-05").build());
a(stripeResponse);
return Customer.fromString(stripeResponse.b());
}
@VisibleForTesting
static String b() {
return String.format(Locale.ENGLISH, "%s/v1/%s", LIVE_API_BASE, SOURCES);
}
@VisibleForTesting
static String b(@NonNull String str) {
return String.format(Locale.ENGLISH, "%s/%s", c(), str);
}
@VisibleForTesting
static String b(@NonNull String str, @NonNull String str2) {
return String.format(Locale.ENGLISH, "%s/%s", a(str), str2);
}
@VisibleForTesting
static String c() {
return String.format(Locale.ENGLISH, "%s/v1/%s", LIVE_API_BASE, CUSTOMERS);
}
@VisibleForTesting
static String c(@NonNull String str) {
return String.format(Locale.ENGLISH, "%s/%s", b(), str);
}
private static HttpURLConnection createDeleteConnection(@NonNull String str, @NonNull RequestOptions requestOptions) throws IOException {
HttpURLConnection createStripeConnection = createStripeConnection(str, requestOptions);
createStripeConnection.setRequestMethod("DELETE");
return createStripeConnection;
}
private static HttpURLConnection createGetConnection(String str, String str2, RequestOptions requestOptions) throws IOException {
HttpURLConnection createStripeConnection = createStripeConnection(formatURL(str, str2), requestOptions);
createStripeConnection.setRequestMethod("GET");
return createStripeConnection;
}
private static HttpURLConnection createPostConnection(@NonNull String str, @NonNull Map<String, Object> map, @NonNull RequestOptions requestOptions) throws IOException, InvalidRequestException {
OutputStream outputStream;
HttpURLConnection createStripeConnection = createStripeConnection(str, requestOptions);
createStripeConnection.setDoOutput(true);
createStripeConnection.setRequestMethod("POST");
createStripeConnection.setRequestProperty("Content-Type", getContentType(requestOptions));
try {
outputStream = createStripeConnection.getOutputStream();
try {
outputStream.write(getOutputBytes(map, requestOptions));
if (outputStream != null) {
outputStream.close();
}
return createStripeConnection;
} catch (Throwable th) {
th = th;
if (outputStream != null) {
outputStream.close();
}
throw th;
}
} catch (Throwable th2) {
th = th2;
outputStream = null;
}
}
private static HttpURLConnection createStripeConnection(String str, RequestOptions requestOptions) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setConnectTimeout(30000);
httpURLConnection.setReadTimeout(80000);
httpURLConnection.setUseCaches(false);
if (urlNeedsHeaderData(str)) {
for (Map.Entry<String, String> entry : a(requestOptions).entrySet()) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
if (urlNeedsPseudoCookie(str)) {
attachPseudoCookie(httpURLConnection, requestOptions);
}
if (httpURLConnection instanceof HttpsURLConnection) {
((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(SSL_SOCKET_FACTORY);
}
return httpURLConnection;
}
private static void fireAndForgetApiCall(@NonNull Map<String, Object> map, @NonNull String str, @NonNull String str2, @Nullable RequestOptions requestOptions, @Nullable LoggingResponseListener loggingResponseListener) {
Boolean bool = true;
String str3 = null;
try {
str3 = Security.getProperty(DNS_CACHE_TTL_PROPERTY_NAME);
Security.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, "0");
} catch (SecurityException unused) {
bool = false;
}
try {
try {
StripeResponse stripeResponse = getStripeResponse(str2, str, map, requestOptions);
if (loggingResponseListener != null) {
loggingResponseListener.onLoggingResponse(stripeResponse);
}
} catch (StripeException e) {
if (loggingResponseListener != null) {
loggingResponseListener.onStripeException(e);
}
if (!bool.booleanValue()) {
}
}
} finally {
if (bool.booleanValue()) {
if (str3 == null) {
Security.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, "-1");
} else {
Security.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, str3);
}
}
}
}
private static List<Parameter> flattenParams(Map<String, Object> map) throws InvalidRequestException {
return flattenParamsMap(map, null);
}
private static List<Parameter> flattenParamsList(List<Object> list, String str) throws InvalidRequestException {
LinkedList linkedList = new LinkedList();
String format = String.format("%s[]", str);
if (list.isEmpty()) {
linkedList.add(new Parameter(str, ""));
} else {
for (Object obj : list) {
linkedList.addAll(flattenParamsValue(obj, format));
}
}
return linkedList;
}
private static List<Parameter> flattenParamsMap(Map<String, Object> map, String str) throws InvalidRequestException {
LinkedList linkedList = new LinkedList();
if (map == null) {
return linkedList;
}
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (str != null) {
key = String.format("%s[%s]", str, key);
}
linkedList.addAll(flattenParamsValue(value, key));
}
return linkedList;
}
private static List<Parameter> flattenParamsValue(Object obj, String str) throws InvalidRequestException {
if (obj instanceof Map) {
return flattenParamsMap((Map) obj, str);
}
if (obj instanceof List) {
return flattenParamsList((List) obj, str);
}
if ("".equals(obj)) {
throw new InvalidRequestException("You cannot set '" + str + "' to an empty string. We interpret empty strings as null in requests. You may set '" + str + "' to null to delete the property.", str, null, 0, null);
} else if (obj == null) {
LinkedList linkedList = new LinkedList();
linkedList.add(new Parameter(str, ""));
return linkedList;
} else {
LinkedList linkedList2 = new LinkedList();
linkedList2.add(new Parameter(str, obj.toString()));
return linkedList2;
}
}
private static String formatURL(String str, String str2) {
if (str2 == null || str2.isEmpty()) {
return str;
}
return String.format("%s%s%s", str, str.contains("?") ? "&" : "?", str2);
}
private static String getContentType(@NonNull RequestOptions requestOptions) {
String str;
Object[] objArr;
if (RequestOptions.TYPE_JSON.equals(requestOptions.e())) {
str = "application/json; charset=%s";
objArr = new Object[]{"UTF-8"};
} else {
str = "application/x-www-form-urlencoded;charset=%s";
objArr = new Object[]{"UTF-8"};
}
return String.format(str, objArr);
}
private static byte[] getOutputBytes(@NonNull Map<String, Object> map, @NonNull RequestOptions requestOptions) throws InvalidRequestException {
try {
if (RequestOptions.TYPE_JSON.equals(requestOptions.e())) {
JSONObject mapToJsonObject = mapToJsonObject(map);
if (mapToJsonObject != null) {
return mapToJsonObject.toString().getBytes("UTF-8");
}
throw new InvalidRequestException("Unable to create JSON data from parameters. Please contact support@stripe.com for assistance.", null, null, 0, null);
}
return a(map).getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new InvalidRequestException("Unable to encode parameters to UTF-8. Please contact support@stripe.com for assistance.", null, null, 0, e);
}
}
private static String getResponseBody(InputStream inputStream) throws IOException {
Scanner useDelimiter = new Scanner(inputStream, "UTF-8").useDelimiter("\\A");
String next = useDelimiter.hasNext() ? useDelimiter.next() : null;
inputStream.close();
return next;
}
private static StripeResponse getStripeResponse(String str, String str2, Map<String, Object> map, RequestOptions requestOptions) throws InvalidRequestException, APIConnectionException, APIException {
HttpURLConnection createGetConnection;
char c = 65535;
HttpURLConnection httpURLConnection = null;
try {
try {
int hashCode = str.hashCode();
if (hashCode != 70454) {
if (hashCode != 2461856) {
if (hashCode == 2012838315 && str.equals("DELETE")) {
c = 2;
}
} else if (str.equals("POST")) {
c = 1;
}
} else if (str.equals("GET")) {
c = 0;
}
switch (c) {
case 0:
createGetConnection = createGetConnection(str2, a(map), requestOptions);
break;
case 1:
createGetConnection = createPostConnection(str2, map, requestOptions);
break;
case 2:
createGetConnection = createDeleteConnection(str2, requestOptions);
break;
default:
throw new APIConnectionException(String.format("Unrecognized HTTP method %s. This indicates a bug in the Stripe bindings. Please contact support@stripe.com for assistance.", str));
}
HttpURLConnection httpURLConnection2 = createGetConnection;
int responseCode = httpURLConnection2.getResponseCode();
StripeResponse stripeResponse = new StripeResponse(responseCode, getResponseBody((responseCode < 200 || responseCode >= 300) ? httpURLConnection2.getErrorStream() : httpURLConnection2.getInputStream()), httpURLConnection2.getHeaderFields());
if (httpURLConnection2 != null) {
httpURLConnection2.disconnect();
}
return stripeResponse;
} catch (IOException e) {
throw new APIConnectionException(String.format("IOException during API request to Stripe (%s): %s Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support@stripe.com.", a(), e.getMessage()), e);
}
} catch (Throwable th) {
if (0 != 0) {
httpURLConnection.disconnect();
}
throw th;
}
}
private static void handleAPIError(String str, int i, String str2) throws InvalidRequestException, AuthenticationException, CardException, APIException {
ErrorParser.StripeError a = ErrorParser.a(str);
if (i == 429) {
throw new RateLimitException(a.message, a.param, str2, Integer.valueOf(i), null);
}
switch (i) {
case 400:
throw new InvalidRequestException(a.message, a.param, str2, Integer.valueOf(i), null);
case 401:
throw new AuthenticationException(a.message, str2, Integer.valueOf(i));
case 402:
throw new CardException(a.message, str2, a.code, a.param, a.decline_code, a.charge, Integer.valueOf(i), null);
case 403:
throw new PermissionException(a.message, str2, Integer.valueOf(i));
case 404:
throw new InvalidRequestException(a.message, a.param, str2, Integer.valueOf(i), null);
default:
throw new APIException(a.message, str2, Integer.valueOf(i), null);
}
}
@Nullable
private static JSONArray listToJsonArray(@Nullable List list) {
if (list == null) {
return null;
}
JSONArray jSONArray = new JSONArray();
for (Object obj : list) {
if (obj instanceof Map) {
obj = mapToJsonObject((Map) obj);
} else if (obj instanceof List) {
obj = listToJsonArray((List) obj);
} else if (!(obj instanceof Number) && !(obj instanceof Boolean)) {
obj = obj.toString();
}
jSONArray.put(obj);
}
return jSONArray;
}
@Nullable
private static JSONObject mapToJsonObject(@Nullable Map<String, ? extends Object> map) {
if (map == null) {
return null;
}
JSONObject jSONObject = new JSONObject();
for (String str : map.keySet()) {
Object obj = map.get(str);
if (obj != null) {
try {
if (obj instanceof Map) {
jSONObject.put(str, mapToJsonObject((Map) obj));
} else {
if (obj instanceof List) {
obj = listToJsonArray((List) obj);
} else if (!(obj instanceof Number) && !(obj instanceof Boolean)) {
obj = obj.toString();
}
jSONObject.put(str, obj);
}
} catch (ClassCastException | JSONException unused) {
}
}
}
return jSONObject;
}
private static StripeResponse requestData(String str, String str2, Map<String, Object> map, RequestOptions requestOptions) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
String str3;
String str4 = null;
if (requestOptions == null) {
return null;
}
Boolean bool = true;
try {
str3 = Security.getProperty(DNS_CACHE_TTL_PROPERTY_NAME);
} catch (SecurityException unused) {
str3 = null;
}
try {
Security.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, "0");
} catch (SecurityException unused2) {
bool = false;
if (requestOptions.d().trim().isEmpty()) {
}
}
if (requestOptions.d().trim().isEmpty()) {
StripeResponse stripeResponse = getStripeResponse(str, str2, map, requestOptions);
int a = stripeResponse.a();
String b = stripeResponse.b();
Map<String, List<String>> c = stripeResponse.c();
List<String> list = c == null ? null : c.get("Request-Id");
if (list != null && list.size() > 0) {
str4 = list.get(0);
}
if (a < 200 || a >= 300) {
handleAPIError(b, a, str4);
}
if (bool.booleanValue()) {
if (str3 == null) {
Security.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, "-1");
} else {
Security.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, str3);
}
}
return stripeResponse;
}
throw new AuthenticationException("No API key provided. (HINT: set your API key using 'Stripe.apiKey = <API-KEY>'. You can generate API keys from the Stripe web interface. See https://stripe.com/api for details or email support@stripe.com if you have questions.", null, 0);
}
@Nullable
private static Token requestToken(String str, String str2, Map<String, Object> map, RequestOptions requestOptions) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
return Token.fromString(requestData(str, str2, map, requestOptions).b());
}
private static void setTelemetryData(@NonNull Context context, @Nullable LoggingResponseListener loggingResponseListener) {
Map<String, Object> a = TelemetryClientUtil.a(context);
StripeNetworkUtils.removeNullAndEmptyParams(a);
if (loggingResponseListener == null || loggingResponseListener.shouldLogTest()) {
fireAndForgetApiCall(a, LOGGING_ENDPOINT, "POST", RequestOptions.builder(null, RequestOptions.TYPE_JSON).a(TelemetryClientUtil.b(context)).build(), loggingResponseListener);
}
}
private static String urlEncode(String str) throws UnsupportedEncodingException {
if (str == null) {
return null;
}
return URLEncoder.encode(str, "UTF-8");
}
private static String urlEncodePair(String str, String str2) throws UnsupportedEncodingException {
return String.format("%s=%s", urlEncode(str), urlEncode(str2));
}
private static boolean urlNeedsHeaderData(@NonNull String str) {
return str.startsWith(LIVE_API_BASE) || str.startsWith(LIVE_LOGGING_BASE);
}
private static boolean urlNeedsPseudoCookie(@NonNull String str) {
return str.startsWith(LOGGING_ENDPOINT);
}
}