public static Transaction convertJSONPurchaseToTransaction(String inAppPurchaseData) throws JSONException { if (inAppPurchaseData == null) { // this can happen when purchase was cancelled, ie for test product id 'android.test.canceled' throw new JSONException("inAppPurchaseData was null."); } JSONObject object = new JSONObject(inAppPurchaseData); Transaction transaction = new Transaction(); transaction.setStoreName(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE); if (object.has(PURCHASE_TOKEN)) { transaction.setTransactionData(object.getString(PURCHASE_TOKEN)); } if (object.has(ORDER_ID)) { transaction.setOrderId(object.getString(ORDER_ID)); } transaction.setIdentifier(object.getString(PRODUCT_ID)); transaction.setPurchaseTime(new Date(object.getLong(PURCHASE_TIME))); if (object.has(PURCHASE_STATE)) { fillTransactionForPurchaseState(transaction, object.getInt(PURCHASE_STATE)); } return transaction; }
public static Transaction transactionFullEditionEuroGooglePlaySandbox() { Transaction transaction = new Transaction(); transaction.setPurchaseCostCurrency("EUR"); transaction.setPurchaseCost(100); transaction.setStoreName(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE); transaction.setPurchaseTime(new Date()); transaction.setIdentifier(PRODUCT_IDENTIFIER_FULL_EDITION); transaction.setTransactionData("minodojglppganfbiedlabed.AO-J1OyNtpooSraUdtKlZ_9gYs0o20ZF_0ryTNACmvaaaG5EwPX0hPruUdGbE3XejoXYCYzJA2xjjAxrDLFhmu9WC4fvTDNL-RDXCWjlHKpzLOigxCr1QhScXR8uXtX8R94iV6MmMHqD"); return transaction; }
transaction.setIdentifier(purchase.getSku()); transaction.setOrderId(purchase.getOrderId()); transaction.setRequestId(purchase.getPurchaseToken());
/** Converts a Receipt to our transaction object. */ static Transaction convertReceiptToTransaction(int i, String requestId, Receipt receipt, final UserData userData) { // build the transaction from the purchase object Transaction transaction = new Transaction(); transaction.setIdentifier(receipt.getSku()); transaction.setOrderId(receipt.getReceiptId()); transaction.setStoreName(PurchaseManagerConfig.STORE_NAME_ANDROID_AMAZON); transaction.setRequestId(requestId); transaction.setUserId(userData.getUserId()); transaction.setPurchaseTime(receipt.getPurchaseDate()); transaction.setPurchaseText("Purchased: " + receipt.getSku().toString()); // transaction.setPurchaseCost(receipt.getSku()); // TODO: GdxPay: impl. // parsing of COST + CURRENCY via skuDetails.getPrice()! // transaction.setPurchaseCostCurrency(null); if (receipt.isCanceled()) { // order has been refunded or cancelled transaction.setReversalTime(receipt.getCancelDate()); // transaction.setReversalText(receipt..getPurchaseState() == 1 ? // "Cancelled" : "Refunded"); } else { // still valid! transaction.setReversalTime(null); transaction.setReversalText(null); } transaction.setTransactionData(receipt.toJSON().toString()); // transaction.setTransactionDataSignature(purchase.getSignature()); return transaction; }
transaction.setIdentifier(offerForStore.getIdentifier());
transaction.setIdentifier(offerForStore.getIdentifier());