use of net.petafuel.styx.core.banklookup.exceptions.BankLookupFailedException in project styx by petafuel.
the class OAuthCallbackProcessor method handlePaymentRealm.
private static RedirectStatus handlePaymentRealm(ServiceRealm serviceRealm, RealmParameter realmParameter, String identifier, OAuthCallback oAuthCallback) {
String path = String.format("%s/%s/%s", serviceRealm.name().toLowerCase(), realmParameter.name().toLowerCase(), identifier);
if (oAuthCallback.getError() == null && handleSuccessfulOAuth2(oAuthCallback.getCode(), oAuthCallback.getState(), path)) {
PaymentEntry paymentEntry = PersistentPayment.getById(identifier);
XS2AStandard xs2AStandard;
try {
xs2AStandard = (new SAD()).getBankByBIC(paymentEntry.getBic());
} catch (BankNotFoundException | BankLookupFailedException e) {
LOG.error("OAuth Callback on serviceRealm={}, identifier={}, realmParameter={} failed due to SAD not being able to initialize the aspsp connected to the payment SCA", serviceRealm, identifier, realmParameter, e);
return new RedirectStatus(StatusType.ERROR, identifier);
}
// In case of oauth we will not schedule the task during payment initiation but here after we received a callback
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setPaymentId(paymentEntry.getPaymentId());
xs2AFactoryInput.setPaymentService(paymentEntry.getPaymentService());
xs2AFactoryInput.setPaymentProduct(paymentEntry.getPaymentProduct());
ThreadManager.getInstance().queueTask(new PaymentStatusPoll(xs2AFactoryInput, xs2AStandard.getAspsp().getBic(), UUID.fromString(paymentEntry.getId())));
return new RedirectStatus(StatusType.SUCCESS, oAuthCallback.getState());
} else {
LOG.error(FAILED_OAUTH2, oAuthCallback.getError(), oAuthCallback.getErrorDescription(), oAuthCallback.getState());
return new RedirectStatus(StatusType.ERROR, oAuthCallback.getState());
}
}
Aggregations