PrimeIPTV Plus v2.1.0版本的 MD5 值为:44f247a9048d0121c6011174ea55496e
以下内容为反编译后的 Stripe.java 源代码,内容仅作参考
package com.stripe.android;
import android.content.Context;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import android.support.annotation.VisibleForTesting;
import com.stripe.android.RequestOptions;
import com.stripe.android.StripeApiHandler;
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.StripeException;
import com.stripe.android.model.AccountParams;
import com.stripe.android.model.BankAccount;
import com.stripe.android.model.Card;
import com.stripe.android.model.Source;
import com.stripe.android.model.SourceParams;
import com.stripe.android.model.StripePaymentSource;
import com.stripe.android.model.Token;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
public class Stripe {
SourceCreator a = new SourceCreator() {
@Override
public void create(@NonNull final SourceParams sourceParams, @NonNull final String str, @Nullable final String str2, @Nullable Executor executor, @NonNull final SourceCallback sourceCallback) {
Stripe.this.executeTask(executor, new AsyncTask<Void, Void, ResponseWrapper>() {
@Override
public ResponseWrapper doInBackground(Void... voidArr) {
try {
return new ResponseWrapper(StripeApiHandler.a(null, Stripe.this.mContext, sourceParams, str, str2, null));
} catch (StripeException e) {
return new ResponseWrapper(e);
}
}
@Override
public void onPostExecute(ResponseWrapper responseWrapper) {
if (responseWrapper.a != null) {
sourceCallback.onSuccess(responseWrapper.a);
} else if (responseWrapper.c != null) {
sourceCallback.onError(responseWrapper.c);
}
}
});
}
};
@VisibleForTesting
TokenCreator b = new TokenCreator() {
@Override
public void create(final Map<String, Object> map, final String str, final String str2, @NonNull final String str3, Executor executor, final TokenCallback tokenCallback) {
Stripe.this.executeTask(executor, new AsyncTask<Void, Void, ResponseWrapper>() {
@Override
public ResponseWrapper doInBackground(Void... voidArr) {
try {
return new ResponseWrapper(StripeApiHandler.a(Stripe.this.mContext, map, RequestOptions.builder(str, str2, RequestOptions.TYPE_QUERY).build(), str3, Stripe.this.mLoggingResponseListener));
} catch (StripeException e) {
return new ResponseWrapper(e);
}
}
@Override
public void onPostExecute(ResponseWrapper responseWrapper) {
Stripe.this.tokenTaskPostExecution(responseWrapper, tokenCallback);
}
});
}
};
private Context mContext;
private String mDefaultPublishableKey;
private StripeApiHandler.LoggingResponseListener mLoggingResponseListener;
private String mStripeAccount;
public class ResponseWrapper {
final Source a;
final Token b;
final Exception c;
private ResponseWrapper(Source source) {
this.a = source;
this.c = null;
this.b = null;
}
private ResponseWrapper(Token token) {
this.b = token;
this.a = null;
this.c = null;
}
private ResponseWrapper(Exception exc) {
this.c = exc;
this.a = null;
this.b = null;
}
}
public interface SourceCreator {
void create(@NonNull SourceParams sourceParams, @NonNull String str, @Nullable String str2, @Nullable Executor executor, @NonNull SourceCallback sourceCallback);
}
@VisibleForTesting
public interface TokenCreator {
void create(Map<String, Object> map, String str, String str2, @NonNull String str3, Executor executor, TokenCallback tokenCallback);
}
public Stripe(@NonNull Context context) {
this.mContext = context;
}
public Stripe(@NonNull Context context, String str) {
this.mContext = context;
setDefaultPublishableKey(str);
}
private void createTokenFromParams(@NonNull Map<String, Object> map, @Size(min = 1) @NonNull String str, @NonNull String str2, @Nullable Executor executor, @NonNull TokenCallback tokenCallback) {
if (tokenCallback == null) {
throw new RuntimeException("Required Parameter: 'callback' is required to use the created token and handle errors");
}
validateKey(str);
this.b.create(map, str, this.mStripeAccount, str2, executor, tokenCallback);
}
public void executeTask(Executor executor, AsyncTask<Void, Void, ResponseWrapper> asyncTask) {
if (executor != null) {
asyncTask.executeOnExecutor(executor, new Void[0]);
} else {
asyncTask.execute(new Void[0]);
}
}
public void tokenTaskPostExecution(ResponseWrapper responseWrapper, TokenCallback tokenCallback) {
if (responseWrapper.b != null) {
tokenCallback.onSuccess(responseWrapper.b);
} else {
tokenCallback.onError(responseWrapper.c != null ? responseWrapper.c : new RuntimeException("Somehow got neither a token response or an error response"));
}
}
private void validateKey(@Size(min = 1) @NonNull String str) {
if (str == null || str.length() == 0) {
throw new IllegalArgumentException("Invalid Publishable Key: You must use a valid publishable key to create a token. For more info, see https://stripe.com/docs/stripe.js.");
}
if (str.startsWith("sk_")) {
throw new IllegalArgumentException("Invalid Publishable Key: You are using a secret key to create a token, instead of the publishable one. For more info, see https://stripe.com/docs/stripe.js");
}
}
public Token createAccountTokenSynchronous(@NonNull AccountParams accountParams) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
return createAccountTokenSynchronous(accountParams, this.mDefaultPublishableKey);
}
public Token createAccountTokenSynchronous(@NonNull AccountParams accountParams, @Nullable String str) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
if ((str == null ? this.mDefaultPublishableKey : str) == null) {
return null;
}
validateKey(str);
try {
return StripeApiHandler.a(this.mContext, accountParams.toParamMap(), RequestOptions.builder(str, this.mStripeAccount, RequestOptions.TYPE_QUERY).build(), Token.TYPE_ACCOUNT, this.mLoggingResponseListener);
} catch (CardException unused) {
return null;
}
}
public void createBankAccountToken(@NonNull BankAccount bankAccount, @NonNull TokenCallback tokenCallback) {
createBankAccountToken(bankAccount, this.mDefaultPublishableKey, null, tokenCallback);
}
public void createBankAccountToken(@NonNull BankAccount bankAccount, @Size(min = 1) @NonNull String str, @Nullable Executor executor, @NonNull TokenCallback tokenCallback) {
if (bankAccount == null) {
throw new RuntimeException("Required parameter: 'bankAccount' is requred to create a token");
}
createTokenFromParams(StripeNetworkUtils.a(this.mContext, bankAccount), str, Token.TYPE_BANK_ACCOUNT, executor, tokenCallback);
}
public Token createBankAccountTokenSynchronous(BankAccount bankAccount) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
return createBankAccountTokenSynchronous(bankAccount, this.mDefaultPublishableKey);
}
public Token createBankAccountTokenSynchronous(BankAccount bankAccount, String str) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
validateKey(str);
RequestOptions build = RequestOptions.builder(str, this.mStripeAccount, RequestOptions.TYPE_QUERY).build();
Context context = this.mContext;
return StripeApiHandler.a(context, StripeNetworkUtils.a(context, bankAccount), build, Token.TYPE_BANK_ACCOUNT, this.mLoggingResponseListener);
}
public void createPiiToken(@NonNull String str, @NonNull TokenCallback tokenCallback) {
createPiiToken(str, this.mDefaultPublishableKey, null, tokenCallback);
}
public void createPiiToken(@NonNull String str, @Size(min = 1) @NonNull String str2, @Nullable Executor executor, @NonNull TokenCallback tokenCallback) {
createTokenFromParams(StripeNetworkUtils.a(this.mContext, str), str2, Token.TYPE_PII, executor, tokenCallback);
}
public Token createPiiTokenSynchronous(@NonNull String str) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
return createPiiTokenSynchronous(str, this.mDefaultPublishableKey);
}
public Token createPiiTokenSynchronous(@NonNull String str, String str2) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
validateKey(str2);
RequestOptions build = RequestOptions.builder(str2, this.mStripeAccount, RequestOptions.TYPE_QUERY).build();
Context context = this.mContext;
return StripeApiHandler.a(context, StripeNetworkUtils.a(context, str), build, Token.TYPE_PII, this.mLoggingResponseListener);
}
public void createSource(@NonNull SourceParams sourceParams, @NonNull SourceCallback sourceCallback) {
createSource(sourceParams, sourceCallback, null, null);
}
public void createSource(@NonNull SourceParams sourceParams, @NonNull SourceCallback sourceCallback, @Nullable String str, @Nullable Executor executor) {
if (str == null) {
str = this.mDefaultPublishableKey;
}
String str2 = str;
if (str2 == null) {
return;
}
this.a.create(sourceParams, str2, this.mStripeAccount, executor, sourceCallback);
}
@Nullable
public Source createSourceSynchronous(@NonNull SourceParams sourceParams) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
return createSourceSynchronous(sourceParams, null);
}
public Source createSourceSynchronous(@NonNull SourceParams sourceParams, @Nullable String str) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
if (str == null) {
str = this.mDefaultPublishableKey;
}
String str2 = str;
if (str2 == null) {
return null;
}
return StripeApiHandler.a(null, this.mContext, sourceParams, str2, this.mStripeAccount, this.mLoggingResponseListener);
}
public void createToken(@NonNull Card card, @NonNull TokenCallback tokenCallback) {
createToken(card, this.mDefaultPublishableKey, tokenCallback);
}
public void createToken(@NonNull Card card, @NonNull String str, @NonNull TokenCallback tokenCallback) {
createToken(card, str, null, tokenCallback);
}
public void createToken(@NonNull Card card, @Size(min = 1) @NonNull String str, @Nullable Executor executor, @NonNull TokenCallback tokenCallback) {
if (card == null) {
throw new RuntimeException("Required Parameter: 'card' is required to create a token");
}
createTokenFromParams(StripeNetworkUtils.a(this.mContext, card), str, "card", executor, tokenCallback);
}
public void createToken(@NonNull Card card, @NonNull Executor executor, @NonNull TokenCallback tokenCallback) {
createToken(card, this.mDefaultPublishableKey, executor, tokenCallback);
}
public Token createTokenSynchronous(Card card) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
return createTokenSynchronous(card, this.mDefaultPublishableKey);
}
public Token createTokenSynchronous(Card card, String str) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
validateKey(str);
RequestOptions build = RequestOptions.builder(str, this.mStripeAccount, RequestOptions.TYPE_QUERY).build();
Context context = this.mContext;
return StripeApiHandler.a(context, StripeNetworkUtils.a(context, card), build, "card", this.mLoggingResponseListener);
}
public void logEventSynchronous(@NonNull List<String> list, @NonNull StripePaymentSource stripePaymentSource) {
RequestOptions.RequestOptionsBuilder builder = RequestOptions.builder(this.mDefaultPublishableKey);
String str = this.mStripeAccount;
if (str != null) {
builder.c(str);
}
StripeApiHandler.a(stripePaymentSource instanceof Token ? LoggingUtils.a(this.mContext, list, this.mDefaultPublishableKey, ((Token) stripePaymentSource).getType()) : LoggingUtils.b(this.mContext, list, this.mDefaultPublishableKey, ((Source) stripePaymentSource).getType()), builder.build(), this.mLoggingResponseListener);
}
public Source retrieveSourceSynchronous(@Size(min = 1) @NonNull String str, @Size(min = 1) @NonNull String str2) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
return retrieveSourceSynchronous(str, str2, null);
}
public Source retrieveSourceSynchronous(@Size(min = 1) @NonNull String str, @Size(min = 1) @NonNull String str2, @Nullable String str3) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
if (str3 == null) {
str3 = this.mDefaultPublishableKey;
}
if (str3 == null) {
return null;
}
return StripeApiHandler.a(str, str2, str3);
}
public void setDefaultPublishableKey(@Size(min = 1) @NonNull String str) {
validateKey(str);
this.mDefaultPublishableKey = str;
}
public void setStripeAccount(@Size(min = 1) @NonNull String str) {
this.mStripeAccount = str;
}
}