Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.1.10]
- Add `source` parameter to Apple Pay request data to support APPLE_PAY_JS_API / PASSKIT scenarios

## [3.1.9]
- Updated `APIResponse.xsd` to include `DeviceId`, replaced `DeviceInfo` and `GeolocationInfo` in `CustomerInfo` with `DeviceId`

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = 'com.altapay'
version = '3.1.9'
version = '3.1.10'

repositories {
mavenCentral()
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/pensio/api/PensioMerchantAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ public APIResponse cardWalletSession(CardWalletSessionRequest request) throws Pe
addParam(params, "applePayRequestData[validationUrl]", request.getApplePayRequestData().getValidationUrl());
addParam(params, "applePayRequestData[domain]", request.getApplePayRequestData().getDomain());

if (request.getApplePayRequestData().getSource() != null) {
addParam(params, "applePayRequestData[source]", request.getApplePayRequestData().getSource().name());
}

// backward compatibility with legacy flow
addParam(params, "validationUrl", request.getApplePayRequestData().getValidationUrl());
addParam(params, "domain", request.getApplePayRequestData().getDomain());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class ApplePayRequestData {

private String validationUrl;
private String domain;
private ApplePaySource source;

public String getValidationUrl() {
return validationUrl;
Expand All @@ -20,4 +21,12 @@ public String getDomain() {
public void setDomain(String domain) {
this.domain = domain;
}

public ApplePaySource getSource() {
return source;
}

public void setSource(ApplePaySource source) {
this.source = source;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.pensio.api.request.provider;

public enum ApplePaySource {
APPLE_PAY_JS_API,
PASSKIT
}
46 changes: 46 additions & 0 deletions src/test/java/com/pensio/api/MerchantApi_ApplePayMappingTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.pensio.api;

import com.pensio.Amount;
import com.pensio.Currency;
import com.pensio.api.generated.APIResponse;
import com.pensio.api.request.CardWalletSessionRequest;
import com.pensio.api.request.provider.ApplePayRequestData;
import com.pensio.api.request.provider.ApplePaySource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Map;

class MerchantApi_ApplePayMappingTests {

@Test
void testCardWalletSessionWithApplePaySource() throws PensioAPIException {

final var validationUrl = "https://apple-pay-gateway.apple.com/paymentservices/startSession";
final var domain = "checkout.altapaysecure.com";
ApplePaySource source = ApplePaySource.APPLE_PAY_JS_API;

final var api = new PensioMerchantAPI("http://base", "user", "pass") {
@Override
protected APIResponse getAPIResponse(String method, HttpMethod httpMethod, Map<String, String> requestVars) throws PensioAPIException {
Assertions.assertEquals("cardWallet/session", method);
Assertions.assertEquals(HttpMethod.POST, httpMethod);
Assertions.assertEquals(validationUrl, requestVars.get("applePayRequestData[validationUrl]"));
Assertions.assertEquals(domain, requestVars.get("applePayRequestData[domain]"));
Assertions.assertEquals(source.name(), requestVars.get("applePayRequestData[source]"));

return null;
}
};

ApplePayRequestData applePayRequestData = new ApplePayRequestData();
applePayRequestData.setValidationUrl(validationUrl);
applePayRequestData.setDomain(domain);
applePayRequestData.setSource(source);

CardWalletSessionRequest request = new CardWalletSessionRequest("ApplePay Test Terminal", "order123", Amount.get(100, Currency.DKK));
request.setApplePayRequestData(applePayRequestData);

api.cardWalletSession(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Created by emerson on 7/5/17.
*/
public class MerchantApi_ParsePostBackXmlResponseTests
class MerchantApi_ParsePostBackXmlResponseTests
{
private PensioMerchantAPI api;

Expand All @@ -25,7 +25,7 @@ public void setUp() throws Exception
}

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

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

}

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

}

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

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

@Test
public void ParsePostBackXmlResponse_ReadECommerceWithout3dSecurePaymentSource() throws PensioAPIException, IOException, URISyntaxException {
void ParsePostBackXmlResponse_ReadECommerceWithout3dSecurePaymentSource() throws PensioAPIException, IOException, URISyntaxException {
String xmlResponse = readFile("com/pensio/api/txt/PaymentSourceECommerceWithout3dSecure.xml");
APIResponse response = api.parsePostBackXMLParameter(xmlResponse);
Assertions.assertEquals("eCommerce_without3ds", response.getBody().getTransactions().getTransaction().get(0).getPaymentSource());
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/pensio/api/PensioMerchantApiUnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class PensioMerchantApiUnitTests {
class PensioMerchantApiUnitTests {

@Test
public void AvoidAnnoyingErrorNoTestsWhileRunningAnt() {
void AvoidAnnoyingErrorNoTestsWhileRunningAnt() {
Assertions.assertTrue(true);
}
}

}
Loading