public class CustomerSession
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CustomerSession.CustomerRetrievalListener |
static interface |
CustomerSession.SourceRetrievalListener |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACTION_API_EXCEPTION |
static java.lang.String |
EVENT_SHIPPING_INFO_SAVED |
static java.lang.String |
EXTRA_EXCEPTION |
| Modifier and Type | Method and Description |
|---|---|
void |
addCustomerSource(android.content.Context context,
java.lang.String sourceId,
java.lang.String sourceType,
CustomerSession.SourceRetrievalListener listener)
Add the input source to the current customer object.
|
void |
addProductUsageTokenIfValid(java.lang.String token) |
void |
deleteCustomerSource(android.content.Context context,
java.lang.String sourceId,
CustomerSession.SourceRetrievalListener listener)
Delete the source from the current customer object.
|
static void |
endCustomerSession()
End the singleton instance of a
CustomerSession. |
Customer |
getCachedCustomer()
Gets a cached customer, or
null if the current customer has expired. |
static CustomerSession |
getInstance()
Gets the singleton instance of
CustomerSession. |
static void |
initCustomerSession(EphemeralKeyProvider keyProvider)
Create a CustomerSession with the provided
EphemeralKeyProvider. |
void |
onKeyError(int errorCode,
java.lang.String errorMessage) |
void |
onKeyUpdate(com.stripe.android.EphemeralKey ephemeralKey,
java.lang.String actionString,
java.util.Map<java.lang.String,java.lang.Object> arguments) |
void |
retrieveCurrentCustomer(CustomerSession.CustomerRetrievalListener listener)
Retrieve the current
Customer. |
void |
setCustomerDefaultSource(android.content.Context context,
java.lang.String sourceId,
java.lang.String sourceType,
CustomerSession.CustomerRetrievalListener listener)
Set the default source of the current customer object.
|
void |
setCustomerShippingInformation(android.content.Context context,
ShippingInformation shippingInformation)
Set the shipping information on the current customer object.
|
void |
updateCurrentCustomer(CustomerSession.CustomerRetrievalListener listener)
Force an update of the current customer, regardless of how much time has passed.
|
public static final java.lang.String ACTION_API_EXCEPTION
public static final java.lang.String EXTRA_EXCEPTION
public static final java.lang.String EVENT_SHIPPING_INFO_SAVED
public static void initCustomerSession(EphemeralKeyProvider keyProvider)
EphemeralKeyProvider.keyProvider - an EphemeralKeyProvider used to get
EphemeralKeys as neededpublic static CustomerSession getInstance()
CustomerSession. If the session has not been
initialized, this will throw a RuntimeException.CustomerSession instance.public static void endCustomerSession()
CustomerSession.
Calls to getInstance() will throw an IllegalStateException
after this call, until the user calls
initCustomerSession(EphemeralKeyProvider) again.public void addProductUsageTokenIfValid(java.lang.String token)
public void retrieveCurrentCustomer(CustomerSession.CustomerRetrievalListener listener)
Customer. If the cached value at mCustomer is not
stale, this returns immediately with the cache. If not, it fetches a new value and returns
that to the listener.listener - a CustomerSession.CustomerRetrievalListener to invoke with the result of getting the
customer, either from the cache or from the serverpublic void updateCurrentCustomer(CustomerSession.CustomerRetrievalListener listener)
listener - a CustomerSession.CustomerRetrievalListener to invoke with the result of getting
the customer from the serverpublic Customer getCachedCustomer()
null if the current customer has expired.mCustomer, or null if the customer object is
expired.public void addCustomerSource(android.content.Context context,
java.lang.String sourceId,
java.lang.String sourceType,
CustomerSession.SourceRetrievalListener listener)
context - the Context to use for resourcessourceId - the ID of the source to be addedlistener - a CustomerSession.SourceRetrievalListener to be notified when the api call is
completepublic void deleteCustomerSource(android.content.Context context,
java.lang.String sourceId,
CustomerSession.SourceRetrievalListener listener)
context - the Context to use for resourcessourceId - the ID of the source to be deletedlistener - a CustomerSession.SourceRetrievalListener to be notified when the api call is
complete. The api call will return the removed source.public void setCustomerShippingInformation(android.content.Context context,
ShippingInformation shippingInformation)
context - a Context to use for resourcesshippingInformation - the data to be setpublic void setCustomerDefaultSource(android.content.Context context,
java.lang.String sourceId,
java.lang.String sourceType,
CustomerSession.CustomerRetrievalListener listener)
context - a Context to use for resourcessourceId - the ID of the source to be setlistener - a CustomerSession.CustomerRetrievalListener to be notified about an update to the
customerpublic void onKeyUpdate(com.stripe.android.EphemeralKey ephemeralKey,
java.lang.String actionString,
java.util.Map<java.lang.String,java.lang.Object> arguments)
public void onKeyError(int errorCode,
java.lang.String errorMessage)