本文整理汇总了Java中org.solovyev.android.checkout.Purchase类的典型用法代码示例。如果您正苦于以下问题:Java Purchase类的具体用法?Java Purchase怎么用?Java Purchase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Purchase类属于org.solovyev.android.checkout包,在下文中一共展示了Purchase类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doVerify
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
@Override
protected void doVerify(@NonNull final List<Purchase> purchases, @NonNull final RequestListener<List<Purchase>> listener) {
// Prepare params
Purchase purchase = purchases.get(0);
boolean isSubscription = Configuration.getSubscriptionProductIds().contains(purchase.sku);
String purchaseType = isSubscription ? "subscription" : "product";
// Post purchase verification request
ApiRequestHandler apiRequestHandler = new ApiRequestHandler(Configuration.getPurchaseConfirmationUrl(purchaseType));
PurchasesVerificationPayload purchasesVerificationPayload = new PurchasesVerificationPayload(purchase);
boolean result = apiRequestHandler.post(purchasesVerificationPayload);
// Trigger success
if(result) {
listener.onSuccess(purchases);
}else{
listener.onError(apiRequestHandler.getStatusCode(), new PurchaseVerificationException(apiRequestHandler.getResponseText()));
}
}
示例2: consume
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
private void consume(final Purchase purchase) {
mCheckout.whenReady(new Checkout.EmptyListener() {
@Override
public void onReady(@Nonnull BillingRequests requests) {
requests.consume(purchase.token, makeRequestListener());
}
});
}
示例3: onClick
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
public void onClick(Sku sku) {
final Purchase purchase = mProduct.getPurchaseInState(sku, Purchase.State.PURCHASED);
if (purchase != null) {
consume(purchase);
} else {
purchase(sku);
}
}
示例4: onLoaded
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
@Override
public void onLoaded(@NonNull Inventory.Products products) {
final Inventory.Product product = products.get(ProductTypes.IN_APP);
mAdapter.setNotifyOnChange(false);
mAdapter.clear();
if (product.supported) {
for (Sku sku : product.getSkus()) {
final Purchase purchase = product.getPurchaseInState(sku, Purchase.State.PURCHASED);
final SkuUi skuUi = new SkuUi(sku, purchase != null);
mAdapter.add(skuUi);
}
// Sort items by prices.
mAdapter.sort(new Comparator<SkuUi>() {
@Override
public int compare(@NonNull SkuUi l, @NonNull SkuUi r) {
return (int) (l.sku.detailedPrice.amount - r.sku.detailedPrice.amount);
}
});
showScene(SCREEN_INVENTORY);
} else {
mEmptyView.setText(R.string.donate_billing_not_supported);
showScene(SCREEN_EMPTY_VIEW);
}
mAdapter.notifyDataSetChanged();
}
示例5: onLoaded
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
@Override
public void onLoaded(@NonNull Inventory.Products products) {
final Inventory.Product product = products.get(ProductTypes.IN_APP);
mAdapter.setNotifyOnChange(false);
mAdapter.clear();
if (product.supported) {
for (Sku sku : product.getSkus()) {
final Purchase purchase = product.getPurchaseInState(sku, Purchase.State.PURCHASED);
final SkuUi skuUi = new MySkuUi(sku, purchase != null);
mAdapter.add(skuUi);
}
// Sort items by prices.
mAdapter.sort(new Comparator<SkuUi>() {
@Override
public int compare(@NonNull SkuUi l, @NonNull SkuUi r) {
return (int) (l.sku.detailedPrice.amount - r.sku.detailedPrice.amount);
}
});
// Show the inventory.
refreshUi(SCREEN_INVENTORY);
} else refreshUi(SCREEN_EMPTY_VIEW);
mAdapter.notifyDataSetChanged();
}
示例6: PurchasesVerificationPayload
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
public PurchasesVerificationPayload(Purchase purchase) {
this.data = purchase.data;
this.order_id = purchase.orderId;
this.package_name = purchase.packageName;
this.payload = purchase.payload;
this.signature = purchase.signature;
this.sku = purchase.sku;
this.state = purchase.state.toString();
this.token = purchase.token;
this.time = purchase.time;
}
示例7: purchase
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
private void purchase(Sku sku) {
final RequestListener<Purchase> listener = makeRequestListener();
mCheckout.startPurchaseFlow(sku, null, listener);
}
示例8: onSuccess
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
@Override
public void onSuccess(@NonNull Purchase purchase) {
purchased();
}
示例9: onSuccess
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
@Override
public void onSuccess(@NonNull Purchase purchase) {
onPurchased();
}
示例10: onSuccess
import org.solovyev.android.checkout.Purchase; //导入依赖的package包/类
@Override
public void onSuccess(@NonNull Purchase purchase) {
onPurchased(false);
}