public class AbstractPunchoutPaymentPluginImpl
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTEXT_AMOUNT
The key of punch-out payment context standing for amount.
|
static java.lang.String |
CONTEXT_CURRENCY
The key of punch-out payment context standing for currency.
|
static java.lang.String |
CONTEXT_ID
The key of punch-out payment context standing for payment instruction identifier.
|
static java.lang.String |
CONTEXT_ORDER_ID
The key of punch-out payment context standing for order identifier.
|
static java.lang.String |
COPYRIGHT
Copyright.
|
Constructor and Description |
---|
AbstractPunchoutPaymentPluginImpl() |
Modifier and Type | Method and Description |
---|---|
FinancialTransaction |
approve(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method executes payment authorization via communicating with the system of payment service provider.
|
FinancialTransaction |
approveAndDeposit(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method executes payment authorization and capture via communicating with the system of payment service provider in one transaction.
|
boolean |
checkHealth()
This method always returns true.
|
void |
checkPaymentInstruction(PluginContext pluginContext,
PaymentInstruction paymentInstruction)
This method checks the payment instruction, it does nothing here.
|
FinancialTransaction |
credit(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method is the default implementation of credit.
|
FinancialTransaction |
deposit(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method is the void implementation of deposit, it does nothing here.
|
java.lang.String |
getAuthenticationURL(PluginContext pluginContext,
PaymentInstruction paymentInstruction)
In punch-out payment flow, shopper would be routed to payment service provider website to input payment information.
|
java.math.BigDecimal |
getAvailableBalance(PluginContext pluginContext,
PaymentInstruction paymentInstruction)
This method returns the available balance.
|
Credit |
getCredit(PluginContext pluginContext,
Credit theCredit)
This method returns the credit.
|
java.lang.String |
getMessage(PluginContext pluginContext,
java.lang.String messageKey)
This method is used to return the translated error string associated to an error key.
|
Payment |
getPayment(PluginContext pluginContext,
Payment payment)
This method returns the payment.
|
void |
initAuthenticationSession(PluginContext pluginContext,
PaymentInstruction paymentInstruction)
This method executes pre-authentication operation with payment service provider and gets some pre-authentication data.
|
java.lang.String |
preprocessProviderResponseData(PluginContext pluginContext,
java.util.Map callbackParameters)
This method pre-processes the response from the punch-out payment service provider.
|
java.util.Map |
processProviderResponse(PluginContext pluginContext,
PaymentInstruction paymentInstruction,
java.util.Map callbackParameters)
This method processes payment transaction response from punch-out payment service provider side.
|
FinancialTransaction |
reverseApproval(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method is the void implementation of
reverseApproval , it sets the response code to success for the financial transaction. |
FinancialTransaction |
reverseCredit(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method is the void implementation of
reverseCredit , it throws FunctionNotSupportedException here. |
FinancialTransaction |
reverseDeposit(PluginContext pluginContext,
FinancialTransaction financialTransaction,
boolean retry)
This method is the void implementation of
reverseDeposit , it throws FunctionNotSupportedException here. |
void |
validatePaymentInstruction(PluginContext pluginContext,
PaymentInstruction paymentInstruction)
This method is the void implementation of
validatePaymentInstruction , it does nothing. |
public static final java.lang.String COPYRIGHT
public static final java.lang.String CONTEXT_ID
public static final java.lang.String CONTEXT_AMOUNT
public static final java.lang.String CONTEXT_CURRENCY
public static final java.lang.String CONTEXT_ORDER_ID
public java.lang.String getMessage(PluginContext pluginContext, java.lang.String messageKey)
pluginContext
- messageKey
- PluginException
public FinancialTransaction approve(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws CommunicationException, PluginException
This method executes payment authorization via communicating with the system of payment service provider.
Because the punch-out payment is totally processed in the website of payment service provider. And then the system of payment service provider will call-back to Commerce application to update the order and payment status. Implementation of this API does nothing except for setting payment status as PENDING in Commerce application. It would leave the call-back interaction update the PENDING payment status to SUCCESS or FAILURE. Usually when you implement your own punch-out payment plug-in, you need not to override this method while just respect current implementation.
pluginContext
- contains the payment method information plus any additional data required to process the payment.financialTransaction
- contains the amount and other payment protocol data required to process the transaction.retry
- indicates this is a retry of the operationFinancialTransaction
that represents the updated authorization financial transaction.PluginException
- thrown when encounter problems.CommunicationException
public FinancialTransaction approveAndDeposit(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws FunctionNotSupportedException, PluginException
This method executes payment authorization and capture via communicating with the system of payment service provider in one transaction.
Because the punch-out payment is totally processed in the website of payment service provider. And then the system of payment service provider will call-back to Commerce application to update the order and payment status. Implementation of this API does nothing except setting payment status on commerce side as PENDING . It would leave the call-back interaction update the PENDING payment status to SUCCESS or FAILURE. Usually when you implement your own punch-out payment plug-in, you need not to override this method while just respect current implementation.
pluginContext
- contains the payment method information plus any additional data required to process the payment.financialTransaction
- contains the amount and other payment protocol data required to process the transaction.retry
- indicates this is a retry of the operationFinancialTransaction
that represents the updated authorization with capture financial transaction.PluginException
- contains the payment method information plus any additional data required to process the payment.FunctionNotSupportedException
public void checkPaymentInstruction(PluginContext pluginContext, PaymentInstruction paymentInstruction) throws InvalidPaymentInstructionException, ConfigurationException, InvalidDataException
pluginContext
- paymentInstruction
- PluginException
InvalidPaymentInstructionException
ConfigurationException
InvalidDataException
public FinancialTransaction credit(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws PluginException
pluginContext
- financialTransaction
- retry
- PluginException
public FinancialTransaction deposit(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws PluginException
pluginContext
- financialTransaction
- retry
- PluginException
public FinancialTransaction reverseApproval(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws CommunicationException, PluginException
reverseApproval
, it sets the response code to success for the financial transaction.pluginContext
- financialTransaction
- retry
- PluginException
CommunicationException
public FinancialTransaction reverseCredit(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws InvalidPaymentInstructionException, FunctionNotSupportedException, InvalidDataException
reverseCredit
, it throws FunctionNotSupportedException
here.pluginContext
- financialTransaction
- retry
- PluginException
InvalidPaymentInstructionException
FunctionNotSupportedException
InvalidDataException
public FinancialTransaction reverseDeposit(PluginContext pluginContext, FinancialTransaction financialTransaction, boolean retry) throws FunctionNotSupportedException, PluginException
reverseDeposit
, it throws FunctionNotSupportedException
here.pluginContext
- financialTransaction
- retry
- PluginException
FunctionNotSupportedException
public void validatePaymentInstruction(PluginContext pluginContext, PaymentInstruction paymentInstruction) throws InvalidPaymentInstructionException, FunctionNotSupportedException
validatePaymentInstruction
, it does nothing.pluginContext
- paymentInstruction
- PluginException
InvalidPaymentInstructionException
FunctionNotSupportedException
public boolean checkHealth()
public java.math.BigDecimal getAvailableBalance(PluginContext pluginContext, PaymentInstruction paymentInstruction) throws FunctionNotSupportedException
FunctionNotSupportedException
here.pluginContext
- paymentInstruction
- PluginException
FunctionNotSupportedException
public Credit getCredit(PluginContext pluginContext, Credit theCredit) throws FunctionNotSupportedException
pluginContext
- theCredit
- PluginException
FunctionNotSupportedException
public Payment getPayment(PluginContext pluginContext, Payment payment) throws FunctionNotSupportedException
pluginContext
- payment
- PluginException
FunctionNotSupportedException
public void initAuthenticationSession(PluginContext pluginContext, PaymentInstruction paymentInstruction) throws CommunicationException, InvalidDataException
This method executes pre-authentication operation with payment service provider and gets some pre-authentication data. For example, some payment service providers need to execute this pre-authentication operation to generate a token and return to e-Commerce application. The token will be as the unique identifier in the whole life cycle of the payment.
Whether the pre-authentication is needed in the payment processing can be configured in payment plug-in descriptor.
pluginContext
- contains all the information needed by a plugin to process the request as obtained from the deployment descriptor.paymentInstruction
- contains the Payment Method information plus any additional data require to process the payment.PluginException
- thrown when the payment instruction is expired.CommunicationException
InvalidDataException
public java.lang.String getAuthenticationURL(PluginContext pluginContext, PaymentInstruction paymentInstruction) throws PluginException
In punch-out payment flow, shopper would be routed to payment service provider website to input payment information. This method is to build the URL of the website of third party payment service provider.
pluginContext
- contains all the information needed by a payment plug-in to process the request as obtained from the deployment descriptor.paymentInstruction
- contains the payment method information plus any additional data which is required to process the payment.PluginException
- thrown when any exception conditions specified by the PluginException
hierarchy are met; for more details, please refer to the plug-in exceptions hierarchy Javadocs
.public java.lang.String preprocessProviderResponseData(PluginContext pluginContext, java.util.Map callbackParameters) throws PluginException
This method pre-processes the response from the punch-out payment service provider. Usually, when shopper inputs payment information and complete payment in payment service provider website, the payment system will call back to Commerce via URL requests. Then order and payment status can be updated in Commerce application. This method is used to parse URL requests to make it readable by the command updating order and payment status.
pluginContext
- contains all of the context information needed by a payment plug-in to process the request as obtained from the deployment descriptor.callbackParameters
- the parameters in callback request.PluginException
- thrown when exceptional situation happens in the payment plug-in.public java.util.Map processProviderResponse(PluginContext pluginContext, PaymentInstruction paymentInstruction, java.util.Map callbackParameters) throws PluginException
This method processes payment transaction response from punch-out payment service provider side. After the preprocessProviderResponseData
parses the URL requests from punch-out payment service provider side and make it readable by Commerce command. This API would be called to communicate with the punch-out payment system to verify whether it is a real and valid request from it.
pluginContext
- contains all of the context information needed by a payment plug-in to process the request as obtained from the deployment descriptor.paymentInstruction
- the PaymentInstruction
container with the basic information and protocol data of the payment methodcallbackParameters
- the parameters in callback requestnull
if the value cannot be retrieved.PluginException
- thrown when exceptional situation happens in the payment plug-in.