InAppBillingPurchase implements Parcelable, Purchase { public static InAppBillingPurchase create(String json) throws JSONException { return create(new JSONObject(json)); }  abstract Purchase purchase(); abstract String packageName(); abstract String dataSignature(); abstract boolean autoRenewing(); abstract long purchaseTime(); abstract int purchaseState(); abstract String receipt(); Product product(); String orderId(); String token(); String developerPayload(); static InAppBillingPurchase create(String json); static InAppBillingPurchase create(JSONObject json); static InAppBillingPurchase create(Product product, Intent purchaseIntent); static InAppBillingPurchase create(Product product, String purchaseData,
                                            String dataSignature); static InAppBillingPurchase create(Purchase purchase, String packageName,
                                            String dataSignature, boolean autoRenew,
                                            long purchaseTime, int purchaseState,
                                            String purchaseData); boolean purchased(); boolean canceled(); boolean refunded(); boolean isTestPurchase(); @Override JSONObject toJson(); static final String GP_ORDER_ID_TEST; static final String GP_KEY_PACKAGE_NAME; static final String GP_KEY_DATA_SIG; static final String GP_KEY_AUTO_RENEW; static final String GP_KEY_PURCHASE_TIME; static final String GP_KEY_PURCHASE_STATE; static final String GP_KEY_PURCHASE_DATA; }
@Test public void acceptsValidJson() throws JSONException { Product product = Product.create(IN_APP_BILLING_PURCHASE_VALID_PRODUCT_JSON); InAppBillingPurchase.create(product, VALID_PURCHASE_RECEIPT_JSON, "test"); InAppBillingPurchase.create(VALID_ONE_TIME_PURCHASE_JSON); }
@Test(expected = JSONException.class) public void rejectsInvalidJson() throws JSONException { InAppBillingPurchase.create("bad json"); }
@Test public void isParcelable() throws JSONException { Product product = Product.create(IN_APP_BILLING_PURCHASE_VALID_PRODUCT_JSON); InAppBillingPurchase purchase = InAppBillingPurchase.create(product, VALID_PURCHASE_RECEIPT_JSON, "test"); Bundle bundle = new Bundle(); String key = "purchase"; bundle.putParcelable(key, purchase); assertThat(bundle.getParcelable(key)).isEqualTo(purchase); }