amk.sdk.deeplink.AMKDeeplink Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java Show documentation
Show all versions of java Show documentation
The AMK Deeplink SDK is a library for AMK's merchant that allow them to be able generate deeplink for their user to pay via AMK Bank app.
package amk.sdk.deeplink;
import amk.sdk.deeplink.entity.model.AMKDLIndividual;
import amk.sdk.deeplink.entity.model.AMKDLMerchant;
import amk.sdk.deeplink.entity.model.AMKDLStatus;
import amk.sdk.deeplink.entity.model.AMKDeeplinkData;
import amk.sdk.deeplink.exception.DeeplinkException;
import amk.sdk.deeplink.entity.response.AMKDLResponse;
import amk.sdk.deeplink.presenter.DeeplinkPresenter;
import static amk.sdk.deeplink.entity.model.AMKDLValidation.*;
public class AMKDeeplink {
private final static int ERROR_CODE = 1;
public AMKDeeplink(String clientId, String privateKeyPath, String jwtAudience) {
DeeplinkPresenter.preConfig(clientId, privateKeyPath, jwtAudience);
}
public AMKDLResponse generateIndividualDeeplink(AMKDLIndividual AMKDLIndividual) {
try {
return DeeplinkPresenter.generateIndividualDeeplink(getValidIndividual(AMKDLIndividual));
} catch (DeeplinkException exception) {
return responseError(exception);
}
}
public AMKDLResponse generateMerchantDeeplink(AMKDLMerchant amkdlMerchant) {
try {
return DeeplinkPresenter.generateMerchantDeeplink(getValidMerchant(amkdlMerchant));
} catch (DeeplinkException exception) {
return responseError(exception);
}
}
private static AMKDLIndividual getValidIndividual(AMKDLIndividual amkdlIndividual) throws DeeplinkException {
amk.sdk.deeplink.entity.model.AMKDLIndividual validAMKDLIndividual = new AMKDLIndividual();
validAMKDLIndividual.setAccountId(getReceiverAccountId(amkdlIndividual.getAccountId()));
validAMKDLIndividual.setReferenceId(getReferenceId(amkdlIndividual.getReferenceId(), amkdlIndividual.getAccountId()));
validAMKDLIndividual.setAccountInformation(getAccountInformation(amkdlIndividual.getAccountInformation()));
validAMKDLIndividual.setAcquiringBank(getAcquiringBankForIndividual(amkdlIndividual.getAcquiringBank()));
validAMKDLIndividual.setCurrency(getCurrencyType(amkdlIndividual.getCurrency()));
validAMKDLIndividual.setAmount(getAmount(amkdlIndividual.getAmount(), amkdlIndividual.getCurrency()));
validAMKDLIndividual.setUsername(getMerchantName(amkdlIndividual.getUsername()));
validAMKDLIndividual.setCity(getMerchantCity(amkdlIndividual.getCity()));
validAMKDLIndividual.setBillNumber(getBillNumber(amkdlIndividual.getBillNumber()));
validAMKDLIndividual.setMobileNumber(getMobileNumber(amkdlIndividual.getMobileNumber()));
validAMKDLIndividual.setStoreLabel(getStoreLabel(amkdlIndividual.getStoreLabel()));
validAMKDLIndividual.setTerminalLabel(getTerminalLabel(amkdlIndividual.getTerminalLabel()));
return validAMKDLIndividual;
}
private static AMKDLMerchant getValidMerchant(AMKDLMerchant amkdlMerchant) throws DeeplinkException {
AMKDLMerchant validAMKDLMerchant = new AMKDLMerchant();
validAMKDLMerchant.setReferenceId(getReferenceId(amkdlMerchant.getReferenceId(), amkdlMerchant.getMerchantId()));
validAMKDLMerchant.setMerchantId(getMerchantId(amkdlMerchant.getMerchantId()));
validAMKDLMerchant.setAcquiringBank(getAcquiringBankForMerchant(amkdlMerchant.getAcquiringBank()));
validAMKDLMerchant.setCurrency(getCurrencyType(amkdlMerchant.getCurrency()));
validAMKDLMerchant.setAmount(getAmount(amkdlMerchant.getAmount(), amkdlMerchant.getCurrency()));
validAMKDLMerchant.setMerchantName(getMerchantName(amkdlMerchant.getMerchantName()));
validAMKDLMerchant.setMerchantCity(getMerchantCity(amkdlMerchant.getMerchantCity()));
validAMKDLMerchant.setBillNumber(getBillNumber(amkdlMerchant.getBillNumber()));
validAMKDLMerchant.setMobileNumber(getMobileNumber(amkdlMerchant.getMobileNumber()));
validAMKDLMerchant.setStoreLabel(getStoreLabel(amkdlMerchant.getStoreLabel()));
validAMKDLMerchant.setTerminalLabel(getTerminalLabel(amkdlMerchant.getTerminalLabel()));
validAMKDLMerchant.setSourceInfo(getSourceInfo(amkdlMerchant.getSourceInfo()));
return validAMKDLMerchant;
}
private static AMKDLResponse responseError(DeeplinkException exception) {
AMKDLResponse response = new AMKDLResponse();
AMKDLStatus status = new AMKDLStatus();
status.setCode(ERROR_CODE);
status.setErrorCode(exception.getErrorCode());
status.setMessage(exception.getMessage());
response.setStatus(status);
return response;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy