本文整理汇总了Java中com.amazon.device.iap.model.PurchaseResponse类的典型用法代码示例。如果您正苦于以下问题:Java PurchaseResponse类的具体用法?Java PurchaseResponse怎么用?Java PurchaseResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PurchaseResponse类属于com.amazon.device.iap.model包,在下文中一共展示了PurchaseResponse类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateOriginalJson
import com.amazon.device.iap.model.PurchaseResponse; //导入依赖的package包/类
/**
* Converts purchase response to json for transfer with purchase object
* <p/>
* <pre>
* {
* "orderId" : "purchaseResponse.getRequestId"
* "productId" : "receipt.getSku"
* "purchaseStatus" : "purchaseRequestStatus.name"
* "userId" : "purchaseResponse.getUserId()" // if non-null
* "itemType" : "receipt.getItemType().name()" // if non-null
* "purchaseToken" : "receipt.getReceiptId()"
* } </pre>
*
* @param purchaseResponse Purchase to convert.
* @return Generate JSON from purchase.
*/
private String generateOriginalJson(@NotNull PurchaseResponse purchaseResponse) {
final JSONObject json = new JSONObject();
try {
Receipt receipt = purchaseResponse.getReceipt();
json.put(JSON_KEY_ORDER_ID, purchaseResponse.getRequestId());
json.put(JSON_KEY_PRODUCT_ID, receipt.getSku());
final PurchaseResponse.RequestStatus requestStatus = purchaseResponse.getRequestStatus();
if (requestStatus != null) {
json.put(JSON_KEY_PURCHASE_STATUS, requestStatus.name());
}
final UserData userData = purchaseResponse.getUserData();
if (userData != null) {
json.put(JSON_KEY_USER_ID, userData.getUserId());
}
final ProductType productType = receipt.getProductType();
if (productType != null) {
json.put(JSON_KEY_RECEIPT_ITEM_TYPE, productType.name());
}
json.put(JSON_KEY_RECEIPT_PURCHASE_TOKEN, receipt.getReceiptId());
Logger.d("generateOriginalJson(): JSON\n", json);
} catch (JSONException e) {
Logger.e("generateOriginalJson() failed to generate JSON", e);
}
return json.toString();
}
开发者ID:onepf,项目名称:OpenIAB,代码行数:42,代码来源:AmazonAppstoreBillingService.java
示例2: onPurchaseResponse
import com.amazon.device.iap.model.PurchaseResponse; //导入依赖的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;
}
}
开发者ID:eggheadgames,项目名称:android-in-app-payments,代码行数:46,代码来源:AmazonBillingListener.java
示例3: onPurchaseResponse
import com.amazon.device.iap.model.PurchaseResponse; //导入依赖的package包/类
/**
* 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 SampleIAPManager#handleReceipt} to handle the purchase
* fulfillment. If the RequestStatus is INVALID_SKU, NOT_SUPPORTED, or
* FAILED, notify corresponding method of {@link SampleIAPManager} .
*/
@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();
showMessage(LOGTYPELOG, "onPurchaseResponse: requestId (" + requestId
+ ") userId ("
+ userId
+ ") purchaseRequestStatus ("
+ status
+ ")");
switch (status) {
case SUCCESSFUL:
final Receipt receipt = response.getReceipt();
updateUserData(response.getUserData());
showMessage(LOGTYPELOG, "onPurchaseResponse: receipt json:" + receipt.toJSON());
handleReceipt(response.getRequestId().toString(), receipt, response.getUserData());
break;
case ALREADY_PURCHASED:
showMessage(LOGTYPELOG, "onPurchaseResponse: already purchased, you should verify the entitlement purchase on your side and make sure the purchase was granted to customer");
observer.handlePurchaseError(new Throwable("onPurchaseResponse: ALREADY_PURCHASED"));
break;
case INVALID_SKU:
showMessage(LOGTYPEERROR,
"onPurchaseResponse: invalid SKU! onProductDataResponse should have disabled buy button already.");
observer.handlePurchaseError(new Throwable("onPurchaseResponse: INVALID_SKU"));
break;
case FAILED:
showMessage(LOGTYPEERROR, "onPurchaseResponse: FAILED");
observer.handlePurchaseError(new Throwable("onPurchaseResponse: FAILED"));
break;
case NOT_SUPPORTED:
showMessage(LOGTYPEERROR, "onPurchaseResponse: NOT_SUPPORTED so remove purchase request from local storage");
observer.handlePurchaseError(new Throwable("onPurchaseResponse: NOT_SUPPORTED"));
break;
}
}
开发者ID:libgdx,项目名称:gdx-pay,代码行数:54,代码来源:PurchaseManagerAndroidAmazon.java
示例4: onPurchaseResponse
import com.amazon.device.iap.model.PurchaseResponse; //导入依赖的package包/类
@Override
public void onPurchaseResponse(
@NonNull final PurchaseResponse purchaseResponse) {
OPFIab.post(purchaseResponse);
}
开发者ID:onepf,项目名称:OPFIab,代码行数:6,代码来源:AmazonBillingHelper.java
注:本文中的com.amazon.device.iap.model.PurchaseResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论