use of com.amazon.purchase.model.Product in project zype-firebuilder by zype.
the class ProductsAction method onResponse.
/**
* Inform the user of the request completion.
*
* @param requestId The request id of this call.
*/
private void onResponse(String requestId) {
Log.d(TAG, "onResponse(): request=" + requestId);
Response response = mPurchaseManager.responseMap.get(requestId);
Map<String, Product> products = mPurchaseManager.productsDataMap.get(requestId);
if (mPurchaseManagerListener != null) {
mPurchaseManagerListener.onProductDataResponse(response, products);
}
cleanUp(requestId);
}
use of com.amazon.purchase.model.Product in project zype-firebuilder by zype.
the class AmazonInAppPurchase method createIapPurchasingListener.
/**
* Creates IAP purchase listener from PurchaseListener.
*/
/*package private*/
PurchasingListener createIapPurchasingListener(final PurchaseListener listener) {
Log.d(TAG, "PurchasingListener registered");
return new PurchasingListener() {
@Override
public void onUserDataResponse(UserDataResponse userDataResponse) {
Log.d(TAG, "UserDataResponse received " + userDataResponse.toString());
Response response = createResponse(isSuccessful(userDataResponse), userDataResponse.getRequestId().toString());
UserData userData = createUserDataFromIapUserData(userDataResponse.getUserData());
listener.onGetUserDataResponse(response, userData);
}
@Override
public void onProductDataResponse(ProductDataResponse productDataResponse) {
Log.d(TAG, "ProductDataResponse received " + productDataResponse.toString());
Response response = createResponse(isSuccessful(productDataResponse), productDataResponse.getRequestId().toString());
Map<String, Product> productMap = createProductMapFromProductDataResponse(productDataResponse.getProductData());
listener.onProductDataResponse(response, productMap, productDataResponse.getUnavailableSkus());
}
@Override
public void onPurchaseResponse(PurchaseResponse purchaseResponse) {
Log.d(TAG, "purchaseResponse received " + purchaseResponse.toString());
Response response = createResponse(isSuccessful(purchaseResponse), purchaseResponse.getRequestId().toString());
com.amazon.device.iap.model.Receipt iapReceipt = purchaseResponse.getReceipt();
String sku = null;
if (iapReceipt != null) {
sku = iapReceipt.getSku();
}
listener.onPurchaseResponse(response, sku, createReceipt(iapReceipt), createUserDataFromIapUserData(purchaseResponse.getUserData()));
}
@Override
public void onPurchaseUpdatesResponse(PurchaseUpdatesResponse purchaseUpdatesResponse) {
Log.d(TAG, "purchaseUpdatesResponse received " + purchaseUpdatesResponse.toString());
Response response = createResponse(isSuccessful(purchaseUpdatesResponse), purchaseUpdatesResponse.getRequestId().toString());
List<Receipt> receipts = createReceiptList(purchaseUpdatesResponse.getReceipts());
UserData userData = createUserDataFromIapUserData(purchaseUpdatesResponse.getUserData());
listener.onUserDataResponse(response, receipts, userData, purchaseUpdatesResponse.hasMore());
}
};
}
use of com.amazon.purchase.model.Product in project zype-firebuilder by zype.
the class PurchaseHelper method initializePurchaseSystem.
/**
* Method to initialize purchase system
*/
private void initializePurchaseSystem() {
// The purchase system should be initialized by the module initializer, if there is no
// initializer available that means the purchase system is not needed.
IPurchase purchaseSystem = (IPurchase) ModuleManager.getInstance().getModule(IPurchase.class.getSimpleName()).getImpl(true);
if (purchaseSystem == null) {
Log.i(TAG, "Purchase system not registered.");
return;
}
try {
registerSkuForActions();
} catch (Exception e) {
Log.e(TAG, "Could not register actions!!", e);
}
// Register the purchase system received via ModuleManager and configure the purchase
// listener.
this.mPurchaseManager = PurchaseManager.getInstance(mContext.getApplicationContext());
try {
mPurchaseManager.init(purchaseSystem, new PurchaseManagerListener() {
@Override
public void onRegisterSkusResponse(Response response) {
if (response == null || !Response.Status.SUCCESSFUL.equals(response.getStatus())) {
Log.e(TAG, "Register products failed " + response);
} else {
// If there is a valid receipt available in the system, set content browser
// variable as true.
String sku = mPurchaseManager.getPurchasedSku();
if (sku == null) {
setSubscription(false, null);
} else {
setSubscription(true, sku);
}
Log.d(TAG, "Register products complete.");
}
mContentBrowser.updateContentActions();
}
@Override
public void onValidPurchaseResponse(Response response, boolean validity, String sku) {
Log.e(TAG, "You should not hit here!!!");
}
/* Zype, Evgeny Cherkasov
* begin */
@Override
public void onProductDataResponse(Response response, Map<String, Product> products) {
Log.e(TAG, "You should not hit here!!!");
}
// @Override
// public String getVideoId() {
// Log.e(TAG, "You should not hit here!!!");
// return null;
// }
@Override
public Bundle getPurchaseExtras() {
Log.e(TAG, "You should not hit here!!!");
return null;
}
});
} catch (Exception e) {
Log.e(TAG, "Could not configure the purchase system. ", e);
}
}
use of com.amazon.purchase.model.Product in project zype-firebuilder by zype.
the class AmazonInAppPurchase method createProductFromIapProduct.
/**
* Converts an IAP product to a purchase product.
*
* @param iapProduct The IAP product to be converted.
* @return The purchase product.
*/
private Product createProductFromIapProduct(com.amazon.device.iap.model.Product iapProduct) {
if (iapProduct == null) {
return null;
}
Product product = new Product();
product.setPrice(iapProduct.getPrice());
product.setSku(iapProduct.getSku());
product.setTitle(iapProduct.getTitle());
product.setDescription(iapProduct.getDescription());
product.setIconUrl(iapProduct.getSmallIconUrl());
product.setProductType(getProductType(iapProduct.getProductType()));
return product;
}
Aggregations