I need to implement credit card transactions using authorize.net. I wanted to ask if anyone had feedback on the approach I'm planning to use, because I'm a relatively young developer and this is a pretty important thing to get right, and there are many smart and experienced people here.
I would have an action method (in a conversation-scoped bean) that looks something like this:
public void processPayment() { //execute an AUTH_ONLY request, which checks funds availability etc, but doesn't transfer funds, and returns an authcode if (successful) { //create payment record (with authcode) and persist to DB. Store transaction id locally for capture step. raiseTransactionSuccessEvent("creditCardSuccess"); } else { //prompt user for corrected info or show error screen as appropriate } } @Observer("creditCardSuccess") public void capturePayment() { //execute a PRIOR_AUTH_CAPTURE request, which does the transfer, using the stored transaction id if (successful) { //don't do much except log a success } else { //email the admin notifying him/her of failure. Admin would probably need to manually trigger a capture. } }