// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java
// public interface IPayable extends IResult {
//     void pay(String data, OnCallback<String> callback);
// }
// 
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java
// public interface OnCallback<T> {
//     void onStarted(Activity activity);
//     void onCompleted(Activity activity);
//     void onSucceed(Activity activity, T result);
//     void onFailed(Activity activity, int code, String message);
// }
// 
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java
// public class Platform {
//     final String name;
//     final String appId;
// 
//     Map<String, String> extra;
// 
//     public Platform(@NonNull String name, @NonNull String appId) {
//         this.name = name;
//         this.appId = appId;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public String getAppId() {
//         return appId;
//     }
// 
//     public String extra(String key) {
//         return extra == null ? "" : extra.get(key);
//     }
// 
//     public Platform extra(String key, String value) {
//         if (extra == null) {
//             extra = new HashMap<>();
//         }
//         extra.put(key, value);
//         return this;
//     }
// }
// 
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java
// public class ResultCode {
//     public static final int RESULT_OK = 0;
//     public static final int RESULT_PENDING = 1;
//     public static final int RESULT_CANCELLED = 2;
//     public static final int RESULT_FAILED = 3;
// 
// }


import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import com.alipay.sdk.app.PayTask;
import ezy.sdk3rd.social.payment.IPayable;
import ezy.sdk3rd.social.sdk.OnCallback;
import ezy.sdk3rd.social.sdk.Platform;
import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.alipay;





public class Alipay implements IPayable {
    public static final String TAG = "ezy.sdk3rd.alipay";

    Activity mActivity;

    Alipay(Activity activity, Platform platform) {
        mActivity = activity;
    }

    @Override
    public void pay(final String data, final OnCallback<String> callback) {

        new AsyncTask<String, Void, Result>() {
            @Override
            protected void onPreExecute() {
                callback.onStarted(mActivity);
            }

            @Override
            protected Result doInBackground(String... params) {
                final PayTask task = new PayTask(mActivity);
                return new Result(task.payV2(data, true));
            }

            @Override
            protected void onPostExecute(Result result) {
                String message = "[" + result.resultStatus + "]" + result.resultText;
                if (result.isSuccess()) {
                    callback.onSucceed(mActivity, "");
                } else if (result.isPending()) {
                    callback.onFailed(mActivity, ResultCode.RESULT_PENDING, message);
                } else if (result.isCancelled()){
                    callback.onFailed(mActivity, ResultCode.RESULT_CANCELLED, message);
                } else {
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java
// public interface IPayable extends IResult {
//     void pay(String data, OnCallback<String> callback);
// }
// 
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java
// public interface OnCallback<T> {
//     void onStarted(Activity activity);
//     void onCompleted(Activity activity);
//     void onSucceed(Activity activity, T result);
//     void onFailed(Activity activity, int code, String message);
// }
// 
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java
// public class Platform {
//     final String name;
//     final String appId;
// 
//     Map<String, String> extra;
// 
//     public Platform(@NonNull String name, @NonNull String appId) {
//         this.name = name;
//         this.appId = appId;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public String getAppId() {
//         return appId;
//     }
// 
//     public String extra(String key) {
//         return extra == null ? "" : extra.get(key);
//     }
// 
//     public Platform extra(String key, String value) {
//         if (extra == null) {
//             extra = new HashMap<>();
//         }
//         extra.put(key, value);
//         return this;
//     }
// }
// 
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java
// public class ResultCode {
//     public static final int RESULT_OK = 0;
//     public static final int RESULT_PENDING = 1;
//     public static final int RESULT_CANCELLED = 2;
//     public static final int RESULT_FAILED = 3;
// 
// }


// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import com.alipay.sdk.app.PayTask;
import ezy.sdk3rd.social.payment.IPayable;
import ezy.sdk3rd.social.sdk.OnCallback;
import ezy.sdk3rd.social.sdk.Platform;
import ezy.sdk3rd.social.sdk.ResultCode;

package ezy.sdk3rd.social.platforms.alipay;





public class Alipay implements IPayable {
    public static final String TAG = "ezy.sdk3rd.alipay";

    Activity mActivity;

    Alipay(Activity activity, Platform platform) {
        mActivity = activity;
    }

    @Override
    public void pay(final String data, final OnCallback<String> callback) {

        new AsyncTask<String, Void, Result>() {
            @Override
            protected void onPreExecute() {
                callback.onStarted(mActivity);
            }

            @Override
            protected Result doInBackground(String... params) {
                final PayTask task = new PayTask(mActivity);
                return new Result(task.payV2(data, true));
            }

            @Override
            protected void onPostExecute(Result result) {
                String message = "[" + result.resultStatus + "]" + result.resultText;
                if (result.isSuccess()) {
                    callback.onSucceed(mActivity, "");
                } else if (result.isPending()) {
                    callback.onFailed(mActivity, ResultCode.RESULT_PENDING, message);
                } else if (result.isCancelled()){
                    callback.onFailed(mActivity, ResultCode.RESULT_CANCELLED, message);
                } else {
                    callback.onFailed(mActivity, ResultCode.RESULT_FAILED, message);