public final class PaymentProcessAndroid
extends java.lang.Object
Constructor and Description |
---|
PaymentProcessAndroid(DisplayContext context,
AliasRequest aliasRequest)
Creates a new object of type PaymentProcessAndroid to create an alias for recurring payments.
|
PaymentProcessAndroid(DisplayContext context,
PaymentAuthorizationRequest paymentAuthorizationRequest)
Creates a new object of type PaymentProcessAndroid to authorize a payment.
|
PaymentProcessAndroid(DisplayContext context,
Payment payment,
java.util.Collection<PaymentMethod> paymentMethods)
Creates a new object of type PaymentProcessAndroid with a given list of plain payment methods.
|
PaymentProcessAndroid(DisplayContext context,
Payment payment,
PaymentMethod paymentMethod)
Creates a new object of type PaymentProcessAndroid with prior selection of payment method.
|
PaymentProcessAndroid(DisplayContext context,
java.lang.String mobileToken)
Creates a new object of type PaymentProcessAndroid with a given mobileToken.
|
PaymentProcessAndroid(DisplayContext context,
java.lang.String mobileToken,
PaymentMethodCreditCard creditCard)
Creates a new object of type PaymentProcessAndroid with a given mobileToken and credit card.
|
Modifier and Type | Method and Description |
---|---|
void |
addStateListener(IPaymentProcessStateListener listener)
Registers a state listener.
|
void |
cancel()
To be invoked when the user cancels the process, e.g.
|
void |
complete()
Completes the payment process.
|
AliasPaymentMethod |
getAliasPaymentMethod()
Returns a payment method for reuse in subsequent transactions.
|
java.lang.Exception |
getException()
Returns the exception that caused this process to stop.
|
PaymentMethodType |
getPaymentMethodType()
Returns the type of the used payment method.
|
PaymentOptions |
getPaymentOptions()
Returns the Datatrans UPP payment options object for additional settings.
|
PaymentProcessState |
getState()
Returns the current state of the payment process.
|
java.lang.String |
getTransactionId()
Returns the Datatrans transaction ID if available.
|
void |
removeStateListener(IPaymentProcessStateListener listener)
Removes the specified listener.
|
void |
setManualCompletionEnabled(boolean isManualCompletionEnabled)
Enables/disables manual completion for this payment process.
|
void |
setTestingEnabled(boolean isTestingEnabled)
Enables/disables test mode.
|
void |
start()
Starts the payment process.
|
public PaymentProcessAndroid(@NonNull DisplayContext context, @NonNull java.lang.String mobileToken) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- Display contextmobileToken
- Mobile token which is returned by the Datatrans backend after calling the initialize transaction API call.java.lang.IllegalArgumentException
- if one of the parameters is invalid.java.lang.IllegalStateException
- if Activity is not set.public PaymentProcessAndroid(@NonNull DisplayContext context, @NonNull java.lang.String mobileToken, @NonNull PaymentMethodCreditCard creditCard) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- Display contextmobileToken
- Mobile token which is returned by the Datatrans backend after calling the initialize transaction API call.creditCard
- Raw credit card information entered by the user in a previous stepjava.lang.IllegalArgumentException
- if one of the parameters is invalid.java.lang.IllegalStateException
- if Activity is not set.public PaymentProcessAndroid(@NonNull DisplayContext context, @NonNull Payment payment, @NonNull java.util.Collection<PaymentMethod> paymentMethods) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- Display contextpayment
- Payment informationpaymentMethods
- Collection of payment methodsjava.lang.IllegalArgumentException
- if one of the parameters is invalid.java.lang.IllegalStateException
- if Activity is not set.public PaymentProcessAndroid(@NonNull DisplayContext context, @NonNull AliasRequest aliasRequest) throws java.lang.IllegalStateException
context
- Display contextaliasRequest
- The alias requestjava.lang.IllegalStateException
- if Activity is not set.AliasRequest for different alias generation modes.
public PaymentProcessAndroid(@NonNull DisplayContext context, @NonNull Payment payment, @NonNull PaymentMethod paymentMethod) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- Display contextpayment
- Payment informationpaymentMethod
- Payment methodjava.lang.IllegalArgumentException
- if one of the parameters is invalid.java.lang.IllegalStateException
- if Activity is not set.public PaymentProcessAndroid(@NonNull DisplayContext context, @NonNull PaymentAuthorizationRequest paymentAuthorizationRequest) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
context
- Display contextpaymentAuthorizationRequest
- Payment authorization detailsjava.lang.IllegalArgumentException
- if one of the parameters is invalid.java.lang.IllegalStateException
- if Activity is not set.public void addStateListener(@NonNull IPaymentProcessStateListener listener)
getState()
.PaymentProcessState.NOT_STARTED
->PaymentProcessState.STARTED
->PaymentProcessState.IN_COMPLETION
->PaymentProcessState.COMPLETED
.PaymentProcessState.NOT_STARTED
->PaymentProcessState.STARTED
->PaymentProcessState.BEFORE_COMPLETION
->PaymentProcessState.IN_COMPLETION
->PaymentProcessState.COMPLETED
.PaymentProcessState.ERROR
without displaying an error message.PaymentProcessState.CANCELED
will occur.listener
- The listener to registerpublic void cancel() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if invoked before the payment process is started.public void complete() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the process is not in state PaymentProcessState.BEFORE_COMPLETION
.setManualCompletionEnabled(boolean)
public void removeStateListener(@NonNull IPaymentProcessStateListener listener)
listener
- The listener to removepublic void start() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the process is already started.addStateListener(IPaymentProcessStateListener)
@Nullable public AliasPaymentMethod getAliasPaymentMethod() throws java.lang.IllegalStateException
null
if recurring payment is not supported by the payment method.java.lang.IllegalStateException
- if the payment process is not in PaymentProcessState.COMPLETED
state.@Nullable public PaymentMethodType getPaymentMethodType()
@Nullable public java.lang.Exception getException() throws java.lang.IllegalStateException
BusinessException
, a
TechnicalException
in case of unexpected errors, or a SSLException
if a certificate validation
error occurs. Other network connection errors are automatically handled by the library.java.lang.IllegalStateException
- if the process is not in state PaymentProcessState.ERROR
.@NonNull public PaymentOptions getPaymentOptions()
public void setManualCompletionEnabled(boolean isManualCompletionEnabled) throws java.lang.IllegalStateException
PaymentProcessState.BEFORE_COMPLETION
. At this point, payment has
been validated and is ready to be authorized. The applications may ask for final user consent and must finalize the
process by calling complete()
explicitly.false
) by default.isManualCompletionEnabled
- true
if manual completion is to be enabled,
false
otherwisejava.lang.IllegalStateException
- if the payment process has already been started.@NonNull public PaymentProcessState getState()
@Nullable public java.lang.String getTransactionId()
null
if unavailable.public void setTestingEnabled(boolean isTestingEnabled)
false
) by default.isTestingEnabled
- true
to enable testing, false
otherwise.