Skip to content

Commit

Permalink
Merge pull request #118 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 4.2.0
  • Loading branch information
rkewlani authored Apr 30, 2019
2 parents ed06589 + 97f85fb commit d3293af
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ant clean all
### 5. Add your Adyen credentials to the BaseStore via Hybris backoffice

For more detailed instructions you can visit the [documentation page](https://docs.adyen.com/developers/plug-ins-and-partners/hybris)
Please make sure your merchant has Variant true in API and responses section so that you get paymentMethod back in response.


## Supported payment methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_CC;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_ONECLICK;
import static com.adyen.v6.constants.Adyenv6coreConstants.RATEPAY;
import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_MULTIBANCO;

@Controller
@RequestMapping(value = AdyenControllerConstants.SUMMARY_CHECKOUT_PREFIX)
Expand Down Expand Up @@ -173,6 +174,11 @@ public String placeOrder(@ModelAttribute("placeOrderForm") final PlaceOrderForm
if (PAYMENT_METHOD_BOLETO.equals(cartData.getAdyenPaymentMethod())) {
addBoletoMessage(redirectModel, orderData.getCode());
}

else if (PAYMENT_METHOD_MULTIBANCO.equals(cartData.getAdyenPaymentMethod())) {
addMultibancoMessage(redirectModel, orderData.getCode());
}

return redirectToOrderConfirmationPage(orderData);
} catch (ApiException e) {
LOGGER.error("API exception ", e);
Expand Down Expand Up @@ -275,6 +281,25 @@ private void addBoletoMessage(RedirectAttributes redirectModel, final String ord
"Boleto PDf: <a target=\"_blank\" href=\"" + orderData.getAdyenBoletoUrl() + "\" title=\"Boleto PDF\">Download</a>");
}


/**
* Adds a flash message containing the Multibanco response fields
*/
private void addMultibancoMessage(RedirectAttributes redirectModel, final String orderCode) {
//Use OrderFacade to force execution of AbstractOrder populators

OrderData orderData = orderFacade.getOrderDetailsForCode(orderCode);

GlobalMessages.addFlashMessage(redirectModel,
GlobalMessages.INFO_MESSAGES_HOLDER,
"<p> Multibanco order summary " + "</p>" +
"<p> Amount: " + orderData.getAdyenMultibancoAmount() + "</p>"
+ "<p> Entity: " + orderData.getAdyenMultibancoEntity() + "</p>"
+ "<p> Deadline: " + orderData.getAdyenMultibancoDeadline() + "</p>"
+ "<p> Reference: " + orderData.getAdyenMultibancoReference() + "</p>"
);
}

/**
* Methods supported via API
* Credit Cards/OneClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.name=platform-module
name=adyenv6b2ccheckoutaddon
releasedate=20170509 1903
vendor=adyen
version=4.1.0
version.api=4.1.0
version=4.2.0
version.api=4.2.0
4 changes: 2 additions & 2 deletions adyenv6backoffice/resources/adyenv6backoffice.build.number
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.name=platform-module
name=adyenv6backoffice
releasedate=20170509 1903
vendor=adyen
version=4.1.0
version.api=4.1.0
version=4.2.0
version.api=4.2.0
Binary file not shown.
13 changes: 13 additions & 0 deletions adyenv6core/resources/adyenv6core-beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<property name="adyenSocialSecurityNumber" type="java.lang.String"/>
<property name="adyenDfValue" type="java.lang.String"/>
<property name="adyenFirstName" type="java.lang.String"/>
<property name="adyenInstallments" type="java.lang.Integer"/>
<property name="adyenLastName" type="java.lang.String"/>
<property name="adyenPaymentToken" type="java.lang.String"/>
<property name="adyenReturnUrl" type="java.lang.String"/>
Expand All @@ -37,8 +38,13 @@
<bean class="de.hybris.platform.commercefacades.order.data.AbstractOrderData">
<property name="adyenBoletoUrl" type="java.lang.String"/>
<property name="adyenBoletoData" type="java.lang.String"/>
<property name="adyenBoletoBarCodeReference" type="String" />
<property name="adyenBoletoExpirationDate" type="java.util.Date"/>
<property name="adyenBoletoDueDate" type="java.util.Date"/>
<property name="adyenMultibancoEntity" type="java.lang.String" />
<property name="adyenMultibancoAmount" type="java.math.BigDecimal" />
<property name="adyenMultibancoDeadline" type="java.lang.String" />
<property name="adyenMultibancoReference" type="java.lang.String" />
</bean>

<bean class="de.hybris.platform.commercefacades.order.data.OrderEntryData">
Expand All @@ -55,13 +61,20 @@
<property name="adyenSelectedReference" type="String" />
<property name="adyenSocialSecurityNumber" type="String" />
<property name="adyenFirstName" type="String" />
<property name="installments" type="Integer" />
<property name="adyenLastName" type="String" />
</bean>

<bean class="de.hybris.platform.commercewebservicescommons.dto.order.AbstractOrderWsDTO">
<property name="adyenBoletoUrl" type="String" />
<property name="adyenBoletoData" type="String" />
<property name="adyenBoletoBarCodeReference" type="String" />
<property name="adyenBoletoExpirationDate" type="java.util.Date" />
<property name="adyenBoletoDueDate" type="java.util.Date" />
<property name="adyenMultibancoEntity" type="String" />
<property name="adyenMultibancoAmount" type="java.math.BigDecimal" />
<property name="adyenMultibancoDeadline" type="String" />
<property name="adyenMultibancoReference" type="String" />
</bean>

</beans>
37 changes: 37 additions & 0 deletions adyenv6core/resources/adyenv6core-items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@
<description>Shopper's first name (applicable for Boleto)</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenInstallments" type="java.lang.Integer">
<description>Number of Installments</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenLastName" type="java.lang.String">
<description>Shopper's last name (applicable for Boleto)</description>
<persistence type="property"/>
Expand All @@ -293,6 +297,39 @@
</columntype>
</persistence>
</attribute>
<attribute qualifier="adyenBoletoBarCodeReference" type="java.lang.String">
<description>Boleto bar code</description>
<persistence type="property">
<columntype>
<value>HYBRIS.LONG_STRING</value>
</columntype>
</persistence>
</attribute>
<attribute qualifier="adyenBoletoDueDate" type="java.util.Date">
<description>Boleto due date</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenBoletoExpirationDate" type="java.util.Date">
<description>Boleto expiration date</description>
<persistence type="property"/>
</attribute>
<!-- Multibanco-->
<attribute qualifier="adyenMultibancoEntity" type="java.lang.String">
<description>Multibanco entity</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenMultibancoAmount" type="java.math.BigDecimal">
<description>Multibanco amount</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenMultibancoDeadline" type="java.lang.String">
<description>Multibanco deadline</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenMultibancoReference" type="java.lang.String">
<description>Multibanco reference</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="adyenPaypalEcsToken" type="java.lang.String">
<description>Paypal ECS payment token</description>
<persistence type="property">
Expand Down
4 changes: 2 additions & 2 deletions adyenv6core/resources/adyenv6core.build.number
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ group.id=com.adyen.v6
module.name=platform-module
name=adyenv6core
vendor=adyen
version=4.1.0
version.api=4.1.0
version=4.2.0
version.api=4.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type.paymentinfo.adyenSocialSecurityNumber.name=Social Security Number
type.paymentinfo.adyenFirstName.name=First Name
type.paymentinfo.adyenLastName.name=Last Name
type.paymentinfo.adyenBoletoUrl.name=Boleto URL
type.paymentinfo.adyenBoletoExpirationDate.name=Boleto Expiration Date
type.paymentinfo.adyenBoletoBarCodeReference.name=Boleto Barcode Reference
type.paymentinfo.adyenBoletoDueDate.name=Boleto Duedate
type.paymentinfo.adyenPaypalEcsToken.name=Paypal ECS payment token
type.paymentinfo.adyenPaypalPayerId.name=Paypal ECS payer ID

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class Adyenv6coreConstants extends GeneratedAdyenv6coreConstants {
public static final String EXTENSIONNAME = "adyenv6core";

public static final String PLUGIN_NAME = "adyen-hybris";
public static final String PLUGIN_VERSION = "4.1.0";
public static final String PLUGIN_VERSION = "4.2.0";
public static final String PAYMENT_PROVIDER = "Adyen";

final public static String PAYMENT_METHOD_CC = "adyen_cc";
Expand All @@ -40,6 +40,8 @@ public final class Adyenv6coreConstants extends GeneratedAdyenv6coreConstants {
final public static String PAYMENT_METHOD_BOLETO = "boleto";
final public static String PAYMENT_METHOD_BOLETO_SANTANDER = "boletobancario_santander";

final public static String PAYMENT_METHOD_MULTIBANCO = "multibanco";

public static final String PROCESS_EVENT_ADYEN_CAPTURED = "AdyenCaptured";
public static final String PROCESS_EVENT_ADYEN_AUTHORIZED = "AdyenAuthorized";
public static final String PROCESS_EVENT_ADYEN_REFUNDED = "AdyenRefunded";
Expand All @@ -52,7 +54,6 @@ public final class Adyenv6coreConstants extends GeneratedAdyenv6coreConstants {
public static final String COUNTRY_CODE_FINLAND = "FI";
public static final String COUNTRY_CODE_NORWAY = "NO";


private Adyenv6coreConstants() {
//empty to avoid instantiating this constant class
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,19 @@ private OrderData createOrderFromPaymentsResponse(final PaymentsResponse payment

orderData.setAdyenBoletoUrl(paymentsResponse.getBoletoUrl());
orderData.setAdyenBoletoData(paymentsResponse.getBoletoData());
orderData.setAdyenBoletoBarCodeReference(paymentsResponse.getBoletoBarCodeReference());
orderData.setAdyenBoletoExpirationDate(paymentsResponse.getBoletoExpirationDate());
orderData.setAdyenBoletoDueDate(paymentsResponse.getBoletoDueDate());

orderData.setAdyenMultibancoEntity(paymentsResponse.getMultibancoEntity());
orderData.setAdyenMultibancoAmount(paymentsResponse.getMultibancoAmount());
orderData.setAdyenMultibancoDeadline(paymentsResponse.getMultibancoDeadline());
orderData.setAdyenMultibancoReference(paymentsResponse.getMultibancoReference());

return orderData;
}


/**
* Create order
*/
Expand Down Expand Up @@ -626,11 +633,7 @@ public void initializeCheckoutData(Model model) {
//Exclude cards, boleto, bcmc and bcmc_mobile_QR and iDeal
alternativePaymentMethods = alternativePaymentMethods.stream()
.filter(paymentMethod -> ! paymentMethod.getType().isEmpty()
&& ! "scheme".equals(paymentMethod.getType())
&& ! "bcmc".equals(paymentMethod.getType())
&& ! "bcmc_mobile_QR".equals(paymentMethod.getType())
&& ! PAYMENT_METHOD_IDEAL.equals(paymentMethod.getType())
&& paymentMethod.getType().indexOf(PAYMENT_METHOD_BOLETO) != 0)
&& !isHiddenPaymentMethod(paymentMethod))
.collect(Collectors.toList());
} catch (ApiException | IOException e) {
LOGGER.error(ExceptionUtils.getStackTrace(e));
Expand Down Expand Up @@ -692,6 +695,23 @@ public void initializeCheckoutData(Model model) {
modelService.save(cartModel);
}

private boolean isHiddenPaymentMethod(PaymentMethod paymentMethod) {
String paymentMethodType = paymentMethod.getType();
if (paymentMethodType == null
|| paymentMethodType.isEmpty()
|| paymentMethodType.equals("scheme")
|| paymentMethodType.equals("bcmc")
|| paymentMethodType.equals("bcmc_mobile_QR")
|| paymentMethodType.equals(PAYMENT_METHOD_IDEAL)
|| (paymentMethodType.contains("wechatpay") && ! paymentMethodType.equals("wechatpayWeb"))
|| paymentMethodType.startsWith(PAYMENT_METHOD_BOLETO)) {
return true;
}
return false;
}



@Override
public boolean showBoleto() {
BaseStoreModel baseStore = baseStoreService.getCurrentBaseStore();
Expand Down Expand Up @@ -793,7 +813,7 @@ public PaymentInfoModel createPaymentInfo(final CartModel cartModel, PaymentDeta
paymentInfo.setAdyenFirstName(paymentDetails.getAdyenFirstName());
paymentInfo.setAdyenLastName(paymentDetails.getAdyenLastName());
paymentInfo.setOwner(cartModel.getOwner());

paymentInfo.setAdyenInstallments(paymentDetails.getInstallments());
return paymentInfo;
}

Expand Down Expand Up @@ -1063,4 +1083,4 @@ public I18NFacade getI18NFacade() {
public void setI18NFacade(I18NFacade i18NFacade) {
this.i18NFacade = i18NFacade;
}
}
}
15 changes: 9 additions & 6 deletions adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.adyen.model.AbstractPaymentRequest;
import com.adyen.model.Address;
import com.adyen.model.Amount;
import com.adyen.model.Installments;
import com.adyen.model.Name;
import com.adyen.model.PaymentRequest;
import com.adyen.model.PaymentRequest3d;
Expand Down Expand Up @@ -260,6 +261,11 @@ private void updatePaymentRequestForCC(PaymentsRequest paymentsRequest, CartData
String encryptedCardNumber = cartData.getAdyenEncryptedCardNumber();
String encryptedExpiryMonth = cartData.getAdyenEncryptedExpiryMonth();
String encryptedExpiryYear = cartData.getAdyenEncryptedExpiryYear();
if (cartData.getAdyenInstallments() != null) {
Installments installmentObj = new Installments();
installmentObj.setValue(cartData.getAdyenInstallments());
paymentsRequest.setInstallments(installmentObj);
}

if (! StringUtils.isEmpty(encryptedCardNumber) && ! StringUtils.isEmpty(encryptedExpiryMonth) && ! StringUtils.isEmpty(encryptedExpiryYear)) {

Expand Down Expand Up @@ -321,15 +327,13 @@ public CaptureRequest createCaptureRequest(final String merchantAccount, final B
.merchantAccount(merchantAccount)
.originalReference(authReference)
.reference(merchantReference);
ApplicationInfo applicationInfo = updateApplicationInfo(request.getApplicationInfo());
request.setApplicationInfo(applicationInfo);
updateApplicationInfo(request.getApplicationInfo());
return request;
}

public CancelOrRefundRequest createCancelOrRefundRequest(final String merchantAccount, final String authReference, final String merchantReference) {
CancelOrRefundRequest request = new CancelOrRefundRequest().merchantAccount(merchantAccount).originalReference(authReference).reference(merchantReference);
ApplicationInfo applicationInfo = updateApplicationInfo(request.getApplicationInfo());
request.setApplicationInfo(applicationInfo);
updateApplicationInfo(request.getApplicationInfo());
return request;
}

Expand All @@ -338,8 +342,7 @@ public RefundRequest createRefundRequest(final String merchantAccount, final Big
.merchantAccount(merchantAccount)
.originalReference(authReference)
.reference(merchantReference);
ApplicationInfo applicationInfo = updateApplicationInfo(request.getApplicationInfo());
request.setApplicationInfo(applicationInfo);
updateApplicationInfo(request.getApplicationInfo());
return request;
}

Expand Down
10 changes: 10 additions & 0 deletions adyenv6core/src/com/adyen/v6/forms/AdyenPaymentForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class AdyenPaymentForm {
private String cardHolder;

private String selectedReference;
private int installments;

//Save card
private boolean rememberTheseDetails;
Expand Down Expand Up @@ -221,6 +222,14 @@ public void setCardBrand(String cardBrand) {
this.cardBrand = cardBrand;
}

public int getInstallments() {
return installments;
}

public void setInstallments(int installments) {
this.installments = installments;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand All @@ -232,6 +241,7 @@ public String toString() {
sb.append(" encryptedExpiryYear isEmpty?: ").append(StringUtils.isEmpty(encryptedExpiryYear)).append("\n");
sb.append(" encryptedSecurityCode isEmpty?: ").append(StringUtils.isEmpty(encryptedSecurityCode)).append("\n");
sb.append(" cardHolder: ").append(Util.toIndentedString(cardHolder)).append("\n");
sb.append(" installments: ").append(Util.toIndentedString(installments)).append("\n");
sb.append(" issuerId: ").append(Util.toIndentedString(issuerId)).append("\n");
sb.append(" rememberTheseDetails: ").append(Util.toIndentedString(rememberTheseDetails)).append("\n");
sb.append(" selectedReference: ").append(Util.toIndentedString(selectedReference)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public void populate(final AbstractOrderModel source, final AbstractOrderData ta

//Set boleto url
target.setAdyenBoletoUrl(paymentInfo.getAdyenBoletoUrl());
target.setAdyenBoletoBarCodeReference(paymentInfo.getAdyenBoletoBarCodeReference());
target.setAdyenBoletoDueDate(paymentInfo.getAdyenBoletoDueDate());
target.setAdyenBoletoExpirationDate(paymentInfo.getAdyenBoletoExpirationDate());
//Set multibanco
target.setAdyenMultibancoAmount(paymentInfo.getAdyenMultibancoAmount());
target.setAdyenMultibancoDeadline(paymentInfo.getAdyenMultibancoDeadline());
target.setAdyenMultibancoReference(paymentInfo.getAdyenMultibancoReference());
target.setAdyenMultibancoEntity(paymentInfo.getAdyenMultibancoEntity());
}
}

Expand Down
1 change: 1 addition & 0 deletions adyenv6core/src/com/adyen/v6/populator/CartPopulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void populate(final CartModel source, final CartData target) throws Conve
target.setAdyenEncryptedExpiryMonth(paymentInfo.getEncryptedExpiryMonth());
target.setAdyenEncryptedExpiryYear(paymentInfo.getEncryptedExpiryYear());
target.setAdyenEncryptedSecurityCode(paymentInfo.getEncryptedSecurityCode());
target.setAdyenInstallments(paymentInfo.getAdyenInstallments());
}
}

Expand Down
Loading

0 comments on commit d3293af

Please sign in to comment.