TransactionStatus status = TransactionAspectSupport.currentTransactionStatus(); System.out.println("Current transaction: " + status.toString());
TransactionStatus transactionStatus = session.getTransaction().getStatus(); if(transactionStatus.equals(TransactionStatus.ROLLED_BACK)){ //action s.a :) }
@PUT @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @Path("/payments/{paymentId:" + UUID_PATTERN + "}/transactions/{paymentTransactionId:" + UUID_PATTERN + "}") @ApiOperation(value = "Update existing paymentTransaction and associated payment state") @ApiResponses(value = {@ApiResponse(code = 204, message = "Successful operation"), @ApiResponse(code = 400, message = "Invalid account data supplied")}) public Response updatePaymentTransactionState(@PathParam("paymentId") final UUID paymentId, @PathParam("paymentTransactionId") final UUID paymentTransactionId, final AdminPaymentJson json, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException { final CallContext callContext = context.createCallContextNoAccountId(createdBy, reason, comment, request); final Payment payment = paymentApi.getPayment(paymentId, false, false, ImmutableList.<PluginProperty>of(), callContext); final PaymentTransaction paymentTransaction = Iterables.tryFind(payment.getTransactions(), new Predicate<PaymentTransaction>() { @Override public boolean apply(final PaymentTransaction input) { return input.getId().equals(paymentTransactionId); } }).orNull(); adminPaymentApi.fixPaymentTransactionState(payment, paymentTransaction, TransactionStatus.valueOf(json.getTransactionStatus()), json.getLastSuccessPaymentState(), json.getCurrentPaymentStateName(), ImmutableList.<PluginProperty>of(), callContext); return Response.status(Status.NO_CONTENT).build(); }
@TimedResource @POST @Path("/{transactionId:" + UUID_PATTERN + "}/") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Mark a pending payment transaction as succeeded or failed", response = PaymentJson.class) @ApiResponses(value = {@ApiResponse(code = 201, message = "Successfully notifiy state change"), @ApiResponse(code = 400, message = "Invalid paymentId supplied"), @ApiResponse(code = 404, message = "Account or Payment not found")}) public Response notifyStateChanged(@PathParam("transactionId") final UUID transactionId, final PaymentTransactionJson json, @QueryParam(QUERY_PAYMENT_CONTROL_PLUGIN_NAME) final List<String> paymentControlPluginNames, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final UriInfo uriInfo, @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException { verifyNonNullOrEmpty(json, "PaymentTransactionJson body should be specified"); verifyNonNullOrEmpty(json.getPaymentId(), "PaymentTransactionJson paymentId needs to be set", json.getStatus(), "PaymentTransactionJson status needs to be set"); final PaymentOptions paymentOptions = createControlPluginApiPaymentOptions(paymentControlPluginNames); final CallContext callContext = context.createCallContextNoAccountId(createdBy, reason, comment, request); final UUID paymentId = json.getPaymentId(); final Payment payment = paymentApi.getPayment(paymentId, false, false, ImmutableList.<PluginProperty>of(), callContext); final Account account = accountUserApi.getAccountById(payment.getAccountId(), callContext); final boolean success = TransactionStatus.SUCCESS.name().equals(json.getStatus()); final Payment result = paymentApi.notifyPendingTransactionOfStateChangedWithPaymentControl(account, transactionId, success, paymentOptions, callContext); return uriBuilder.buildResponse(uriInfo, PaymentResource.class, "getPayment", result.getId(), request); }
final BigDecimal requestedAmount = BigDecimal.TEN; final BigDecimal refundAmount = BigDecimal.ONE; final Iterable<PluginProperty> pendingPluginProperties = ImmutableList.<PluginProperty>of(new PluginProperty(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, TransactionStatus.PENDING.toString(), false));
@Override public boolean apply(final PaymentTransaction input) { return TransactionType.CHARGEBACK.equals(input.getTransactionType()) && TransactionStatus.SUCCESS.equals(input.getTransactionStatus()); } });
Assert.assertEquals(transactionModel.getTransactionStatus().toString(), "UNKNOWN");
public PaymentTransactionJson(final PaymentTransaction transaction, final String paymentExternalKey, @Nullable final List<AuditLog> transactionLogs) { this(transaction.getId(), transaction.getExternalKey(), transaction.getPaymentId(), paymentExternalKey, transaction.getTransactionType(), transaction.getAmount(), transaction.getCurrency() != null ? transaction.getCurrency() : null, transaction.getEffectiveDate(), transaction.getProcessedAmount(), transaction.getProcessedCurrency() != null ? transaction.getProcessedCurrency() : null, transaction.getTransactionStatus() != null ? transaction.getTransactionStatus().toString() : null, transaction.getGatewayErrorCode(), transaction.getGatewayErrorMsg(), transaction.getPaymentInfoPlugin() == null ? null : transaction.getPaymentInfoPlugin().getFirstPaymentReferenceId(), transaction.getPaymentInfoPlugin() == null ? null : transaction.getPaymentInfoPlugin().getSecondPaymentReferenceId(), transaction.getPaymentInfoPlugin() == null ? null : toPluginPropertyJson(transaction.getPaymentInfoPlugin().getProperties()), toAuditLogJson(transactionLogs)); }