Skip to content

Commit 3b93874

Browse files
committed
BroadleafCommerce/QA#497 Implementation of the solution discussed in the referenced issue.
1 parent af05474 commit 3b93874

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.broadleafcommerce.common.money.Money;
2525
import org.broadleafcommerce.common.payment.PaymentType;
2626
import org.broadleafcommerce.common.payment.dto.PaymentRequestDTO;
27+
import org.broadleafcommerce.common.util.BLCSystemProperty;
2728
import org.broadleafcommerce.core.order.domain.FulfillmentGroup;
2829
import org.broadleafcommerce.core.order.domain.Order;
2930
import org.broadleafcommerce.core.order.service.FulfillmentGroupService;
@@ -170,10 +171,25 @@ protected void populateShipTo(Order order, PaymentRequestDTO requestDTO) {
170171
if (fgAddress.getPhonePrimary() != null) {
171172
phone = fgAddress.getPhonePrimary().getPhoneNumber();
172173
}
173-
174+
String firstName;
175+
String lastName;
176+
if (BLCSystemProperty.resolveBooleanSystemProperty("validator.address.fullNameOnly")) {
177+
String fullName = fgAddress.getFullName();
178+
179+
if ((fullName.indexOf(' ') != -1) && (fullName.length() > fullName.indexOf(' ') + 1)) {
180+
firstName = fullName.substring(0, fullName.indexOf('_'));
181+
lastName = fullName.substring(fullName.lastIndexOf(' ') + 1, fullName.length());
182+
} else {
183+
firstName = fullName;
184+
lastName = "";
185+
}
186+
} else {
187+
firstName = fgAddress.getFirstName();
188+
lastName = fgAddress.getLastName();
189+
}
174190
requestDTO.shipTo()
175-
.addressFirstName(fgAddress.getFirstName())
176-
.addressLastName(fgAddress.getLastName())
191+
.addressFirstName(firstName)
192+
.addressLastName(lastName)
177193
.addressCompanyName(fgAddress.getCompanyName())
178194
.addressLine1(fgAddress.getAddressLine1())
179195
.addressLine2(fgAddress.getAddressLine2())
@@ -213,10 +229,25 @@ protected void populateBillTo(Order order, PaymentRequestDTO requestDTO) {
213229
if (billAddress.getPhonePrimary() != null) {
214230
phone = billAddress.getPhonePrimary().getPhoneNumber();
215231
}
216-
232+
String firstName;
233+
String lastName;
234+
if (BLCSystemProperty.resolveBooleanSystemProperty("validator.address.fullNameOnly")) {
235+
String fullName = billAddress.getFullName();
236+
237+
if ((fullName.indexOf(' ') != -1) && (fullName.length() > fullName.indexOf(' ') + 1)) {
238+
firstName = fullName.substring(0, fullName.indexOf('_'));
239+
lastName = fullName.substring(fullName.lastIndexOf(' ') + 1, fullName.length());
240+
} else {
241+
firstName = fullName;
242+
lastName = "";
243+
}
244+
} else {
245+
firstName = billAddress.getFirstName();
246+
lastName = billAddress.getLastName();
247+
}
217248
requestDTO.billTo()
218-
.addressFirstName(billAddress.getFirstName())
219-
.addressLastName(billAddress.getLastName())
249+
.addressFirstName(firstName)
250+
.addressLastName(lastName)
220251
.addressCompanyName(billAddress.getCompanyName())
221252
.addressLine1(billAddress.getAddressLine1())
222253
.addressLine2(billAddress.getAddressLine2())

0 commit comments

Comments
 (0)