use of com.amazon.device.iap.model.Receipt 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