Search in sources :

Example 1 with PaymentStatusPoll

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;
}
Also used : PaymentStatusPoll(net.petafuel.styx.keepalive.tasks.PaymentStatusPoll) StrongAuthenticatableResource(net.petafuel.styx.core.xs2a.entities.StrongAuthenticatableResource)

Example 2 with PaymentStatusPoll

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());
    }
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) RedirectStatus(net.petafuel.styx.api.v1.status.entity.RedirectStatus) PaymentEntry(net.petafuel.styx.core.persistence.models.PaymentEntry) SAD(net.petafuel.styx.core.banklookup.sad.SAD) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) PaymentStatusPoll(net.petafuel.styx.keepalive.tasks.PaymentStatusPoll) BankLookupFailedException(net.petafuel.styx.core.banklookup.exceptions.BankLookupFailedException) BankNotFoundException(net.petafuel.styx.core.banklookup.exceptions.BankNotFoundException)

Aggregations

PaymentStatusPoll (net.petafuel.styx.keepalive.tasks.PaymentStatusPoll)2 RedirectStatus (net.petafuel.styx.api.v1.status.entity.RedirectStatus)1 XS2AStandard (net.petafuel.styx.core.banklookup.XS2AStandard)1 BankLookupFailedException (net.petafuel.styx.core.banklookup.exceptions.BankLookupFailedException)1 BankNotFoundException (net.petafuel.styx.core.banklookup.exceptions.BankNotFoundException)1 SAD (net.petafuel.styx.core.banklookup.sad.SAD)1 PaymentEntry (net.petafuel.styx.core.persistence.models.PaymentEntry)1 StrongAuthenticatableResource (net.petafuel.styx.core.xs2a.entities.StrongAuthenticatableResource)1 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)1