Class Receipt

java.lang.Object
com.codename1.payment.Receipt
All Implemented Interfaces:
Externalizable

public class Receipt extends Object implements Externalizable
Encapsulates a receipt for an in-app purchase.
  • Field Details

  • Constructor Details

    • Receipt

      public Receipt()
    • Receipt

      public Receipt(String sku, Date expiryDate, Date cancellationDate, Date purchaseDate, int quantity, String transactionId, String orderData, String storeCode, String internalId)
      Convenience constructor
  • Method Details

    • getSku

      public String getSku()
      Returns

      the sku

    • setSku

      public void setSku(String sku)
      Parameters
      • sku: the sku to set
      See also
      • #getSku()
    • getExpiryDate

      public Date getExpiryDate()

      The expiry date of the receipt, in case this is a subscription receipt.

      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 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).

      Returns

      the expiryDate Will be null for non-subscriptions.

    • setExpiryDate

      public void setExpiryDate(Date expiryDate)
      Parameters
      • expiryDate: the expiryDate to set
      See also
      • #getExpiryDate()
    • getVersion

      public 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

      Returns

      version number for the persistant code

      Specified by:
      getVersion in interface Externalizable
    • externalize

      public void externalize(DataOutputStream out) throws IOException

      Allows us to store an object state, this method must be implemented in order to save the state of an object

      Parameters
      • out: the stream into which the object must be serialized
      Throws
      • java.io.IOException: the method may throw an exception
      Specified by:
      externalize in interface Externalizable
      Throws:
      IOException
    • internalize

      public void internalize(int version, DataInputStream in) throws IOException

      Loads the object from the input stream and allows deserialization

      Parameters
      • version: the version the class returned during the externalization processs

      • in: the input stream used to load the class

      Throws
      • java.io.IOException: the method may throw an exception
      Specified by:
      internalize in interface Externalizable
      Throws:
      IOException
    • getObjectId

      public String getObjectId()

      The object id must be unique, it is used to identify the object when loaded even when it is obfuscated.

      Returns

      a unique id

      Specified by:
      getObjectId in interface Externalizable
    • getCancellationDate

      public Date getCancellationDate()

      Cancellation date of the receipt, if it has been cancelled. A cancelled receipt should be treated as if the purchase had never been made in the first place.

      Returns

      the cancellationDate

    • setCancellationDate

      public void setCancellationDate(Date cancellationDate)
      Parameters
      • cancellationDate: the cancellationDate to set
      See also
      • #getCancellationDate()
    • getPurchaseDate

      public Date getPurchaseDate()

      Date of purchase.

      Returns

      the purchaseDate

    • setPurchaseDate

      public void setPurchaseDate(Date originalPurchaseDate)
      Parameters
      • originalPurchaseDate: the purchaseDate to set
      See also
      • #getPurchaseDate()
    • getQuantity

      public int getQuantity()

      Quantity. Currently this will always be 1, but potentially could be used internally to denote other quantities.

      Returns

      the quantity

    • setQuantity

      public void setQuantity(int quantity)
      Parameters
      • quantity: the quantity to set
      See also
      • #getQuantity()
    • getTransactionId

      public String getTransactionId()

      The store-specific transaction ID. This will match exactly the transaction id of the store the issued the receipt. Use the storeCode to differentiate between transactions of different stores, which may potentially have the same transaction Ids.

      Returns

      the transactionId

    • setTransactionId

      public void setTransactionId(String transactionId)
      Parameters
      • transactionId: the transactionId to set
      See also
      • #getTransactionId()
    • getOrderData

      public String getOrderData()

      The order data that may be used to verify the receipt with the appropriate REST service. This data will be in different formats for different stores.

      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.

      Returns

      the orderData

    • setOrderData

      public void setOrderData(String orderData)
      Parameters
      • orderData: the orderData to set
      See also
      • #getOrderData()
    • getStoreCode

      public String getStoreCode()

      The store code from which this receipt originated. Will usually be one of #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.

      Returns

      the storeCode

    • setStoreCode

      public void setStoreCode(String storeCode)
      Parameters
      • storeCode: the storeCode to set
      See also
      • #getStoreCode()
    • getInternalId

      public String getInternalId()

      An internal ID that may be optionally used to link the receipt to an internal order ID.

      Returns

      the internalId

    • setInternalId

      public void setInternalId(String internalId)
      Parameters
      • internalId: the internalId to set
      See also
      • #getInternalId()
    • toString

      public String toString()
      Overrides:
      toString in class Object