本文整理汇总了Java中com.amazon.device.iap.model.FulfillmentResult类的典型用法代码示例。如果您正苦于以下问题:Java FulfillmentResult类的具体用法?Java FulfillmentResult怎么用?Java FulfillmentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FulfillmentResult类属于com.amazon.device.iap.model包,在下文中一共展示了FulfillmentResult类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleReceipt
import com.amazon.device.iap.model.FulfillmentResult; //导入依赖的package包/类
/**
* Method to handle receipts
*
* @param requestId
* @param receipt
* @param userData
*/
public void handleReceipt(final String requestId, final Receipt receipt, final UserData userData) {
showMessage(LOGTYPELOG, "Handle receipt: requestId (" + requestId
+ ") receipt: "
+ receipt
+ ")");
// convert receipt to transaction
Transaction trans = AmazonTransactionUtils.convertReceiptToTransaction(1, requestId, receipt, userData); // provides cancleState also
switch (receipt.getProductType()) {
case CONSUMABLE:
// inform the listener
observer.handlePurchase(trans);
// Automatically consume item
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);
break;
case ENTITLED:
// inform the listener
observer.handlePurchase(trans);
break;
case SUBSCRIPTION:
// TODO: check subscription sample for how to handle consumable purchases
break;
}
}
示例2: consume
import com.amazon.device.iap.model.FulfillmentResult; //导入依赖的package包/类
@Override
public void consume(@NonNull final ConsumeRequest request) {
final Purchase purchase = request.getPurchase();
final String token = purchase.getToken();
if (!TextUtils.isEmpty(token)) {
PurchasingService.notifyFulfillment(token, FulfillmentResult.FULFILLED);
postResponse(new ConsumeResponse(SUCCESS, getName(), purchase));
} else {
postEmptyResponse(request, ITEM_UNAVAILABLE);
}
}
示例3: onPurchaseResponse
import com.amazon.device.iap.model.FulfillmentResult; //导入依赖的package包/类
@Override
public void onPurchaseResponse(PurchaseResponse response) {
logDebug("onPurchaseResponse " + response.getRequestStatus());
final String requestId = response.getRequestId().toString();
final String userId = response.getUserData().getUserId();
final PurchaseResponse.RequestStatus status = response.getRequestStatus();
final Receipt receipt;
logDebug("onPurchaseResponse: requestId (" + requestId + ") userId (" + userId + ") purchaseRequestStatus (" + status + ")");
switch (status) {
case SUCCESSFUL:
receipt = response.getReceipt();
if (receipt != null) {
logDebug("onPurchaseResponse: receipt json:" + receipt.toJSON());
logDebug("onPurchaseResponse: getUserId:" + response.getUserData().getUserId());
logDebug("onPurchaseResponse: getMarketplace:" + response.getUserData().getMarketplace());
if (receipt.getProductType() == ProductType.SUBSCRIPTION) {
amazonBillingService.subscriptionOwned(receipt.getSku(), false);
} else {
amazonBillingService.productOwned(receipt.getSku(), false);
}
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);
}
break;
case ALREADY_PURCHASED:
logDebug("onPurchaseResponse: already purchased, you should verify the entitlement purchase on your side and make sure the purchase was granted to customer");
receipt = response.getReceipt();
if (receipt != null && !receipt.isCanceled()) {
if (receipt.getProductType() == ProductType.SUBSCRIPTION) {
amazonBillingService.subscriptionOwned(receipt.getSku(), true);
} else {
amazonBillingService.productOwned(receipt.getSku(), true);
}
}
break;
case INVALID_SKU:
logDebug("onPurchaseResponse: invalid SKU! onProductDataResponse should have disabled buy button already.");
break;
case FAILED:
case NOT_SUPPORTED:
logDebug("onPurchaseResponse: failed so remove purchase request from local storage");
break;
}
}
示例4: onPurchaseUpdatesResponse
import com.amazon.device.iap.model.FulfillmentResult; //导入依赖的package包/类
/**
* This is the callback for {@link PurchasingService#getPurchaseUpdates}.
*
* You will receive Entitlement receipts from this callback.
*
*/
@Override
public void onPurchaseUpdatesResponse(final PurchaseUpdatesResponse response) {
showMessage(LOGTYPELOG, "onPurchaseUpdatesResponse: requestId (" + response.getRequestId()
+ ") purchaseUpdatesResponseStatus ("
+ response.getRequestStatus()
+ ") userId ("
+ response.getUserData().getUserId()
+ ")");
final PurchaseUpdatesResponse.RequestStatus status = response.getRequestStatus();
switch (status) {
case SUCCESSFUL:
updateUserData(response.getUserData());
// for (final Receipt receipt : response.getReceipts()) {
// handleReceipt(response.getRequestId().toString(), receipt, response.getUserData());
// }
// send result to observer --------
List<Transaction> transactions = new ArrayList<Transaction>(response.getReceipts().size());
Array<Receipt> consumables = new Array<Receipt>(response.getReceipts().size());
for (int i = 0; i < response.getReceipts().size(); i++) {
Receipt receipt = response.getReceipts().get(i);
// Memoize consumables for later check
if (receipt.getProductType() == ProductType.CONSUMABLE)
consumables.add(receipt);
transactions.add(AmazonTransactionUtils.convertReceiptToTransaction(i, response.getRequestId().toString(), receipt, response.getUserData()));
}
// send inventory to observer
observer.handleRestore(transactions.toArray(new Transaction[transactions.size()]));
// Automatically consume consumables if this was not previously the case
for (int i = 0; i < consumables.size; i++) {
Receipt consumable = consumables.get(i);
PurchasingService.notifyFulfillment(consumable.getReceiptId(), FulfillmentResult.FULFILLED);
}
//---- check if there are more receipts -------
if (response.hasMore()) {
PurchasingService.getPurchaseUpdates(false);
}
break;
case FAILED:
showMessage(LOGTYPEERROR, "onPurchaseUpdatesResponse: FAILED, should retry request");
observer.handleRestoreError(new Throwable("onPurchaseUpdatesResponse: FAILED, should retry request"));
break;
case NOT_SUPPORTED:
showMessage(LOGTYPEERROR, "onPurchaseUpdatesResponse: NOT_SUPPORTED, should retry request");
observer.handleRestoreError(new Throwable("onPurchaseUpdatesResponse: NOT_SUPPORTED, should retry request"));
break;
}
}
示例5: consume
import com.amazon.device.iap.model.FulfillmentResult; //导入依赖的package包/类
@Override
public void consume(Purchase itemInfo) {
PurchasingService.notifyFulfillment(itemInfo.getToken(), FulfillmentResult.FULFILLED);
}