Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class CommercePackage
- Object
- CommercePackage
One thing a customer can buy from an Offering: a store product together
with the role it plays in the offering (the monthly plan, the annual plan,
a lifetime unlock).
Everything the Codename One Commerce service said about the package is
fixed when the instance is made. The store’s own Product, which carries
the localized price, is attached later, once the store has been asked.
Fields
public static final String TYPE_LIFETIME = "LIFETIME" | A one time purchase that never expires. |
public static final String TYPE_ANNUAL = "ANNUAL" | A subscription billed once a year. |
public static final String TYPE_SIX_MONTH = "SIX_MONTH" | A subscription billed every six months. |
public static final String TYPE_THREE_MONTH = "THREE_MONTH" | A subscription billed every three months. |
public static final String TYPE_TWO_MONTH = "TWO_MONTH" | A subscription billed every two months. |
public static final String TYPE_MONTHLY = "MONTHLY" | A subscription billed once a month. |
public static final String TYPE_WEEKLY = "WEEKLY" | A subscription billed once a week. |
public static final String TYPE_CUSTOM = "CUSTOM" | A package that is none of the standard ones. |
Methods
public String getOfferingId() | The id of the offering this package was listed in, or null for a package that came from no offering. |
public String getId() | The id of the package inside its offering. |
public String getType() | The role of the package, one of the TYPE_ constants. |
public boolean isType(String packageType) | Whether the package is of the given type. |
public String getProductId() | The store product id (SKU) this package sells. |
public String getPeriod() | The billing period as an ISO-8601 duration such as P1M, or null for a package that is not billed periodically. |
public String getTrialPeriod() | The free trial as an ISO-8601 duration such as P7D, or null when the package has none. |
public String getIntroPrice() | The introductory price as text, or null when the package has none. |
public String getIntroPeriod() | How long the introductory price lasts, as an ISO-8601 duration, or null when the package has none. |
public boolean isEligibleForIntro() | Whether this customer may still take the free trial or introductory price of the package, as far as the service knows. |
public boolean isSubscription() | Whether buying the package starts a subscription. |
public Product getProduct() | The store’s product for this package, which carries the localized price and name. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Field details
TYPE_LIFETIME
public static final String TYPE_LIFETIME = "LIFETIME"A one time purchase that never expires.
TYPE_ANNUAL
public static final String TYPE_ANNUAL = "ANNUAL"A subscription billed once a year.
TYPE_SIX_MONTH
public static final String TYPE_SIX_MONTH = "SIX_MONTH"A subscription billed every six months.
TYPE_THREE_MONTH
public static final String TYPE_THREE_MONTH = "THREE_MONTH"A subscription billed every three months.
TYPE_TWO_MONTH
public static final String TYPE_TWO_MONTH = "TWO_MONTH"A subscription billed every two months.
TYPE_MONTHLY
public static final String TYPE_MONTHLY = "MONTHLY"A subscription billed once a month.
TYPE_WEEKLY
public static final String TYPE_WEEKLY = "WEEKLY"A subscription billed once a week.
TYPE_CUSTOM
public static final String TYPE_CUSTOM = "CUSTOM"A package that is none of the standard ones.
Method details
getOfferingId
public String getOfferingId()The id of the offering this package was listed in, or null for a
package that came from no offering. A web checkout names the package
by both ids.
getId
public String getId()The id of the package inside its offering.
getType
public String getType()The role of the package, one of the
TYPE_ constants. A package the
service gave no type is TYPE_CUSTOM.isType
public boolean isType(String packageType)Whether the package is of the given type. Types are compared without
regard to case.
Parameters
packageTypeString- one of the
TYPE_constants
getProductId
public String getProductId()The store product id (SKU) this package sells.
getPeriod
public String getPeriod()The billing period as an ISO-8601 duration such as
P1M, or null for
a package that is not billed periodically.getTrialPeriod
public String getTrialPeriod()The free trial as an ISO-8601 duration such as
P7D, or null when
the package has none.getIntroPrice
public String getIntroPrice()The introductory price as text, or null when the package has none.
getIntroPeriod
public String getIntroPeriod()How long the introductory price lasts, as an ISO-8601 duration, or
null when the package has none.
isEligibleForIntro
public boolean isEligibleForIntro()Whether this customer may still take the free trial or introductory
price of the package, as far as the service knows.
isSubscription
public boolean isSubscription()Whether buying the package starts a subscription. Everything is a
subscription except a
TYPE_LIFETIME package and a TYPE_CUSTOM
one with no billing period.getProduct
public Product getProduct()The store’s product for this package, which carries the localized
price and name.
Returns
the product, or null while the store has not been asked or does not
list products on this platform
toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())