use of com.soomla.store.events.MarketRefundEvent in project android-store by soomla.
the class SoomlaStore method handleSuccessfulPurchase.
/**
* Checks the state of the purchase and responds accordingly, giving the user an item,
* throwing an error, or taking the item away and paying the user back.
*
* @param purchase purchase whose state is to be checked.
*/
private void handleSuccessfulPurchase(IabPurchase purchase, boolean isRestoring) {
String sku = purchase.getSku();
PurchasableVirtualItem pvi;
try {
pvi = StoreInfo.getPurchasableItem(sku);
} catch (VirtualItemNotFoundException e) {
SoomlaUtils.LogError(TAG, "(handleSuccessfulPurchase - purchase or query-inventory) " + "ERROR : Couldn't find the " + " VirtualCurrencyPack OR MarketItem with productId: " + sku + ". It's unexpected so an unexpected error is being emitted.");
BusProvider.getInstance().post(new UnexpectedStoreErrorEvent(UnexpectedStoreErrorEvent.ErrorCode.PURCHASE_FAIL));
return;
}
switch(purchase.getPurchaseState()) {
case 0:
{
if (purchase.isServerVerified()) {
this.finalizeTransaction(purchase, pvi, isRestoring);
} else {
BusProvider.getInstance().post(new UnexpectedStoreErrorEvent(purchase.getVerificationErrorCode() != null ? purchase.getVerificationErrorCode() : UnexpectedStoreErrorEvent.ErrorCode.GENERAL));
}
break;
}
case 1:
case 2:
SoomlaUtils.LogDebug(TAG, "IabPurchase refunded.");
if (!StoreConfig.friendlyRefunds) {
pvi.take(1);
}
BusProvider.getInstance().post(new MarketRefundEvent(pvi, purchase.getDeveloperPayload()));
break;
}
}
Aggregations