public abstract class Purchase extends Object
In-app-purchase API's rely on managed server based products, other payment systems use the manual approach. An application dealing with virtual goods must support both since not all devices feature in-app-purchase API's. An application dealing with physical goods & services must use the latter according to the TOS of current in-app-purchase solutions.
Constructor and Description |
---|
Purchase() |
Modifier and Type | Method and Description |
---|---|
static Purchase |
getInAppPurchase()
Returns the native OS purchase implementation if applicable, if unavailable this
method will try to fallback to a custom purchase implementation and failing that
will return null
|
static Purchase |
getInAppPurchase(boolean d)
Deprecated.
use the version that takes no arguments
|
Product[] |
getProducts(String[] skus)
Returns the product list for the given SKU array
|
boolean |
isItemListingSupported()
Indicates whether the payment platform supports things such as "item listing" or
requires that items be coded into the system.
|
boolean |
isManagedPaymentSupported()
Indicates whether the purchasing platform supports managed payments which
work by picking products that are handled by the servers/OS of the platform vendor.
|
boolean |
isManualPaymentSupported()
Indicates whether the purchasing platform supports manual payments which
are just payments of a specific amount of money.
|
boolean |
isRefundable(String sku)
Indicates whether refunding is possible when the SKU is purchased
|
boolean |
isRestoreSupported()
Indicates whether a purchase restore button is supported by the OS
|
boolean |
isSubscriptionSupported()
Returns true if the subscription API is supported in this platform
|
boolean |
isUnsubscribeSupported()
Some platforms support subscribing but don't support unsubscribe
|
String |
pay(double amount,
String currency)
Performs payment of a specific amount based on the manual payment API, notice that
this doesn't use the in-app-purchase functionality of the device!
|
String |
pay(double amount,
String currency,
String invoiceNumber)
Performs payment of a specific amount based on the manual payment API, notice that
this doesn't use the in-app-purchase functionality of the device!
|
void |
purchase(String sku)
Begins the purchase process for the given SKU
|
void |
refund(String sku)
Tries to refund the given SKU if applicable in the current market/product
|
void |
restore()
Restores purchases if applicable, this will only work if isRestoreSupported() returns true
|
void |
subscribe(String sku)
Begins subscribe process for the given subscription SKU
|
void |
unsubscribe(String sku)
Cancels the subscription to a given SKU
|
boolean |
wasPurchased(String sku)
Returns true if the given SKU was purchased in the past, notice this method might not
work as expected for Unmanaged/consumable products which can be purchased multiple
times.
|
public boolean isManualPaymentSupported()
public boolean isManagedPaymentSupported()
public String pay(double amount, String currency)
amount
- the amount to paycurrency
- the three letter currency typeRuntimeException
- This method is a part of the manual payments API and will fail if
isManualPaymentSupported() returns falsepublic String pay(double amount, String currency, String invoiceNumber)
amount
- the amount to paycurrency
- the three letter currency typeinvoiceNumber
- application specific invoice numberRuntimeException
- This method is a part of the manual payments API and will fail if
isManualPaymentSupported() returns falsepublic boolean isItemListingSupported()
public Product[] getProducts(String[] skus)
sku
- the ids for the specific productsRuntimeException
- This method is a part of the managed payments API and will fail if
isManagedPaymentSupported() returns falseRuntimeException
- This method works only if isItemListingSupported() returns truepublic boolean wasPurchased(String sku)
sku
- the id of the productRuntimeException
- This method is a part of the managed payments API and will fail if
isManagedPaymentSupported() returns falsepublic void purchase(String sku)
sku
- the SKU with which to perform the purchase processRuntimeException
- This method is a part of the managed payments API and will fail if
isManagedPaymentSupported() returns falsepublic void subscribe(String sku)
sku
- the SKU with which to perform the purchase processRuntimeException
- This method is a part of the managed payments API and will fail if
isManagedPaymentSupported() returns falsepublic void unsubscribe(String sku)
sku
- the SKU with which to perform the purchase processRuntimeException
- This method is a part of the managed payments API and will fail if
isManagedPaymentSupported() returns falsepublic boolean isRefundable(String sku)
sku
- the skupublic void refund(String sku)
sku
- the id for the productpublic static Purchase getInAppPurchase()
public static Purchase getInAppPurchase(boolean d)
public boolean isSubscriptionSupported()
public boolean isUnsubscribeSupported()
public boolean isRestoreSupported()
public void restore()