TODO: Age check methods
TODO: Make sure that no calls result in cross-provider data, like a card stored with on provider being used for transactions on another.
TODO: Provide batch close calls?
- Author:
- AO Industries, Inc.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final PersistenceMechanism
protected final MerchantServicesProvider
-
Constructor Summary
ConstructorDescriptionCreditCardProcessor
(MerchantServicesProvider provider, PersistenceMechanism persistenceMechanism) Creates a newCreditCardProcessor
. -
Method Summary
Modifier and TypeMethodDescriptionauthorize
(Principal principal, Group group, TransactionRequest transactionRequest, CreditCard creditCard) Authorizes a sale.boolean
Queries the provider to see if they support the secure storage of credit cards.capture
(Principal principal, Transaction transaction) Captures the funds from a previous call toauthorize
.credit
(TransactionRequest transactionRequest, CreditCard creditCard) Requests a credit.void
deleteCreditCard
(Principal principal, CreditCard creditCard) Deletes the credit card information from the secure storage.Gets the uniqueId of the provider this processor is using.sale
(Principal principal, Group group, TransactionRequest transactionRequest, CreditCard creditCard) Performs an immediate sale, effectively a combination ofauthorize
andcapture
.void
storeCreditCard
(Principal principal, Group group, CreditCard creditCard) Stores a credit card securely for later reuse.void
synchronizeStoredCards
(Principal principal, PrintWriter verboseOut, PrintWriter infoOut, PrintWriter warningOut, boolean dryRun) Synchronizes any replacement masked card numbers or expiration dates from the provider back into the persistence mechanism.void
updateCreditCard
(Principal principal, CreditCard creditCard) Updates the credit card details, all except the card number and expiration.void
updateCreditCardExpiration
(Principal principal, CreditCard creditCard, byte expirationMonth, short expirationYear) Updates the credit card expiration.void
updateCreditCardNumberAndExpiration
(Principal principal, CreditCard creditCard, String cardNumber, byte expirationMonth, short expirationYear, String cardCode) Updates the credit card number, expiration, and (optionally) card code.voidTransaction
(Principal principal, Transaction transaction) Voids a previous transaction.
-
Field Details
-
provider
-
persistenceMechanism
-
-
Constructor Details
-
CreditCardProcessor
public CreditCardProcessor(MerchantServicesProvider provider, PersistenceMechanism persistenceMechanism) Creates a newCreditCardProcessor
.
-
-
Method Details
-
getProviderId
Gets the uniqueId of the provider this processor is using. -
sale
public Transaction sale(Principal principal, Group group, TransactionRequest transactionRequest, CreditCard creditCard) throws SQLException Performs an immediate sale, effectively a combination ofauthorize
andcapture
. The transaction is inserted into the persistence layer first in a PROCESSING state, the provider performs the sale, and then the persistence layer transaction state is changed to the appropriate final state. Thus, any problem or restart will not lose record of the transaction, and the PROCESSING state transaction may be manually resolved.- Parameters:
principal
-null
is acceptablegroup
-null
is acceptabletransactionRequest
- The transaction details for this salecreditCard
- The credit card to charge for this sale. The masked card number and/or expiration might be updated during the sale, and if updated the changes will have already been persisted.- Throws:
SQLException
- See Also:
-
authorize
public Transaction authorize(Principal principal, Group group, TransactionRequest transactionRequest, CreditCard creditCard) throws SQLException Authorizes a sale. The funds are reserved but not captured until a later call to capture. The transaction is inserted into the persistence layer first in a PROCESSING state, the provider performs the authorization, and then the persistence layer transaction state is changed to the appropriate final state. Thus, any problem or restart will not lose record of the transaction, and the PROCESSING state transaction may be manually resolved.- Parameters:
principal
-null
is acceptablegroup
-null
is acceptabletransactionRequest
- The transaction details for this salecreditCard
- The credit card to charge for this sale. The masked card number and/or expiration might be updated during the sale, and if updated the changes will have already been persisted.- Throws:
SQLException
- See Also:
-
capture
Captures the funds from a previous call toauthorize
.- Parameters:
principal
-null
is acceptable- Throws:
SQLException
- See Also:
-
voidTransaction
Voids a previous transaction. Updates the persistence mechanism. Updates the voidResult on the transaction. If the void was successful, updates the status of the transaction passed in. Transaction status must be AUTHORIZED, CAPTURED, or HOLD.- Throws:
SQLException
- when unable to update the persistence layer- See Also:
-
credit
Requests a credit. -
canStoreCreditCards
Queries the provider to see if they support the secure storage of credit cards.- Throws:
IOException
- when unable to contact the bank
-
storeCreditCard
public void storeCreditCard(Principal principal, Group group, CreditCard creditCard) throws IOException, SQLException Stores a credit card securely for later reuse. Sets the providerId, providerUniqueId, principalName, groupName, and persistenceUniqueId. Upon success, clears the cardNumber and expiration date.- Throws:
IOException
- when unable to contact the bankSQLException
- when unable to store in the persistence layer
-
updateCreditCard
public void updateCreditCard(Principal principal, CreditCard creditCard) throws IOException, SQLException Updates the credit card details, all except the card number and expiration. If card stored to secure storage, updates that storage. Any desired changes must have been made tocreditCard
object preceding this call.- Throws:
IOException
- when unable to contact the bankSQLException
- when unable to store in the persistence layer
-
updateCreditCardNumberAndExpiration
public void updateCreditCardNumberAndExpiration(Principal principal, CreditCard creditCard, String cardNumber, byte expirationMonth, short expirationYear, String cardCode) throws IOException, SQLException Updates the credit card number, expiration, and (optionally) card code. If card stored to secure storage, updates that storage. Also updatescreditCard
directly.- Throws:
IOException
- when unable to contact the bankSQLException
- when unable to store in the persistence layer
-
updateCreditCardExpiration
public void updateCreditCardExpiration(Principal principal, CreditCard creditCard, byte expirationMonth, short expirationYear) throws IOException, SQLException Updates the credit card expiration. If card stored to secure storage, updates that storage. Also updatescreditCard
directly.- Throws:
IOException
- when unable to contact the bankSQLException
-
deleteCreditCard
public void deleteCreditCard(Principal principal, CreditCard creditCard) throws IOException, SQLException Deletes the credit card information from the secure storage. Clears the providerUniqueId and persistenceUniqueId on the creditCard.- Throws:
IOException
- when unable to contact the bankSQLException
- when unable to update the persistence layer
-
synchronizeStoredCards
public void synchronizeStoredCards(Principal principal, PrintWriter verboseOut, PrintWriter infoOut, PrintWriter warningOut, boolean dryRun) throws IOException, SQLException Synchronizes any replacement masked card numbers or expiration dates from the provider back into the persistence mechanism.This should be called periodically to keep the local representation of the card up-to-date with any new card information available from the payment provider, such as automatic card expiration updates.
Scheduling of the synchronization is beyond the scope of this project, but AO Cron may be fit for purpose.
- Throws:
IOException
SQLException
-