├── .gitignore ├── LICENSE ├── README.md ├── sources ├── payment-hub │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── openmf │ │ │ └── psp │ │ │ ├── PaymentHubApplication.java │ │ │ ├── PaymentHubController.java │ │ │ ├── component │ │ │ ├── ChannelRestClient.java │ │ │ ├── FspRestClient.java │ │ │ └── RestClient.java │ │ │ ├── config │ │ │ ├── ApplicationSettings.java │ │ │ ├── AuthEncodeType.java │ │ │ ├── AuthProfileType.java │ │ │ ├── AuthProperties.java │ │ │ ├── Binding.java │ │ │ ├── BindingProperties.java │ │ │ ├── ChannelSettings.java │ │ │ ├── FspSettings.java │ │ │ ├── Header.java │ │ │ ├── HeaderProperties.java │ │ │ ├── HubSettings.java │ │ │ ├── IbanSettings.java │ │ │ ├── ListConfig.java │ │ │ ├── Operation.java │ │ │ ├── OperationProperties.java │ │ │ ├── SwitchSettings.java │ │ │ ├── TenantDependentProperties.java │ │ │ ├── TenantProperties.java │ │ │ └── UriProperties.java │ │ │ ├── dto │ │ │ ├── ComplexName.java │ │ │ ├── ErrorInformation.java │ │ │ ├── Extension.java │ │ │ ├── FspMoneyData.java │ │ │ ├── GeoCode.java │ │ │ ├── MoneyData.java │ │ │ ├── Party.java │ │ │ ├── PartyIdInfo.java │ │ │ ├── Payee.java │ │ │ ├── Payer.java │ │ │ ├── PersonalInfo.java │ │ │ ├── Refund.java │ │ │ ├── TransactionType.java │ │ │ ├── channel │ │ │ │ ├── RegisterAliasRequestDTO.java │ │ │ │ ├── TransactionChannelAsyncResponseDTO.java │ │ │ │ ├── TransactionChannelRequestDTO.java │ │ │ │ └── TransactionChannelResponseDTO.java │ │ │ └── fsp │ │ │ │ ├── LoginFineractCnResponseDTO.java │ │ │ │ ├── LoginFineractXResponseDTO.java │ │ │ │ ├── LoginFspResponse.java │ │ │ │ ├── PartyFspResponseDTO.java │ │ │ │ ├── QuoteFspRequestDTO.java │ │ │ │ ├── QuoteFspResponseDTO.java │ │ │ │ ├── RoleData.java │ │ │ │ ├── TransactionRequestFspRequestDTO.java │ │ │ │ ├── TransactionRequestFspResponseDTO.java │ │ │ │ ├── TransferFspRequestDTO.java │ │ │ │ └── TransferFspResponseDTO.java │ │ │ ├── gsma │ │ │ ├── config │ │ │ │ └── GSMASettings.java │ │ │ ├── dto │ │ │ │ ├── AccountStatus.java │ │ │ │ ├── FineractTransaction.java │ │ │ │ ├── GSMATransaction.java │ │ │ │ ├── IdDocument.java │ │ │ │ ├── InternationalTransferInformation.java │ │ │ │ ├── Kyc.java │ │ │ │ ├── Party.java │ │ │ │ ├── PostalAddress.java │ │ │ │ └── SubjectName.java │ │ │ └── routebuilder │ │ │ │ ├── channel │ │ │ │ ├── BaseTransaction.java │ │ │ │ ├── MerchantPayment.java │ │ │ │ └── PeerToPeerTransfer.java │ │ │ │ └── processor │ │ │ │ ├── CheckReceiverAccountsProcessor.java │ │ │ │ ├── CheckTransactionProcessor.java │ │ │ │ ├── CheckTransactionTypeProcessor.java │ │ │ │ └── PostTransactionProcessor.java │ │ │ ├── internal │ │ │ ├── FspContext.java │ │ │ └── FspId.java │ │ │ ├── mojaloop │ │ │ ├── cache │ │ │ │ └── TransactionContextHolder.java │ │ │ ├── component │ │ │ │ ├── CodecContextFactoryDpc.java │ │ │ │ ├── IlpBuilder.java │ │ │ │ ├── IlpBuilderDpc.java │ │ │ │ ├── IlpConditionHandlerImplDpc.java │ │ │ │ ├── InterledgerPaymentCodecDpc.java │ │ │ │ ├── InterledgerPaymentDpc.java │ │ │ │ ├── InterledgerPaymentOerCodecDpc.java │ │ │ │ └── SwitchRestClient.java │ │ │ ├── config │ │ │ │ └── MockSettings.java │ │ │ ├── constant │ │ │ │ └── ExchangeHeader.java │ │ │ ├── dto │ │ │ │ └── mojaloop │ │ │ │ │ ├── ErrorSwitchResponseDTO.java │ │ │ │ │ ├── ParticipantSwitchRequestDTO.java │ │ │ │ │ ├── ParticipantSwitchResponseDTO.java │ │ │ │ │ ├── PartySwitchResponseDTO.java │ │ │ │ │ ├── QuoteSwitchRequestDTO.java │ │ │ │ │ ├── QuoteSwitchResponseDTO.java │ │ │ │ │ ├── TransactionRequestSwitchRequestDTO.java │ │ │ │ │ ├── TransactionRequestSwitchResponseDTO.java │ │ │ │ │ ├── TransferSwitchRequestDTO.java │ │ │ │ │ └── TransferSwitchResponseDTO.java │ │ │ ├── internal │ │ │ │ ├── Ilp.java │ │ │ │ ├── PartyContext.java │ │ │ │ ├── TransactionCacheContext.java │ │ │ │ └── TransactionRoleContext.java │ │ │ ├── routebuilder │ │ │ │ ├── channel │ │ │ │ │ ├── ChannelPartiesRouteBuilder.java │ │ │ │ │ ├── ChannelPaymentRequestRouteBuilder.java │ │ │ │ │ └── ChannelStatusRequestRouteBuilder.java │ │ │ │ ├── mock │ │ │ │ │ └── MockRouteBuilder.java │ │ │ │ ├── processor │ │ │ │ │ ├── ChannelTransactionsResponseProcessor.java │ │ │ │ │ ├── CommitTransferFspProcessor.java │ │ │ │ │ ├── CommitTransferSwitchProcessor.java │ │ │ │ │ ├── PartiesFspProcessor.java │ │ │ │ │ ├── PartiesSwitchProcessor.java │ │ │ │ │ ├── PartiesSwitchResponseProcessor.java │ │ │ │ │ ├── PrepareTransferFspProcessor.java │ │ │ │ │ ├── QuotesFspProcessor.java │ │ │ │ │ ├── QuotesSwitchProcessor.java │ │ │ │ │ ├── QuotesSwitchResponseProcessor.java │ │ │ │ │ ├── TransactionRequestFspProcessor.java │ │ │ │ │ ├── TransactionRequestResponseSwitchProcessor.java │ │ │ │ │ ├── TransactionRequestSwitchProcessor.java │ │ │ │ │ └── TransfersSwitchResponseProcessor.java │ │ │ │ └── switchconsumer │ │ │ │ │ ├── SwitchErrorResponseRouteBuilder.java │ │ │ │ │ ├── SwitchRequestRouteBuilder.java │ │ │ │ │ └── SwitchResponseRouteBuilder.java │ │ │ └── type │ │ │ │ ├── TransactionAction.java │ │ │ │ ├── TransactionActionType.java │ │ │ │ ├── TransactionState.java │ │ │ │ └── TransferState.java │ │ │ ├── routebuilder │ │ │ └── AdminRouteBuilder.java │ │ │ ├── type │ │ │ ├── AmountType.java │ │ │ ├── AuthenticationType.java │ │ │ ├── IdentifierType.java │ │ │ ├── InitiatorType.java │ │ │ ├── Scenario.java │ │ │ ├── SubScenario.java │ │ │ ├── TransactionRequestState.java │ │ │ └── TransactionRole.java │ │ │ └── util │ │ │ ├── ContextUtil.java │ │ │ ├── IbanUtil.java │ │ │ ├── JsonUtil.java │ │ │ ├── RestTemplateHeaderModifierInterceptor.java │ │ │ ├── UUIDUtil.java │ │ │ └── UrlParamUtil.java │ │ └── resources │ │ └── log4j2.xml └── pom.xml └── work ├── gsma └── application.yml └── mojaloop └── application.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | .idea 5 | *.iml 6 | *.ipr 7 | *.iws 8 | .gradle 9 | /local.properties 10 | /.idea/workspace.xml 11 | /.idea/libraries 12 | /sources/payment-hub/target 13 | .DS_Store 14 | /build 15 | /captures 16 | .externalNativeBuild 17 | *.class 18 | *.jar 19 | *.war 20 | *.ear 21 | .gradle 22 | build 23 | *.DS_Store 24 | .DS_Store 25 | catalina.base_IS_UNDEFINED/ -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/PaymentHubApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp; 9 | 10 | import org.apache.camel.CamelContext; 11 | import org.openmf.psp.config.ChannelSettings; 12 | import org.openmf.psp.config.FspSettings; 13 | import org.openmf.psp.config.HubSettings; 14 | import org.openmf.psp.config.IbanSettings; 15 | import org.openmf.psp.config.SwitchSettings; 16 | import org.openmf.psp.mojaloop.config.MockSettings; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 23 | import org.springframework.web.client.RestTemplate; 24 | 25 | @SpringBootApplication(scanBasePackages = "hu.dpc.rt") 26 | @EnableConfigurationProperties({ChannelSettings.class, HubSettings.class, FspSettings.class, SwitchSettings.class, MockSettings.class, IbanSettings.class}) 27 | public class PaymentHubApplication { 28 | 29 | public static void main(String[] args) { 30 | //if (CommonValues.getJavaVersion() == 8) { 31 | SpringApplication.run(PaymentHubApplication.class, args); 32 | //} else { 33 | // System.err.println("Java 8 only!"); 34 | //} 35 | } 36 | 37 | @Autowired 38 | private CamelContext camelContext; 39 | 40 | @Bean 41 | public RestTemplate restTemplate() { 42 | HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(); 43 | httpRequestFactory.setConnectionRequestTimeout(30000); 44 | httpRequestFactory.setConnectTimeout(30000); 45 | httpRequestFactory.setReadTimeout(30000); 46 | 47 | return new RestTemplate(httpRequestFactory); 48 | } 49 | 50 | /*@Bean 51 | public RestTemplate restTemplate() throws Exception { 52 | RestTemplate restTemplate = new RestTemplate(); 53 | HttpClient client = createHttpClient(); 54 | ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(client); 55 | restTemplate.setRequestFactory(factory); 56 | return restTemplate; 57 | } 58 | 59 | private HttpClient createHttpClient() throws Exception { 60 | InputStream trustStream = new FileInputStream(keystoreHolder.getKeystoreFile()); 61 | char[] trustPassword = keystoreHolder.getKeystorePassword().toCharArray(); 62 | 63 | KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); 64 | trustStore.load(trustStream, trustPassword); 65 | 66 | final SSLContext sslContext = SSLContexts.custom() 67 | .loadKeyMaterial(new File(keystoreHolder.getKeystoreFile().toString()), keystoreHolder.getKeystorePassword().toCharArray(), 68 | keystoreHolder.getKeystorePassword().toCharArray(), (aliases, socket) -> clientKeyAlias) 69 | .loadTrustMaterial(trustStore, (x509Certificates, s) -> false).build(); 70 | 71 | final SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, new String[] { "TLSv1.2" }, null, 72 | SSLConnectionSocketFactory.getDefaultHostnameVerifier()); 73 | 74 | final Registry registry = RegistryBuilder.create() 75 | .register("https", sslSocketFactory).build(); 76 | 77 | final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); 78 | connectionManager.setMaxTotal(10); 79 | connectionManager.setDefaultMaxPerRoute(10); 80 | 81 | return HttpClients.custom().setSSLSocketFactory(sslSocketFactory).setConnectionManager(connectionManager).build(); 82 | }*/ 83 | 84 | // @Bean 85 | // public CamelTransportFactory camelTransportFactory() 86 | // { 87 | // CamelTransportFactory camelTransportFactory = new CamelTransportFactory(); 88 | // 89 | // camelTransportFactory.setCamelContext(camelContext); 90 | // 91 | // 92 | // return camelTransportFactory; 93 | // } 94 | } 95 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/PaymentHubController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp; 9 | 10 | //@RestController 11 | public class PaymentHubController { 12 | 13 | private static final String[] PETS = new String[]{"Snoopy", "Fido", "Tony the Tiger"}; 14 | 15 | /*@GetMapping(value = "/pets/{id}") 16 | public Map petById(@PathVariable("id") Integer id) { 17 | if (id != null && id > 0 && id <= PETS.length + 1) { 18 | int index = id - 1; 19 | String pet = PETS[index]; 20 | return Collections.singletonMap("name", pet); 21 | } else { 22 | return Collections.emptyMap(); 23 | } 24 | 25 | }*/ 26 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/component/ChannelRestClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.component; 9 | 10 | import org.openmf.psp.config.ChannelSettings; 11 | import org.openmf.psp.config.TenantProperties; 12 | import org.openmf.psp.dto.channel.TransactionChannelAsyncResponseDTO; 13 | import org.openmf.psp.internal.FspId; 14 | import org.openmf.psp.util.JsonUtil; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.http.HttpMethod; 19 | import org.springframework.stereotype.Component; 20 | 21 | import javax.annotation.PostConstruct; 22 | import java.util.Arrays; 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | 26 | @Component 27 | public class ChannelRestClient { 28 | 29 | private static Logger logger = LoggerFactory.getLogger(ChannelRestClient.class); 30 | 31 | private RestClient restClient; 32 | 33 | private ChannelSettings channelSettings; 34 | 35 | 36 | @Autowired 37 | public ChannelRestClient(RestClient restClient, ChannelSettings channelSettings) { 38 | this.restClient = restClient; 39 | this.channelSettings = channelSettings; 40 | } 41 | 42 | @PostConstruct 43 | public void postConstruct() { 44 | } 45 | 46 | public void callPaymentAsyncResponse(TransactionChannelAsyncResponseDTO response, FspId fspId) { 47 | String tenant = fspId.getTenant(); 48 | TenantProperties operation = channelSettings.getOperation(ChannelSettings.ChannelOperation.NOTIFICATION_TRANSFERS, tenant); 49 | 50 | String url = operation.getUrl() + '/' + response.getTransactionId(); 51 | 52 | Map headers = getHeaders(tenant); 53 | logger.debug(String.format("Sending request %s, method: %s, \nheader-keys: %s, \nheader-values: %s, \nbody: %s, ", 54 | url, HttpMethod.PUT, Arrays.toString(headers.keySet().toArray()), Arrays.toString(headers.values().toArray()), 55 | JsonUtil.toJson(response))); 56 | 57 | // restClient.call(url, HttpMethod.PUT, headers, JsonUtil.toJson(response)); 58 | } 59 | 60 | private Map getHeaders(String tenantId) { 61 | Map headers = new HashMap<>(); 62 | 63 | String tenantHeader = channelSettings.getHeader(ChannelSettings.ChannelHeader.TENANT).getKey(); 64 | headers.put(tenantHeader, tenantId); 65 | return headers; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/component/RestClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.component; 9 | 10 | import java.time.ZoneId; 11 | import java.time.ZonedDateTime; 12 | import java.time.format.DateTimeFormatter; 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | import org.openmf.psp.util.RestTemplateHeaderModifierInterceptor; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.http.HttpEntity; 23 | import org.springframework.http.HttpHeaders; 24 | import org.springframework.http.HttpMethod; 25 | import org.springframework.http.MediaType; 26 | import org.springframework.http.client.ClientHttpRequestInterceptor; 27 | import org.springframework.stereotype.Component; 28 | import org.springframework.web.client.RestTemplate; 29 | 30 | @Component 31 | public class RestClient { 32 | 33 | private static Logger logger = LoggerFactory.getLogger(RestClient.class); 34 | 35 | static final DateTimeFormatter HEADER_DATE_TIME_FORMATTER = DateTimeFormatter.RFC_1123_DATE_TIME; 36 | 37 | private RestTemplate restTemplate; 38 | 39 | @Autowired 40 | public RestClient(RestTemplate restTemplate) { 41 | this.restTemplate = restTemplate; 42 | } 43 | 44 | public String call(String endpointUrl, HttpMethod httpMethod, Map headers, String body) { 45 | HttpHeaders httpHeaders = new HttpHeaders(); 46 | httpHeaders.setContentType(MediaType.APPLICATION_JSON); 47 | // If it is a PUT request, it will throw an error if the 'accept' or 'accept-charset' headers are set 48 | // RestTemplate sets accept-charset, accept, and accept-encoding by default, so get rid of them 49 | if (httpMethod != HttpMethod.PUT) { 50 | httpHeaders.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 51 | } else { 52 | restTemplate.setInterceptors(Arrays.asList(new RestTemplateHeaderModifierInterceptor())); 53 | } 54 | 55 | headers.forEach((key, value) -> httpHeaders.set(key, value)); 56 | 57 | HttpEntity entity = new HttpEntity<>(body, httpHeaders); 58 | 59 | logger.debug(String.format("Sending request %s, method: %s, \nheader-keys: %s, \nheader-values: %s, \nbody: %s, ", endpointUrl, httpMethod, Arrays.toString(httpHeaders.keySet().toArray()), Arrays.toString(httpHeaders.values().toArray()), body)); 60 | 61 | String res = restTemplate.exchange(endpointUrl, httpMethod, entity, String.class).getBody(); 62 | 63 | if (httpMethod == HttpMethod.PUT) { 64 | // Reset so that we aren't messing with headers after this request 65 | List interceptors = new ArrayList<>(); 66 | restTemplate.setInterceptors(interceptors); 67 | } 68 | 69 | return res; 70 | } 71 | 72 | public static String formatHeaderDate(ZonedDateTime date) { 73 | return date == null ? null : date.format(HEADER_DATE_TIME_FORMATTER); 74 | } 75 | 76 | public static String formatServerHeaderDate() { 77 | return formatHeaderDate(ZonedDateTime.now(ZoneId.of("UTC"))); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/AuthEncodeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package org.openmf.psp.config; 10 | 11 | import org.apache.logging.log4j.util.Strings; 12 | 13 | import java.util.Base64; 14 | 15 | public enum AuthEncodeType { 16 | NONE, 17 | BASE64 { 18 | @Override 19 | public String encode(String value) { 20 | return value == null ? null : new String(Base64.getEncoder().encode(value.getBytes())); 21 | } 22 | }, 23 | ; 24 | 25 | public static AuthEncodeType forConfig(String config) { 26 | if (Strings.isEmpty(config)) 27 | return NONE; 28 | return AuthEncodeType.valueOf(config.toUpperCase()); 29 | } 30 | 31 | public String encode(String value) { 32 | return value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/AuthProfileType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.apache.logging.log4j.util.Strings; 11 | 12 | public enum AuthProfileType { 13 | NONE, 14 | BASIC { 15 | protected String getPrefix() { 16 | return "Basic "; 17 | } 18 | }, 19 | BASIC_TWOFACTOR { 20 | protected String getPrefix() { 21 | return "Basic "; 22 | } 23 | }, 24 | OAUTH { 25 | protected String getPrefix() { 26 | return "Bearer "; 27 | } 28 | }, 29 | OAUTH_TWOFACTOR { 30 | protected String getPrefix() { 31 | return "Bearer "; 32 | } 33 | }, 34 | ; 35 | 36 | 37 | public static AuthProfileType forConfig(String config) { 38 | if (Strings.isEmpty(config)) 39 | return NONE; 40 | return AuthProfileType.valueOf(config.toUpperCase()); 41 | } 42 | 43 | public String encode(String value) { 44 | if (value == null) 45 | return null; 46 | String prefix = getPrefix(); 47 | return Strings.isEmpty(prefix) || value.startsWith(prefix) ? value : (prefix + value); 48 | } 49 | 50 | protected String getPrefix() { 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/AuthProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.openmf.psp.dto.fsp.LoginFspResponse; 11 | 12 | public class AuthProperties { 13 | 14 | private AuthProfileType profile; 15 | private AuthEncodeType encode; 16 | private Class loginClass; 17 | 18 | protected AuthProperties() { 19 | } 20 | 21 | public AuthProfileType getProfile() { 22 | return profile; 23 | } 24 | 25 | public void setProfile(AuthProfileType profile) { 26 | this.profile = profile; 27 | } 28 | 29 | public AuthEncodeType getEncode() { 30 | return encode; 31 | } 32 | 33 | public void setEncode(AuthEncodeType encode) { 34 | this.encode = encode; 35 | } 36 | 37 | public Class getLoginClass() { 38 | return loginClass; 39 | } 40 | 41 | public void setLoginClass(Class loginClass) { 42 | this.loginClass = loginClass; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/Binding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public interface Binding extends ListConfig { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/BindingProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public class BindingProperties extends TenantDependentProperties { 11 | 12 | protected BindingProperties() { 13 | } 14 | 15 | public BindingProperties(String name) { 16 | super(name); 17 | } 18 | 19 | @Override 20 | protected String getDefaultName() { 21 | return ApplicationSettings.BINDING_DEFAULT_SETTINGS; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/ChannelSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.context.properties.ConfigurationProperties; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | import javax.annotation.PostConstruct; 15 | 16 | @Configuration 17 | @ConfigurationProperties("channel-settings") 18 | public class ChannelSettings extends ApplicationSettings { 19 | 20 | private boolean corsEnabled; 21 | 22 | HubSettings hubSettings; 23 | 24 | ChannelSettings() { 25 | } 26 | 27 | @Autowired 28 | public ChannelSettings(HubSettings hubSettings) { 29 | this.hubSettings = hubSettings; 30 | } 31 | 32 | @PostConstruct 33 | public void postConstruct() { 34 | postConstruct(hubSettings); 35 | } 36 | 37 | public boolean isCorsEnabled() { 38 | return corsEnabled; 39 | } 40 | 41 | public void setCorsEnabled(boolean corsEnabled) { 42 | this.corsEnabled = corsEnabled; 43 | } 44 | 45 | public enum ChannelHeader implements Header { 46 | TENANT("tenant"), 47 | ; 48 | 49 | private final String configName; 50 | 51 | ChannelHeader(String configName) { 52 | this.configName = configName; 53 | } 54 | @Override 55 | 56 | public String getConfigName() { 57 | return configName; 58 | } 59 | } 60 | 61 | public enum ChannelOperation implements Operation { 62 | NOTIFICATION_QUOTES("quotes"), 63 | NOTIFICATION_TRANSFERS("transfers"), 64 | RESPONSE("response"), 65 | ; 66 | 67 | private final String configName; 68 | 69 | ChannelOperation(String configName) { 70 | this.configName = configName; 71 | } 72 | 73 | @Override 74 | public String getConfigName() { 75 | return configName; 76 | } 77 | } 78 | 79 | public enum ChannelBinding implements Binding { 80 | PAYMENT("payment"), 81 | STATUS("status"), 82 | CLIENT_STATUS("client-status"), 83 | PARTIES("parties"), 84 | ; 85 | 86 | private final String configName; 87 | 88 | ChannelBinding(String configName) { 89 | this.configName = configName; 90 | } 91 | 92 | @Override 93 | public String getConfigName() { 94 | return configName; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/FspSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.context.properties.ConfigurationProperties; 12 | 13 | import javax.annotation.PostConstruct; 14 | 15 | @ConfigurationProperties("fsp-settings") 16 | public class FspSettings extends ApplicationSettings { 17 | 18 | private String ilpSecret; 19 | private AuthProperties auth; 20 | 21 | HubSettings hubSettings; 22 | 23 | FspSettings() { 24 | } 25 | 26 | @Autowired 27 | public FspSettings(HubSettings hubSettings) { 28 | this.hubSettings = hubSettings; 29 | } 30 | 31 | @PostConstruct 32 | public void postConstruct() { 33 | postConstruct(hubSettings); 34 | } 35 | 36 | public String getIlpSecret() { 37 | return ilpSecret; 38 | } 39 | 40 | public void setIlpSecret(String ilpSecret) { 41 | this.ilpSecret = ilpSecret; 42 | } 43 | 44 | public AuthProperties getAuth() { 45 | return auth; 46 | } 47 | 48 | public void setAuth(AuthProperties auth) { 49 | this.auth = auth; 50 | } 51 | 52 | public enum FspHeader implements Header { 53 | USER("user"), 54 | TENANT("tenant"), 55 | ; 56 | 57 | private final String configName; 58 | 59 | FspHeader(String configName) { 60 | this.configName = configName; 61 | } 62 | 63 | @Override 64 | public String getConfigName() { 65 | return configName; 66 | } 67 | } 68 | 69 | public enum FspOperation implements Operation { 70 | AUTH("auth"), 71 | PARTIES("parties"), 72 | REQUESTS("requests"), 73 | QUOTES("quotes"), 74 | TRANSFERS("transfers"), 75 | ; 76 | 77 | private final String configName; 78 | 79 | FspOperation(String configName) { 80 | this.configName = configName; 81 | } 82 | 83 | @Override 84 | public String getConfigName() { 85 | return configName; 86 | } 87 | } 88 | 89 | public enum FspBinding implements Binding { 90 | ; 91 | @Override 92 | public String getConfigName() { 93 | return null; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/Header.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public interface Header extends ListConfig { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/HeaderProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public class HeaderProperties { 11 | 12 | private String name; 13 | private String key; 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getKey() { 24 | return key; 25 | } 26 | 27 | public void setKey(String key) { 28 | this.key = key; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/HubSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.springframework.boot.context.properties.ConfigurationProperties; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @Configuration 17 | @ConfigurationProperties("hub-settings") 18 | public class HubSettings { 19 | 20 | private String instance; 21 | private Long expiration; 22 | private List tenants; 23 | 24 | public String getInstance() { 25 | return instance; 26 | } 27 | 28 | public void setInstance(String instance) { 29 | this.instance = instance; 30 | } 31 | 32 | public Long getExpiration() { 33 | return expiration; 34 | } 35 | 36 | public void setExpiration(Long expiration) { 37 | this.expiration = expiration; 38 | } 39 | 40 | public List getTenants() { 41 | return tenants; 42 | } 43 | 44 | public void setTenants(List tenants) { 45 | this.tenants = tenants == null ? new ArrayList<>(0) : tenants; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/IbanSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.springframework.boot.context.properties.ConfigurationProperties; 11 | 12 | @ConfigurationProperties("iban-settings") 13 | public class IbanSettings { 14 | 15 | private int fspInstanceIdFirstIndex; 16 | private int fspInstanceIdLength; 17 | private int fspTenantIdFirstIndex; 18 | private int fspTenantIdLength; 19 | 20 | public int getFspInstanceIdFirstIndex() { 21 | return fspInstanceIdFirstIndex; 22 | } 23 | 24 | public void setFspInstanceIdFirstIndex(int fspInstanceIdFirstIndex) { 25 | this.fspInstanceIdFirstIndex = fspInstanceIdFirstIndex; 26 | } 27 | 28 | public int getFspInstanceIdLength() { 29 | return fspInstanceIdLength; 30 | } 31 | 32 | public void setFspInstanceIdLength(int fspInstanceIdLength) { 33 | this.fspInstanceIdLength = fspInstanceIdLength; 34 | } 35 | 36 | public int getFspTenantIdFirstIndex() { 37 | return fspTenantIdFirstIndex; 38 | } 39 | 40 | public void setFspTenantIdFirstIndex(int fspTenantIdFirstIndex) { 41 | this.fspTenantIdFirstIndex = fspTenantIdFirstIndex; 42 | } 43 | 44 | public int getFspTenantIdLength() { 45 | return fspTenantIdLength; 46 | } 47 | 48 | public void setFspTenantIdLength(int fspTenantIdLength) { 49 | this.fspTenantIdLength = fspTenantIdLength; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/ListConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public interface ListConfig { 11 | 12 | String getConfigName(); 13 | } 14 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public interface Operation extends ListConfig { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/OperationProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public class OperationProperties extends TenantDependentProperties { 11 | 12 | protected OperationProperties() { 13 | } 14 | 15 | public OperationProperties(String name) { 16 | super(name); 17 | } 18 | 19 | @Override 20 | protected String getDefaultName() { 21 | return ApplicationSettings.OPERATION_DEFAULT_SETTINGS; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/SwitchSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.context.properties.ConfigurationProperties; 12 | 13 | import javax.annotation.PostConstruct; 14 | 15 | @ConfigurationProperties("switch-settings") 16 | public class SwitchSettings extends ApplicationSettings { 17 | 18 | private boolean integrationEnabled; 19 | 20 | HubSettings hubSettings; 21 | 22 | SwitchSettings() { 23 | } 24 | 25 | @Autowired 26 | public SwitchSettings(HubSettings hubSettings) { 27 | this.hubSettings = hubSettings; 28 | } 29 | 30 | @PostConstruct 31 | public void postConstruct() { 32 | postConstruct(hubSettings); 33 | } 34 | 35 | public boolean isIntegrationEnabled() { 36 | return integrationEnabled; 37 | } 38 | 39 | public void setIntegrationEnabled(boolean integrationEnabled) { 40 | this.integrationEnabled = integrationEnabled; 41 | } 42 | 43 | public enum SwitchHeader implements Header { 44 | SOURCE("source"), 45 | DESTINATION("destination"), 46 | ; 47 | 48 | private final String configName; 49 | 50 | SwitchHeader(String configName) { 51 | this.configName = configName; 52 | } 53 | 54 | @Override 55 | public String getConfigName() { 56 | return configName; 57 | } 58 | } 59 | 60 | public enum SwitchOperation implements Operation { 61 | PARTICIPANTS("participants"), 62 | PARTIES("parties"), 63 | REQUESTS("requests"), 64 | QUOTES("quotes"), 65 | TRANSFERS("transfers"), 66 | ; 67 | 68 | private final String configName; 69 | 70 | SwitchOperation(String configName) { 71 | this.configName = configName; 72 | } 73 | 74 | @Override 75 | public String getConfigName() { 76 | return configName; 77 | } 78 | } 79 | 80 | public enum SwitchBinding implements Binding { 81 | PARTICIPANTS("participants"), 82 | PARTIES("parties"), 83 | REQUESTS("requests"), 84 | QUOTES("quotes"), 85 | TRANSFERS("transfers"), 86 | ; 87 | 88 | private final String configName; 89 | 90 | SwitchBinding(String configName) { 91 | this.configName = configName; 92 | } 93 | 94 | @Override 95 | public String getConfigName() { 96 | return configName; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/TenantDependentProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public abstract class TenantDependentProperties extends UriProperties { 14 | 15 | private List tenants; 16 | 17 | protected TenantDependentProperties() { 18 | } 19 | 20 | protected TenantDependentProperties(String name) { 21 | super(name); 22 | } 23 | 24 | public List getTenants() { 25 | return tenants; 26 | } 27 | 28 | public void setTenants(List tenants) { 29 | this.tenants = tenants == null ? new ArrayList<>(0) : tenants; 30 | } 31 | 32 | public TenantProperties getTenant(String tenant) { 33 | if (tenant == null || tenants == null) 34 | return null; 35 | for (TenantProperties channelTenant : tenants) { 36 | if (tenant.equals(channelTenant.getName())) 37 | return channelTenant; 38 | } 39 | return null; 40 | } 41 | 42 | protected TenantProperties addTenant(TenantProperties tenant) { 43 | if (tenants == null) 44 | tenants = new ArrayList<>(1); 45 | tenants.add(tenant); 46 | return tenant; 47 | } 48 | 49 | void postConstruct(TenantDependentProperties oProps) { 50 | super.postConstruct(oProps); 51 | 52 | if (tenants == null) 53 | return; 54 | 55 | for (TenantProperties tenant : tenants) { 56 | tenant.postConstruct(this); 57 | if (oProps != null && oProps != this) { 58 | tenant.postConstruct(oProps.getTenant(tenant.getName())); 59 | tenant.postConstruct(oProps); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/TenantProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | public class TenantProperties extends UriProperties { 11 | 12 | protected TenantProperties() { 13 | } 14 | 15 | protected TenantProperties(String name) { 16 | super(name); 17 | } 18 | 19 | @Override 20 | protected String getDefaultName() { 21 | return null; // no default tenant 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/config/UriProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.config; 9 | 10 | import org.apache.logging.log4j.util.Strings; 11 | 12 | public abstract class UriProperties { 13 | 14 | private String name; 15 | private String user; 16 | private String password; 17 | private String host; 18 | private String port; 19 | private String base; 20 | 21 | protected UriProperties() { 22 | } 23 | 24 | protected UriProperties(String name) { 25 | this.name = name; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getUser() { 37 | return user; 38 | } 39 | 40 | public void setUser(String user) { 41 | this.user = user; 42 | } 43 | 44 | public String getPassword() { 45 | return password; 46 | } 47 | 48 | public void setPassword(String password) { 49 | this.password = password; 50 | } 51 | 52 | public String getHost() { 53 | return host; 54 | } 55 | 56 | public void setHost(String host) { 57 | this.host = host; 58 | } 59 | 60 | public String getPort() { 61 | return port; 62 | } 63 | 64 | public void setPort(String port) { 65 | this.port = port; 66 | } 67 | 68 | public String getBase() { 69 | return base; 70 | } 71 | 72 | public void setBase(String base) { 73 | this.base = base; 74 | } 75 | 76 | public String getUrl() { 77 | return host + (Strings.isEmpty(port) ? "" : (':' + port)) + (Strings.isEmpty(base) ? "" : ((base.charAt(0) == '/' ? "" : '/') + base)); 78 | } 79 | 80 | protected abstract String getDefaultName(); 81 | 82 | boolean isDefault() { 83 | return name.equals(getDefaultName()); 84 | } 85 | 86 | void postConstruct(UriProperties oProps) { 87 | if (oProps == null || oProps == this) 88 | return; 89 | 90 | // empty is a valid value 91 | if (user == null) 92 | user = oProps.getUser(); 93 | if (password == null) 94 | password = oProps.getPassword(); 95 | if (host == null) 96 | host = oProps.getHost(); 97 | if (port == null) 98 | port = oProps.getPort(); 99 | if (base == null) 100 | base = oProps.getBase(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/ComplexName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class ComplexName extends PartyIdInfo { 11 | 12 | private String firstName; 13 | private String middleName; 14 | private String lastName; 15 | 16 | public String getFirstName() { 17 | return firstName; 18 | } 19 | 20 | public void setFirstName(String firstName) { 21 | this.firstName = firstName; 22 | } 23 | 24 | public String getMiddleName() { 25 | return middleName; 26 | } 27 | 28 | public void setMiddleName(String middleName) { 29 | this.middleName = middleName; 30 | } 31 | 32 | public String getLastName() { 33 | return lastName; 34 | } 35 | 36 | public void setLastName(String lastName) { 37 | this.lastName = lastName; 38 | } 39 | 40 | void update(ComplexName oName) { 41 | if (oName == null) 42 | return; 43 | 44 | String oFn = oName.firstName; 45 | if (oFn != null) 46 | firstName = oFn; 47 | 48 | String oMn = oName.middleName; 49 | if (oFn != null) 50 | middleName = oMn; 51 | 52 | String oLn = oName.lastName; 53 | if (oLn != null) 54 | lastName = oLn; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/ErrorInformation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | public class ErrorInformation { 14 | 15 | private short errorCode; //mandatory, 4 digits 16 | private String errorDescription; //mandatory 17 | private List extensionList; 18 | 19 | public short getErrorCode() { 20 | return errorCode; 21 | } 22 | 23 | public void setErrorCode(short errorCode) { 24 | this.errorCode = errorCode; 25 | } 26 | 27 | public String getErrorDescription() { 28 | return errorDescription; 29 | } 30 | 31 | public void setErrorDescription(String errorDescription) { 32 | this.errorDescription = errorDescription; 33 | } 34 | 35 | public List getExtensionList() { 36 | return extensionList; 37 | } 38 | 39 | public void setExtensionList(List extensionList) { 40 | this.extensionList = extensionList; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "ErrorInformation{" + 46 | "errorCode:" + errorCode + 47 | ", errorDescription:'" + errorDescription + '\'' + 48 | ", extensionList:" + (extensionList == null ? "" : Arrays.toString(extensionList.toArray())) + 49 | '}'; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/Extension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class Extension { 11 | 12 | private String key; // mandatory, String(1..32) 13 | private String value; // mandatory, String(1..128) 14 | 15 | Extension() { 16 | } 17 | 18 | public Extension(String key, String value) { 19 | this.key = key; 20 | this.value = value; 21 | } 22 | 23 | public String getKey() { 24 | return key; 25 | } 26 | 27 | void setKey(String key) { 28 | this.key = key; 29 | } 30 | 31 | public String getValue() { 32 | return value; 33 | } 34 | 35 | public void setValue(String value) { 36 | this.value = value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/FspMoneyData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | import com.ilp.conditions.models.pdp.Money; 11 | 12 | import java.beans.Transient; 13 | import java.math.BigDecimal; 14 | 15 | import org.openmf.psp.util.ContextUtil; 16 | 17 | public class FspMoneyData { 18 | 19 | private BigDecimal amount; 20 | private String currency; 21 | 22 | public FspMoneyData() { 23 | } 24 | 25 | public FspMoneyData(BigDecimal amount, String currency) { 26 | this.amount = amount; 27 | this.currency = currency; 28 | } 29 | 30 | public BigDecimal getAmount() { 31 | return amount; 32 | } 33 | 34 | public void setAmount(BigDecimal amount) { 35 | this.amount = amount; 36 | } 37 | 38 | public String getCurrency() { 39 | return currency; 40 | } 41 | 42 | public void setCurrency(String currency) { 43 | this.currency = currency; 44 | } 45 | 46 | @Transient 47 | public Money toIlpMoney() { 48 | Money money = new Money(); 49 | money.setAmount(ContextUtil.formatAmount(amount)); 50 | money.setCurrency(currency); 51 | return money; 52 | } 53 | 54 | @Transient 55 | public static MoneyData toMoneyData(FspMoneyData moneyData) { 56 | return moneyData == null ? null : moneyData.toMoneyData(); 57 | } 58 | 59 | @Transient 60 | public MoneyData toMoneyData() { 61 | return new MoneyData(amount, currency); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/GeoCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class GeoCode { 11 | 12 | private String longitude; 13 | private String latitude; 14 | 15 | public String getLongitude() { 16 | return longitude; 17 | } 18 | 19 | public void setLongitude(String longitude) { 20 | this.longitude = longitude; 21 | } 22 | 23 | public String getLatitude() { 24 | return latitude; 25 | } 26 | 27 | public void setLatitude(String latitude) { 28 | this.latitude = latitude; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/MoneyData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | import com.ilp.conditions.models.pdp.Money; 11 | 12 | import java.beans.Transient; 13 | import java.math.BigDecimal; 14 | 15 | import org.openmf.psp.util.ContextUtil; 16 | 17 | public class MoneyData { 18 | 19 | private String amount; 20 | private String currency; 21 | 22 | public MoneyData() { 23 | } 24 | 25 | public MoneyData(String amount, String currency) { 26 | this.amount = amount; 27 | this.currency = currency; 28 | } 29 | 30 | public MoneyData(BigDecimal amount, String currency) { 31 | this(ContextUtil.formatAmount(amount), currency); 32 | } 33 | 34 | public String getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(String amount) { 39 | this.amount = amount; 40 | } 41 | 42 | @Transient 43 | public BigDecimal getAmountDecimal() { 44 | return ContextUtil.parseAmount(amount); 45 | } 46 | 47 | public void setAmount(BigDecimal amount) { 48 | this.amount = ContextUtil.formatAmount(amount); 49 | } 50 | 51 | public String getCurrency() { 52 | return currency; 53 | } 54 | 55 | public void setCurrency(String currency) { 56 | this.currency = currency; 57 | } 58 | 59 | @Transient 60 | public Money getIlpMoney() { 61 | Money money = new Money(); 62 | money.setAmount(amount); 63 | money.setCurrency(currency); 64 | return money; 65 | } 66 | 67 | @Transient 68 | public static FspMoneyData toFspMoneyData(MoneyData moneyData) { 69 | return moneyData == null ? null : moneyData.toFspMoneyData(); 70 | } 71 | 72 | @Transient 73 | public FspMoneyData toFspMoneyData() { 74 | return new FspMoneyData(getAmountDecimal(), currency); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/PartyIdInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | import org.openmf.psp.type.IdentifierType; 11 | 12 | public class PartyIdInfo { 13 | 14 | private IdentifierType partyIdType; // mandatory, immutable 15 | private String partyIdentifier; // mandatory, immutable 16 | private String partySubIdOrType; // optional, immutable 17 | private String fspId; // optional 18 | 19 | PartyIdInfo() { 20 | } 21 | 22 | public PartyIdInfo(IdentifierType partyIdType, String partyIdentifier, String partySubIdOrType, String fspId) { 23 | this.partyIdType = partyIdType; 24 | this.partyIdentifier = partyIdentifier; 25 | this.partySubIdOrType = partySubIdOrType; 26 | this.fspId = fspId; 27 | } 28 | 29 | public PartyIdInfo(IdentifierType partyIdType, String partyIdentifier, String partySubIdOrType) { 30 | this(partyIdType, partyIdentifier, partySubIdOrType, null); 31 | } 32 | 33 | public IdentifierType getPartyIdType() { 34 | return partyIdType; 35 | } 36 | 37 | void setPartyIdType(IdentifierType partyIdType) { 38 | this.partyIdType = partyIdType; 39 | } 40 | 41 | public String getPartyIdentifier() { 42 | return partyIdentifier; 43 | } 44 | 45 | void setPartyIdentifier(String partyIdentifier) { 46 | this.partyIdentifier = partyIdentifier; 47 | } 48 | 49 | public String getPartySubIdOrType() { 50 | return partySubIdOrType; 51 | } 52 | 53 | void setPartySubIdOrType(String partySubIdOrType) { 54 | this.partySubIdOrType = partySubIdOrType; 55 | } 56 | 57 | public String getFspId() { 58 | return fspId; 59 | } 60 | 61 | public void setFspId(String fspId) { 62 | if (fspId == null) 63 | return; 64 | if (this.fspId != null && !this.fspId.equals(fspId)) 65 | throw new RuntimeException("Technical error: try to change fspId from " + this.fspId + " to " + fspId); 66 | this.fspId = fspId; 67 | } 68 | 69 | public void update(PartyIdInfo oInfo) { 70 | if (oInfo == null) 71 | return; 72 | if (!equals(oInfo)) 73 | throw new RuntimeException("Incompatible party info " + this + '/' + oInfo); 74 | 75 | String oFspId = oInfo.fspId; 76 | if (oFspId != null) 77 | fspId = oFspId; 78 | } 79 | 80 | @Override 81 | public String toString() { 82 | return "PartyIdInfo{" + 83 | "idType:" + partyIdType + 84 | ", id:'" + partyIdentifier + '\'' + 85 | ", subIdOrType:'" + partySubIdOrType + '\'' + 86 | ", fspId:'" + fspId + '\'' + 87 | '}'; 88 | } 89 | 90 | @Override 91 | public boolean equals(Object o) { 92 | if (this == o) return true; 93 | if (o == null || getClass() != o.getClass()) return false; 94 | 95 | PartyIdInfo that = (PartyIdInfo) o; 96 | 97 | if (partyIdType != that.partyIdType) return false; 98 | if (!partyIdentifier.equals(that.partyIdentifier)) return false; 99 | return partySubIdOrType != null ? partySubIdOrType.equals(that.partySubIdOrType) : that.partySubIdOrType == null; 100 | } 101 | 102 | @Override 103 | public int hashCode() { 104 | int result = partyIdType.hashCode(); 105 | result = 31 * result + partyIdentifier.hashCode(); 106 | result = 31 * result + (partySubIdOrType != null ? partySubIdOrType.hashCode() : 0); 107 | return result; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/Payee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class Payee { 11 | 12 | private PartyIdInfo partyIdInfo; 13 | private String merchantClassificationCode; 14 | 15 | public PartyIdInfo getPartyIdInfo() { 16 | return partyIdInfo; 17 | } 18 | 19 | public void setPartyIdInfo(PartyIdInfo partyIdInfo) { 20 | this.partyIdInfo = partyIdInfo; 21 | } 22 | 23 | public String getMerchantClassificationCode() { 24 | return merchantClassificationCode; 25 | } 26 | 27 | public void setMerchantClassificationCode(String merchantClassificationCode) { 28 | this.merchantClassificationCode = merchantClassificationCode; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/Payer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class Payer { 11 | 12 | private PartyIdInfo partyIdInfo; 13 | 14 | public PartyIdInfo getPartyIdInfo() { 15 | return partyIdInfo; 16 | } 17 | 18 | public void setPartyIdInfo(PartyIdInfo partyIdInfo) { 19 | this.partyIdInfo = partyIdInfo; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/PersonalInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class PersonalInfo { 11 | 12 | private ComplexName complexName; 13 | private String dateOfBirth; 14 | 15 | public ComplexName getComplexName() { 16 | return complexName; 17 | } 18 | 19 | public void setComplexName(ComplexName complexName) { 20 | this.complexName = complexName; 21 | } 22 | 23 | public String getDateOfBirth() { 24 | return dateOfBirth; 25 | } 26 | 27 | public void setDateOfBirth(String dateOfBirth) { 28 | this.dateOfBirth = dateOfBirth; 29 | } 30 | 31 | void update(PersonalInfo oInfo) { 32 | if (oInfo == null) 33 | return; 34 | 35 | ComplexName oName = oInfo.complexName; 36 | if (complexName == null) 37 | complexName = oName; 38 | else 39 | complexName.update(oName); 40 | 41 | String oDate = oInfo.dateOfBirth; 42 | if (oDate != null) 43 | dateOfBirth = oDate; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/Refund.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | public class Refund { 11 | 12 | private String originalTransactionId; 13 | private String refundReason; 14 | 15 | public String getOriginalTransactionId() { 16 | return originalTransactionId; 17 | } 18 | 19 | public void setOriginalTransactionId(String originalTransactionId) { 20 | this.originalTransactionId = originalTransactionId; 21 | } 22 | 23 | public String getRefundReason() { 24 | return refundReason; 25 | } 26 | 27 | public void setRefundReason(String refundReason) { 28 | this.refundReason = refundReason; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/TransactionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto; 9 | 10 | import org.openmf.psp.type.InitiatorType; 11 | import org.openmf.psp.type.Scenario; 12 | import org.openmf.psp.type.SubScenario; 13 | import org.openmf.psp.type.TransactionRole; 14 | 15 | public class TransactionType { 16 | 17 | private Scenario scenario; 18 | private SubScenario subScenario; 19 | private TransactionRole initiator; 20 | private InitiatorType initiatorType; 21 | private Refund refundInfo; 22 | private String balanceOfPayments; // 3 digits number, see https://www.imf.org/external/np/sta/bopcode/ 23 | 24 | public Scenario getScenario() { 25 | return scenario; 26 | } 27 | 28 | public void setScenario(Scenario scenario) { 29 | this.scenario = scenario; 30 | } 31 | 32 | public SubScenario getSubScenario() { 33 | return subScenario; 34 | } 35 | 36 | public void setSubScenario(SubScenario subScenario) { 37 | this.subScenario = subScenario; 38 | } 39 | 40 | public TransactionRole getInitiator() { 41 | return initiator; 42 | } 43 | 44 | public void setInitiator(TransactionRole initiator) { 45 | this.initiator = initiator; 46 | } 47 | 48 | public InitiatorType getInitiatorType() { 49 | return initiatorType; 50 | } 51 | 52 | public void setInitiatorType(InitiatorType initiatorType) { 53 | this.initiatorType = initiatorType; 54 | } 55 | 56 | public Refund getRefundInfo() { 57 | return refundInfo; 58 | } 59 | 60 | public void setRefundInfo(Refund refundInfo) { 61 | this.refundInfo = refundInfo; 62 | } 63 | 64 | public String getBalanceOfPayments() { 65 | return balanceOfPayments; 66 | } 67 | 68 | public void setBalanceOfPayments(String balanceOfPayments) { 69 | this.balanceOfPayments = balanceOfPayments; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/channel/RegisterAliasRequestDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.channel; 9 | 10 | import org.openmf.psp.type.IdentifierType; 11 | 12 | public class RegisterAliasRequestDTO { 13 | 14 | private String accountId; 15 | private IdentifierType idType; 16 | private String idValue; 17 | 18 | public String getAccountId() { 19 | return accountId; 20 | } 21 | 22 | public void setAccountId(String accountId) { 23 | this.accountId = accountId; 24 | } 25 | 26 | public IdentifierType getIdType() { 27 | return idType; 28 | } 29 | 30 | public void setIdType(IdentifierType idType) { 31 | this.idType = idType; 32 | } 33 | 34 | public String getIdValue() { 35 | return idValue; 36 | } 37 | 38 | public void setIdValue(String idValue) { 39 | this.idValue = idValue; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/channel/TransactionChannelAsyncResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.channel; 9 | 10 | import java.beans.Transient; 11 | import java.time.LocalDateTime; 12 | 13 | import org.openmf.psp.mojaloop.type.TransferState; 14 | import org.openmf.psp.util.ContextUtil; 15 | 16 | /** 17 | * { 18 | * "clientRefId": "{{ch_client1_ref}}", 19 | * "transactionId": "{{hub_transaction1_id}}", 20 | * "completedTimestamp": "2019-01-22T00:00:00.000-01:00", 21 | * "transferState": "COMMITTED" 22 | * } 23 | */ 24 | public class TransactionChannelAsyncResponseDTO { 25 | 26 | private String clientRefId; 27 | private String transactionId; 28 | private String completedTimestamp; 29 | private String transferId; 30 | private TransferState transferState; 31 | private TransactionChannelRequestDTO originalRequestData; 32 | 33 | TransactionChannelAsyncResponseDTO() { 34 | } 35 | 36 | public TransactionChannelAsyncResponseDTO(String clientRefId, String transactionId, LocalDateTime completedTimestamp, String transferId, TransferState transferState, 37 | TransactionChannelRequestDTO originalRequestData) { 38 | this.clientRefId = clientRefId; 39 | this.transactionId = transactionId; 40 | this.completedTimestamp = ContextUtil.formatDate(completedTimestamp); 41 | this.transferId = transferId; 42 | this.transferState = transferState; 43 | this.originalRequestData = originalRequestData; 44 | } 45 | 46 | public String getClientRefId() { 47 | return clientRefId; 48 | } 49 | 50 | public void setClientRefId(String clientRefId) { 51 | this.clientRefId = clientRefId; 52 | } 53 | 54 | public String getTransactionId() { 55 | return transactionId; 56 | } 57 | 58 | public void setTransactionId(String transactionId) { 59 | this.transactionId = transactionId; 60 | } 61 | 62 | public String getCompletedTimestamp() { 63 | return completedTimestamp; 64 | } 65 | 66 | public void setCompletedTimestamp(String completedTimestamp) { 67 | this.completedTimestamp = completedTimestamp; 68 | } 69 | 70 | @Transient 71 | public LocalDateTime getCompletedTimestampDate() { 72 | return ContextUtil.parseDate(completedTimestamp); 73 | } 74 | 75 | public void setCompletedTimestamp(LocalDateTime completedTimestamp) { 76 | this.completedTimestamp = ContextUtil.formatDate(completedTimestamp); 77 | } 78 | 79 | public String getTransferId() { 80 | return transferId; 81 | } 82 | 83 | public void setTransferId(String transferId) { 84 | this.transferId = transferId; 85 | } 86 | 87 | public TransferState getTransferState() { 88 | return transferState; 89 | } 90 | 91 | public void setTransferState(TransferState transferState) { 92 | this.transferState = transferState; 93 | } 94 | 95 | public TransactionChannelRequestDTO getOriginalRequestData() { 96 | return originalRequestData; 97 | } 98 | 99 | public void setOriginalRequestData(TransactionChannelRequestDTO originalRequestData) { 100 | this.originalRequestData = originalRequestData; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/channel/TransactionChannelResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.channel; 9 | 10 | public class TransactionChannelResponseDTO { 11 | 12 | private String transactionId; 13 | 14 | 15 | public TransactionChannelResponseDTO(String transactionId) { 16 | this.transactionId = transactionId; 17 | } 18 | 19 | public String getTransactionId() { 20 | return transactionId; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/LoginFineractCnResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | import java.util.Date; 11 | 12 | public class LoginFineractCnResponseDTO implements LoginFspResponse { 13 | 14 | private String tokenType; 15 | private String accessToken; 16 | private Date accessTokenExpiration; 17 | private Date refreshTokenExpiration; 18 | private Date passwordExpiration; 19 | 20 | public String getTokenType() { 21 | return tokenType; 22 | } 23 | 24 | public void setTokenType(String tokenType) { 25 | this.tokenType = tokenType; 26 | } 27 | 28 | @Override 29 | public String getAccessToken() { 30 | return accessToken; 31 | } 32 | 33 | public void setAccessToken(String accessToken) { 34 | this.accessToken = accessToken; 35 | } 36 | 37 | @Override 38 | public Date getAccessTokenExpiration() { 39 | return accessTokenExpiration; 40 | } 41 | 42 | public void setAccessTokenExpiration(Date accessTokenExpiration) { 43 | this.accessTokenExpiration = accessTokenExpiration; 44 | } 45 | 46 | public Date getRefreshTokenExpiration() { 47 | return refreshTokenExpiration; 48 | } 49 | 50 | public void setRefreshTokenExpiration(Date refreshTokenExpiration) { 51 | this.refreshTokenExpiration = refreshTokenExpiration; 52 | } 53 | 54 | public Date getPasswordExpiration() { 55 | return passwordExpiration; 56 | } 57 | 58 | public void setPasswordExpiration(Date passwordExpiration) { 59 | this.passwordExpiration = passwordExpiration; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/LoginFineractXResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | import java.util.Collection; 11 | import java.util.Date; 12 | 13 | public class LoginFineractXResponseDTO implements LoginFspResponse { 14 | 15 | private String username; 16 | private Long userId; 17 | private String base64EncodedAuthenticationKey; 18 | 19 | private boolean authenticated; 20 | private boolean shouldRenewPassword; 21 | private boolean isTwoFactorAuthenticationRequired; 22 | 23 | private Long officeId; 24 | 25 | private String officeName; 26 | 27 | 28 | private Collection roles; 29 | 30 | private Collection permissions; 31 | 32 | public String getUsername() { 33 | return username; 34 | } 35 | 36 | public void setUsername(String username) { 37 | this.username = username; 38 | } 39 | 40 | public Long getUserId() { 41 | return userId; 42 | } 43 | 44 | public void setUserId(Long userId) { 45 | this.userId = userId; 46 | } 47 | 48 | public String getBase64EncodedAuthenticationKey() { 49 | return base64EncodedAuthenticationKey; 50 | } 51 | 52 | public void setBase64EncodedAuthenticationKey(String base64EncodedAuthenticationKey) { 53 | this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey; 54 | } 55 | 56 | public boolean isAuthenticated() { 57 | return authenticated; 58 | } 59 | 60 | public void setAuthenticated(boolean authenticated) { 61 | this.authenticated = authenticated; 62 | } 63 | 64 | public boolean isShouldRenewPassword() { 65 | return shouldRenewPassword; 66 | } 67 | 68 | public void setShouldRenewPassword(boolean shouldRenewPassword) { 69 | this.shouldRenewPassword = shouldRenewPassword; 70 | } 71 | 72 | public boolean getIsTwoFactorAuthenticationRequired() { 73 | return isTwoFactorAuthenticationRequired; 74 | } 75 | 76 | public void setIsTwoFactorAuthenticationRequired(boolean isTwoFactorAuthenticationRequired) { 77 | this.isTwoFactorAuthenticationRequired = isTwoFactorAuthenticationRequired; 78 | } 79 | 80 | public Long getOfficeId() { 81 | return officeId; 82 | } 83 | 84 | public void setOfficeId(Long officeId) { 85 | this.officeId = officeId; 86 | } 87 | 88 | public String getOfficeName() { 89 | return officeName; 90 | } 91 | 92 | public void setOfficeName(String officeName) { 93 | this.officeName = officeName; 94 | } 95 | 96 | public Collection getRoles() { 97 | return roles; 98 | } 99 | 100 | public void setRoles(Collection roles) { 101 | this.roles = roles; 102 | } 103 | 104 | public Collection getPermissions() { 105 | return permissions; 106 | } 107 | 108 | public void setPermissions(Collection permissions) { 109 | this.permissions = permissions; 110 | } 111 | 112 | @Override 113 | public String getAccessToken() { 114 | return base64EncodedAuthenticationKey; 115 | } 116 | 117 | @Override 118 | public Date getAccessTokenExpiration() { 119 | return shouldRenewPassword ? new Date(System.currentTimeMillis() + 5 * 60 * 60 * 1000) : null; //TODO: TIMEZONE 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/LoginFspResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | import java.util.Date; 11 | 12 | public interface LoginFspResponse { 13 | 14 | public String getAccessToken(); 15 | 16 | public Date getAccessTokenExpiration(); 17 | } 18 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/PartyFspResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | /** 11 | * { 12 | * accountId: "" 13 | * } 14 | */ 15 | public class PartyFspResponseDTO { 16 | 17 | private String accountId; 18 | 19 | public String getAccountId() { 20 | return accountId; 21 | } 22 | 23 | public void setAccountId(String accountId) { 24 | this.accountId = accountId; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/QuoteFspRequestDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | import org.openmf.psp.dto.FspMoneyData; 11 | import org.openmf.psp.dto.TransactionType; 12 | import org.openmf.psp.type.AmountType; 13 | import org.openmf.psp.type.TransactionRole; 14 | 15 | /** 16 | * { 17 | * "transactionCode": "ae87c51c141611e9ab14d663bd873d93", 18 | * "requestCode": "1cec02ee141611e9ab14d663bd873d93", 19 | * "quoteCode": "c992aed6141a11e9ab14d663bd873d93", 20 | * "accountId": "c14ee40813a511e9ab14d663bd873d93", 21 | * "amount": { 22 | * "amount": "2000", 23 | * "currency": "IDR" 24 | * }, 25 | * "amountType": "RECEIVE", 26 | * "transactionRole": "PAYER", 27 | * "transactionType": { 28 | * "scenario": "PAYMENT", 29 | * "subScenario": null, 30 | * "initiator": "PAYEE", 31 | * "initiatorType": "CONSUMER" 32 | * } 33 | * } 34 | */ 35 | public class QuoteFspRequestDTO { 36 | 37 | private String transactionCode; 38 | private String requestCode; 39 | private String quoteCode; 40 | private String accountId; 41 | private FspMoneyData amount; 42 | private AmountType amountType; 43 | private TransactionRole transactionRole; 44 | private TransactionType transactionType; 45 | 46 | public QuoteFspRequestDTO() { 47 | } 48 | 49 | public QuoteFspRequestDTO(String transactionCode, String requestCode, String quoteCode, String accountId, FspMoneyData amount, AmountType amountType, 50 | TransactionRole transactionRole, TransactionType transactionType) { 51 | this.transactionCode = transactionCode; 52 | this.requestCode = requestCode; 53 | this.quoteCode = quoteCode; 54 | this.accountId = accountId; 55 | this.amount = amount; 56 | this.amountType = amountType; 57 | this.transactionRole = transactionRole; 58 | this.transactionType = transactionType; 59 | } 60 | 61 | public String getTransactionCode() { 62 | return transactionCode; 63 | } 64 | 65 | public void setTransactionCode(String transactionCode) { 66 | this.transactionCode = transactionCode; 67 | } 68 | 69 | public String getRequestCode() { 70 | return requestCode; 71 | } 72 | 73 | public void setRequestCode(String requestCode) { 74 | this.requestCode = requestCode; 75 | } 76 | 77 | public String getQuoteCode() { 78 | return quoteCode; 79 | } 80 | 81 | public void setQuoteCode(String quoteCode) { 82 | this.quoteCode = quoteCode; 83 | } 84 | 85 | public String getAccountId() { 86 | return accountId; 87 | } 88 | 89 | public void setAccountId(String accountId) { 90 | this.accountId = accountId; 91 | } 92 | 93 | public FspMoneyData getAmount() { 94 | return amount; 95 | } 96 | 97 | public void setAmount(FspMoneyData amount) { 98 | this.amount = amount; 99 | } 100 | 101 | public AmountType getAmountType() { 102 | return amountType; 103 | } 104 | 105 | public void setAmountType(AmountType amountType) { 106 | this.amountType = amountType; 107 | } 108 | 109 | public TransactionRole getTransactionRole() { 110 | return transactionRole; 111 | } 112 | 113 | public void setTransactionRole(TransactionRole transactionRole) { 114 | this.transactionRole = transactionRole; 115 | } 116 | 117 | public TransactionType getTransactionType() { 118 | return transactionType; 119 | } 120 | 121 | public void setTransactionType(TransactionType transactionType) { 122 | this.transactionType = transactionType; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/QuoteFspResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 11 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 12 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; 13 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; 14 | 15 | import java.time.LocalDateTime; 16 | import java.util.List; 17 | 18 | import org.openmf.psp.dto.Extension; 19 | import org.openmf.psp.dto.FspMoneyData; 20 | import org.openmf.psp.type.TransactionRequestState; 21 | 22 | /** 23 | * { 24 | * transactionCode: "", 25 | * quoteCode: "", 26 | * fspFee: { 27 | * amount: 28 | * currency: 29 | * }, 30 | * fspCommission: { 31 | * amount: 32 | * currency: 33 | * }, 34 | * expiration: LocalDateTime, 35 | * extensiontList: [ 36 | * { 37 | * key: "", 38 | * value: 39 | * } 40 | * ] 41 | * } 42 | */ 43 | public class QuoteFspResponseDTO { 44 | 45 | private String transactionCode; //mandatory 46 | private String quoteCode; //mandatory 47 | private TransactionRequestState state; //mandatory 48 | private FspMoneyData fspFee; 49 | private FspMoneyData fspCommission; 50 | @JsonSerialize(using = LocalDateTimeSerializer.class) 51 | @JsonDeserialize(using = LocalDateTimeDeserializer.class) 52 | private LocalDateTime expiration; 53 | private List extensionList; 54 | 55 | public String getTransactionCode() { 56 | return transactionCode; 57 | } 58 | 59 | public void setTransactionCode(String transactionCode) { 60 | this.transactionCode = transactionCode; 61 | } 62 | 63 | public String getQuoteCode() { 64 | return quoteCode; 65 | } 66 | 67 | public void setQuoteCode(String quoteCode) { 68 | this.quoteCode = quoteCode; 69 | } 70 | 71 | public TransactionRequestState getState() { 72 | return state; 73 | } 74 | 75 | public void setState(TransactionRequestState state) { 76 | this.state = state; 77 | } 78 | 79 | public FspMoneyData getFspFee() { 80 | return fspFee; 81 | } 82 | 83 | public void setFspFee(FspMoneyData fspFee) { 84 | this.fspFee = fspFee; 85 | } 86 | 87 | public FspMoneyData getFspCommission() { 88 | return fspCommission; 89 | } 90 | 91 | public void setFspCommission(FspMoneyData fspCommission) { 92 | this.fspCommission = fspCommission; 93 | } 94 | 95 | public LocalDateTime getExpiration() { 96 | return expiration; 97 | } 98 | 99 | public void setExpiration(LocalDateTime expiration) { 100 | this.expiration = expiration; 101 | } 102 | 103 | public List getExtensionList() { 104 | return extensionList; 105 | } 106 | 107 | public void setExtensionList(List extensionList) { 108 | this.extensionList = extensionList; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/RoleData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | public class RoleData { 11 | 12 | private Long id; 13 | private String name; 14 | private String description; 15 | private Boolean disabled; 16 | 17 | public Long getId() { 18 | return id; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public String getDescription() { 26 | return description; 27 | } 28 | 29 | public Boolean getDisabled() { 30 | return disabled; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/TransactionRequestFspResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 11 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 12 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; 13 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; 14 | 15 | import java.time.LocalDateTime; 16 | import java.util.List; 17 | 18 | import org.openmf.psp.dto.Extension; 19 | import org.openmf.psp.type.TransactionRequestState; 20 | 21 | 22 | public class TransactionRequestFspResponseDTO { 23 | 24 | private String transactionCode; 25 | private String requestCode; 26 | private TransactionRequestState state; 27 | @JsonSerialize(using = LocalDateTimeSerializer.class) 28 | @JsonDeserialize(using = LocalDateTimeDeserializer.class) 29 | private LocalDateTime expiration; // mandatory 30 | private List extensionList; 31 | 32 | public String getTransactionCode() { 33 | return transactionCode; 34 | } 35 | 36 | public void setTransactionCode(String transactionCode) { 37 | this.transactionCode = transactionCode; 38 | } 39 | 40 | public String getRequestCode() { 41 | return requestCode; 42 | } 43 | 44 | public void setRequestCode(String requestCode) { 45 | this.requestCode = requestCode; 46 | } 47 | 48 | public TransactionRequestState getState() { 49 | return state; 50 | } 51 | 52 | public void setState(TransactionRequestState state) { 53 | this.state = state; 54 | } 55 | 56 | public LocalDateTime getExpiration() { 57 | return expiration; 58 | } 59 | 60 | public void setExpiration(LocalDateTime expiration) { 61 | this.expiration = expiration; 62 | } 63 | 64 | public List getExtensionList() { 65 | return extensionList; 66 | } 67 | 68 | public void setExtensionList(List extensionList) { 69 | this.extensionList = extensionList; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/dto/fsp/TransferFspResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.dto.fsp; 9 | 10 | 11 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 12 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 13 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; 14 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; 15 | 16 | import java.time.LocalDateTime; 17 | import java.util.List; 18 | 19 | import org.openmf.psp.dto.Extension; 20 | import org.openmf.psp.type.TransactionRequestState; 21 | 22 | 23 | public class TransferFspResponseDTO { 24 | 25 | private String transactionCode; // mandatory 26 | private String transferCode; // mandatory 27 | private TransactionRequestState state; // mandatory 28 | @JsonSerialize(using = LocalDateTimeSerializer.class) 29 | @JsonDeserialize(using = LocalDateTimeDeserializer.class) 30 | private LocalDateTime completedTimestamp; 31 | @JsonSerialize(using = LocalDateTimeSerializer.class) 32 | @JsonDeserialize(using = LocalDateTimeDeserializer.class) 33 | private LocalDateTime expiration; 34 | private List extensionList; 35 | 36 | public String getTransactionCode() { 37 | return transactionCode; 38 | } 39 | 40 | public void setTransactionCode(String transactionCode) { 41 | this.transactionCode = transactionCode; 42 | } 43 | 44 | public String getTransferCode() { 45 | return transferCode; 46 | } 47 | 48 | public void setTransferCode(String transferCode) { 49 | this.transferCode = transferCode; 50 | } 51 | 52 | public TransactionRequestState getState() { 53 | return state; 54 | } 55 | 56 | public void setState(TransactionRequestState state) { 57 | this.state = state; 58 | } 59 | 60 | public LocalDateTime getCompletedTimestamp() { 61 | return completedTimestamp; 62 | } 63 | 64 | public void setCompletedTimestamp(LocalDateTime completedTimestamp) { 65 | this.completedTimestamp = completedTimestamp; 66 | } 67 | 68 | public LocalDateTime getExpiration() { 69 | return expiration; 70 | } 71 | 72 | public void setExpiration(LocalDateTime expiration) { 73 | this.expiration = expiration; 74 | } 75 | 76 | public List getExtensionList() { 77 | return extensionList; 78 | } 79 | 80 | public void setExtensionList(List extensionList) { 81 | this.extensionList = extensionList; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/config/GSMASettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package org.openmf.psp.gsma.config; 10 | 11 | /** 12 | @Author Sidhant Gupta 13 | */ 14 | 15 | import javax.annotation.PostConstruct; 16 | 17 | import org.openmf.psp.config.ApplicationSettings; 18 | import org.openmf.psp.config.Binding; 19 | import org.openmf.psp.config.Header; 20 | import org.openmf.psp.config.HubSettings; 21 | import org.openmf.psp.config.Operation; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.boot.context.properties.ConfigurationProperties; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | @Configuration 27 | @ConfigurationProperties("ott-settings") 28 | public class GSMASettings extends ApplicationSettings { 29 | 30 | private boolean corsEnabled; 31 | private String apikey; 32 | 33 | HubSettings hubSettings; 34 | 35 | GSMASettings() { 36 | } 37 | 38 | @Autowired 39 | public GSMASettings(HubSettings hubSettings) { 40 | this.hubSettings = hubSettings; 41 | } 42 | 43 | @PostConstruct 44 | public void postConstruct() { 45 | postConstruct(hubSettings); 46 | } 47 | 48 | public boolean isCorsEnabled() { 49 | return corsEnabled; 50 | } 51 | 52 | public void setCorsEnabled(boolean corsEnabled) { 53 | this.corsEnabled = corsEnabled; 54 | } 55 | 56 | public String getApikey() { 57 | return apikey; 58 | } 59 | 60 | public void setApikey(String apikey) { 61 | this.apikey = apikey; 62 | } 63 | 64 | public enum OttHeader implements Header { 65 | TENANT("tenant"), 66 | ; 67 | 68 | private final String configName; 69 | 70 | OttHeader(String configName) { 71 | this.configName = configName; 72 | } 73 | @Override 74 | 75 | public String getConfigName() { 76 | return configName; 77 | } 78 | } 79 | 80 | public enum OttOperation implements Operation { 81 | TRANSACTIONS("transactions"), 82 | ACCOUNTS("accounts"), 83 | ; 84 | 85 | private final String configName; 86 | 87 | OttOperation(String configName) { 88 | this.configName = configName; 89 | } 90 | 91 | @Override 92 | public String getConfigName() { 93 | return configName; 94 | } 95 | } 96 | 97 | public enum OttBinding implements Binding { 98 | MERCHANTPAYMENT("merchantpayment"), 99 | TRANSFER("transfer") 100 | ; 101 | 102 | private final String configName; 103 | 104 | OttBinding(String configName) { 105 | this.configName = configName; 106 | } 107 | 108 | @Override 109 | public String getConfigName() { 110 | return configName; 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/AccountStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | /* 15 | { 16 | "status": "available", 17 | "subStatus": null, 18 | "lei": "AAAA0012345678901299" 19 | } 20 | */ 21 | //Refactor to use interoperability APIs instead. 22 | public class AccountStatus { 23 | 24 | String status; 25 | String subStatus; 26 | String lei; 27 | 28 | public String getStatus() { 29 | return status; 30 | } 31 | 32 | public void setStatus(String status) { 33 | this.status = status; 34 | } 35 | 36 | public String getSubStatus() { 37 | return subStatus; 38 | } 39 | 40 | public void setSubStatus(String subStatus) { 41 | this.subStatus = subStatus; 42 | } 43 | 44 | public String getLei() { 45 | return lei; 46 | } 47 | 48 | public void setLei(String lei) { 49 | this.lei = lei; 50 | } 51 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/FineractTransaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | 13 | package org.openmf.psp.gsma.dto; 14 | 15 | public class FineractTransaction { 16 | 17 | public FineractTransaction() { 18 | } 19 | 20 | String locale; 21 | String dateFormat; 22 | String transactionDate; 23 | String transactionAmount; 24 | String paymentTypeId; 25 | String accountNumber; 26 | String checkNumber; 27 | String routingCode; 28 | String receiptNumber; 29 | String bankNumber; 30 | 31 | public String getLocale() { 32 | return locale; 33 | } 34 | 35 | public void setLocale(String locale) { 36 | this.locale = locale; 37 | } 38 | 39 | public String getDateFormat() { 40 | return dateFormat; 41 | } 42 | 43 | public void setDateFormat(String dateFormat) { 44 | this.dateFormat = dateFormat; 45 | } 46 | 47 | public String getTransactionDate() { 48 | return transactionDate; 49 | } 50 | 51 | public void setTransactionDate(String transactionDate) { 52 | this.transactionDate = transactionDate; 53 | } 54 | 55 | public String getTransactionAmount() { 56 | return transactionAmount; 57 | } 58 | 59 | public void setTransactionAmount(String transactionAmount) { 60 | this.transactionAmount = transactionAmount; 61 | } 62 | 63 | public String getPaymentTypeId() { 64 | return paymentTypeId; 65 | } 66 | 67 | public void setPaymentTypeId(String paymentTypeId) { 68 | this.paymentTypeId = paymentTypeId; 69 | } 70 | 71 | public String getAccountNumber() { 72 | return accountNumber; 73 | } 74 | 75 | public void setAccountNumber(String accountNumber) { 76 | this.accountNumber = accountNumber; 77 | } 78 | 79 | public String getCheckNumber() { 80 | return checkNumber; 81 | } 82 | 83 | public void setCheckNumber(String checkNumber) { 84 | this.checkNumber = checkNumber; 85 | } 86 | 87 | public String getRoutingCode() { 88 | return routingCode; 89 | } 90 | 91 | public void setRoutingCode(String routingCode) { 92 | this.routingCode = routingCode; 93 | } 94 | 95 | public String getReceiptNumber() { 96 | return receiptNumber; 97 | } 98 | 99 | public void setReceiptNumber(String receiptNumber) { 100 | this.receiptNumber = receiptNumber; 101 | } 102 | 103 | public String getBankNumber() { 104 | return bankNumber; 105 | } 106 | 107 | public void setBankNumber(String bankNumber) { 108 | this.bankNumber = bankNumber; 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/IdDocument.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | public class IdDocument { 15 | 16 | String idType; 17 | String idNumber; 18 | String issueDate; 19 | String expiryDate; 20 | String issuer; 21 | String issuerPlace; 22 | String issuerCountry; 23 | String otherIdDescription; 24 | 25 | public String getIdType() { 26 | return idType; 27 | } 28 | 29 | public void setIdType(String idType) { 30 | this.idType = idType; 31 | } 32 | 33 | public String getIdNumber() { 34 | return idNumber; 35 | } 36 | 37 | public void setIdNumber(String idNumber) { 38 | this.idNumber = idNumber; 39 | } 40 | 41 | public String getIssueDate() { 42 | return issueDate; 43 | } 44 | 45 | public void setIssueDate(String issueDate) { 46 | this.issueDate = issueDate; 47 | } 48 | 49 | public String getExpiryDate() { 50 | return expiryDate; 51 | } 52 | 53 | public void setExpiryDate(String expiryDate) { 54 | this.expiryDate = expiryDate; 55 | } 56 | 57 | public String getIssuer() { 58 | return issuer; 59 | } 60 | 61 | public void setIssuer(String issuer) { 62 | this.issuer = issuer; 63 | } 64 | 65 | public String getIssuerPlace() { 66 | return issuerPlace; 67 | } 68 | 69 | public void setIssuerPlace(String issuerPlace) { 70 | this.issuerPlace = issuerPlace; 71 | } 72 | 73 | public String getIssuerCountry() { 74 | return issuerCountry; 75 | } 76 | 77 | public void setIssuerCountry(String issuerCountry) { 78 | this.issuerCountry = issuerCountry; 79 | } 80 | 81 | public String getOtherIdDescription() { 82 | return otherIdDescription; 83 | } 84 | 85 | public void setOtherIdDescription(String otherIdDescription) { 86 | this.otherIdDescription = otherIdDescription; 87 | } 88 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/InternationalTransferInformation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | /* 15 | "internationalTransferInformation": { 16 | "originCountry": "AD", 17 | "quotationReference": "string", 18 | "quoteId": "string", 19 | "receivingCountry": "AD", 20 | "remittancePurpose": "string", 21 | "relationshipSender": "string", 22 | "deliveryMethod": "directtoaccount", 23 | "senderBlockingReason": "string", 24 | "recipientBlockingReason": "string" 25 | } 26 | */ 27 | 28 | public class InternationalTransferInformation { 29 | 30 | String originCountry; 31 | String quotationReference; 32 | String quoteId; 33 | String receivingCountry; 34 | String remittancePurpose; 35 | String relationshipSender; 36 | String deliveryMethod; 37 | String senderBlockingReason; 38 | String recipientBlockingReason; 39 | 40 | 41 | public String getOriginCountry() { 42 | return originCountry; 43 | } 44 | 45 | public void setOriginCountry(String originCountry) { 46 | this.originCountry = originCountry; 47 | } 48 | 49 | public String getQuotationReference() { 50 | return quotationReference; 51 | } 52 | 53 | public void setQuotationReference(String quotationReference) { 54 | this.quotationReference = quotationReference; 55 | } 56 | 57 | public String getQuoteId() { 58 | return quoteId; 59 | } 60 | 61 | public void setQuoteId(String quoteId) { 62 | this.quoteId = quoteId; 63 | } 64 | 65 | public String getReceivingCountry() { 66 | return receivingCountry; 67 | } 68 | 69 | public void setReceivingCountry(String receivingCountry) { 70 | this.receivingCountry = receivingCountry; 71 | } 72 | 73 | public String getRemittancePurpose() { 74 | return remittancePurpose; 75 | } 76 | 77 | public void setRemittancePurpose(String remittancePurpose) { 78 | this.remittancePurpose = remittancePurpose; 79 | } 80 | 81 | public String getRelationshipSender() { 82 | return relationshipSender; 83 | } 84 | 85 | public void setRelationshipSender(String relationshipSender) { 86 | this.relationshipSender = relationshipSender; 87 | } 88 | 89 | public String getDeliveryMethod() { 90 | return deliveryMethod; 91 | } 92 | 93 | public void setDeliveryMethod(String deliveryMethod) { 94 | this.deliveryMethod = deliveryMethod; 95 | } 96 | 97 | public String getSenderBlockingReason() { 98 | return senderBlockingReason; 99 | } 100 | 101 | public void setSenderBlockingReason(String senderBlockingReason) { 102 | this.senderBlockingReason = senderBlockingReason; 103 | } 104 | 105 | public String getRecipientBlockingReason() { 106 | return recipientBlockingReason; 107 | } 108 | 109 | public void setRecipientBlockingReason(String recipientBlockingReason) { 110 | this.recipientBlockingReason = recipientBlockingReason; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/Kyc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | /* 15 | "senderKyc": { 16 | "nationality": "AD", 17 | "dateOfBirth": "string", 18 | "occupation": "string", 19 | "employerName": "string", 20 | "contactPhone": "string", 21 | "gender": "m", 22 | "idDocument": [ 23 | { 24 | "idType": "passport", 25 | "idNumber": "string", 26 | "issueDate": "string", 27 | "expiryDate": "string", 28 | "issuer": "string", 29 | "issuerPlace": "string", 30 | "issuerCountry": "AD", 31 | "otherIdDescription": "string" 32 | } 33 | ], 34 | "postalAddress": { 35 | "addressLine1": "string", 36 | "addressLine2": "string", 37 | "addressLine3": "string", 38 | "city": "string", 39 | "stateProvince": "string", 40 | "postalCode": "string", 41 | "country": "AD" 42 | }, 43 | "subjectName": { 44 | "title": "string", 45 | "firstName": "string", 46 | "middleName": "string", 47 | "lastName": "string", 48 | "fullName": "string", 49 | "nativeName": "string" 50 | }, 51 | "emailAddress": "string", 52 | "birthCountry": "AD" 53 | } 54 | */ 55 | 56 | public class Kyc { 57 | 58 | String nationality; 59 | String dateOfBirth; 60 | String occupation; 61 | String employerName; 62 | String contactPhone; 63 | char gender; 64 | 65 | IdDocument[] idDocument; 66 | 67 | PostalAddress postalAddress; 68 | 69 | SubjectName subjectName; 70 | 71 | String emailAddress; 72 | String birthCountry; 73 | 74 | public String getNationality() { 75 | return nationality; 76 | } 77 | 78 | public void setNationality(String nationality) { 79 | this.nationality = nationality; 80 | } 81 | 82 | public String getDateOfBirth() { 83 | return dateOfBirth; 84 | } 85 | 86 | public void setDateOfBirth(String dateOfBirth) { 87 | this.dateOfBirth = dateOfBirth; 88 | } 89 | 90 | public String getOccupation() { 91 | return occupation; 92 | } 93 | 94 | public void setOccupation(String occupation) { 95 | this.occupation = occupation; 96 | } 97 | 98 | public String getEmployerName() { 99 | return employerName; 100 | } 101 | 102 | public void setEmployerName(String employerName) { 103 | this.employerName = employerName; 104 | } 105 | 106 | public String getContactPhone() { 107 | return contactPhone; 108 | } 109 | 110 | public void setContactPhone(String contactPhone) { 111 | this.contactPhone = contactPhone; 112 | } 113 | 114 | public char getGender() { 115 | return gender; 116 | } 117 | 118 | public void setGender(char gender) { 119 | this.gender = gender; 120 | } 121 | 122 | public IdDocument[] getIdDocument() { 123 | return idDocument; 124 | } 125 | 126 | public void setIdDocument(IdDocument[] idDocument) { 127 | this.idDocument = idDocument; 128 | } 129 | 130 | public PostalAddress getPostalAddress() { 131 | return postalAddress; 132 | } 133 | 134 | public void setPostalAddress(PostalAddress postalAddress) { 135 | this.postalAddress = postalAddress; 136 | } 137 | 138 | public SubjectName getSubjectName() { 139 | return subjectName; 140 | } 141 | 142 | public void setSubjectName(SubjectName subjectName) { 143 | this.subjectName = subjectName; 144 | } 145 | 146 | public String getEmailAddress() { 147 | return emailAddress; 148 | } 149 | 150 | public void setEmailAddress(String emailAddress) { 151 | this.emailAddress = emailAddress; 152 | } 153 | 154 | public String getBirthCountry() { 155 | return birthCountry; 156 | } 157 | 158 | public void setBirthCountry(String birthCountry) { 159 | this.birthCountry = birthCountry; 160 | } 161 | 162 | 163 | 164 | } 165 | 166 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/Party.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | public class Party { 15 | 16 | String key; 17 | String value; 18 | 19 | public String getKey() { 20 | return key; 21 | } 22 | 23 | public void setKey(String key) { 24 | this.key = key; 25 | } 26 | 27 | public String getValue() { 28 | return value; 29 | } 30 | 31 | public void setValue(String value) { 32 | this.value = value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/PostalAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | /* 15 | "postalAddress": { 16 | "addressLine1": "string", 17 | "addressLine2": "string", 18 | "addressLine3": "string", 19 | "city": "string", 20 | "stateProvince": "string", 21 | "postalCode": "string", 22 | "country": "AD" 23 | } 24 | */ 25 | 26 | public class PostalAddress { 27 | 28 | String addressLine1; 29 | String addressLine2; 30 | String addressLine3; 31 | String city; 32 | String stateProvince; 33 | String postalCode; 34 | String country; 35 | 36 | public String getAddressLine1() { 37 | return addressLine1; 38 | } 39 | 40 | public void setAddressLine1(String addressLine1) { 41 | this.addressLine1 = addressLine1; 42 | } 43 | 44 | public String getAddressLine2() { 45 | return addressLine2; 46 | } 47 | 48 | public void setAddressLine2(String addressLine2) { 49 | this.addressLine2 = addressLine2; 50 | } 51 | 52 | public String getAddressLine3() { 53 | return addressLine3; 54 | } 55 | 56 | public void setAddressLine3(String addressLine3) { 57 | this.addressLine3 = addressLine3; 58 | } 59 | 60 | public String getCity() { 61 | return city; 62 | } 63 | 64 | public void setCity(String city) { 65 | this.city = city; 66 | } 67 | 68 | public String getStateProvince() { 69 | return stateProvince; 70 | } 71 | 72 | public void setStateProvince(String stateProvince) { 73 | this.stateProvince = stateProvince; 74 | } 75 | 76 | public String getPostalCode() { 77 | return postalCode; 78 | } 79 | 80 | public void setPostalCode(String postalCode) { 81 | this.postalCode = postalCode; 82 | } 83 | 84 | public String getCountry() { 85 | return country; 86 | } 87 | 88 | public void setCountry(String country) { 89 | this.country = country; 90 | } 91 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/dto/SubjectName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.dto; 13 | 14 | /* 15 | "subjectName": { 16 | "title": "string", 17 | "firstName": "string", 18 | "middleName": "string", 19 | "lastName": "string", 20 | "fullName": "string", 21 | "nativeName": "string" 22 | } 23 | */ 24 | 25 | public class SubjectName { 26 | 27 | String title; 28 | String firstName; 29 | String middleName; 30 | String lastName; 31 | String nativeName; 32 | 33 | public String getTitle() { 34 | return title; 35 | } 36 | 37 | public void setTitle(String title) { 38 | this.title = title; 39 | } 40 | 41 | public String getFirstName() { 42 | return firstName; 43 | } 44 | 45 | public void setFirstName(String firstName) { 46 | this.firstName = firstName; 47 | } 48 | 49 | public String getMiddleName() { 50 | return middleName; 51 | } 52 | 53 | public void setMiddleName(String middleName) { 54 | this.middleName = middleName; 55 | } 56 | 57 | public String getLastName() { 58 | return lastName; 59 | } 60 | 61 | public void setLastName(String lastName) { 62 | this.lastName = lastName; 63 | } 64 | 65 | public String getNativeName() { 66 | return nativeName; 67 | } 68 | 69 | public void setNativeName(String nativeName) { 70 | this.nativeName = nativeName; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/channel/BaseTransaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.channel; 13 | 14 | import org.apache.camel.builder.RouteBuilder; 15 | import org.openmf.psp.gsma.config.GSMASettings; 16 | import org.springframework.context.annotation.Configuration; 17 | 18 | @Configuration 19 | public class BaseTransaction extends RouteBuilder { 20 | 21 | @Override 22 | public void configure() throws Exception { 23 | 24 | from("direct:conductTransaction") 25 | .id("conductTransaction") 26 | .log("Starting transaction") 27 | .to("direct:checkTransactionRequest") 28 | ; 29 | 30 | from("direct:checkTransactionRequest") 31 | .id("checkTransactionRequest") 32 | .log("Checking transaction...") 33 | .process("checkTransactionsTypeProcessor") 34 | .choice() 35 | .when(exchange -> exchange.getIn().getBody(String.class).equals("")) 36 | .log("Breaking...") 37 | .otherwise() 38 | .to("direct:verifyTransactions") 39 | .end() 40 | ; 41 | 42 | from("direct:verifyTransactions") 43 | .id("verifyTransactions") 44 | .choice() 45 | .when(exchange -> exchange.getProperty("transactionType", String.class).equals(GSMASettings.OttBinding.TRANSFER)) 46 | .to("direct:checkReceiverId") 47 | .otherwise() 48 | .to("direct:commitTransaction") 49 | ; 50 | 51 | from("direct:checkReceiverId") 52 | .id("checkReceiverId") 53 | .process("checkReceiverAccountsProcessor") 54 | .choice() 55 | .when(exchange -> exchange.getIn().getBody() == null) 56 | .log("Error: credit party does not exist") 57 | .otherwise() 58 | .process(exchange -> { 59 | exchange.getIn().setBody(exchange.getProperty("mainBody")); 60 | }) 61 | .to("direct:commitTransaction") 62 | ; 63 | 64 | from("direct:commitTransaction") 65 | .id("commitTransaction") 66 | .log("Committing transaction...") 67 | .process("postTransactionsProcessor") 68 | .to("direct:giveConfirmation") 69 | ; 70 | 71 | from("direct:giveConfirmation") 72 | .id("giveConfirmation") 73 | .log("Checking transaction status...") 74 | .process("checkTransactionsProcessor") 75 | .choice() 76 | .when(exchange -> exchange.getProperty("isTransactionSuccess", boolean.class)) 77 | .log("Transaction completed") 78 | .otherwise() 79 | .log("Transaction failed") 80 | ; 81 | } 82 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/channel/MerchantPayment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.channel; 13 | 14 | import javax.ws.rs.HttpMethod; 15 | 16 | import org.apache.camel.CamelContext; 17 | import org.apache.camel.builder.RouteBuilder; 18 | import org.apache.camel.model.dataformat.JsonLibrary; 19 | import org.openmf.psp.config.BindingProperties; 20 | import org.openmf.psp.config.HubSettings; 21 | import org.openmf.psp.config.OperationProperties; 22 | import org.openmf.psp.gsma.config.GSMASettings; 23 | import org.openmf.psp.gsma.dto.GSMATransaction; 24 | import org.springframework.beans.factory.annotation.Autowired; 25 | import org.springframework.context.annotation.Configuration; 26 | 27 | @Configuration 28 | public class MerchantPayment extends RouteBuilder { 29 | 30 | 31 | private HubSettings hubSettings; 32 | private GSMASettings ottSettings; 33 | 34 | @Autowired 35 | public MerchantPayment (CamelContext camelContext, HubSettings hubSettings, GSMASettings ottSettings) { 36 | 37 | super(camelContext); 38 | this.hubSettings = hubSettings; 39 | this.ottSettings = ottSettings; 40 | } 41 | 42 | @Override 43 | public void configure() throws Exception { 44 | getContext().getShutdownStrategy().setTimeout(1); 45 | 46 | OperationProperties transactionsOperation = ottSettings.getOperation(GSMASettings.OttOperation.TRANSACTIONS); 47 | String apiTransactionsEndpoint = transactionsOperation.getUrl(); 48 | 49 | BindingProperties binding = ottSettings.getBinding(GSMASettings.OttBinding.MERCHANTPAYMENT); 50 | String url = binding.getUrl(); 51 | 52 | String consumerEndpoint = "jetty:" + url + "?httpMethodRestrict=" + HttpMethod.POST + "&enableCORS=" + 53 | ottSettings.isCorsEnabled(); 54 | 55 | from(consumerEndpoint) 56 | .id("receive-merchant-payment-request") 57 | .log("Request received") 58 | .streamCaching() 59 | .process(exchange -> { 60 | exchange.setProperty("apikey", ottSettings.getApikey()); 61 | exchange.setProperty("apiTransactionsEndpoint", apiTransactionsEndpoint); 62 | exchange.setProperty("transactionType", binding.getName()); 63 | exchange.setProperty("mainBody", exchange.getIn().getBody(String.class)); 64 | }) 65 | .unmarshal().json(JsonLibrary.Jackson, GSMATransaction.class) 66 | .to("direct:conductTransaction") 67 | ; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/channel/PeerToPeerTransfer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.channel; 13 | 14 | import javax.ws.rs.HttpMethod; 15 | 16 | import org.apache.camel.CamelContext; 17 | import org.apache.camel.builder.RouteBuilder; 18 | import org.apache.camel.model.dataformat.JsonLibrary; 19 | import org.openmf.psp.config.BindingProperties; 20 | import org.openmf.psp.config.HubSettings; 21 | import org.openmf.psp.config.OperationProperties; 22 | import org.openmf.psp.gsma.config.GSMASettings; 23 | import org.openmf.psp.gsma.dto.GSMATransaction; 24 | import org.springframework.beans.factory.annotation.Autowired; 25 | import org.springframework.context.annotation.Configuration; 26 | 27 | @Configuration 28 | public class PeerToPeerTransfer extends RouteBuilder { 29 | 30 | private HubSettings hubSettings; 31 | private GSMASettings ottSettings; 32 | 33 | @Autowired 34 | public PeerToPeerTransfer (CamelContext camelContext, HubSettings hubSettings, 35 | GSMASettings ottSettings) { 36 | super(camelContext); 37 | this.hubSettings = hubSettings; 38 | this.ottSettings = ottSettings; 39 | } 40 | 41 | @Override 42 | public void configure() throws Exception { 43 | getContext().getShutdownStrategy().setTimeout(1); 44 | 45 | OperationProperties transactionsOperation = ottSettings.getOperation(GSMASettings.OttOperation.TRANSACTIONS); 46 | String apiTransactionsEndpoint = transactionsOperation.getUrl(); 47 | 48 | OperationProperties AccountsOperation = ottSettings.getOperation(GSMASettings.OttOperation.ACCOUNTS); 49 | String apiAccountsEndpoint = AccountsOperation.getUrl(); 50 | 51 | BindingProperties binding = ottSettings.getBinding(GSMASettings.OttBinding.TRANSFER); 52 | String url = binding.getUrl(); 53 | 54 | String consumerEndpoint = "jetty:" + url + "?httpMethodRestrict=" + HttpMethod.POST + "&enableCORS=" + 55 | ottSettings.isCorsEnabled(); 56 | 57 | from(consumerEndpoint) 58 | .id("receive-transfer-request") 59 | .log("Request received") 60 | .streamCaching() 61 | .process(exchange -> { 62 | exchange.setProperty("apikey", ottSettings.getApikey()); 63 | exchange.setProperty("apiTransactionsEndpoint", apiTransactionsEndpoint); 64 | exchange.setProperty("apiAccountsEndpoint", apiAccountsEndpoint); 65 | exchange.setProperty("transactionType", binding.getName()); 66 | exchange.setProperty("mainBody", exchange.getIn().getBody(String.class)); 67 | }) 68 | .unmarshal().json(JsonLibrary.Jackson, GSMATransaction.class) 69 | .to("direct:conductTransaction") 70 | ; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/processor/CheckReceiverAccountsProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.processor; 13 | 14 | import java.time.LocalDateTime; 15 | 16 | import org.apache.camel.Exchange; 17 | import org.apache.camel.Message; 18 | import org.apache.camel.Processor; 19 | import org.openmf.psp.gsma.dto.AccountStatus; 20 | import org.openmf.psp.gsma.dto.GSMATransaction; 21 | import org.openmf.psp.gsma.dto.Party; 22 | import org.springframework.http.HttpEntity; 23 | import org.springframework.http.HttpHeaders; 24 | import org.springframework.http.HttpMethod; 25 | import org.springframework.stereotype.Component; 26 | import org.springframework.web.client.RestTemplate; 27 | 28 | @Component("checkReceiverAccountsProcessor") 29 | public class CheckReceiverAccountsProcessor implements Processor { 30 | 31 | RestTemplate restTemplate; 32 | 33 | public CheckReceiverAccountsProcessor (RestTemplate restTemplate) { 34 | 35 | this.restTemplate = restTemplate; 36 | } 37 | 38 | @Override 39 | public void process (Exchange exchange) throws Exception { 40 | 41 | Message in = exchange.getIn(); 42 | GSMATransaction transactionObject = in.getBody(GSMATransaction.class); 43 | 44 | for (Party p: transactionObject.getCreditParty()) { 45 | String key = p.getKey(); 46 | String value = p.getValue(); 47 | 48 | HttpHeaders httpHeaders = new HttpHeaders(); 49 | 50 | String date = LocalDateTime.now().toString(); 51 | httpHeaders.set("Date", date); 52 | 53 | String body = null; 54 | HttpEntity entity = new HttpEntity<>(body, httpHeaders); 55 | 56 | HttpMethod httpMethod = HttpMethod.GET; 57 | 58 | String apikey = exchange.getProperty("apikey", String.class); 59 | 60 | //String endpointUrl = exchange.getProperty("apiEndpoint", String.class) + "?apikey=" + apikey; 61 | 62 | String endpointUrl = exchange.getProperty("apiAccountsEndpoint", String.class) + key + "@" + 63 | value + "/status" + "?apikey=" + apikey; 64 | 65 | //System.out.println(key + value); 66 | 67 | AccountStatus response = restTemplate.exchange(endpointUrl, httpMethod, entity, 68 | AccountStatus.class).getBody(); 69 | 70 | if (response.getStatus().equals("available") != true) { 71 | 72 | System.out.println("Account does not exist, breaking"); 73 | exchange.getIn().setBody(null); 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/processor/CheckTransactionProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.processor; 13 | 14 | import org.apache.camel.Exchange; 15 | import org.apache.camel.Message; 16 | import org.apache.camel.Processor; 17 | import org.openmf.psp.gsma.dto.GSMATransaction; 18 | import org.springframework.stereotype.Component; 19 | import org.springframework.web.client.RestTemplate; 20 | 21 | @Component("checkTransactionProcessor") 22 | public class CheckTransactionProcessor implements Processor { 23 | 24 | RestTemplate restTemplate; 25 | 26 | public CheckTransactionProcessor (RestTemplate restTemplate) { 27 | 28 | this.restTemplate = restTemplate; 29 | } 30 | 31 | @Override 32 | public void process (Exchange exchange) throws Exception { 33 | 34 | Message in = exchange.getIn(); 35 | GSMATransaction transactionObject = in.getBody(GSMATransaction.class); 36 | 37 | if (transactionObject.getTransactionStatus().equals("completed")) { 38 | exchange.setProperty("isTransactionSuccess", true); 39 | } 40 | 41 | exchange.getOut().setBody(transactionObject); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/processor/CheckTransactionTypeProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.processor; 13 | 14 | import org.apache.camel.Exchange; 15 | import org.apache.camel.Message; 16 | import org.apache.camel.Processor; 17 | import org.openmf.psp.gsma.dto.GSMATransaction; 18 | import org.springframework.stereotype.Component; 19 | import org.springframework.web.client.RestTemplate; 20 | 21 | @Component("checkTransactionTypeProcessor") 22 | public class CheckTransactionTypeProcessor implements Processor { 23 | 24 | RestTemplate restTemplate; 25 | 26 | public CheckTransactionTypeProcessor (RestTemplate restTemplate) { 27 | this.restTemplate = restTemplate; 28 | } 29 | 30 | @Override 31 | public void process (Exchange exchange) throws Exception { 32 | 33 | Message in = exchange.getIn(); 34 | GSMATransaction transactionObject = in.getBody(GSMATransaction.class); 35 | 36 | //TODO: add more checks 37 | 38 | String transactionType = exchange.getProperty("transactionType", String.class); 39 | 40 | if (!(transactionType.equals(transactionObject.getType()))) { 41 | System.out.println("Transaction type does not match."); 42 | exchange.getIn().setBody(null); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/gsma/routebuilder/processor/PostTransactionProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | @Author Sidhant Gupta 11 | */ 12 | package org.openmf.psp.gsma.routebuilder.processor; 13 | 14 | import java.time.LocalDateTime; 15 | import java.util.Arrays; 16 | import java.util.UUID; 17 | 18 | import org.apache.camel.Exchange; 19 | import org.apache.camel.Processor; 20 | import org.openmf.psp.gsma.dto.GSMATransaction; 21 | import org.springframework.http.HttpEntity; 22 | import org.springframework.http.HttpHeaders; 23 | import org.springframework.http.HttpMethod; 24 | import org.springframework.http.MediaType; 25 | import org.springframework.stereotype.Component; 26 | import org.springframework.web.client.RestTemplate; 27 | 28 | @Component("postTransactionProcessor") 29 | public class PostTransactionProcessor implements Processor { 30 | 31 | RestTemplate restTemplate; 32 | 33 | public PostTransactionProcessor(RestTemplate restTemplate) { 34 | this.restTemplate = restTemplate; 35 | } 36 | 37 | @Override 38 | public void process (Exchange exchange) throws Exception { 39 | 40 | String body = exchange.getProperty("mainBody", String.class); 41 | 42 | HttpHeaders httpHeaders = new HttpHeaders(); 43 | httpHeaders.setContentType(MediaType.APPLICATION_JSON); 44 | httpHeaders.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 45 | 46 | String corrId = UUID.randomUUID().toString(); 47 | httpHeaders.set("X-CorrelationID", corrId); 48 | 49 | String date = LocalDateTime.now().toString(); 50 | httpHeaders.set("Date", date); 51 | 52 | HttpEntity entity = new HttpEntity<>(body, httpHeaders); 53 | 54 | HttpMethod httpMethod = HttpMethod.POST; 55 | 56 | String apikey = exchange.getProperty("apikey", String.class); 57 | 58 | String endpointUrl = exchange.getProperty("apiTransactionsEndpoint", String.class) + "?apikey=" + apikey; 59 | 60 | GSMATransaction response = restTemplate.exchange(endpointUrl, httpMethod, entity, 61 | GSMATransaction.class).getBody(); 62 | 63 | exchange.getIn().setBody(response); 64 | } 65 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/internal/FspContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.internal; 9 | 10 | import org.openmf.psp.component.FspRestClient; 11 | 12 | public class FspContext { 13 | 14 | private FspId fspId; 15 | private FspRestClient.TenantAuth tenantAuth; 16 | 17 | public FspId getFspId() { 18 | return fspId; 19 | } 20 | 21 | public void setFspId(FspId fspId) { 22 | this.fspId = fspId; 23 | } 24 | 25 | public FspRestClient.TenantAuth getTenantAuth() { 26 | return tenantAuth; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/internal/FspId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.internal; 9 | 10 | public class FspId { 11 | 12 | private String instance; 13 | private String tenant; 14 | 15 | public FspId(String instance, String tenant) { 16 | this.instance = instance; 17 | this.tenant = tenant; 18 | } 19 | 20 | public String getInstance() { 21 | return instance; 22 | } 23 | 24 | public String getTenant() { 25 | return tenant; 26 | } 27 | 28 | public String getId() { 29 | return instance + tenant; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object o) { 34 | if (this == o) return true; 35 | if (o == null || getClass() != o.getClass()) return false; 36 | 37 | FspId fspId = (FspId) o; 38 | 39 | if (!instance.equals(fspId.instance)) return false; 40 | return tenant.equals(fspId.tenant); 41 | } 42 | 43 | @Override 44 | public int hashCode() { 45 | int result = instance.hashCode(); 46 | result = 31 * result + tenant.hashCode(); 47 | return result; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "FspId{" + 53 | "instance:'" + instance + '\'' + 54 | ", tenant:'" + tenant + '\'' + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/component/CodecContextFactoryDpc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.component; 9 | 10 | import org.interledger.Condition; 11 | import org.interledger.InterledgerAddress; 12 | import org.interledger.codecs.CodecContext; 13 | import org.interledger.codecs.oer.OerGeneralizedTimeCodec; 14 | import org.interledger.codecs.oer.OerIA5StringCodec; 15 | import org.interledger.codecs.oer.OerLengthPrefixCodec; 16 | import org.interledger.codecs.oer.OerOctetStringCodec; 17 | import org.interledger.codecs.oer.OerUint256Codec; 18 | import org.interledger.codecs.oer.OerUint32Codec; 19 | import org.interledger.codecs.oer.OerUint64Codec; 20 | import org.interledger.codecs.oer.OerUint8Codec; 21 | import org.interledger.codecs.oer.ilp.ConditionOerCodec; 22 | import org.interledger.codecs.oer.ilp.InterledgerAddressOerCodec; 23 | import org.interledger.codecs.oer.ilp.InterledgerPacketTypeOerCodec; 24 | import org.interledger.codecs.oer.ilp.InterledgerPaymentOerCodec; 25 | import org.interledger.codecs.oer.ilqp.QuoteByDestinationAmountRequestOerCodec; 26 | import org.interledger.codecs.oer.ilqp.QuoteByDestinationAmountResponseOerCodec; 27 | import org.interledger.codecs.oer.ilqp.QuoteBySourceAmountRequestOerCodec; 28 | import org.interledger.codecs.oer.ilqp.QuoteBySourceAmountResponseOerCodec; 29 | import org.interledger.codecs.oer.ilqp.QuoteLiquidityRequestOerCodec; 30 | import org.interledger.codecs.oer.ilqp.QuoteLiquidityResponseOerCodec; 31 | import org.interledger.codecs.oer.ipr.InterledgerPaymentRequestOerCodec; 32 | import org.interledger.codecs.packettypes.InterledgerPacketType; 33 | import org.interledger.codecs.psk.PskMessageBinaryCodec; 34 | import org.interledger.ilp.InterledgerPayment; 35 | import org.interledger.ilqp.QuoteByDestinationAmountRequest; 36 | import org.interledger.ilqp.QuoteByDestinationAmountResponse; 37 | import org.interledger.ilqp.QuoteBySourceAmountRequest; 38 | import org.interledger.ilqp.QuoteBySourceAmountResponse; 39 | import org.interledger.ilqp.QuoteLiquidityRequest; 40 | import org.interledger.ilqp.QuoteLiquidityResponse; 41 | import org.interledger.ipr.InterledgerPaymentRequest; 42 | import org.interledger.psk.PskMessage; 43 | 44 | 45 | public class CodecContextFactoryDpc { 46 | public CodecContextFactoryDpc() { 47 | } 48 | 49 | public static CodecContext interledger() { 50 | return (new CodecContext()).register(OerUint8Codec.OerUint8.class, new OerUint8Codec()).register(OerUint32Codec.OerUint32.class, new OerUint32Codec()).register(OerUint64Codec.OerUint64.class, new OerUint64Codec()).register(OerUint256Codec.OerUint256.class, new OerUint256Codec()).register(OerLengthPrefixCodec.OerLengthPrefix.class, new OerLengthPrefixCodec()).register(OerIA5StringCodec.OerIA5String.class, new OerIA5StringCodec()).register(OerOctetStringCodec.OerOctetString.class, new OerOctetStringCodec()).register(OerGeneralizedTimeCodec.OerGeneralizedTime.class, new OerGeneralizedTimeCodec()).register(InterledgerAddress.class, new InterledgerAddressOerCodec()).register(InterledgerPacketType.class, new InterledgerPacketTypeOerCodec()).register(InterledgerPayment.class, new InterledgerPaymentOerCodec()).register(InterledgerPaymentRequest.class, new InterledgerPaymentRequestOerCodec()).register(Condition.class, new ConditionOerCodec()).register(QuoteByDestinationAmountRequest.class, new QuoteByDestinationAmountRequestOerCodec()).register(QuoteByDestinationAmountResponse.class, new QuoteByDestinationAmountResponseOerCodec()).register(QuoteBySourceAmountRequest.class, new QuoteBySourceAmountRequestOerCodec()).register(QuoteBySourceAmountResponse.class, new QuoteBySourceAmountResponseOerCodec()).register(QuoteLiquidityRequest.class, new QuoteLiquidityRequestOerCodec()).register(QuoteLiquidityResponse.class, new QuoteLiquidityResponseOerCodec()).register(PskMessage.class, new PskMessageBinaryCodec()).register(InterledgerPaymentDpc.class, new InterledgerPaymentOerCodecDpc()); 51 | } 52 | 53 | public static CodecContext interledgerJson() { 54 | throw new RuntimeException("Not yet implemented!"); 55 | } 56 | 57 | public static CodecContext interledgerProtobuf() { 58 | throw new RuntimeException("Not yet implemented!"); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/component/InterledgerPaymentCodecDpc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.component; 9 | 10 | 11 | import org.interledger.codecs.InterledgerPacketCodec; 12 | import org.interledger.codecs.packettypes.InterledgerPacketType; 13 | import org.interledger.codecs.packettypes.PaymentPacketType; 14 | 15 | public interface InterledgerPaymentCodecDpc extends InterledgerPacketCodec { 16 | InterledgerPacketType TYPE = new PaymentPacketType(); 17 | 18 | default InterledgerPacketType getTypeId() { 19 | return TYPE; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/component/InterledgerPaymentDpc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.component; 9 | 10 | import org.interledger.InterledgerAddress; 11 | import org.interledger.InterledgerPacket; 12 | 13 | import java.util.Arrays; 14 | import java.util.Objects; 15 | 16 | public interface InterledgerPaymentDpc extends InterledgerPacket { 17 | static InterledgerPaymentDpc.Builder builder() { 18 | return new InterledgerPaymentDpc.Builder(); 19 | } 20 | 21 | InterledgerAddress getDestinationAccount(); 22 | 23 | String getDestinationAmount(); 24 | 25 | byte[] getData(); 26 | 27 | public static class Builder { 28 | private InterledgerAddress destinationAccount; 29 | private String destinationAmount; 30 | private byte[] data; 31 | 32 | public Builder() { 33 | } 34 | 35 | public InterledgerPaymentDpc.Builder destinationAccount(InterledgerAddress destinationAccount) { 36 | this.destinationAccount = (InterledgerAddress)Objects.requireNonNull(destinationAccount); 37 | return this; 38 | } 39 | 40 | public InterledgerPaymentDpc.Builder destinationAmount(String destinationAmount) { 41 | this.destinationAmount = (String)Objects.requireNonNull(destinationAmount); 42 | return this; 43 | } 44 | 45 | public InterledgerPaymentDpc.Builder data(byte[] data) { 46 | this.data = (byte[])Objects.requireNonNull(data); 47 | return this; 48 | } 49 | 50 | public InterledgerPaymentDpc build() { 51 | return new InterledgerPaymentDpc.Builder.Impl(this); 52 | } 53 | 54 | private static final class Impl implements InterledgerPaymentDpc { 55 | private final InterledgerAddress destinationAccount; 56 | private final String destinationAmount; 57 | private final byte[] data; 58 | 59 | private Impl(InterledgerPaymentDpc.Builder builder) { 60 | Objects.requireNonNull(builder); 61 | this.destinationAccount = (InterledgerAddress)Objects.requireNonNull(builder.destinationAccount, "destinationAccount must not be null!"); 62 | this.destinationAmount = (String)Objects.requireNonNull(builder.destinationAmount, "destinationAmount must not be null!"); 63 | this.data = (byte[])Objects.requireNonNull(builder.data, "data must not be null!"); 64 | } 65 | 66 | public InterledgerAddress getDestinationAccount() { 67 | return this.destinationAccount; 68 | } 69 | 70 | public String getDestinationAmount() { 71 | return this.destinationAmount; 72 | } 73 | 74 | public byte[] getData() { 75 | return Arrays.copyOf(this.data, this.data.length); 76 | } 77 | 78 | public boolean equals(Object obj) { 79 | if (this == obj) { 80 | return true; 81 | } else if (obj != null && this.getClass() == obj.getClass()) { 82 | InterledgerPaymentDpc.Builder.Impl impl = (InterledgerPaymentDpc.Builder.Impl)obj; 83 | return this.destinationAccount.equals(impl.destinationAccount) && this.destinationAmount.equals(impl.destinationAmount) && Arrays.equals(this.data, impl.data); 84 | } else { 85 | return false; 86 | } 87 | } 88 | 89 | public int hashCode() { 90 | int result = this.destinationAccount.hashCode(); 91 | result = 31 * result + this.destinationAmount.hashCode(); 92 | result = 31 * result + Arrays.hashCode(this.data); 93 | return result; 94 | } 95 | 96 | public String toString() { 97 | return "InterledgerPayment.Impl{destinationAccount=" + this.destinationAccount + ", destinationAmount=" + this.destinationAmount + ", data=" + Arrays.toString(this.data) + '}'; 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/component/InterledgerPaymentOerCodecDpc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.component; 9 | 10 | import org.interledger.InterledgerAddress; 11 | import org.interledger.codecs.CodecContext; 12 | import org.interledger.codecs.oer.OerIA5StringCodec; 13 | import org.interledger.codecs.oer.OerOctetStringCodec; 14 | import org.interledger.codecs.packettypes.InterledgerPacketType; 15 | 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | import java.io.OutputStream; 19 | import java.util.Objects; 20 | 21 | 22 | public class InterledgerPaymentOerCodecDpc implements InterledgerPaymentCodecDpc { 23 | public InterledgerPaymentOerCodecDpc() { 24 | } 25 | 26 | public InterledgerPaymentDpc read(CodecContext context, InputStream inputStream) throws IOException { 27 | Objects.requireNonNull(context); 28 | Objects.requireNonNull(inputStream); 29 | String destinationAmount = context.read(OerIA5StringCodec.OerIA5String.class, inputStream).getValue(); 30 | InterledgerAddress destinationAccount = context.read(InterledgerAddress.class, inputStream); 31 | byte[] data = context.read(OerOctetStringCodec.OerOctetString.class, inputStream).getValue(); 32 | return InterledgerPaymentDpc.builder().destinationAmount(destinationAmount).destinationAccount(destinationAccount).data(data).build(); 33 | } 34 | 35 | public void write(CodecContext context, InterledgerPaymentDpc instance, OutputStream outputStream) throws IOException { 36 | Objects.requireNonNull(context); 37 | Objects.requireNonNull(instance); 38 | Objects.requireNonNull(outputStream); 39 | context.write(InterledgerPacketType.class, this.getTypeId(), outputStream); 40 | context.write(OerIA5StringCodec.OerIA5String.class, new OerIA5StringCodec.OerIA5String(instance.getDestinationAmount()), outputStream); 41 | context.write(InterledgerAddress.class, instance.getDestinationAccount(), outputStream); 42 | context.write(OerOctetStringCodec.OerOctetString.class, new OerOctetStringCodec.OerOctetString(instance.getData()), outputStream); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/config/MockSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.config; 9 | 10 | import org.springframework.boot.context.properties.ConfigurationProperties; 11 | 12 | @ConfigurationProperties("mock-settings") 13 | public class MockSettings { 14 | 15 | private boolean startChannelConsumers; 16 | private boolean startMojaloopConsumers; 17 | private boolean startFspConsumers; 18 | 19 | public boolean isStartChannelConsumers() { 20 | return startChannelConsumers; 21 | } 22 | 23 | public void setStartChannelConsumers(boolean startChannelConsumers) { 24 | this.startChannelConsumers = startChannelConsumers; 25 | } 26 | 27 | public boolean isStartMojaloopConsumers() { 28 | return startMojaloopConsumers; 29 | } 30 | 31 | public void setStartMojaloopConsumers(boolean startMojaloopConsumers) { 32 | this.startMojaloopConsumers = startMojaloopConsumers; 33 | } 34 | 35 | public boolean isStartFspConsumers() { 36 | return startFspConsumers; 37 | } 38 | 39 | public void setStartFspConsumers(boolean startFspConsumers) { 40 | this.startFspConsumers = startFspConsumers; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/constant/ExchangeHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.constant; 9 | 10 | public enum ExchangeHeader { 11 | 12 | TRANSACTION_ID("Transaction-Id"), // String 13 | 14 | CURRENT_FSP_ID("Current-Fsp-Id"), // FspId 15 | CURRENT_ROLE("Current-Role"), // TransactionRole 16 | CALLER_FSP("Caller-Fsp-Id"), // FspId - switch caller FSPIOP-Source 17 | 18 | PAYER_FSP_ID("Payer-FSP-Id"), // FspId 19 | PAYEE_FSP_ID("Payee-FSP-Id"), // FspId 20 | 21 | PARTIES_ROLE("Parties-Role"), // TransactionRole 22 | QUOTES_ROLE("Quotes-Role"), // TransactionRole 23 | TRANSFER_ROLE("Transfer-Role"), // TransactionRole 24 | 25 | PARTIES_INFO("Parties-Info"), // PartyIdInfo 26 | NOTIFY("Notify"), // NotifyBuilder 27 | ; 28 | 29 | private String key; 30 | 31 | private ExchangeHeader(String key) { 32 | this.key = key; 33 | } 34 | 35 | public String getKey() { 36 | return key; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/ErrorSwitchResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | 11 | import org.openmf.psp.dto.ErrorInformation; 12 | 13 | public class ErrorSwitchResponseDTO { 14 | 15 | private ErrorInformation errorInformation; 16 | 17 | public ErrorInformation getErrorInformation() { 18 | return errorInformation; 19 | } 20 | 21 | public void setErrorInformation(ErrorInformation errorInformation) { 22 | this.errorInformation = errorInformation; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "ErrorSwitchResponseDTO{" + 28 | "errorInformation:" + errorInformation + 29 | '}'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/ParticipantSwitchRequestDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | public class ParticipantSwitchRequestDTO { 11 | 12 | private String fspId; 13 | private String currency; 14 | 15 | public String getFspId() { 16 | return fspId; 17 | } 18 | 19 | public void setFspId(String fspId) { 20 | this.fspId = fspId; 21 | } 22 | 23 | public String getCurrency() { 24 | return currency; 25 | } 26 | 27 | public void setCurrency(String currency) { 28 | this.currency = currency; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/ParticipantSwitchResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | public class ParticipantSwitchResponseDTO { 11 | 12 | private String fspId; 13 | 14 | public String getFspId() { 15 | return fspId; 16 | } 17 | 18 | public void setFspId(String fspId) { 19 | this.fspId = fspId; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/PartySwitchResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | import org.openmf.psp.dto.Party; 11 | 12 | public class PartySwitchResponseDTO { 13 | 14 | private Party party; 15 | 16 | PartySwitchResponseDTO() { 17 | } 18 | 19 | public PartySwitchResponseDTO(Party party) { 20 | this.party = party; 21 | } 22 | 23 | public Party getParty() { 24 | return party; 25 | } 26 | 27 | public void setParty(Party party) { 28 | this.party = party; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/QuoteSwitchResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | import java.beans.Transient; 11 | import java.time.LocalDateTime; 12 | import java.util.List; 13 | 14 | import org.openmf.psp.dto.Extension; 15 | import org.openmf.psp.dto.GeoCode; 16 | import org.openmf.psp.dto.MoneyData; 17 | import org.openmf.psp.util.ContextUtil; 18 | 19 | public class QuoteSwitchResponseDTO { 20 | 21 | private MoneyData transferAmount; // mandatory 22 | private MoneyData payeeReceiveAmount; 23 | private MoneyData payeeFspFee; 24 | private MoneyData payeeFspCommission; 25 | private String expiration; // mandatory 26 | private GeoCode geoCode; 27 | private String ilpPacket; // mandatory 28 | private String condition; // mandatory 29 | private List extensionList; 30 | 31 | QuoteSwitchResponseDTO() { 32 | } 33 | 34 | public QuoteSwitchResponseDTO(MoneyData transferAmount, MoneyData payeeReceiveAmount, MoneyData payeeFspFee, MoneyData payeeFspCommission, 35 | LocalDateTime expiration, GeoCode geoCode, String ilpPacket, String condition, List extensionList) { 36 | this.transferAmount = transferAmount; 37 | this.payeeReceiveAmount = payeeReceiveAmount; 38 | this.payeeFspFee = payeeFspFee; 39 | this.payeeFspCommission = payeeFspCommission; 40 | this.expiration = ContextUtil.formatDate(expiration); 41 | this.geoCode = geoCode; 42 | this.ilpPacket = ilpPacket; 43 | this.condition = condition; 44 | this.extensionList = extensionList; 45 | } 46 | 47 | public QuoteSwitchResponseDTO(MoneyData transferAmount, LocalDateTime expiration, String ilpPacket, String condition) { 48 | this(transferAmount, null, null, null, expiration, null, ilpPacket, condition, null); 49 | } 50 | 51 | public MoneyData getTransferAmount() { 52 | return transferAmount; 53 | } 54 | 55 | public void setTransferAmount(MoneyData transferAmount) { 56 | this.transferAmount = transferAmount; 57 | } 58 | 59 | public MoneyData getPayeeReceiveAmount() { 60 | return payeeReceiveAmount; 61 | } 62 | 63 | public void setPayeeReceiveAmount(MoneyData payeeReceiveAmount) { 64 | this.payeeReceiveAmount = payeeReceiveAmount; 65 | } 66 | 67 | public MoneyData getPayeeFspFee() { 68 | return payeeFspFee; 69 | } 70 | 71 | public void setPayeeFspFee(MoneyData payeeFspFee) { 72 | this.payeeFspFee = payeeFspFee; 73 | } 74 | 75 | public MoneyData getPayeeFspCommission() { 76 | return payeeFspCommission; 77 | } 78 | 79 | public void setPayeeFspCommission(MoneyData payeeFspCommission) { 80 | this.payeeFspCommission = payeeFspCommission; 81 | } 82 | 83 | public String getExpiration() { 84 | return expiration; 85 | } 86 | 87 | public void setExpiration(String expiration) { 88 | this.expiration = expiration; 89 | } 90 | 91 | @Transient 92 | public LocalDateTime getExpirationDate() { 93 | return ContextUtil.parseDate(expiration); 94 | } 95 | 96 | public void setExpiration(LocalDateTime expiration) { 97 | this.expiration = ContextUtil.formatDate(expiration); 98 | } 99 | 100 | public GeoCode getGeoCode() { 101 | return geoCode; 102 | } 103 | 104 | public void setGeoCode(GeoCode geoCode) { 105 | this.geoCode = geoCode; 106 | } 107 | 108 | public String getIlpPacket() { 109 | return ilpPacket; 110 | } 111 | 112 | public void setIlpPacket(String ilpPacket) { 113 | this.ilpPacket = ilpPacket; 114 | } 115 | 116 | public String getCondition() { 117 | return condition; 118 | } 119 | 120 | public void setCondition(String condition) { 121 | this.condition = condition; 122 | } 123 | 124 | public List getExtensionList() { 125 | return extensionList; 126 | } 127 | 128 | public void setExtensionList(List extensionList) { 129 | this.extensionList = extensionList; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/TransactionRequestSwitchRequestDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 11 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 12 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; 13 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; 14 | 15 | import java.time.LocalDateTime; 16 | import java.util.List; 17 | 18 | import org.openmf.psp.dto.Extension; 19 | import org.openmf.psp.dto.GeoCode; 20 | import org.openmf.psp.dto.MoneyData; 21 | import org.openmf.psp.dto.Party; 22 | import org.openmf.psp.dto.PartyIdInfo; 23 | import org.openmf.psp.dto.TransactionType; 24 | import org.openmf.psp.type.AuthenticationType; 25 | 26 | /** 27 | * { 28 | * accountId: "" 29 | * } 30 | */ 31 | public class TransactionRequestSwitchRequestDTO { 32 | 33 | private String transactionRequestId; // mandatory 34 | private Party payee; // mandatory 35 | private PartyIdInfo payer; // mandatory 36 | private MoneyData amount; // mandatory 37 | private TransactionType transactionType; // mandatory 38 | private String note; 39 | private GeoCode geoCode; 40 | private AuthenticationType authenticationType; 41 | @JsonSerialize(using = LocalDateTimeSerializer.class) 42 | @JsonDeserialize(using = LocalDateTimeDeserializer.class) 43 | private LocalDateTime expiration; 44 | private List extensionList; 45 | 46 | 47 | public String getTransactionRequestId() { 48 | return transactionRequestId; 49 | } 50 | 51 | public void setTransactionRequestId(String transactionRequestId) { 52 | this.transactionRequestId = transactionRequestId; 53 | } 54 | 55 | public Party getPayee() { 56 | return payee; 57 | } 58 | 59 | public void setPayee(Party payee) { 60 | this.payee = payee; 61 | } 62 | 63 | public PartyIdInfo getPayer() { 64 | return payer; 65 | } 66 | 67 | public void setPayer(PartyIdInfo payer) { 68 | this.payer = payer; 69 | } 70 | 71 | public MoneyData getAmount() { 72 | return amount; 73 | } 74 | 75 | public void setAmount(MoneyData amount) { 76 | this.amount = amount; 77 | } 78 | 79 | public TransactionType getTransactionType() { 80 | return transactionType; 81 | } 82 | 83 | public void setTransactionType(TransactionType transactionType) { 84 | this.transactionType = transactionType; 85 | } 86 | 87 | public String getNote() { 88 | return note; 89 | } 90 | 91 | public void setNote(String note) { 92 | this.note = note; 93 | } 94 | 95 | public GeoCode getGeoCode() { 96 | return geoCode; 97 | } 98 | 99 | public void setGeoCode(GeoCode geoCode) { 100 | this.geoCode = geoCode; 101 | } 102 | 103 | public AuthenticationType getAuthenticationType() { 104 | return authenticationType; 105 | } 106 | 107 | public void setAuthenticationType(AuthenticationType authenticationType) { 108 | this.authenticationType = authenticationType; 109 | } 110 | 111 | public LocalDateTime getExpiration() { 112 | return expiration; 113 | } 114 | 115 | public void setExpiration(LocalDateTime expiration) { 116 | this.expiration = expiration; 117 | } 118 | 119 | public List getExtensionList() { 120 | return extensionList; 121 | } 122 | 123 | public Extension getExtension(String key) { 124 | if (extensionList == null) 125 | return null; 126 | for (Extension extension : extensionList) { 127 | if (extension.getKey().equals(key)) 128 | return extension; 129 | } 130 | return null; 131 | } 132 | 133 | public String getExtensionValue(String key) { 134 | Extension extension = getExtension(key); 135 | return extension == null ? null : extension.getValue(); 136 | } 137 | 138 | public void setExtensionList(List extensionList) { 139 | this.extensionList = extensionList; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/TransactionRequestSwitchResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | import java.util.List; 11 | 12 | import org.openmf.psp.dto.Extension; 13 | import org.openmf.psp.type.TransactionRequestState; 14 | 15 | /** 16 | * { 17 | * accountId: "" 18 | * } 19 | */ 20 | public class TransactionRequestSwitchResponseDTO { 21 | 22 | private String transactionId; 23 | private TransactionRequestState transactionRequestState; 24 | private List extensionList; 25 | 26 | public String getTransactionId() { 27 | return transactionId; 28 | } 29 | 30 | public void setTransactionId(String transactionId) { 31 | this.transactionId = transactionId; 32 | } 33 | 34 | public TransactionRequestState getTransactionRequestState() { 35 | return transactionRequestState; 36 | } 37 | 38 | public void setTransactionRequestState(TransactionRequestState transactionRequestState) { 39 | this.transactionRequestState = transactionRequestState; 40 | } 41 | 42 | public List getExtensionList() { 43 | return extensionList; 44 | } 45 | 46 | public void setExtensionList(List extensionList) { 47 | this.extensionList = extensionList; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/dto/mojaloop/TransferSwitchResponseDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.dto.mojaloop; 9 | 10 | 11 | import java.beans.Transient; 12 | import java.time.LocalDateTime; 13 | import java.util.List; 14 | 15 | import org.openmf.psp.dto.Extension; 16 | import org.openmf.psp.mojaloop.type.TransferState; 17 | import org.openmf.psp.util.ContextUtil; 18 | 19 | 20 | public class TransferSwitchResponseDTO { 21 | 22 | private String fulfilment; 23 | private String completedTimestamp; 24 | private TransferState transferState; // mandatory 25 | private List extensionList; 26 | 27 | TransferSwitchResponseDTO() { 28 | } 29 | 30 | public TransferSwitchResponseDTO(String fulfilment, LocalDateTime completedTimestamp, TransferState transferState, List extensionList) { 31 | this.fulfilment = fulfilment; 32 | this.completedTimestamp = ContextUtil.formatDate(completedTimestamp); 33 | this.transferState = transferState; 34 | this.extensionList = extensionList; 35 | } 36 | 37 | public TransferSwitchResponseDTO(TransferState transferState) { 38 | this(null, null, transferState, null); 39 | } 40 | 41 | public String getFulfilment() { 42 | return fulfilment; 43 | } 44 | 45 | public void setFulfilment(String fulfilment) { 46 | this.fulfilment = fulfilment; 47 | } 48 | 49 | public String getCompletedTimestamp() { 50 | return completedTimestamp; 51 | } 52 | 53 | public void setCompletedTimestamp(String completedTimestamp) { 54 | this.completedTimestamp = completedTimestamp; 55 | } 56 | 57 | @Transient 58 | public LocalDateTime getCompletedTimestampDate() { 59 | return ContextUtil.parseDate(completedTimestamp); 60 | } 61 | 62 | public void setCompletedTimestamp(LocalDateTime completedTimestamp) { 63 | this.completedTimestamp = ContextUtil.formatDate(completedTimestamp); 64 | } 65 | 66 | public TransferState getTransferState() { 67 | return transferState; 68 | } 69 | 70 | public void setTransferState(TransferState transferState) { 71 | this.transferState = transferState; 72 | } 73 | 74 | public List getExtensionList() { 75 | return extensionList; 76 | } 77 | 78 | public void setExtensionList(List extensionList) { 79 | this.extensionList = extensionList; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/internal/Ilp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.internal; 9 | 10 | import com.ilp.conditions.models.pdp.Transaction; 11 | 12 | public class Ilp { 13 | 14 | private final String packet; // mandatory 15 | private final String condition; // mandatory 16 | private final String fulfilment; // optional 17 | private final Transaction transaction; // mandatory 18 | 19 | public Ilp(String packet, String condition, String fulfilment, Transaction transaction) { 20 | this.packet = packet; 21 | this.condition = condition; 22 | this.fulfilment = fulfilment; 23 | this.transaction = transaction; 24 | } 25 | 26 | public Ilp(String packet, String condition, Transaction transaction) { 27 | this(packet, condition, null, transaction); 28 | } 29 | 30 | public String getPacket() { 31 | return packet; 32 | } 33 | 34 | public String getCondition() { 35 | return condition; 36 | } 37 | 38 | public String getFulfilment() { 39 | return fulfilment; 40 | } 41 | 42 | public Transaction getTransaction() { 43 | return transaction; 44 | } 45 | 46 | void update(Ilp oIlp) { 47 | if (oIlp == null) 48 | return; 49 | if (!packet.equals(oIlp.getPacket())) 50 | throw new RuntimeException("Ilp packet is not valid " + packet + " vs." + oIlp.getPacket()); 51 | if (!condition.equals(oIlp.getCondition())) 52 | throw new RuntimeException("Ilp condition is not valid " + packet + " vs." + oIlp.getPacket()); 53 | if (fulfilment != null && oIlp.getFulfilment() != null && !fulfilment.equals(oIlp.getFulfilment())) 54 | throw new RuntimeException("Ilp fulfilment is not valid " + fulfilment + " vs." + oIlp.getFulfilment()); 55 | 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "Ilp{" + 61 | "packet:'" + packet + '\'' + 62 | ", condition:'" + condition + '\'' + 63 | ", fulfilment:'" + fulfilment + '\'' + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/internal/PartyContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.internal; 9 | 10 | import org.openmf.psp.dto.Party; 11 | import org.openmf.psp.dto.PartyIdInfo; 12 | import org.openmf.psp.dto.fsp.PartyFspResponseDTO; 13 | import org.openmf.psp.internal.FspId; 14 | import org.openmf.psp.mojaloop.dto.mojaloop.PartySwitchResponseDTO; 15 | import org.openmf.psp.util.ContextUtil; 16 | 17 | public class PartyContext { 18 | 19 | private Party party; // optional, but this or fspId must be set 20 | private FspId fspId; // optional, but party or this must be set 21 | private String accountId; // optional 22 | 23 | PartyContext() { 24 | } 25 | 26 | public PartyContext(Party party, String accountId) { 27 | this.party = party; 28 | this.accountId = accountId; 29 | } 30 | 31 | public PartyContext(FspId fspId) { 32 | this.fspId = fspId; 33 | } 34 | 35 | public Party getParty() { 36 | return party; 37 | } 38 | 39 | public void setParty(Party party) { 40 | this.party = party; 41 | } 42 | 43 | public FspId getFspId() { 44 | return fspId; 45 | } 46 | 47 | public void setFspId(FspId fspId) { 48 | if (fspId == null) 49 | return; 50 | if (this.fspId != null && !this.fspId.getId().equals(fspId.getId())) 51 | throw new RuntimeException("Technical error: try to change fspId from " + this.fspId + " to " + fspId); 52 | this.fspId = fspId; 53 | if (party != null) { 54 | party.getPartyIdInfo().setFspId(fspId.getId()); 55 | } 56 | } 57 | 58 | public String getAccountId() { 59 | return accountId; 60 | } 61 | 62 | public void setAccountId(String accountId) { 63 | this.accountId = accountId; 64 | } 65 | 66 | public void update(PartyContext oContext) { 67 | if (oContext == null) 68 | return; 69 | 70 | update(oContext.getParty()); 71 | 72 | String oAccount = oContext.accountId; 73 | if (oAccount != null) 74 | accountId = oAccount; 75 | } 76 | 77 | public void update(PartyFspResponseDTO partiesDTO) { 78 | if (partiesDTO == null) 79 | return; 80 | 81 | String oAccount = partiesDTO.getAccountId(); 82 | if (oAccount != null) 83 | accountId = oAccount; 84 | } 85 | 86 | void update(PartySwitchResponseDTO partiesDTO) { 87 | if (partiesDTO == null) 88 | return; 89 | 90 | update(partiesDTO.getParty()); 91 | } 92 | 93 | void update(Party oParty) { 94 | if (party == null) 95 | party = oParty; 96 | else 97 | party.update(oParty); 98 | 99 | updateFspId(oParty); 100 | } 101 | 102 | void update(PartyIdInfo oPartyIdInfo) { 103 | if (party == null) 104 | party = new Party(oPartyIdInfo); 105 | else 106 | party.update(oPartyIdInfo); 107 | 108 | updateFspId(oPartyIdInfo); 109 | } 110 | 111 | private void updateFspId(Party oParty) { 112 | if (oParty != null) { 113 | updateFspId(oParty.getPartyIdInfo()); 114 | } 115 | } 116 | 117 | private void updateFspId(PartyIdInfo oPartyIdInfo) { 118 | if (oPartyIdInfo == null) 119 | return; 120 | 121 | String oFspId = oPartyIdInfo.getFspId(); 122 | if (oFspId != null) 123 | setFspId(ContextUtil.parseFspId(oFspId)); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/ChannelTransactionsResponseProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.component.ChannelRestClient; 13 | import org.openmf.psp.dto.channel.TransactionChannelAsyncResponseDTO; 14 | import org.openmf.psp.internal.FspId; 15 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 16 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 17 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.stereotype.Component; 20 | 21 | /** 22 | * Processor to send async PUT response to channel, when the payment transaction was successfully finished. 23 | */ 24 | @Component("channelTransactionsResponseProcessor") 25 | public class ChannelTransactionsResponseProcessor implements Processor { 26 | 27 | private ChannelRestClient channelRestClient; 28 | 29 | private TransactionContextHolder transactionContextHolder; 30 | 31 | @Autowired 32 | public ChannelTransactionsResponseProcessor(ChannelRestClient channelRestClient, TransactionContextHolder transactionContextHolder) { 33 | this.channelRestClient = channelRestClient; 34 | this.transactionContextHolder = transactionContextHolder; 35 | } 36 | 37 | @Override 38 | public void process(Exchange exchange) throws Exception { 39 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 40 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 41 | 42 | TransactionChannelAsyncResponseDTO paymentAsyncResponseDTO = new TransactionChannelAsyncResponseDTO(transactionContext.getChannelClientRef(), transactionId, 43 | transactionContext.getCompletedStamp(), transactionContext.getTransferId(), transactionContext.getTransferState(), transactionContext.getPaymentRequestDTO()); 44 | 45 | channelRestClient.callPaymentAsyncResponse(paymentAsyncResponseDTO, exchange.getProperty(ExchangeHeader.CURRENT_FSP_ID.getKey(), FspId.class)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/CommitTransferFspProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.component.FspRestClient; 13 | import org.openmf.psp.dto.FspMoneyData; 14 | import org.openmf.psp.dto.MoneyData; 15 | import org.openmf.psp.dto.fsp.TransferFspRequestDTO; 16 | import org.openmf.psp.dto.fsp.TransferFspResponseDTO; 17 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 18 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 19 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 20 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 21 | import org.openmf.psp.type.TransactionRole; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.stereotype.Component; 24 | 25 | /** 26 | * Processor to send POST /transfers COMMIT request to FSP. 27 | */ 28 | @Component("commitTransferFspProcessor") 29 | public class CommitTransferFspProcessor implements Processor { 30 | 31 | private FspRestClient fspRestClient; 32 | 33 | private TransactionContextHolder transactionContextHolder; 34 | 35 | @Autowired 36 | public CommitTransferFspProcessor(FspRestClient fspRestClient, TransactionContextHolder transactionContextHolder) { 37 | this.fspRestClient = fspRestClient; 38 | this.transactionContextHolder = transactionContextHolder; 39 | } 40 | 41 | @Override 42 | public void process(Exchange exchange) throws Exception { 43 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 44 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 45 | 46 | TransactionRole transferRole = exchange.getProperty(ExchangeHeader.TRANSFER_ROLE.getKey(), TransactionRole.class); 47 | if (transferRole == null) 48 | transferRole = exchange.getProperty(ExchangeHeader.CURRENT_ROLE.getKey(), TransactionRole.class); 49 | 50 | TransactionRoleContext roleContext = transactionContext.getRoleContext(transferRole); 51 | String accountId = roleContext.getPartyContext().getAccountId(); 52 | 53 | String transferId = transactionContext.getOrCreateTransferId(); 54 | 55 | FspMoneyData amount = new FspMoneyData(transactionContext.getTransferAmount(), transactionContext.getCurrency()); 56 | TransferFspRequestDTO transferRequestDTO = new TransferFspRequestDTO(transactionId, transferId, accountId, amount, 57 | MoneyData.toFspMoneyData(roleContext.getFee()), MoneyData.toFspMoneyData(roleContext.getCommission()), 58 | transferRole, transactionContext.getTransactionType(), transactionContext.getNote()); 59 | 60 | TransferFspResponseDTO transferResponseDTO = fspRestClient.callTransferCommit(transferRequestDTO, roleContext.getFspId()); 61 | 62 | transactionContextHolder.updateFspCommitTransfer(transactionId, transferRole, transferResponseDTO); 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/PartiesFspProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.component.FspRestClient; 13 | import org.openmf.psp.dto.PartyIdInfo; 14 | import org.openmf.psp.dto.fsp.PartyFspResponseDTO; 15 | import org.openmf.psp.internal.FspId; 16 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 17 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 18 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 19 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 20 | import org.openmf.psp.type.IdentifierType; 21 | import org.openmf.psp.type.TransactionRole; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.stereotype.Component; 24 | 25 | /** 26 | * Processor to send GET /parties request to FSP. 27 | */ 28 | @Component("partiesFspProcessor") 29 | public class PartiesFspProcessor implements Processor { 30 | 31 | private TransactionContextHolder transactionContextHolder; 32 | 33 | private FspRestClient fspRestClient; 34 | 35 | @Autowired 36 | public PartiesFspProcessor(TransactionContextHolder transactionContextHolder, FspRestClient fspRestClient) { 37 | this.transactionContextHolder = transactionContextHolder; 38 | this.fspRestClient = fspRestClient; 39 | } 40 | 41 | @Override 42 | public void process(Exchange exchange) throws Exception { 43 | String transactionId = null; 44 | TransactionRole partiesRole = null; 45 | PartyIdInfo partyIdInfo = null; 46 | 47 | if (exchange.getProperty(ExchangeHeader.CALLER_FSP.getKey()) != null) { 48 | partyIdInfo = exchange.getProperty(ExchangeHeader.PARTIES_INFO.getKey(), PartyIdInfo.class); 49 | } 50 | else { 51 | transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 52 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 53 | 54 | partiesRole = exchange.getProperty(ExchangeHeader.PARTIES_ROLE.getKey(), TransactionRole.class); 55 | TransactionRoleContext roleContext = transactionContext.getRoleContext(partiesRole); 56 | 57 | partyIdInfo = roleContext.getPartyContext().getParty().getPartyIdInfo(); 58 | } 59 | 60 | IdentifierType idType = partyIdInfo.getPartyIdType(); 61 | String idValue = partyIdInfo.getPartyIdentifier(); 62 | String subIdOrType = partyIdInfo.getPartySubIdOrType(); 63 | 64 | FspId currentFsp = exchange.getProperty(ExchangeHeader.CURRENT_FSP_ID.getKey(), FspId.class); 65 | 66 | PartyFspResponseDTO partiesResponseDTO = fspRestClient.callParties(idType, idValue, subIdOrType, currentFsp); 67 | 68 | if (transactionId != null) 69 | transactionContextHolder.updateFspParty(transactionId, partiesRole, partiesResponseDTO); 70 | else 71 | transactionContextHolder.updateFspParty(partyIdInfo, partiesResponseDTO); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/PartiesSwitchResponseProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.dto.PartyIdInfo; 13 | import org.openmf.psp.internal.FspId; 14 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 15 | import org.openmf.psp.mojaloop.component.SwitchRestClient; 16 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 17 | import org.openmf.psp.mojaloop.dto.mojaloop.PartySwitchResponseDTO; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.stereotype.Component; 20 | 21 | /** 22 | * Processor to send PUT /parties response through the switch. 23 | */ 24 | @Component("partiesSwitchResponseProcessor") 25 | public class PartiesSwitchResponseProcessor implements Processor { 26 | 27 | private TransactionContextHolder transactionContextHolder; 28 | 29 | private SwitchRestClient switchRestClient; 30 | 31 | @Autowired 32 | public PartiesSwitchResponseProcessor(TransactionContextHolder transactionContextHolder, SwitchRestClient switchRestClient) { 33 | this.transactionContextHolder = transactionContextHolder; 34 | this.switchRestClient = switchRestClient; 35 | } 36 | 37 | @Override 38 | public void process(Exchange exchange) throws Exception { 39 | FspId sourceFspId = exchange.getProperty(ExchangeHeader.CURRENT_FSP_ID.getKey(), FspId.class); 40 | FspId destFspId = exchange.getProperty(ExchangeHeader.CALLER_FSP.getKey(), FspId.class); 41 | 42 | PartyIdInfo partyIdInfo = exchange.getProperty(ExchangeHeader.PARTIES_INFO.getKey(), PartyIdInfo.class); 43 | PartySwitchResponseDTO response = new PartySwitchResponseDTO(transactionContextHolder.getPartyContext(partyIdInfo).getParty()); 44 | switchRestClient.callPutParties(response, sourceFspId, destFspId); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/PrepareTransferFspProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.component.FspRestClient; 13 | import org.openmf.psp.dto.FspMoneyData; 14 | import org.openmf.psp.dto.fsp.TransferFspRequestDTO; 15 | import org.openmf.psp.dto.fsp.TransferFspResponseDTO; 16 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 17 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 18 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 19 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 20 | import org.openmf.psp.type.TransactionRole; 21 | import org.openmf.psp.util.IbanUtil; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.stereotype.Component; 24 | 25 | /** 26 | * Processor to send POST /transfers PREPARE request to FSP. 27 | */ 28 | @Component("prepareTransferFspProcessor") 29 | public class PrepareTransferFspProcessor implements Processor { 30 | 31 | private FspRestClient fspRestClient; 32 | 33 | private TransactionContextHolder transactionContextHolder; 34 | 35 | private IbanUtil ibanUtil; 36 | 37 | PrepareTransferFspProcessor() { 38 | } 39 | 40 | @Autowired 41 | public PrepareTransferFspProcessor(FspRestClient fspRestClient, TransactionContextHolder transactionContextHolder, 42 | IbanUtil ibanUtil) { 43 | this.fspRestClient = fspRestClient; 44 | this.transactionContextHolder = transactionContextHolder; 45 | this.ibanUtil = ibanUtil; 46 | } 47 | 48 | @Override 49 | public void process(Exchange exchange) throws Exception { 50 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 51 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 52 | 53 | TransactionRole currentRole = exchange.getProperty(ExchangeHeader.CURRENT_ROLE.getKey(), TransactionRole.class); 54 | TransactionRoleContext roleContext = transactionContext.getRoleContext(currentRole); 55 | String accountId = roleContext.getPartyContext().getAccountId(); 56 | 57 | String transferId = transactionContext.getOrCreateTransferId(); 58 | 59 | FspMoneyData amount = new FspMoneyData(transactionContext.getTransferAmount(), transactionContext.getCurrency()); 60 | TransferFspRequestDTO transferRequestDTO = new TransferFspRequestDTO(transactionId, transferId, accountId, amount, roleContext.getFspQuoteDTO().getFspFee(), 61 | roleContext.getFspQuoteDTO().getFspCommission(), currentRole, transactionContext.getTransactionType(), transactionContext.getNote()); 62 | 63 | TransferFspResponseDTO transferResponseDTO = fspRestClient.callPrepareTransfer(transferRequestDTO, roleContext.getFspId()); 64 | 65 | transactionContextHolder.updateFspPrepareTransfer(transactionId, currentRole, transferResponseDTO); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/QuotesFspProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.component.FspRestClient; 13 | import org.openmf.psp.dto.FspMoneyData; 14 | import org.openmf.psp.dto.fsp.QuoteFspRequestDTO; 15 | import org.openmf.psp.dto.fsp.QuoteFspResponseDTO; 16 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 17 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 18 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 19 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 20 | import org.openmf.psp.type.TransactionRole; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.stereotype.Component; 23 | 24 | /** 25 | * Processor to send POST /quotes request to FSP. 26 | */ 27 | @Component("quotesFspProcessor") 28 | public class QuotesFspProcessor implements Processor { 29 | 30 | private FspRestClient fspRestClient; 31 | 32 | private TransactionContextHolder transactionContextHolder; 33 | 34 | @Autowired 35 | public QuotesFspProcessor(FspRestClient fspRestClient, TransactionContextHolder transactionContextHolder) { 36 | this.fspRestClient = fspRestClient; 37 | this.transactionContextHolder = transactionContextHolder; 38 | } 39 | 40 | @Override 41 | public void process(Exchange exchange) throws Exception { 42 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 43 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 44 | 45 | TransactionRole quotesRole = exchange.getProperty(ExchangeHeader.QUOTES_ROLE.getKey(), TransactionRole.class); 46 | if (quotesRole == null) 47 | quotesRole = exchange.getProperty(ExchangeHeader.CURRENT_ROLE.getKey(), TransactionRole.class); 48 | 49 | TransactionRoleContext roleContext = transactionContext.getRoleContext(quotesRole); 50 | String accountId = roleContext.getPartyContext().getAccountId(); 51 | 52 | String quoteId = transactionContext.getOrCreateQuoteId(); 53 | 54 | FspMoneyData amount = new FspMoneyData(transactionContext.getTransferAmount(), transactionContext.getCurrency()); 55 | QuoteFspRequestDTO request = new QuoteFspRequestDTO(transactionId, transactionContext.getTransactionRequestId(), 56 | quoteId, accountId, amount, transactionContext.getAmountType(), quotesRole, transactionContext.getTransactionType()); 57 | 58 | QuoteFspResponseDTO quotesResponseDTO = fspRestClient.callQuotes(request, roleContext.getFspId()); 59 | 60 | transactionContextHolder.updateFspQuote(transactionId, quotesRole, quotesResponseDTO); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/QuotesSwitchResponseProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.dto.MoneyData; 13 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 14 | import org.openmf.psp.mojaloop.component.IlpBuilderDpc; 15 | import org.openmf.psp.mojaloop.component.SwitchRestClient; 16 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 17 | import org.openmf.psp.mojaloop.dto.mojaloop.QuoteSwitchResponseDTO; 18 | import org.openmf.psp.mojaloop.internal.Ilp; 19 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 20 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 21 | import org.openmf.psp.type.AmountType; 22 | import org.openmf.psp.type.TransactionRole; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.stereotype.Component; 25 | 26 | import java.math.BigDecimal; 27 | 28 | /** 29 | * Processor to send PUT /quotes response through the switch. 30 | */ 31 | @Component("quotesSwitchResponseProcessor") 32 | public class QuotesSwitchResponseProcessor implements Processor { 33 | 34 | private TransactionContextHolder transactionContextHolder; 35 | 36 | private SwitchRestClient switchRestClient; 37 | 38 | private IlpBuilderDpc ilpBuilderDpc; 39 | 40 | @Autowired 41 | public QuotesSwitchResponseProcessor(TransactionContextHolder transactionContextHolder, SwitchRestClient switchRestClient, 42 | IlpBuilderDpc ilpBuilderDpc) { 43 | this.transactionContextHolder = transactionContextHolder; 44 | this.switchRestClient = switchRestClient; 45 | this.ilpBuilderDpc = ilpBuilderDpc; 46 | } 47 | 48 | @Override 49 | public void process(Exchange exchange) throws Exception { 50 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 51 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 52 | 53 | TransactionRoleContext payeeContext = transactionContext.getRoleContext(TransactionRole.PAYEE); 54 | TransactionRoleContext payerContext = transactionContext.getRoleContext(TransactionRole.PAYER); 55 | 56 | BigDecimal transactionAmount = transactionContext.getTransactionAmount(); 57 | BigDecimal transferAmount = transactionContext.getTransferAmount(); 58 | String currency = transactionContext.getCurrency(); 59 | 60 | MoneyData fee = payeeContext.getFee() == null ? new MoneyData("0", currency) : payeeContext.getFee(); 61 | MoneyData commission = payeeContext.getCommission() == null ? new MoneyData("0", currency) : payeeContext.getCommission(); 62 | 63 | BigDecimal payeeReceiveAmount = transactionContext.getAmountType() == AmountType.RECEIVE 64 | ? transactionAmount 65 | : transferAmount.add(commission.getAmountDecimal()).subtract(fee.getAmountDecimal()); 66 | 67 | Ilp ilp = ilpBuilderDpc.build(transactionId, transactionContext.getQuoteId(), transactionAmount, currency, 68 | payerContext.getPartyContext().getParty(), payeeContext.getPartyContext().getParty(), transferAmount); 69 | transactionContextHolder.registerIlp(transactionId, ilp); 70 | 71 | MoneyData transferData = new MoneyData(transferAmount, currency); 72 | MoneyData receiveData = new MoneyData(payeeReceiveAmount, currency); 73 | QuoteSwitchResponseDTO response = new QuoteSwitchResponseDTO(transferData, receiveData, fee, commission, transactionContext.getExpiration(), 74 | transactionContext.getGeoCode(), ilp.getPacket(), ilp.getCondition(), transactionContext.getExtensionList()); 75 | 76 | switchRestClient.callPutQuotes(response, transactionContext.getQuoteId(), payeeContext.getFspId(), payerContext.getFspId()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/TransactionRequestFspProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.component.FspRestClient; 13 | import org.openmf.psp.dto.FspMoneyData; 14 | import org.openmf.psp.dto.fsp.TransactionRequestFspRequestDTO; 15 | import org.openmf.psp.dto.fsp.TransactionRequestFspResponseDTO; 16 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 17 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 18 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 19 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 20 | import org.openmf.psp.type.TransactionRole; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.stereotype.Component; 23 | 24 | /** 25 | * Processor to send POST /transactionRequests request to FSP. 26 | */ 27 | @Component("transactionRequestFspProcessor") 28 | public class TransactionRequestFspProcessor implements Processor { 29 | 30 | private TransactionContextHolder transactionContextHolder; 31 | 32 | private FspRestClient fspRestClient; 33 | 34 | @Autowired 35 | public TransactionRequestFspProcessor(TransactionContextHolder transactionContextHolder, FspRestClient fspRestClient) { 36 | this.transactionContextHolder = transactionContextHolder; 37 | this.fspRestClient = fspRestClient; 38 | } 39 | 40 | @Override 41 | public void process(Exchange exchange) throws Exception { 42 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 43 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 44 | 45 | TransactionRole currentRole = TransactionRole.PAYER; 46 | TransactionRoleContext roleContext = transactionContext.getRoleContext(currentRole); 47 | String accountId = roleContext.getPartyContext().getAccountId(); 48 | 49 | String requestId = transactionContext.getOrCreateTransactionRequestId(); 50 | 51 | FspMoneyData amount = new FspMoneyData(transactionContext.getTransactionAmount(), transactionContext.getCurrency()); 52 | TransactionRequestFspRequestDTO request = new TransactionRequestFspRequestDTO(transactionId, requestId, accountId, 53 | amount, currentRole, transactionContext.getTransactionType(), transactionContext.getNote(), 54 | transactionContext.getGeoCode(), transactionContext.getExpiration(), transactionContext.getExtensionList()); 55 | 56 | TransactionRequestFspResponseDTO responseDTO = fspRestClient.callTransactionRequest(request, roleContext.getFspId()); 57 | 58 | transactionContextHolder.updateFspTransactionRequest(transactionId, currentRole, responseDTO); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/TransactionRequestResponseSwitchProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.dto.PartyIdInfo; 13 | import org.openmf.psp.internal.FspId; 14 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 15 | import org.openmf.psp.mojaloop.component.SwitchRestClient; 16 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 17 | import org.openmf.psp.mojaloop.dto.mojaloop.PartySwitchResponseDTO; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.stereotype.Component; 20 | 21 | /** 22 | * Processor to send PUT /transactionRequests response through the switch. 23 | */ 24 | @Component("transactionRequestResponseSwitchProcessor") 25 | public class TransactionRequestResponseSwitchProcessor implements Processor { 26 | 27 | private TransactionContextHolder transactionContextHolder; 28 | 29 | private SwitchRestClient switchRestClient; 30 | 31 | @Autowired 32 | public TransactionRequestResponseSwitchProcessor(TransactionContextHolder transactionContextHolder, SwitchRestClient switchRestClient) { 33 | this.transactionContextHolder = transactionContextHolder; 34 | this.switchRestClient = switchRestClient; 35 | } 36 | 37 | @Override 38 | public void process(Exchange exchange) throws Exception { 39 | FspId sourceFspId = exchange.getProperty(ExchangeHeader.CURRENT_FSP_ID.getKey(), FspId.class); 40 | FspId destFspId = exchange.getProperty(ExchangeHeader.CALLER_FSP.getKey(), FspId.class); 41 | 42 | PartyIdInfo partyIdInfo = exchange.getProperty(ExchangeHeader.PARTIES_INFO.getKey(), PartyIdInfo.class); 43 | PartySwitchResponseDTO response = new PartySwitchResponseDTO(transactionContextHolder.getPartyContext(partyIdInfo).getParty()); 44 | switchRestClient.callPutParties(response, sourceFspId, destFspId); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/TransactionRequestSwitchProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.config.SwitchSettings; 13 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 14 | import org.openmf.psp.mojaloop.component.SwitchRestClient; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Component; 17 | 18 | /** 19 | * Processor to send POST /transactionRequests request to the PAYER FSP through interoperable switch. 20 | */ 21 | @Component("transactionRequestSwitchProcessor") 22 | public class TransactionRequestSwitchProcessor implements Processor { 23 | 24 | private TransactionContextHolder transactionContextHolder; 25 | 26 | private SwitchSettings switchSettings; 27 | private SwitchRestClient switchRestClient; 28 | 29 | @Autowired 30 | public TransactionRequestSwitchProcessor(TransactionContextHolder transactionContextHolder, SwitchSettings switchSettings, 31 | SwitchRestClient switchRestClient) { 32 | this.transactionContextHolder = transactionContextHolder; 33 | this.switchSettings = switchSettings; 34 | this.switchRestClient = switchRestClient; 35 | } 36 | 37 | @Override 38 | public void process(Exchange exchange) throws Exception { 39 | // add transaction id to the extension list EXTENSION_KEY_TRANSACTION_ID 40 | throw new RuntimeException("Call /transactionRequest is not supported yet"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/routebuilder/processor/TransfersSwitchResponseProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.routebuilder.processor; 9 | 10 | import org.apache.camel.Exchange; 11 | import org.apache.camel.Processor; 12 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 13 | import org.openmf.psp.mojaloop.component.SwitchRestClient; 14 | import org.openmf.psp.mojaloop.constant.ExchangeHeader; 15 | import org.openmf.psp.mojaloop.dto.mojaloop.TransferSwitchResponseDTO; 16 | import org.openmf.psp.mojaloop.internal.TransactionCacheContext; 17 | import org.openmf.psp.mojaloop.internal.TransactionRoleContext; 18 | import org.openmf.psp.mojaloop.type.TransferState; 19 | import org.openmf.psp.type.TransactionRole; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.stereotype.Component; 22 | 23 | import java.time.LocalDateTime; 24 | import java.time.ZonedDateTime; 25 | import java.time.format.DateTimeFormatter; 26 | 27 | /** 28 | * Processor to send PUT /transfers COMMIT response through the switch. 29 | */ 30 | @Component("transfersSwitchResponseProcessor") 31 | public class TransfersSwitchResponseProcessor implements Processor { 32 | 33 | private TransactionContextHolder transactionContextHolder; 34 | 35 | private SwitchRestClient switchRestClient; 36 | 37 | @Autowired 38 | public TransfersSwitchResponseProcessor(TransactionContextHolder transactionContextHolder, SwitchRestClient switchRestClient) { 39 | this.transactionContextHolder = transactionContextHolder; 40 | this.switchRestClient = switchRestClient; 41 | } 42 | 43 | @Override 44 | public void process(Exchange exchange) throws Exception { 45 | String transactionId = exchange.getProperty(ExchangeHeader.TRANSACTION_ID.getKey(), String.class); 46 | TransactionCacheContext transactionContext = transactionContextHolder.getTransactionContext(transactionId); 47 | 48 | TransactionRoleContext payeeContext = transactionContext.getRoleContext(TransactionRole.PAYEE); 49 | TransactionRoleContext payerContext = transactionContext.getRoleContext(TransactionRole.PAYER); 50 | 51 | 52 | LocalDateTime localDateTime = LocalDateTime.now(); 53 | TransferSwitchResponseDTO response = new TransferSwitchResponseDTO(transactionContext.getIlp().getFulfilment(), 54 | localDateTime, TransferState.COMMITTED, transactionContext.getExtensionList()); 55 | 56 | switchRestClient.callPutTransferCommit(response, transactionContext.getTransferId(), payeeContext.getFspId(), payerContext.getFspId()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/type/TransactionActionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.type; 9 | 10 | public enum TransactionActionType { 11 | 12 | PREPARE("PREPARE"), 13 | CREATE("CREATE"); 14 | 15 | private String name; 16 | 17 | private TransactionActionType(String name) { 18 | this.name = name; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/type/TransactionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.type; 9 | 10 | public enum TransactionState { 11 | 12 | RECEIVED, 13 | PENDING, 14 | COMPLETED, 15 | REJECTED; 16 | 17 | public static TransactionState forAction(TransactionAction action) { 18 | switch (action) { 19 | case REQUEST: 20 | case QUOTE: 21 | case PREPARE: 22 | return PENDING; 23 | case COMMIT: 24 | return COMPLETED; 25 | case REQUEST_FAILED: 26 | case QUOTE_FAILED: 27 | case PREPARE_FAILED: 28 | case COMMIT_FAILED: 29 | case ABORT: 30 | return REJECTED; 31 | default: 32 | return null; // TODO fail 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/mojaloop/type/TransferState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.mojaloop.type; 9 | 10 | public enum TransferState { 11 | 12 | RECEIVED, 13 | RESERVED, 14 | COMMITTED, 15 | ABORTED; 16 | 17 | public static TransferState forAction(TransactionAction action) { 18 | switch (action) { 19 | case REQUEST: 20 | case QUOTE: 21 | return RECEIVED; 22 | case PREPARE: 23 | return RESERVED; 24 | case COMMIT: 25 | return COMMITTED; 26 | case REQUEST_FAILED: 27 | case QUOTE_FAILED: 28 | case PREPARE_FAILED: 29 | case COMMIT_FAILED: 30 | case ABORT: 31 | return ABORTED; 32 | default: 33 | return null; // TODO fail 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/routebuilder/AdminRouteBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.routebuilder; 9 | 10 | import org.apache.camel.CamelContext; 11 | import org.apache.camel.builder.RouteBuilder; 12 | import org.openmf.psp.config.ChannelSettings; 13 | import org.openmf.psp.mojaloop.cache.TransactionContextHolder; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.context.annotation.Configuration; 18 | 19 | /** 20 | * List of administration endpoints, like the one which queries and the other which empties all the caches. 21 | */ 22 | @Configuration 23 | public class AdminRouteBuilder extends RouteBuilder { 24 | 25 | private static Logger logger = LoggerFactory.getLogger(AdminRouteBuilder.class); 26 | 27 | private ChannelSettings channelSettings; 28 | 29 | private TransactionContextHolder transactionContextHolder; 30 | 31 | @Autowired 32 | public AdminRouteBuilder(CamelContext context, ChannelSettings channelSettings, TransactionContextHolder transactionContextHolder) { 33 | super(context); 34 | this.channelSettings = channelSettings; 35 | this.transactionContextHolder = transactionContextHolder; 36 | } 37 | 38 | @Override 39 | public void configure() throws Exception { 40 | // from("jetty:http://" + channelSettings.getChannelRestBindHost() + ":" + channelSettings.getChannelRestBindPort() 41 | // + "/admin/contexts/{transactionId}?httpMethodRestrict=GET") 42 | // .id("admin-context-get-consumer") 43 | // .log("admin-context-get-consumer called!") 44 | // .process(exchange -> { 45 | // HttpServletRequest httpServletRequest = exchange.getIn().getBody(HttpServletRequest.class); 46 | // String transactionId = UrlParamUtil.extractFromContextPath(httpServletRequest.getPathInfo(), 3); 47 | // exchange.getIn().setBody(transactionContextHolder.getTransactionContext(transactionId)); 48 | // }) 49 | // .marshal().json(JsonLibrary.Jackson) 50 | // ; 51 | // 52 | // from("jetty:http://" + channelSettings.getChannelRestBindHost() + ":" + channelSettings.getChannelRestBindPort() 53 | // + "/admin/contexts/client/{channelClientRef}?httpMethodRestrict=GET") 54 | // .id("admin-context-get-by-channelclientref-consumer") 55 | // .log("admin-context-get-by-channeclientref-consumer called!") 56 | // .process(exchange -> { 57 | // HttpServletRequest httpServletRequest = exchange.getIn().getBody(HttpServletRequest.class); 58 | // String channelClientRef = UrlParamUtil.extractFromContextPath(httpServletRequest.getPathInfo(), 4); 59 | // exchange.getIn().setBody(transactionContextHolder.getContextByChannelClientRef(channelClientRef)); 60 | // }) 61 | // .marshal().json(JsonLibrary.Jackson) 62 | // ; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/AmountType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum AmountType { 11 | 12 | SEND, 13 | RECEIVE; 14 | } 15 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/AuthenticationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum AuthenticationType { 11 | OTP, 12 | QRCODE, 13 | ; 14 | } 15 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/IdentifierType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum IdentifierType { 11 | 12 | MSISDN, 13 | EMAIL, 14 | PERSONAL_ID, 15 | BUSINESS, 16 | DEVICE, 17 | ACCOUNT_ID, 18 | IBAN, 19 | ALIAS; 20 | } 21 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/InitiatorType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum InitiatorType { 11 | 12 | CONSUMER, 13 | AGENT, 14 | BUSINESS, 15 | DEVICE, 16 | ; 17 | } 18 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/Scenario.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum Scenario { 11 | 12 | DEPOSIT, 13 | WITHDRAWAL, 14 | TRANSFER, 15 | PAYMENT, 16 | REFUND, 17 | ; 18 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/SubScenario.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum SubScenario { 11 | 12 | TEST, 13 | ; 14 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/TransactionRequestState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum TransactionRequestState { 11 | 12 | RECEIVED, 13 | PENDING, 14 | ACCEPTED, 15 | REJECTED, 16 | ; 17 | } 18 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/type/TransactionRole.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.type; 9 | 10 | public enum TransactionRole { 11 | 12 | PAYER, 13 | PAYEE; 14 | 15 | 16 | public static TransactionRole[] VALUES = values(); 17 | } 18 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/util/IbanUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.util; 9 | 10 | import org.openmf.psp.config.IbanSettings; 11 | import org.openmf.psp.internal.FspId; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Component; 14 | 15 | import javax.annotation.PostConstruct; 16 | 17 | @Component 18 | public class IbanUtil { 19 | 20 | @Autowired 21 | private IbanSettings ibanSettings; 22 | 23 | private int fspInstanceIdFirstIndex; 24 | private int fspInstanceIdLength; 25 | private int fspInstanceIdLastIndex; 26 | private int fspTenantIdFirstIndex; 27 | private int fspTenantIdLength; 28 | private int fspTenantIdLastIndex; 29 | 30 | @PostConstruct 31 | public void postConstruct() { 32 | fspInstanceIdFirstIndex = ibanSettings.getFspInstanceIdFirstIndex(); 33 | fspInstanceIdLength = ibanSettings.getFspInstanceIdLength(); 34 | fspInstanceIdLastIndex = fspInstanceIdFirstIndex + fspInstanceIdLength; 35 | fspTenantIdFirstIndex = ibanSettings.getFspTenantIdFirstIndex(); 36 | fspTenantIdLength = ibanSettings.getFspTenantIdLength(); 37 | fspTenantIdLastIndex = fspTenantIdFirstIndex + fspTenantIdLength; 38 | } 39 | 40 | public FspId extractFspIdFromIban(String iban) { 41 | String fspInstance = iban.substring(fspInstanceIdFirstIndex, fspInstanceIdLastIndex); 42 | String fspTenant = iban.substring(fspTenantIdFirstIndex, fspTenantIdLastIndex); 43 | 44 | return new FspId(fspInstance, fspTenant); 45 | } 46 | 47 | public String extractAccountIdFromIban(String iban) { 48 | 49 | return iban.substring(fspTenantIdLastIndex); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/util/JsonUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.util; 9 | 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.core.JsonProcessingException; 12 | import com.fasterxml.jackson.databind.DeserializationFeature; 13 | import com.fasterxml.jackson.databind.ObjectMapper; 14 | 15 | import java.io.IOException; 16 | 17 | public class JsonUtil { 18 | 19 | private static ObjectMapper mapper = new ObjectMapper() 20 | .setSerializationInclusion(JsonInclude.Include.NON_NULL) 21 | .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); 22 | 23 | 24 | public static String toJson(Object pojo) { 25 | try { 26 | return mapper.writeValueAsString(pojo); 27 | } catch (JsonProcessingException e) { 28 | throw new RuntimeException(String.format("Error while mapping from POJO (%s) to JSON string!", pojo.getClass()), e); 29 | } 30 | } 31 | 32 | public static T toPojo(String json, Class type) { 33 | try { 34 | return mapper.readValue(json, type); 35 | } catch (IOException e) { 36 | throw new RuntimeException(String.format("Error while mapping from JSON string to POJO (%s)!", type), e); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/util/RestTemplateHeaderModifierInterceptor.java: -------------------------------------------------------------------------------- 1 | package org.openmf.psp.util; 2 | 3 | import java.io.IOException; 4 | 5 | import org.springframework.http.HttpHeaders; 6 | import org.springframework.http.HttpRequest; 7 | import org.springframework.http.client.ClientHttpRequestExecution; 8 | import org.springframework.http.client.ClientHttpRequestInterceptor; 9 | import org.springframework.http.client.ClientHttpResponse; 10 | 11 | public class RestTemplateHeaderModifierInterceptor 12 | implements ClientHttpRequestInterceptor { 13 | 14 | @Override 15 | public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException 16 | { 17 | HttpHeaders headers = request.getHeaders(); 18 | headers.remove("Accept-Encoding"); 19 | headers.remove("Accept-Charset"); 20 | headers.remove("Accept"); 21 | 22 | return execution.execute(request, body); 23 | } 24 | } -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/util/UUIDUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.util; 9 | 10 | import java.util.UUID; 11 | 12 | public class UUIDUtil { 13 | 14 | public static String generateUUID(){ 15 | return UUID.randomUUID().toString(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/java/org/openmf/psp/util/UrlParamUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code Form is subject to the terms of the Mozilla 3 | * Public License, v. 2.0. If a copy of the MPL was not distributed 4 | * with this file, You can obtain one at 5 | * 6 | * https://mozilla.org/MPL/2.0/. 7 | */ 8 | package org.openmf.psp.util; 9 | 10 | public class UrlParamUtil { 11 | 12 | //TODO: rewrite this for better performance 13 | public static String extractFromContextPath(String contextPath, int index) { 14 | 15 | //ContextPath starts with a leading slash 16 | return contextPath.split("/")[index]; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /sources/payment-hub/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /work/gsma/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This Source Code Form is subject to the terms of the Mozilla 3 | # Public License, v. 2.0. If a copy of the MPL was not distributed 4 | # with this file, You can obtain one at 5 | # 6 | # https://mozilla.org/MPL/2.0/. 7 | # 8 | 9 | debug: true 10 | 11 | spring: 12 | main: 13 | web-application-type: none 14 | 15 | # the name of Camel 16 | camel: 17 | springboot: 18 | name: RestCamel 19 | 20 | iban-settings: 21 | fsp-instance-id-first-index: 4 22 | fsp-instance-id-length: 4 23 | fsp-tenant-id-first-index: 8 24 | fsp-tenant-id-length: 4 25 | 26 | hub-settings: 27 | instance: in02 28 | expiration: 30000 29 | tenants: tn03, tn04 30 | 31 | channel-settings: 32 | cors-enabled: true 33 | headers: 34 | - name: tenant 35 | key: X-Tenant-Identifier 36 | operations: #hub -> channel 37 | - name: operation-basic-settings 38 | host: https://fineract.mifos.io 39 | tenants: 40 | - name: tn03 41 | port: 48888 42 | - name: tn04 43 | port: 48889 44 | - name: quotes #post notification 45 | base: interoperation/quotes 46 | - name: transfers #post notification 47 | base: interoperation/transfers 48 | - name: response #put async response 49 | base: interoperation/transactions 50 | bindings: #channel -> hub 51 | - name: binding-basic-settings 52 | host: http://0.0.0.0 53 | port: 80 54 | - name: parties 55 | base: channel/parties 56 | - name: payment #post payment request 57 | base: channel/transactions #/in01/channel/transactions 58 | - name: status #get status by hub id 59 | base: channel/transactions 60 | - name: client-status #get status by client id 61 | base: channel/transactions/client 62 | 63 | fsp-settings: 64 | ilp-secret: h4on38bsDjKiat2783gnklgafikmeuu5123kpobb7jm99 65 | auth: 66 | profile: BASIC 67 | encode: NONE 68 | login-class: org.openmf.psp.dto.fsp.LoginFineractXResponseDTO 69 | headers: 70 | - name: user 71 | key: User 72 | - name: tenant 73 | key: Fineract-Platform-TenantId 74 | operations: #hub -> fsp 75 | - name: operation-basic-settings 76 | user: mifos 77 | password: password 78 | host: https://fineract.mifos.io 79 | port: 8443 80 | - name: auth #login 81 | base: fineract-provider/api/v1/authentication 82 | - name: requests 83 | base: fineract-provider/api/v1/interoperation/requests 84 | - name: parties 85 | base: fineract-provider/api/v1/interoperation/parties 86 | - name: quotes 87 | base: fineract-provider/api/v1/interoperation/quotes 88 | - name: transfers 89 | base: fineract-provider/api/v1/interoperation/transfers 90 | 91 | 92 | ott-settings: 93 | cors-enabled: true 94 | apikey: u8YfSQNnNsGFAaqRm3sGShpO2ywLRJgs 95 | operations: #hub -> ott 96 | - name: operation-basic-settings 97 | host: https://sandbox.mobilemoneyapi.io/simulator/v1.0/mm 98 | tenants: 99 | - name: tn03 100 | port: 48888 101 | - name: tn04 102 | port: 48889 103 | - name: transactions 104 | base: transactions 105 | - name: accounts 106 | base: accounts 107 | bindings: #ott -> hub 108 | - name: binding-basic-settings 109 | host: http://0.0.0.0 110 | port: 58080 111 | - name: merchantpayment # post merchant payment 112 | base: merchantpayment 113 | - name: transfer # post peer-to-peer transfer 114 | base: transfer 115 | 116 | mock-settings: 117 | start-channel-consumers: false 118 | start-switch-consumers: false 119 | start-fsp-consumers: false 120 | -------------------------------------------------------------------------------- /work/mojaloop/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This Source Code Form is subject to the terms of the Mozilla 3 | # Public License, v. 2.0. If a copy of the MPL was not distributed 4 | # with this file, You can obtain one at 5 | # 6 | # https://mozilla.org/MPL/2.0/. 7 | # 8 | 9 | debug: true 10 | 11 | spring: 12 | main: 13 | web-application-type: none 14 | 15 | # the name of Camel 16 | camel: 17 | springboot: 18 | name: RestCamel 19 | 20 | iban-settings: 21 | fsp-instance-id-first-index: 4 22 | fsp-instance-id-length: 4 23 | fsp-tenant-id-first-index: 8 24 | fsp-tenant-id-length: 4 25 | 26 | hub-settings: 27 | instance: in02 28 | expiration: 30000 29 | tenants: tn03, tn04 30 | 31 | channel-settings: 32 | cors-enabled: true 33 | headers: 34 | - name: tenant 35 | key: X-Tenant-Identifier 36 | operations: #hub -> channel 37 | - name: operation-basic-settings 38 | host: https://fineract.mifos.io 39 | tenants: 40 | - name: tn03 41 | port: 48888 42 | - name: tn04 43 | port: 48889 44 | - name: quotes #post notification 45 | base: interoperation/quotes 46 | - name: transfers #post notification 47 | base: interoperation/transfers 48 | - name: response #put async response 49 | base: interoperation/transactions 50 | bindings: #channel -> hub 51 | - name: binding-basic-settings 52 | host: http://0.0.0.0 53 | port: 80 54 | - name: parties 55 | base: channel/parties 56 | - name: payment #post payment request 57 | base: channel/transactions #/in01/channel/transactions 58 | - name: status #get status by hub id 59 | base: channel/transactions 60 | - name: client-status #get status by client id 61 | base: channel/transactions/client 62 | 63 | fsp-settings: 64 | ilp-secret: h4on38bsDjKiat2783gnklgafikmeuu5123kpobb7jm99 65 | auth: 66 | profile: BASIC 67 | encode: NONE 68 | login-class: org.openmf.psp.dto.fsp.LoginFineractXResponseDTO 69 | headers: 70 | - name: user 71 | key: User 72 | - name: tenant 73 | key: Fineract-Platform-TenantId 74 | operations: #hub -> fsp 75 | - name: operation-basic-settings 76 | user: mifos 77 | password: password 78 | host: https://fineract.mifos.io 79 | port: 8443 80 | - name: auth #login 81 | base: fineract-provider/api/v1/authentication 82 | - name: requests 83 | base: fineract-provider/api/v1/interoperation/requests 84 | - name: parties 85 | base: fineract-provider/api/v1/interoperation/parties 86 | - name: quotes 87 | base: fineract-provider/api/v1/interoperation/quotes 88 | - name: transfers 89 | base: fineract-provider/api/v1/interoperation/transfers 90 | 91 | switch-settings: 92 | integration-enabled: true 93 | headers: 94 | - name: source 95 | key: FSPIOP-Source 96 | - name: destination 97 | key: FSPIOP-Destination 98 | operations: #hub -> switch post and put 99 | - name: operation-basic-settings 100 | host: http://account-lookup-service.local 101 | port: 80 102 | - name: participants #post participant registration 103 | base: participants 104 | - name: parties #get, put parties 105 | base: parties 106 | - name: oracles #get, post oracles 107 | host: http://account-lookup-service-admin.local 108 | base: oracles 109 | - name: requests 110 | host: http://ml-api-adapter.local 111 | base: transactionRequests 112 | - name: quotes #post, put quotes 113 | host: http://quoting-service.local 114 | base: quotes 115 | - name: transfers #post, put transfers 116 | host: http://ml-api-adapter.local 117 | base: transfers 118 | bindings: #switch -> hub post and put 119 | - name: binding-basic-settings 120 | host: http://0.0.0.0 121 | tenants: 122 | - name: tn03 123 | port: 58180 124 | - name: tn04 125 | port: 58181 126 | - name: participants 127 | base: switch/participants 128 | - name: parties 129 | base: switch/parties 130 | - name: requests 131 | base: switch/transactionRequests 132 | - name: quotes 133 | base: switch/quotes 134 | - name: transfers 135 | base: switch/transfers 136 | 137 | mock-settings: 138 | start-channel-consumers: false 139 | start-switch-consumers: false 140 | start-fsp-consumers: false 141 | --------------------------------------------------------------------------------