Sending payment information to the payment gateway

PolicyCenter uses a Gosu object that implements the PaymentInformation interface to transfer data to the payment gateway plugin. PolicyCenter saves a PaymentGatewayTransaction entity instance before sending a payment request to the payment gateway. This transaction has a String Reference property that identifies the payment gateway request. Typically, you implement separate paths for taking payment from a known payment instrument and from a new payment instrument.

For a known payment instrument, call the takePaymentUsingPaymentInstrument plugin method. This method takes an object that implements the PaymentInformation interface as an argument and returns an object that implements the PaymentGatewayResponse interface. The payment gateway does not need to present a user interface because it has all the necessary information to take the payment. The payment information argument includes the token that identifies the credit card to the payment gateway as well as the amount to charge to the card. If the payment request succeeds, the response processor creates an UpFrontPayment entity instance for the payment and updates the set of up-front payments on the job.

For a new payment instrument, call the requestSecureToken and redirectToPaymentGateway plugin methods. The requestSecureToken method takes an object that implements the PaymentInformation interface as an argument and returns an object that implements the PaymentGatewayResponse interface. For example, depending on your payment gateway, in the requestSecureToken method, you use the payment information to construct an HTTP GET command and receive the token in the response. The redirectToPaymentGateway method takes the response object that the requestSecureToken method returns and an object that implements the PaymentInformation interface as arguments. Use the payment information argument to specify any payment details that are not encoded in the secure token in the response argument. This method opens the exit point that transfers control to the payment gateway.

Some payment gateways require verification of a new payment instrument. To provide this verification, implement the submitAccountVerification plugin method. This method takes an object that implements the PaymentInformation interface as an argument and returns an object that implements the PaymentGatewayResponse interface.

The payment gateway typically uses a servlet to send the result of the payment request that uses a new payment instrument to PolicyCenter.