Skip to content

Commit 1a56ede

Browse files
authored
Merge pull request #35 from Adyen/cancel-or-refund
#34 support for specific skin requests without the need to change the…
2 parents f3ff1f1 + bf7e863 commit 1a56ede

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/main/java/com/adyen/model/hpp/DirectoryLookupRequest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public class DirectoryLookupRequest {
2828
private String sessionValidity;
2929
private String merchantReference;
3030
private String countryCode;
31+
private String skinCode;
32+
private String merchantAccount;
33+
private String hmacKey;
34+
3135

3236
public DirectoryLookupRequest() {
3337
sessionValidity = Util.calculateSessionValidity();
@@ -77,4 +81,31 @@ public DirectoryLookupRequest setCountryCode(String countryCode) {
7781
this.countryCode = countryCode;
7882
return this;
7983
}
84+
85+
public String getSkinCode() {
86+
return skinCode;
87+
}
88+
89+
public DirectoryLookupRequest setSkinCode(String skinCode) {
90+
this.skinCode = skinCode;
91+
return this;
92+
}
93+
94+
public String getMerchantAccount() {
95+
return merchantAccount;
96+
}
97+
98+
public DirectoryLookupRequest setMerchantAccount(String merchantAccount) {
99+
this.merchantAccount = merchantAccount;
100+
return this;
101+
}
102+
103+
public String getHmacKey() {
104+
return hmacKey;
105+
}
106+
107+
public DirectoryLookupRequest setHmacKey(String hmacKey) {
108+
this.hmacKey = hmacKey;
109+
return this;
110+
}
80111
}

src/main/java/com/adyen/service/HostedPaymentPages.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,21 @@ public SortedMap<String, String> getPostParametersFromDLRequest(DirectoryLookupR
6464
// Set HTTP Post variables
6565
final SortedMap<String, String> postParameters = new TreeMap<>();
6666
postParameters.put(CURRENCY_CODE, request.getCurrencyCode());
67-
postParameters.put(MERCHANT_ACCOUNT, config.getMerchantAccount());
67+
68+
if (request.getMerchantAccount() != null) {
69+
postParameters.put(MERCHANT_ACCOUNT, request.getMerchantAccount());
70+
} else {
71+
postParameters.put(MERCHANT_ACCOUNT, config.getMerchantAccount());
72+
}
73+
6874
postParameters.put(PAYMENT_AMOUNT, request.getPaymentAmount());
69-
postParameters.put(SKIN_CODE, config.getSkinCode());
75+
76+
if (request.getSkinCode() != null) {
77+
postParameters.put(SKIN_CODE, request.getSkinCode());
78+
} else {
79+
postParameters.put(SKIN_CODE, config.getSkinCode());
80+
}
81+
7082
postParameters.put(MERCHANT_REFERENCE, request.getMerchantReference());
7183
postParameters.put(SESSION_VALIDITY, request.getSessionValidity());
7284
postParameters.put(COUNTRY_CODE, request.getCountryCode());
@@ -75,7 +87,14 @@ public SortedMap<String, String> getPostParametersFromDLRequest(DirectoryLookupR
7587

7688
String dataToSign = hmacValidator.getDataToSign(postParameters);
7789

78-
String merchantSig = hmacValidator.calculateHMAC(dataToSign, config.getHmacKey());
90+
String hmacKey;
91+
if (request.getHmacKey() != null) {
92+
hmacKey = request.getHmacKey();
93+
} else {
94+
hmacKey = config.getHmacKey();
95+
}
96+
97+
String merchantSig = hmacValidator.calculateHMAC(dataToSign, hmacKey);
7998
postParameters.put(MERCHANT_SIG, merchantSig);
8099

81100
return postParameters;

0 commit comments

Comments
 (0)