use of net.petafuel.styx.keepalive.tasks.PaymentStatusPoll in project styx by petafuel.
the class STYX07 method apply.
@Override
public boolean apply(XS2AFactoryInput xs2AFactoryInput, XS2ARequest xs2ARequest, XS2AResponse xs2AResponse) throws ImplementerOptionException {
if (Boolean.FALSE.equals(ioParser.getOption(IO, IOParser.Option.REQUIRED))) {
return false;
}
if (!(xs2AResponse instanceof StrongAuthenticatableResource)) {
LOG.debug("Not executing, response is not StrongAuthenticatableResource");
return false;
}
StrongAuthenticatableResource scaResource = (StrongAuthenticatableResource) xs2AResponse;
ThreadManager.getInstance().queueTask(new PaymentStatusPoll(xs2AFactoryInput, ioParser.getAspsp().getBic(), scaResource.getxRequestId()));
return true;
}
use of net.petafuel.styx.keepalive.tasks.PaymentStatusPoll 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