use of com.amazon.device.iap.model.PurchaseUpdatesResponse 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.device.iap.model.PurchaseUpdatesResponse in project SeriesGuide by UweTrottmann.
the class AmazonPurchasingListener method onPurchaseUpdatesResponse.
/**
* Callback for {@link PurchasingService#getPurchaseUpdates}.
*
* You will receive receipts for all possible purchase history from this callback.
*/
@Override
public void onPurchaseUpdatesResponse(final PurchaseUpdatesResponse response) {
Timber.d("onPurchaseUpdatesResponse: requestId (%s) purchaseUpdatesResponseStatus (%s) userId (%s)", response.getRequestId(), response.getRequestStatus(), response.getUserData().getUserId());
final PurchaseUpdatesResponse.RequestStatus status = response.getRequestStatus();
switch(status) {
case SUCCESSFUL:
iapManager.setAmazonUserId(response.getUserData().getUserId(), response.getUserData().getMarketplace());
for (final Receipt receipt : response.getReceipts()) {
iapManager.handleReceipt(receipt, response.getUserData());
}
if (response.hasMore()) {
PurchasingService.getPurchaseUpdates(false);
}
iapManager.reloadPurchaseStatus();
break;
case FAILED:
case NOT_SUPPORTED:
Timber.d("onProductDataResponse: failed, should retry request");
iapManager.disableAllPurchases();
break;
}
}
Aggregations