public class CompletePurchase implements HelperIntent
Helper intent to build a digital transaction (virtual good) request.
@ForIntent("buildOrder")
public CompletableFuture
The following code demonstrates how to handle the purchase response from the Google Play store.
@ForIntent("actions_intent_COMPLETE_PURCHASE")
public CompletableFuture handlePurchaseResponse(
ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder();
String purchaseResult = request.getArgument("COMPLETE_PURCHASE_VALUE").getTextValue();
if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_OK")) {
responseBuilder.add("Purchase completed! You're all set!").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ALREADY_OWNED")) {
responseBuilder.add("Purchase failed. You already own the item.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ITEM_UNAVAILABLE")) {
responseBuilder.add("Purchase failed. Item is not available.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ITEM_CHANGE_REQUESTED")) {
responseBuilder.add("Purchase failed. Item is not available.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_USER_CANCELLED")) {
responseBuilder.add("Purchase failed. Item is not available.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ERROR") ||
purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_UNSPECIFIED")) {
responseBuilder.add("Purchase failed. Do you want to try again?").endConversation();
} else {
responseBuilder.add("There was an internal error. Please try again later").endConversation();
}
return CompletableFuture.completedFuture(responseBuilder.build());
}
Constructor and Description |
---|
CompletePurchase()
Helper intent to build a digital transaction (virtual good) request.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName() |
java.util.Map<java.lang.String,java.lang.Object> |
getParameters() |
CompletePurchase |
setDeveloperPayload(java.lang.String developerPayload) |
CompletePurchase |
setSkuId(com.google.api.services.actions_fulfillment.v2.model.SkuId skuId) |
getName, getParameters
public CompletePurchase()
Helper intent to build a digital transaction (virtual good) request.
@ForIntent("buildOrder")
public CompletableFuture
The following code demonstrates how to handle the purchase response from the Google Play store.
@ForIntent("actions_intent_COMPLETE_PURCHASE")
public CompletableFuture handlePurchaseResponse(
ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder();
String purchaseResult = request.getArgument("COMPLETE_PURCHASE_VALUE").getTextValue();
if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_OK")) {
responseBuilder.add("Purchase completed! You're all set!").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ALREADY_OWNED")) {
responseBuilder.add("Purchase failed. You already own the item.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ITEM_UNAVAILABLE")) {
responseBuilder.add("Purchase failed. Item is not available.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ITEM_CHANGE_REQUESTED")) {
responseBuilder.add("Purchase failed. Item is not available.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_USER_CANCELLED")) {
responseBuilder.add("Purchase failed. Item is not available.").endConversation();
} else if (purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_ERROR") ||
purchaseResult.equalsIgnoreCase("PURCHASE_STATUS_UNSPECIFIED")) {
responseBuilder.add("Purchase failed. Do you want to try again?").endConversation();
} else {
responseBuilder.add("There was an internal error. Please try again later").endConversation();
}
return CompletableFuture.completedFuture(responseBuilder.build());
}
public CompletePurchase setSkuId(com.google.api.services.actions_fulfillment.v2.model.SkuId skuId)
public CompletePurchase setDeveloperPayload(java.lang.String developerPayload)
public java.lang.String getName()
public java.util.Map<java.lang.String,java.lang.Object> getParameters()