// Path: payme/src/main/java/main/java/com/github/jberkel/pay/me/model/ItemType.java
// public enum ItemType {
//     /** normal in app purchase */
//     INAPP,
//     /** subscription */
//     SUBS,
//     /** unknown type */
//     UNKNOWN;
// 
//     public String toString() {
//         return name().toLowerCase(Locale.ENGLISH);
//     }
// 
//     public static ItemType fromString(String type) {
//         for (ItemType t : values()) {
//             if (t.toString().equals(type)) return t;
//         }
//         return UNKNOWN;
//     }
// }
// 
// Path: payme/src/main/java/main/java/com/github/jberkel/pay/me/model/Purchase.java
// public class Purchase {
// 
//     private final String mOrderId;
//     private final String mPackageName;
//     private final String mSku;
//     private final long mPurchaseTime;
//     private final int mPurchaseState;
//     private final String mDeveloperPayload;
//     private final String mToken;
// 
//     private final ItemType mItemType;
//     private final State mState;
//     private final String mSignature;
//     private final String mOriginalJson;
// 
// 
//     /**
//      * @param itemType the item type for this purchase, cannot be null.
//      * @param jsonPurchaseInfo the JSON representation of this purchase
//      * @param signature the signature
//      * @throws JSONException if the purchase cannot be parsed or is invalid.
//      */
//     public Purchase(ItemType itemType, String jsonPurchaseInfo, String signature) throws JSONException {
//         if (itemType == null) throw new IllegalArgumentException("itemType cannot be null");
//         mItemType = itemType;
//         final JSONObject json = new JSONObject(jsonPurchaseInfo);
// 
//         mOrderId = json.optString(ORDER_ID);
//         mPackageName = json.optString(PACKAGE_NAME);
//         mSku = json.optString(PRODUCT_ID);
//         mPurchaseTime = json.optLong(PURCHASE_TIME);
//         mPurchaseState = json.optInt(PURCHASE_STATE);
//         mDeveloperPayload = json.optString(DEVELOPER_PAYLOAD);
//         mToken = json.optString(TOKEN, json.optString(PURCHASE_TOKEN));
// 
//         mOriginalJson = jsonPurchaseInfo;
//         mSignature = signature;
//         mState = State.fromCode(mPurchaseState);
// 
//         if (TextUtils.isEmpty(mSku)) {
//             throw new JSONException("SKU is empty");
//         }
//     }
// 
//     public ItemType getItemType() {
//         return mItemType;
//     }
// 
//     /**
//      * @return A unique order identifier for the transaction. This corresponds to the Google Wallet Order ID.
//      */
//     public String getOrderId() {
//         return mOrderId;
//     }
// 
//     /**
//      *
//      * @return The application package from which the purchase originated.
//      */
//     public String getPackageName() {
//         return mPackageName;
//     }
// 
//     /**
//      * @return The item's product identifier. Every item has a product ID, which you must specify in
//      * the application's product list on the Google Play Developer Console.
//      */
//     public String getSku() {
//         return mSku;
//     }
// 
//     /**
//      * @return The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
//      */
//     public long getPurchaseTime() {
//         return mPurchaseTime;
//     }
// 
//     /**
//      * @return The purchase state of the order. Possible values are 0 (purchased), 1 (canceled), or 2 (refunded).
//      */
//     public int getRawState() {
//         return mPurchaseState;
//     }
// 
//     /**
//      * @return The parsed purchase state of the order.
//      */
//     public State getState() {
//         return mState;
//     }
// 
//     /**
//      * @return A developer-specified string that contains supplemental information about an order. You
//      * can specify a value for this field when you make a getBuyIntent request.
//      */
//     public String getDeveloperPayload() {
//         return mDeveloperPayload;
//     }
// 
//     /**
//      * @return A token that uniquely identifies a purchase for a given item and user pair.
//      */
//     public String getToken() {
//         return mToken;
//     }
// 
//     /**
//      * @return the original JSON response, as received from the billing service.
//      */
//     public String getOriginalJson() {
//         return mOriginalJson;
//     }
// 
//     /**
//      * @return the signature, as received from the billing service.
//      */
//     public String getSignature() { return mSignature; }
// 
//     @Override
//     public String toString() {
//         return "Purchase(type:" + mItemType + "):" + mOriginalJson;
//     }
// 
//     /**
//      * The purchase state of the order.
//      */
//     public enum State {
//         PURCHASED(0),
//         CANCELED(1),
//         REFUNDED(2),
//         UNKNOWN(-1);
// 
//         final int code;
// 
//         State(int code) {
//             this.code = code;
//         }
//         public static State fromCode(int code) {
//             for (State s : values()) {
//                 if (s.code == code) return s;
//             }
//             return UNKNOWN;
//         }
//     }
// 
//     // fields used in service JSON response
//     private static final String PACKAGE_NAME = "packageName";
//     private static final String PRODUCT_ID = "productId";
//     private static final String PURCHASE_TIME = "purchaseTime";
//     private static final String PURCHASE_STATE = "purchaseState";
//     private static final String DEVELOPER_PAYLOAD = "developerPayload";
//     private static final String PURCHASE_TOKEN = "purchaseToken";
//     private static final String TOKEN = "token";
//     private static final String ORDER_ID = "orderId";
// }


