Skip to content

Commit e0505c5

Browse files
committed
Merge branch 'BroadleafCommerce-4.0.x' of https://github.com/BroadleafCommerce/BroadleafCommerce into develop
2 parents dfd8bb8 + 3b29d72 commit e0505c5

File tree

5 files changed

+113
-15
lines changed

5 files changed

+113
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* #%L
3+
* BroadleafCommerce Common Libraries
4+
* %%
5+
* Copyright (C) 2009 - 2015 Broadleaf Commerce
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
/**
21+
*
22+
*/
23+
package org.broadleafcommerce.common.payment.service;
24+
25+
import org.broadleafcommerce.common.payment.dto.PaymentRequestDTO;
26+
27+
28+
/**
29+
* Simple interface for returning a {@link PaymentRequestDTO} based on the current order in the system (like something on
30+
* threadlocal).
31+
*
32+
* @author Phillip Verheyden (phillipuniverse)
33+
*/
34+
public interface CurrentOrderPaymentRequestService {
35+
36+
/**
37+
* Returns a {@link PaymentRequestDTO} based on all the information from the current order in the system, like one
38+
* on threadlocal
39+
*/
40+
public PaymentRequestDTO getPaymentRequestFromCurrentOrder();
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* #%L
3+
* BroadleafCommerce Framework Web
4+
* %%
5+
* Copyright (C) 2009 - 2015 Broadleaf Commerce
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
/**
21+
*
22+
*/
23+
package org.broadleafcommerce.core.web.payment.service;
24+
25+
import org.broadleafcommerce.common.payment.dto.PaymentRequestDTO;
26+
import org.broadleafcommerce.common.payment.service.CurrentOrderPaymentRequestService;
27+
import org.broadleafcommerce.core.order.domain.Order;
28+
import org.broadleafcommerce.core.payment.service.OrderToPaymentRequestDTOService;
29+
import org.broadleafcommerce.core.web.order.CartState;
30+
import org.springframework.stereotype.Service;
31+
32+
import javax.annotation.Resource;
33+
34+
35+
/**
36+
*
37+
* @author Phillip Verheyden (phillipuniverse)
38+
*/
39+
@Service("blDefaultCurrentPaymentRequestService")
40+
public class DefaultCurrentOrderPaymentRequestService implements CurrentOrderPaymentRequestService {
41+
42+
@Resource
43+
protected OrderToPaymentRequestDTOService paymentRequestDTOService;
44+
45+
@Override
46+
public PaymentRequestDTO getPaymentRequestFromCurrentOrder() {
47+
Order currentCart = CartState.getCart();
48+
PaymentRequestDTO request = paymentRequestDTOService.translateOrder(currentCart);
49+
return request;
50+
}
51+
52+
}

core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/checkout/service/workflow/ValidateAndConfirmPaymentActivity.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,29 +145,29 @@ public ProcessContext<CheckoutSeed> execute(ProcessContext<CheckoutSeed> context
145145
PaymentGatewayConfigurationService cfg = paymentConfigurationServiceProvider.getGatewayConfigurationService(tx.getOrderPayment().getGatewayType());
146146
PaymentResponseDTO responseDTO = null;
147147

148+
PaymentRequestDTO confirmationRequest = orderToPaymentRequestService.translatePaymentTransaction(payment.getAmount(), tx);
149+
populateBillingAddressOnRequest(confirmationRequest, payment);
150+
populateCustomerOnRequest(confirmationRequest, payment);
151+
populateShippingAddressOnRequest(confirmationRequest, payment);
152+
148153
if (PaymentType.CREDIT_CARD.equals(payment.getType())) {
149154
// Handles the PCI-Compliant Scenario where you have an UNCONFIRMED CREDIT_CARD payment on the order.
150155
// This can happen if you send the Credit Card directly to Broadleaf or you use a Digital Wallet solution like MasterPass.
151156
// The Actual Credit Card PAN is stored in blSecurePU and will need to be sent to the Payment Gateway for processing.
152157

153-
PaymentRequestDTO s2sRequest = orderToPaymentRequestService.translatePaymentTransaction(payment.getAmount(), tx);
154-
populateCreditCardOnRequest(s2sRequest, payment);
155-
populateBillingAddressOnRequest(s2sRequest, payment);
156-
populateCustomerOnRequest(s2sRequest, payment);
157-
populateShippingAddressOnRequest(s2sRequest, payment);
158+
populateCreditCardOnRequest(confirmationRequest, payment);
158159

159160
if (cfg.getConfiguration().isPerformAuthorizeAndCapture()) {
160-
responseDTO = cfg.getTransactionService().authorizeAndCapture(s2sRequest);
161+
responseDTO = cfg.getTransactionService().authorizeAndCapture(confirmationRequest);
161162
} else {
162-
responseDTO = cfg.getTransactionService().authorize(s2sRequest);
163+
responseDTO = cfg.getTransactionService().authorize(confirmationRequest);
163164
}
164165

165166
} else {
166167
// This handles the THIRD_PARTY_ACCOUNT scenario (like PayPal Express Checkout) where
167168
// the transaction just needs to be confirmed with the Gateway
168169

169-
responseDTO = cfg.getTransactionConfirmationService()
170-
.confirmTransaction(orderToPaymentRequestService.translatePaymentTransaction(payment.getAmount(), tx));
170+
responseDTO = cfg.getTransactionConfirmationService().confirmTransaction(confirmationRequest);
171171
}
172172

173173
if (responseDTO == null) {

core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/payment/service/DefaultPaymentGatewayCheckoutService.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.broadleafcommerce.common.i18n.service.ISOService;
2828
import org.broadleafcommerce.common.payment.PaymentAdditionalFieldType;
2929
import org.broadleafcommerce.common.payment.PaymentGatewayType;
30-
import org.broadleafcommerce.common.payment.PaymentType;
3130
import org.broadleafcommerce.common.payment.dto.AddressDTO;
3231
import org.broadleafcommerce.common.payment.dto.GatewayCustomerDTO;
3332
import org.broadleafcommerce.common.payment.dto.PaymentResponseDTO;
@@ -171,8 +170,7 @@ public Long applyPaymentToOrder(PaymentResponseDTO responseDTO, PaymentGatewayCo
171170

172171
paymentsToInvalidate.add(p);
173172

174-
if (PaymentType.CREDIT_CARD.equals(p.getType()) &&
175-
PaymentGatewayType.TEMPORARY.equals(p.getGatewayType()) ) {
173+
if (PaymentGatewayType.TEMPORARY.equals(p.getGatewayType()) ) {
176174
tempBillingAddress = p.getBillingAddress();
177175
}
178176
}
@@ -201,8 +199,7 @@ public Long applyPaymentToOrder(PaymentResponseDTO responseDTO, PaymentGatewayCo
201199
}
202200

203201
//Set the Credit Card Info on the Additional Fields Map
204-
if (PaymentType.CREDIT_CARD.equals(responseDTO.getPaymentType()) &&
205-
responseDTO.getCreditCard() != null && responseDTO.getCreditCard().creditCardPopulated()) {
202+
if (responseDTO.getCreditCard() != null && responseDTO.getCreditCard().creditCardPopulated()) {
206203

207204
transaction.getAdditionalFields().put(PaymentAdditionalFieldType.NAME_ON_CARD.getType(),
208205
responseDTO.getCreditCard().getCreditCardHolderName());

core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/payment/service/OrderToPaymentRequestDTOServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ public PaymentRequestDTO translatePaymentTransaction(Money transactionAmount, Pa
8383
.orderCurrencyCode(paymentTransaction.getOrderPayment().getCurrency().getCurrencyCode())
8484
.orderId(paymentTransaction.getOrderPayment().getOrder().getId().toString());
8585

86+
Order order = paymentTransaction.getOrderPayment().getOrder();
87+
populateCustomerInfo(order, requestDTO);
88+
populateShipTo(order, requestDTO);
89+
populateBillTo(order, requestDTO);
90+
populateTotals(order, requestDTO);
91+
populateDefaultLineItemsAndSubtotal(order, requestDTO);
92+
8693
//Copy Additional Fields from PaymentTransaction into the Request DTO.
8794
//This will contain any gateway specific information needed to perform actions on this transaction
8895
Map<String, String> additionalFields = paymentTransaction.getAdditionalFields();
@@ -196,7 +203,7 @@ public void populateShipTo(Order order, PaymentRequestDTO requestDTO) {
196203
@Override
197204
public void populateBillTo(Order order, PaymentRequestDTO requestDTO) {
198205
for (OrderPayment payment : order.getPayments()) {
199-
if (payment.isActive() && PaymentType.CREDIT_CARD.equals(payment.getType())) {
206+
if (payment.isActive()) {
200207
Address billAddress = payment.getBillingAddress();
201208
if (billAddress != null) {
202209
String stateAbbr = null;

0 commit comments

Comments
 (0)