package com.android.billingclient.api; import android.text.TextUtils; import com.unity3d.ads.metadata.InAppPurchaseMetaData; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes.dex */ public class Purchase { /* renamed from: a, reason: collision with root package name */ private final String f3898a; /* renamed from: b, reason: collision with root package name */ private final String f3899b; /* renamed from: c, reason: collision with root package name */ private final JSONObject f3900c; public Purchase(String str, String str2) { this.f3898a = str; this.f3899b = str2; this.f3900c = new JSONObject(str); } private final ArrayList i() { ArrayList arrayList = new ArrayList(); if (this.f3900c.has("productIds")) { JSONArray optJSONArray = this.f3900c.optJSONArray("productIds"); if (optJSONArray != null) { for (int i10 = 0; i10 < optJSONArray.length(); i10++) { arrayList.add(optJSONArray.optString(i10)); } } } else if (this.f3900c.has(InAppPurchaseMetaData.KEY_PRODUCT_ID)) { arrayList.add(this.f3900c.optString(InAppPurchaseMetaData.KEY_PRODUCT_ID)); } return arrayList; } public String a() { String optString = this.f3900c.optString("orderId"); if (TextUtils.isEmpty(optString)) { return null; } return optString; } public String b() { return this.f3898a; } public String c() { return this.f3900c.optString("packageName"); } public List d() { return i(); } public int e() { return this.f3900c.optInt("purchaseState", 1) != 4 ? 1 : 2; } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Purchase)) { return false; } Purchase purchase = (Purchase) obj; return TextUtils.equals(this.f3898a, purchase.b()) && TextUtils.equals(this.f3899b, purchase.h()); } public long f() { return this.f3900c.optLong("purchaseTime"); } public String g() { JSONObject jSONObject = this.f3900c; return jSONObject.optString("token", jSONObject.optString("purchaseToken")); } public String h() { return this.f3899b; } public int hashCode() { return this.f3898a.hashCode(); } public String toString() { return "Purchase. Json: ".concat(String.valueOf(this.f3898a)); } }