use of com.amazon.device.iap.model.PurchaseResponse 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.PurchaseResponse in project SeriesGuide by UweTrottmann.
the class AmazonPurchasingListener method onPurchaseResponse.
/**
* This is the callback for {@link PurchasingService#purchase}. For each time the application
* sends a purchase request {@link PurchasingService#purchase}, Amazon Appstore will call this
* callback when the purchase request is completed. If the RequestStatus is Successful or
* AlreadyPurchased then application needs to call {@link com.battlelancer.seriesguide.billing.amazon.AmazonIapManager#handleReceipt}
* to handle the purchase fulfillment. If the RequestStatus is INVALID_SKU, NOT_SUPPORTED, or
* FAILED, notify corresponding method of {@link com.battlelancer.seriesguide.billing.amazon.AmazonIapManager}
* .
*/
@Override
public void onPurchaseResponse(final PurchaseResponse response) {
final String requestId = response.getRequestId().toString();
final String userId = response.getUserData().getUserId();
final PurchaseResponse.RequestStatus status = response.getRequestStatus();
Timber.d("onPurchaseResponse: requestId (%s) userId (%s) purchaseRequestStatus (%s)", requestId, userId, status);
switch(status) {
case SUCCESSFUL:
final Receipt receipt = response.getReceipt();
Timber.d("onPurchaseResponse: receipt json: %s", receipt.toJSON());
iapManager.handleReceipt(receipt, response.getUserData());
iapManager.reloadPurchaseStatus();
break;
case ALREADY_PURCHASED:
Timber.i("onPurchaseResponse: already purchased, verify subscription purchase again");
iapManager.reloadPurchaseStatus();
break;
case INVALID_SKU:
Timber.d("onPurchaseResponse: invalid SKU! onProductDataResponse should have disabled buy button already.");
iapManager.purchaseFailed();
break;
case FAILED:
case NOT_SUPPORTED:
Timber.d("onPurchaseResponse: failed, remove purchase request from local storage");
iapManager.purchaseFailed();
break;
}
}
use of com.amazon.device.iap.model.PurchaseResponse in project Osmand by osmandapp.
the class IapPurchasingListener method onPurchaseResponse.
/**
* This is the callback for {@link PurchasingService#purchase}. For each
* time the application sends a purchase request
* {@link PurchasingService#purchase}, Amazon Appstore will call this
* callback when the purchase request is completed.
*/
@Override
public void onPurchaseResponse(final PurchaseResponse response) {
final String requestId = response.getRequestId().toString();
final String userId = response.getUserData().getUserId();
final PurchaseResponse.RequestStatus status = response.getRequestStatus();
Log.d(TAG, "onPurchaseResponse: requestId (" + requestId + ") userId (" + userId + ") purchaseRequestStatus (" + status + ")");
switch(status) {
case SUCCESSFUL:
final Receipt receipt = response.getReceipt();
Log.d(TAG, "onPurchaseResponse: receipt json:" + receipt.toJSON());
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);
notifyPurchaseResponseListeners(response);
break;
case ALREADY_PURCHASED:
Log.i(TAG, "onPurchaseResponse: already purchased, you should verify the subscription " + "purchase on your side and make sure the purchase was granted to customer");
notifyPurchaseResponseListeners(null);
break;
case INVALID_SKU:
Log.d(TAG, "onPurchaseResponse: invalid SKU! onProductDataResponse should have disabled buy button already.");
notifyPurchaseResponseListeners(null);
break;
case FAILED:
case NOT_SUPPORTED:
Log.d(TAG, "onPurchaseResponse: failed so remove purchase request from local storage");
notifyPurchaseResponseListeners(null);
break;
}
}
use of com.amazon.device.iap.model.PurchaseResponse in project OsmAnd by osmandapp.
the class IapPurchasingListener method onPurchaseResponse.
/**
* This is the callback for {@link PurchasingService#purchase}. For each
* time the application sends a purchase request
* {@link PurchasingService#purchase}, Amazon Appstore will call this
* callback when the purchase request is completed.
*/
@Override
public void onPurchaseResponse(final PurchaseResponse response) {
final String requestId = response.getRequestId().toString();
final String userId = response.getUserData().getUserId();
final PurchaseResponse.RequestStatus status = response.getRequestStatus();
Log.d(TAG, "onPurchaseResponse: requestId (" + requestId + ") userId (" + userId + ") purchaseRequestStatus (" + status + ")");
switch(status) {
case SUCCESSFUL:
final Receipt receipt = response.getReceipt();
Log.d(TAG, "onPurchaseResponse: receipt json:" + receipt.toJSON());
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);
notifyPurchaseResponseListeners(response);
break;
case ALREADY_PURCHASED:
Log.i(TAG, "onPurchaseResponse: already purchased, you should verify the subscription " + "purchase on your side and make sure the purchase was granted to customer");
notifyPurchaseResponseListeners(null);
break;
case INVALID_SKU:
Log.d(TAG, "onPurchaseResponse: invalid SKU! onProductDataResponse should have disabled buy button already.");
notifyPurchaseResponseListeners(null);
break;
case FAILED:
case NOT_SUPPORTED:
Log.d(TAG, "onPurchaseResponse: failed so remove purchase request from local storage");
notifyPurchaseResponseListeners(null);
break;
}
}
Aggregations