CashierPurchase implements Purchase { public JSONObject toJson() throws JSONException { final JSONObject object = product().toJson(); object.put(KEY_ORDER_ID, orderId()); object.put(KEY_TOKEN, token()); object.put(KEY_RECEIPT, receipt()); object.put(KEY_DEV_PAYLOAD, developerPayload()); return object; }  abstract Product product(); abstract String orderId(); abstract String token(); abstract String receipt(); abstract String developerPayload(); static CashierPurchase create(String json); static CashierPurchase create(JSONObject json); static CashierPurchase create(Product product,
                                       String orderId,
                                       String token,
                                       String receipt,
                                       String developerPayload); JSONObject toJson(); static final String KEY_ORDER_ID; static final String KEY_TOKEN; static final String KEY_RECEIPT; static final String KEY_DEV_PAYLOAD; }
@Test public void serializesToJson() throws JSONException { assertJsonHasProperties(purchase.toJson(), purchase); }