import com.github.jberkel.pay.me.listener.OnIabPurchaseFinishedListener;
import com.github.jberkel.pay.me.model.ItemType;
import com.github.jberkel.pay.me.model.Purchase;
import static com.github.jberkel.pay.me.model.ItemType.UNKNOWN;
package com.github.jberkel.pay.me;



class PurchaseFlowState implements OnIabPurchaseFinishedListener {
    static final PurchaseFlowState NONE = new PurchaseFlowState(-1, UNKNOWN, null);

    /** The request code used to launch purchase flow */
    final int requestCode;
    /** The item type of the current purchase flow */
// Path: payme/src/main/java/main/java/com/github/jberkel/pay/me/model/ItemType.java
// public enum ItemType {
//     /** normal in app purchase */
//     INAPP,
//     /** subscription */
//     SUBS,
//     /** unknown type */
//     UNKNOWN;
// 
//     public String toString() {
//         return name().toLowerCase(Locale.ENGLISH);
//     }
// 
//     public static ItemType fromString(String type) {
//         for (ItemType t : values()) {
//             if (t.toString().equals(type)) return t;
//         }
//         return UNKNOWN;
//     }
// }
// 
// Path: payme/src/main/java/main/java/com/github/jberkel/pay/me/model/Purchase.java
// public class Purchase {
// 
//     private final String mOrderId;
//     private final String mPackageName;
//     private final String mSku;
//     private final long mPurchaseTime;
//     private final int mPurchaseState;
//     private final String mDeveloperPayload;
//     private final String mToken;
// 
//     private final ItemType mItemType;
//     private final State mState;
//     private final String mSignature;
//     private final String mOriginalJson;
// 
// 
//     /**
//      * @param itemType the item type for this purchase, cannot be null.
//      * @param jsonPurchaseInfo the JSON representation of this purchase
//      * @param signature the signature
//      * @throws JSONException if the purchase cannot be parsed or is invalid.
//      */
//     public Purchase(ItemType itemType, String jsonPurchaseInfo, String signature) throws JSONException {
//         if (itemType == null) throw new IllegalArgumentException("itemType cannot be null");
//         mItemType = itemType;
//         final JSONObject json = new JSONObject(jsonPurchaseInfo);
// 
//         mOrderId = json.optString(ORDER_ID);
//         mPackageName = json.optString(PACKAGE_NAME);
//         mSku = json.optString(PRODUCT_ID);
//         mPurchaseTime = json.optLong(PURCHASE_TIME);
//         mPurchaseState = json.optInt(PURCHASE_STATE);
//         mDeveloperPayload = json.optString(DEVELOPER_PAYLOAD);
//         mToken = json.optString(TOKEN, json.optString(PURCHASE_TOKEN));
// 
//         mOriginalJson = jsonPurchaseInfo;
//         mSignature = signature;
//         mState = State.fromCode(mPurchaseState);
// 
//         if (TextUtils.isEmpty(mSku)) {
//             throw new JSONException("SKU is empty");
//         }
//     }
// 
//     public ItemType getItemType() {
//         return mItemType;
//     }
// 
//     /**
//      * @return A unique order identifier for the transaction. This corresponds to the Google Wallet Order ID.
//      */
//     public String getOrderId() {
//         return mOrderId;
//     }
// 
//     /**
//      *
//      * @return The application package from which the purchase originated.
//      */
//     public String getPackageName() {
//         return mPackageName;
//     }
// 
//     /**
//      * @return The item's product identifier. Every item has a product ID, which you must specify in
//      * the application's product list on the Google Play Developer Console.
//      */
//     public String getSku() {
//         return mSku;
//     }
// 
//     /**
//      * @return The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
//      */
//     public long getPurchaseTime() {
//         return mPurchaseTime;
//     }
// 
//     /**
//      * @return The purchase state of the order. Possible values are 0 (purchased), 1 (canceled), or 2 (refunded).
//      */
//     public int getRawState() {
//         return mPurchaseState;
//     }
// 
//     /**
//      * @return The parsed purchase state of the order.
//      */
//     public State getState() {
//         return mState;
//     }
// 
//     /**
//      * @return A developer-specified string that contains supplemental information about an order. You
//      * can specify a value for this field when you make a getBuyIntent request.
//      */
//     public String getDeveloperPayload() {
//         return mDeveloperPayload;
//     }
// 
//     /**
//      * @return A token that uniquely identifies a purchase for a given item and user pair.
//      */
//     public String getToken() {
//         return mToken;
//     }
// 
//     /**
//      * @return the original JSON response, as received from the billing service.
//      */
//     public String getOriginalJson() {
//         return mOriginalJson;
//     }
// 
//     /**
//      * @return the signature, as received from the billing service.
//      */
//     public String getSignature() { return mSignature; }
// 
//     @Override
//     public String toString() {
//         return "Purchase(type:" + mItemType + "):" + mOriginalJson;
//     }
// 
//     /**
//      * The purchase state of the order.
//      */
//     public enum State {
//         PURCHASED(0),
//         CANCELED(1),
//         REFUNDED(2),
//         UNKNOWN(-1);
// 
//         final int code;
// 
//         State(int code) {
//             this.code = code;
//         }
//         public static State fromCode(int code) {
//             for (State s : values()) {
//                 if (s.code == code) return s;
//             }
//             return UNKNOWN;
//         }
//     }
// 
//     // fields used in service JSON response
//     private static final String PACKAGE_NAME = "packageName";
//     private static final String PRODUCT_ID = "productId";
//     private static final String PURCHASE_TIME = "purchaseTime";
//     private static final String PURCHASE_STATE = "purchaseState";
//     private static final String DEVELOPER_PAYLOAD = "developerPayload";
//     private static final String PURCHASE_TOKEN = "purchaseToken";
//     private static final String TOKEN = "token";
//     private static final String ORDER_ID = "orderId";
// }


// Path: payme/src/main/java/main/java/com/github/jberkel/pay/me/PurchaseFlowState.java
import com.github.jberkel.pay.me.listener.OnIabPurchaseFinishedListener;
import com.github.jberkel.pay.me.model.ItemType;
import com.github.jberkel.pay.me.model.Purchase;
import static com.github.jberkel.pay.me.model.ItemType.UNKNOWN;

package com.github.jberkel.pay.me;



class PurchaseFlowState implements OnIabPurchaseFinishedListener {
    static final PurchaseFlowState NONE = new PurchaseFlowState(-1, UNKNOWN, null);

    /** The request code used to launch purchase flow */
    final int requestCode;
    /** The item type of the current purchase flow */
    final ItemType itemType;