Source:
<code>public CaptureResponse capture(CaptureGatewayRequest request) { String transactionId = request.getTransactionId(); try { StripeCharge stripeCaptureResponse = captureWithPlatform(request); Optional<Long> maybeFee = Optional.empty(); if (stripeCaptureResponse.isPlatformCharge()) { <START> maybeFee = calculateFee(request.getAmount(), stripeCaptureResponse); <END> Long netTransferAmount = maybeFee .map(fee -> calculateNetTransferAmount(request.getAmount(), fee)) .orElse(request.getAmount()); transferToConnectAccount(request, netTransferAmount); } return new CaptureResponse( stripeCaptureResponse.getId(), COMPLETE, maybeFee.orElse(null) ); } catch (GatewayErrorException e) { if (e.getFamily() == CLIENT_ERROR) { StripeErrorResponse stripeErrorResponse = jsonObjectMapper.getObject(e.getResponseFromGateway(), StripeErrorResponse.class); String errorCode = stripeErrorResponse.getError().getCode(); String errorMessage = stripeErrorResponse.getError().getMessage(); logger.error("Capture failed for transaction id {}. Failure code from Stripe: {}, failure message from Stripe: {}. External Charge id: {}. Response code from Stripe: {}", transactionId, errorCode, errorMessage, request.getExternalId(), e.getStatus()); return fromBaseCaptureResponse(new StripeCaptureResponse(transactionId, errorCode, errorMessage), null); } if (e.getFamily() == SERVER_ERROR) { logger.error("Capture failed for transaction id {}. Reason: {}. Status code from Stripe: {}. Charge External Id: {}", transactionId, e.getMessage(), e.getStatus(), request.getExternalId()); GatewayError gatewayError = gatewayConnectionError("An internal server error occurred when capturing charge_external_id: " + request.getExternalId()); return CaptureResponse.fromGatewayError(gatewayError); } logger.info("Unrecognised response status during capture. charge_external_id={}, status={}, response={}", request.getExternalId(), e.getStatus(), e.getResponseFromGateway()); throw new RuntimeException("Unrecognised response status during capture."); } catch (GatewayException e) { return CaptureResponse.fromGatewayError(e.toGatewayError()); } }</code><technical_language>name calculateConnectFee similar</technical_language>

Target:
public CaptureResponse capture(CaptureGatewayRequest request) { String transactionId = request.getTransactionId(); try { StripeCharge stripeCaptureResponse = captureWithPlatform(request); Optional<Long> maybeFee = Optional.empty(); if (stripeCaptureResponse.isPlatformCharge()) { maybeFee = calculateProcessingFee(request.getAmount(), stripeCaptureResponse); Long netTransferAmount = maybeFee .map(fee -> calculateNetTransferAmount(request.getAmount(), fee)) .orElse(request.getAmount()); transferToConnectAccount(request, netTransferAmount); } return new CaptureResponse( stripeCaptureResponse.getId(), COMPLETE, maybeFee.orElse(null) ); } catch (GatewayErrorException e) { if (e.getFamily() == CLIENT_ERROR) { StripeErrorResponse stripeErrorResponse = jsonObjectMapper.getObject(e.getResponseFromGateway(), StripeErrorResponse.class); String errorCode = stripeErrorResponse.getError().getCode(); String errorMessage = stripeErrorResponse.getError().getMessage(); logger.error("Capture failed for transaction id {}. Failure code from Stripe: {}, failure message from Stripe: {}. External Charge id: {}. Response code from Stripe: {}", transactionId, errorCode, errorMessage, request.getExternalId(), e.getStatus()); return fromBaseCaptureResponse(new StripeCaptureResponse(transactionId, errorCode, errorMessage), null); } if (e.getFamily() == SERVER_ERROR) { logger.error("Capture failed for transaction id {}. Reason: {}. Status code from Stripe: {}. Charge External Id: {}", transactionId, e.getMessage(), e.getStatus(), request.getExternalId()); GatewayError gatewayError = gatewayConnectionError("An internal server error occurred when capturing charge_external_id: " + request.getExternalId()); return CaptureResponse.fromGatewayError(gatewayError); } logger.info("Unrecognised response status during capture. charge_external_id={}, status={}, response={}", request.getExternalId(), e.getStatus(), e.getResponseFromGateway()); throw new RuntimeException("Unrecognised response status during capture."); } catch (GatewayException e) { return CaptureResponse.fromGatewayError(e.toGatewayError()); } }