public class Receipt extends Object implements Externalizable
Modifier and Type | Field and Description |
---|---|
static String |
STORE_CODE_ITUNES |
static String |
STORE_CODE_PLAY |
static String |
STORE_CODE_SIMULATOR |
static String |
STORE_CODE_WINDOWS |
Constructor and Description |
---|
Receipt() |
Receipt(String sku,
Date expiryDate,
Date cancellationDate,
Date purchaseDate,
int quantity,
String transactionId,
String orderData,
String storeCode,
String internalId)
Convenience constructor
|
Modifier and Type | Method and Description |
---|---|
void |
externalize(DataOutputStream out)
Allows us to store an object state, this method must be implemented
in order to save the state of an object
|
Date |
getCancellationDate()
Cancellation date of the receipt, if it has been cancelled.
|
Date |
getExpiryDate()
The expiry date of the receipt, in case this is a subscription receipt.
|
String |
getInternalId()
An internal ID that may be optionally used to link the receipt to an internal
order ID.
|
String |
getObjectId()
The object id must be unique, it is used to identify the object when loaded
even when it is obfuscated.
|
String |
getOrderData()
The order data that may be used to verify the receipt with the appropriate
REST service.
|
Date |
getPurchaseDate()
Date of purchase.
|
int |
getQuantity()
Quantity.
|
String |
getSku() |
String |
getStoreCode()
The store code from which this receipt originated.
|
String |
getTransactionId()
The store-specific transaction ID.
|
int |
getVersion()
Returns the version for the current persistance code, the version will be
pased to internalized thus allowing the internalize method to recognize
classes persisted in older revisions
|
void |
internalize(int version,
DataInputStream in)
Loads the object from the input stream and allows deserialization
|
void |
setCancellationDate(Date cancellationDate) |
void |
setExpiryDate(Date expiryDate) |
void |
setInternalId(String internalId) |
void |
setOrderData(String orderData) |
void |
setPurchaseDate(Date originalPurchaseDate) |
void |
setQuantity(int quantity) |
void |
setSku(String sku) |
void |
setStoreCode(String storeCode) |
void |
setTransactionId(String transactionId) |
String |
toString()
Returns a string representation of the object.
|
public static final String STORE_CODE_ITUNES
public static final String STORE_CODE_PLAY
public static final String STORE_CODE_WINDOWS
public static final String STORE_CODE_SIMULATOR
public String getSku()
public Date getExpiryDate()
NOTE: The expiry date will NOT be set automatically when the
receipt is generated by the platform. It should be set by the ReceiptStore
in the
ReceiptStore.submitReceipt(com.codename1.payment.Receipt, com.codename1.util.SuccessCallback)
step,
and usually on the server-side (in cases where a server is being used to track subscriptions), then the expiry
date will be made available when the receipt is loaded using ReceiptStore.fetchReceipts(com.codename1.util.SuccessCallback)
.
public void setExpiryDate(Date expiryDate)
expiryDate
- the expiryDate to setgetExpiryDate()
public int getVersion()
getVersion
in interface Externalizable
public void externalize(DataOutputStream out) throws IOException
externalize
in interface Externalizable
out
- the stream into which the object must be serializedIOException
- the method may throw an exceptionpublic void internalize(int version, DataInputStream in) throws IOException
internalize
in interface Externalizable
version
- the version the class returned during the externalization processsin
- the input stream used to load the classIOException
- the method may throw an exceptionpublic String getObjectId()
getObjectId
in interface Externalizable
public Date getCancellationDate()
public void setCancellationDate(Date cancellationDate)
cancellationDate
- the cancellationDate to setgetCancellationDate()
public Date getPurchaseDate()
public void setPurchaseDate(Date originalPurchaseDate)
originalPurchaseDate
- the purchaseDate to setgetPurchaseDate()
public int getQuantity()
public void setQuantity(int quantity)
quantity
- the quantity to setgetQuantity()
public String getTransactionId()
storeCode
to differentiate
between transactions of different stores, which may potentially have the
same transaction Ids.public void setTransactionId(String transactionId)
transactionId
- the transactionId to setgetTransactionId()
public String getOrderData()
iTunes has a base64 encoded string, Play has a JSON structure, Windows has an XML string, etc...
This will be filled in at the time that the receipt is generated by the platform's implementation, so developers should never have to explicitly set this.
public void setOrderData(String orderData)
orderData
- the orderData to setgetOrderData()
public String getStoreCode()
STORE_CODE_ITUNES
, STORE_CODE_PLAY
, STORE_CODE_WINDOWS
,
or STORE_CODE_SIMULATOR
, but developers could also use custom codes
if they use a different store, or no store at all. This code can be used
for validating the receipt.public void setStoreCode(String storeCode)
storeCode
- the storeCode to setgetStoreCode()
public String getInternalId()
public void setInternalId(String internalId)
internalId
- the internalId to setgetInternalId()
public String toString()
Object