Skip to content

Commit a74b4e9

Browse files
authored
Merge pull request #74 from AltaPay/COREP-5410-support-native-apple-pay-integration
[COREP-5410] applepay source attribute to support APPLE_PAY_JS_API / …
2 parents 5505b7a + b2ea89f commit a74b4e9

File tree

8 files changed

+80
-11
lines changed

8 files changed

+80
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [3.1.10]
5+
- Add `source` parameter to Apple Pay request data to support APPLE_PAY_JS_API / PASSKIT scenarios
6+
47
## [3.1.9]
58
- Updated `APIResponse.xsd` to include `DeviceId`, replaced `DeviceInfo` and `GeolocationInfo` in `CustomerInfo` with `DeviceId`
69

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = 'com.altapay'
12-
version = '3.1.9'
12+
version = '3.1.10'
1313

1414
repositories {
1515
mavenCentral()

src/main/java/com/pensio/api/PensioMerchantAPI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ public APIResponse cardWalletSession(CardWalletSessionRequest request) throws Pe
677677
addParam(params, "applePayRequestData[validationUrl]", request.getApplePayRequestData().getValidationUrl());
678678
addParam(params, "applePayRequestData[domain]", request.getApplePayRequestData().getDomain());
679679

680+
if (request.getApplePayRequestData().getSource() != null) {
681+
addParam(params, "applePayRequestData[source]", request.getApplePayRequestData().getSource().name());
682+
}
683+
680684
// backward compatibility with legacy flow
681685
addParam(params, "validationUrl", request.getApplePayRequestData().getValidationUrl());
682686
addParam(params, "domain", request.getApplePayRequestData().getDomain());

src/main/java/com/pensio/api/request/provider/ApplePayRequestData.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class ApplePayRequestData {
44

55
private String validationUrl;
66
private String domain;
7+
private ApplePaySource source;
78

89
public String getValidationUrl() {
910
return validationUrl;
@@ -20,4 +21,12 @@ public String getDomain() {
2021
public void setDomain(String domain) {
2122
this.domain = domain;
2223
}
24+
25+
public ApplePaySource getSource() {
26+
return source;
27+
}
28+
29+
public void setSource(ApplePaySource source) {
30+
this.source = source;
31+
}
2332
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.pensio.api.request.provider;
2+
3+
public enum ApplePaySource {
4+
APPLE_PAY_JS_API,
5+
PASSKIT
6+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.pensio.api;
2+
3+
import com.pensio.Amount;
4+
import com.pensio.Currency;
5+
import com.pensio.api.generated.APIResponse;
6+
import com.pensio.api.request.CardWalletSessionRequest;
7+
import com.pensio.api.request.provider.ApplePayRequestData;
8+
import com.pensio.api.request.provider.ApplePaySource;
9+
import org.junit.jupiter.api.Assertions;
10+
import org.junit.jupiter.api.Test;
11+
12+
import java.util.Map;
13+
14+
class MerchantApi_ApplePayMappingTests {
15+
16+
@Test
17+
void testCardWalletSessionWithApplePaySource() throws PensioAPIException {
18+
19+
final var validationUrl = "https://apple-pay-gateway.apple.com/paymentservices/startSession";
20+
final var domain = "checkout.altapaysecure.com";
21+
ApplePaySource source = ApplePaySource.APPLE_PAY_JS_API;
22+
23+
final var api = new PensioMerchantAPI("http://base", "user", "pass") {
24+
@Override
25+
protected APIResponse getAPIResponse(String method, HttpMethod httpMethod, Map<String, String> requestVars) throws PensioAPIException {
26+
Assertions.assertEquals("cardWallet/session", method);
27+
Assertions.assertEquals(HttpMethod.POST, httpMethod);
28+
Assertions.assertEquals(validationUrl, requestVars.get("applePayRequestData[validationUrl]"));
29+
Assertions.assertEquals(domain, requestVars.get("applePayRequestData[domain]"));
30+
Assertions.assertEquals(source.name(), requestVars.get("applePayRequestData[source]"));
31+
32+
return null;
33+
}
34+
};
35+
36+
ApplePayRequestData applePayRequestData = new ApplePayRequestData();
37+
applePayRequestData.setValidationUrl(validationUrl);
38+
applePayRequestData.setDomain(domain);
39+
applePayRequestData.setSource(source);
40+
41+
CardWalletSessionRequest request = new CardWalletSessionRequest("ApplePay Test Terminal", "order123", Amount.get(100, Currency.DKK));
42+
request.setApplePayRequestData(applePayRequestData);
43+
44+
api.cardWalletSession(request);
45+
}
46+
}

src/test/java/com/pensio/api/MerchantApi_ParsePostBackXmlResponseTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Created by emerson on 7/5/17.
1616
*/
17-
public class MerchantApi_ParsePostBackXmlResponseTests
17+
class MerchantApi_ParsePostBackXmlResponseTests
1818
{
1919
private PensioMerchantAPI api;
2020

@@ -25,7 +25,7 @@ public void setUp() throws Exception
2525
}
2626

2727
@Test
28-
public void ParsePostBackXmlResponse_ReadCardHolderMessageMustBeShown() throws PensioAPIException, IOException, URISyntaxException {
28+
void ParsePostBackXmlResponse_ReadCardHolderMessageMustBeShown() throws PensioAPIException, IOException, URISyntaxException {
2929
String xmlResponse = readFile("com/pensio/api/txt/CardHolderMessageMustBeShownFalse.xml");
3030
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
3131
Assertions.assertFalse(response.getBody().isCardHolderMessageMustBeShown());
@@ -45,37 +45,37 @@ private String readFile(String file) throws IOException, URISyntaxException {
4545
}
4646

4747
@Test
48-
public void ParsePostBackXmlResponse_ReadReasonCode() throws PensioAPIException, IOException, URISyntaxException {
48+
void ParsePostBackXmlResponse_ReadReasonCode() throws PensioAPIException, IOException, URISyntaxException {
4949
String xmlResponse = readFile("com/pensio/api/txt/ReasonCode.xml");
5050
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
5151
Assertions.assertEquals("NONE", response.getBody().getTransactions().getTransaction().get(0).getReasonCode());
5252

5353
}
5454

5555
@Test
56-
public void ParsePostBackXmlResponse_ReadPaymentId() throws PensioAPIException, IOException, URISyntaxException {
56+
void ParsePostBackXmlResponse_ReadPaymentId() throws PensioAPIException, IOException, URISyntaxException {
5757
String xmlResponse = readFile("com/pensio/api/txt/ReasonCode.xml");
5858
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
5959
Assertions.assertEquals("17794956-9bb6-4854-9712-bce5931e6e3a", response.getBody().getTransactions().getTransaction().get(0).getPaymentId());
6060

6161
}
6262

6363
@Test
64-
public void ParsePostBackXmlResponse_ReadPaymentSource() throws PensioAPIException, IOException, URISyntaxException {
64+
void ParsePostBackXmlResponse_ReadPaymentSource() throws PensioAPIException, IOException, URISyntaxException {
6565
String xmlResponse = readFile("com/pensio/api/txt/PaymentSource.xml");
6666
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
6767
Assertions.assertEquals("eCommerce", response.getBody().getTransactions().getTransaction().get(0).getPaymentSource());
6868
}
6969

7070
@Test
71-
public void ParsePostBackXmlResponse_WrongPaymentSource() throws PensioAPIException, IOException, URISyntaxException {
71+
void ParsePostBackXmlResponse_WrongPaymentSource() throws PensioAPIException, IOException, URISyntaxException {
7272
String xmlResponse = readFile("com/pensio/api/txt/PaymentSource.xml");
7373
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
7474
Assertions.assertNotSame("eCommerce_without3ds", response.getBody().getTransactions().getTransaction().get(0).getPaymentSource());
7575
}
7676

7777
@Test
78-
public void ParsePostBackXmlResponse_ReadECommerceWithout3dSecurePaymentSource() throws PensioAPIException, IOException, URISyntaxException {
78+
void ParsePostBackXmlResponse_ReadECommerceWithout3dSecurePaymentSource() throws PensioAPIException, IOException, URISyntaxException {
7979
String xmlResponse = readFile("com/pensio/api/txt/PaymentSourceECommerceWithout3dSecure.xml");
8080
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
8181
Assertions.assertEquals("eCommerce_without3ds", response.getBody().getTransactions().getTransaction().get(0).getPaymentSource());

src/test/java/com/pensio/api/PensioMerchantApiUnitTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import org.junit.jupiter.api.Assertions;
44
import org.junit.jupiter.api.Test;
55

6-
public class PensioMerchantApiUnitTests {
6+
class PensioMerchantApiUnitTests {
77

88
@Test
9-
public void AvoidAnnoyingErrorNoTestsWhileRunningAnt() {
9+
void AvoidAnnoyingErrorNoTestsWhileRunningAnt() {
1010
Assertions.assertTrue(true);
1111
}
12-
}
12+
13+
}

0 commit comments

Comments
 (0)