Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public interface PurchaseCallback

Known subtypesPendingPurchaseCallback

Callback interface that the main class must implement in order for in-app-purchasing to work. Once the main class implements this interface the methods within it are invoked to indicate the various purchase states.

Methods

public abstract void itemPurchased(String sku)Indicates a the given SKU was purchased by a user.
public abstract void itemPurchaseError(String sku, String errorMessage)Callback indicating a the given SKU purchase failed
public abstract void itemRefunded(String sku)Invoked if a refund was granted for a purchase.
public abstract void subscriptionStarted(String sku)Deprecated Invoked when a subscription SKU is started
public abstract void subscriptionCanceled(String sku)Deprecated Invoked when a subscription SKU is canceled
public abstract void paymentFailed(String paymentCode, String failureReason)Indicates that a manual payment has failed
public abstract void paymentSucceeded(String paymentCode, double amount, String currency)Indicates that a manual payment has passed

Method details

itemPurchased

public abstract void itemPurchased(String sku)
Indicates a the given SKU was purchased by a user. When purchasing multiple SKU’s at once multiple calls to this method will be performed.

Parameters

sku String
the sku purchased

itemPurchaseError

public abstract void itemPurchaseError(String sku, String errorMessage)
Callback indicating a the given SKU purchase failed

Parameters

sku String
the id
errorMessage String
Not documented.

itemRefunded

public abstract void itemRefunded(String sku)

Invoked if a refund was granted for a purchase.

Called on iOS and macOS (StoreKit 2) when Apple revokes a purchase: a refund, or a Family Sharing purchase the organizer withdrew. Other platforms do not call it, so treat it as a prompt to recompute ownership from the receipts (see Purchase#getReceipts()), which is the signal that works everywhere.

Parameters

sku String
the sku purchased

subscriptionStarted

public abstract void subscriptionStarted(String sku)
Deprecated. Subscriptions should be handled directly in the associated store (iOS/Google Play, etc..). See https://www.codenameone.com/blog/intro-to-in-app-purchase.html for a guide into how to set up in-app purchase for all scenarios including subscriptions.
Invoked when a subscription SKU is started

Parameters

sku String
the sku purchased

subscriptionCanceled

public abstract void subscriptionCanceled(String sku)
Deprecated. Subscriptions should be handled directly in the associated store (iOS/Google Play, etc..). See https://www.codenameone.com/blog/intro-to-in-app-purchase.html for a guide into how to set up in-app purchase for all scenarios including subscriptions.
Invoked when a subscription SKU is canceled

Parameters

sku String
the sku purchased

paymentFailed

public abstract void paymentFailed(String paymentCode, String failureReason)
Indicates that a manual payment has failed

Parameters

paymentCode String
the transaction id of the payment
failureReason String
Not documented.

paymentSucceeded

public abstract void paymentSucceeded(String paymentCode, double amount, String currency)
Indicates that a manual payment has passed

Parameters

paymentCode String
the transaction id of the payment
amount double
Not documented.
currency String
Not documented.