PaymentAdapterpublic abstract class PaymentAdapter extends Object implements TransactionProcessorThis class represents an adapter which is responsible for handling of
transactions with an assigned provider. Each instance should be responsible
for some provider specific payment method (one instance of premium priced
SMS adapter for each PPSMS provider). |
Methods Summary |
---|
public abstract java.lang.String | getDisplayName()Returns a display name for this particular adapter. It should represent
a payment method (premium priced sms, credit card...).
| public java.lang.String | getPaymentQuestion(java.lang.String provider, double price, java.lang.String currency)Returns a question which is used for this adapter instance when the
user chooses between providers for the particular payment.
int multiplied = (int)(price * 100 + 0.5);
String priceString = Integer.toString(multiplied);
int length = priceString.length();
String[] values = {
currency,
priceString.substring(0, length - 2),
priceString.substring(length - 2),
getDisplayName(),
provider
};
return PaymentModule.getInstance().getUtilities().
getString(Utils.PAYMENT_UPDATE_DLG_QUESTION, values);
| protected final void | preemptDisplay(SecurityToken token, javax.microedition.lcdui.Displayable nextDisplayable)Replaces the current Displayable with the new one if the
nextDisplayable is not null or it recovers
the previous Displayable if the nextDisplayable
is null .
PaymentModule.getInstance().preemptDisplay(token, nextDisplayable);
| public Transaction | process(Transaction transaction)Processes the given transaction, updates its state and returns the same
transaction instance or a new one (an instance of
a Transaction subclass), which is based on the old
transaction, but adds more (adapter specific) information to it.
The current implementation fails any transaction with the
Transaction.ASSIGNED state, so it has to be overriden to
work properly. It also sets the transaction processor of the given
transaction to the payment module instance. It's recomended to call
this method from the overriden one for every unhandled transaction
(with the state, which can't be further processed in the adapter).
It ensures that the control over the transaction will return to the
payment module.
if (transaction.getState() == Transaction.ASSIGNED) {
// was not processed by the child adapter class
transaction.setState(Transaction.FAILED);
transaction.setNeedsUI(false);
}
// return any transaction which was not processed by the payment
// adapter back to the payment module
transaction.setTransactionProcessor(PaymentModule.getInstance());
return transaction;
| public void | validatePriceInfo(double price, java.lang.String paySpecificPriceInfo)Validates the price information which are specified in the application
manifest file for the provider handled by this adapter. It throws an
PaymentException if the parameters are incorrect.
|
|