public class PaymentSession
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
PaymentSession.PaymentSessionListener
Represents a listener for PaymentSession actions, used to update the host activity
when necessary.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
EXTRA_PAYMENT_SESSION_ACTIVE |
static java.lang.String |
PAYMENT_SESSION_CONFIG |
static java.lang.String |
PAYMENT_SESSION_DATA_KEY |
static java.lang.String |
TOKEN_PAYMENT_SESSION |
| Constructor and Description |
|---|
PaymentSession(android.app.Activity hostActivity)
Create a PaymentSession attached to the given host Activity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
completePayment(PaymentCompletionProvider provider)
Complete a payment using the given provider.
|
PaymentSessionData |
getPaymentSessionData() |
boolean |
handlePaymentData(int requestCode,
int resultCode,
android.content.Intent data)
Method to handle Activity results from Stripe activities.
|
boolean |
init(PaymentSession.PaymentSessionListener listener,
PaymentSessionConfig paymentSessionConfig)
Initialize the PaymentSession with a
PaymentSession.PaymentSessionListener to be notified of
data changes. |
boolean |
init(PaymentSession.PaymentSessionListener listener,
PaymentSessionConfig paymentSessionConfig,
android.os.Bundle savedInstanceState)
Initialize the PaymentSession with a
PaymentSession.PaymentSessionListener to be notified of
data changes. |
void |
onDestroy()
Should be called during the host
Activity's onDestroy to detach listeners. |
void |
presentPaymentMethodSelection()
Launch the
PaymentMethodsActivity to allow the user to select a payment method,
or to add a new one. |
void |
presentShippingFlow()
Launch the
PaymentFlowActivity to allow the user to fill in payment details. |
void |
savePaymentSessionInstanceState(android.os.Bundle outState)
Save the data associated with this PaymentSession.
|
void |
setCartTotal(long cartTotal)
Set the cart total for this PaymentSession.
|
boolean |
updateIsPaymentReadyToCharge(PaymentSessionConfig paymentSessionConfig,
PaymentSessionData paymentSessionData)
Function that looks at the
PaymentSessionConfig and determines whether the data in
the provided PaymentSessionData is ready to charge. |
public static final java.lang.String TOKEN_PAYMENT_SESSION
public static final java.lang.String EXTRA_PAYMENT_SESSION_ACTIVE
public static final java.lang.String PAYMENT_SESSION_DATA_KEY
public static final java.lang.String PAYMENT_SESSION_CONFIG
public PaymentSession(android.app.Activity hostActivity)
hostActivity - an Activity from which to launch other Stripe Activities. This
Activity will receive results in
Activity.onActivityResult(int, int, Intent) that should be passed
back to this session.public void completePayment(PaymentCompletionProvider provider)
provider - a PaymentCompletionProvider that connects to a server and completes
a charge on a background thread.public boolean handlePaymentData(int requestCode,
int resultCode,
android.content.Intent data)
Activity.onActivityResult(int, int, Intent) function.requestCode - the request code used to open the resulting activityresultCode - a result code representing the success of the intended actiondata - an Intent with the resulting data from the Activitytrue if the activity result was handled by this function,
otherwise falsepublic boolean updateIsPaymentReadyToCharge(PaymentSessionConfig paymentSessionConfig, PaymentSessionData paymentSessionData)
PaymentSessionConfig and determines whether the data in
the provided PaymentSessionData is ready to charge.
Return with whether the data is ready to charge.paymentSessionConfig - specifies what data is required.paymentSessionData - holds the data that has been collected.PaymentSessionData is ready to charge.public boolean init(PaymentSession.PaymentSessionListener listener, PaymentSessionConfig paymentSessionConfig)
PaymentSession.PaymentSessionListener to be notified of
data changes.listener - a PaymentSession.PaymentSessionListener that will receive notifications of changes
in payment session status, including networking statuspaymentSessionConfig - a PaymentSessionConfig used to decide which items are
necessary in the PaymentSession.true if the PaymentSession is initialized, false if a state error
occurs. Failure can only occur if there is no initialized CustomerSession.public boolean init(PaymentSession.PaymentSessionListener listener, PaymentSessionConfig paymentSessionConfig, android.os.Bundle savedInstanceState)
PaymentSession.PaymentSessionListener to be notified of
data changes.listener - a PaymentSession.PaymentSessionListener that will receive notifications of changes
in payment session status, including networking statuspaymentSessionConfig - a PaymentSessionConfig used to decide which items are
necessary in the PaymentSession.savedInstanceState - a Bundle containing the saved state of a PaymentSession
that was stored in savePaymentSessionInstanceState(Bundle)true if the PaymentSession is initialized, false if a state error
occurs. Failure can only occur if there is no initialized CustomerSession.public void presentPaymentMethodSelection()
PaymentMethodsActivity to allow the user to select a payment method,
or to add a new one.public void savePaymentSessionInstanceState(android.os.Bundle outState)
Activity.onSaveInstanceState(Bundle) method.outState - the host activity's outgoing Bundlepublic void setCartTotal(long cartTotal)
cartTotal - the current total price for all non-shipping and non-tax items in
a customer's cartpublic void presentShippingFlow()
PaymentFlowActivity to allow the user to fill in payment details.public PaymentSessionData getPaymentSessionData()
public void onDestroy()
Activity's onDestroy to detach listeners.