This service is used by the PaymentConfirmationService to create a PaymentTransaction to send to the configured payment gateway via the PaymentGatewayTransactionService as well as record the response of the authorization on the transaction.
PaymentTransactions
store individual transactions for Payments, that is, the operations the payment has undergone through a payment gateway.
Thus, in a typical Broadleaf flow, there would be an "authorize" transaction created during checkout indicating the payment method is valid and authorized by the payer for use; then, at the time of fulfillment, a "capture" transaction would be added to the payment indicating the funds have been transferred.
PaymentTransactions
also contain some audit data.
-
AUTHORIZE
: Funds have been authorized for capture.
This might appear as a 'pending' transaction on a customer’s credit card statement.
-
REVERSE_AUTH
: The reverse of an AUTHORIZE
transaction.
This can only occur after funds have been authorized, and before they have been captured.
-
CAPTURE
: Funds have been charged/submitted/debited from the customer and payment is complete.
Can only occur after an amount has been authorized.
-
AUTHORIZE_AND_CAPTURE
: Funds have been captured/authorized all at once.
While this might be the simplest to implement from an order management perspective, the recommended approach is to AUTHORIZE
during checkout, and then CAPTURE
at the time of fulfillment.
-
REFUND
: Funds have been refunded/credited.
This can only occur after funds have been captured or settled.
-
DETACHED_CREDIT
: Some payment processors allow you to issue credit to a customer that is not tied to an initial AUTHORIZE
or AUTHORIZE_AND_CAPTURE
transaction.
-
Most payment gateways disable this feature by default because it is against card association (e.g. Visa, MasterCard) rules.
-
However, there may be legitimate instances where you had a sale transaction but are not able to issue a refund (e.g. closed account of original payment, etc…)
-
This can also be referred to as a "blind credit" or "stand-alone credit"
PassthroughTransactionService
Out-of-the-box, Broadleaf provides an implementation of the PaymentTransactionService
for development-only purposes that doesn’t actual integrate with any payment gateway provider (e.g., PayPal or Stripe) called PassthroughTransactionService.
This will allow developers to work on the checkout process without having to immediately handle integrating a payment gateway.
It will handle requests to authorize, capture, auth-and-capture, refund, and void with dummy responses that can be used seamlessly in the checkout flow just by enabling it with the property, broadleaf.payment.gateway.passthrough-transactions.active=true
.
If also using the starter commerce app, set REACT_APP_PAYMENT_GATEWAY_TYPE=PASSTHROUGH
; otherwise, make sure to include the gateway type of PASSTHROUGH
in the payment’s gateway properties during checkout: paymentGatewayProperties['gatewayType'] = PASSTHROUGH
.