Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;
Expand All @@ -34,8 +35,9 @@
public class CreateUserPaymentMercadoPagoRepositoryAdapter implements CreateUserPaymentRepository {

private static final String EXTERNAL_REFERENCE_PREFIX = "CUOCO_PRO_UPGRADE";
private static final String HOST_DOMAIN = "cuoco.com.ar";
private static final String API_CONTEXT = "/api";

@Value("${shared.base-url}")
private String baseUrl;

private final HttpServletRequest request;
private final MercadoPagoConfig config;
Expand Down Expand Up @@ -64,10 +66,10 @@ public UserPayment execute(UserPayment userPayment) {
return response;

} catch (MPException e) {
log.error("Error while creating preference in MercadoPago SDK", e);
log.error("Error while creating preference in MercadoPago SDK: {}", e.getMessage());
throw new NotAvailableException(ErrorDescription.NOT_AVAILABLE.getValue());
} catch (MPApiException e) {
log.error("Failed to create preference payment with MercadoPago API", e);
log.error("Failed to create preference payment with MercadoPago API: {}", e.getApiResponse());
throw new NotAvailableException(ErrorDescription.NOT_AVAILABLE.getValue());
}
}
Expand All @@ -90,8 +92,7 @@ private PreferenceRequest buildPreference(UserPayment userPayment) {
}

private PreferenceBackUrlsRequest buildBackUrls() {

String baseUrl = request.getRequestURL().toString().replace(request.getRequestURI(), Constants.EMPTY.getValue());
log.info("Creating payment preference backs using URL {}", baseUrl);

return PreferenceBackUrlsRequest.builder()
.success(baseUrl + config.getCallbacks().getSuccess())
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ mercado-pago:
secondary-color: ${MP_BRANDING_SECONDARY_COLOR:#FFA500}
show-mercado-pago-branding: ${MP_BRANDING_ENABLE_MP_BRANDING:false}
shared:
base-url: ${BASE_URL:https://dev.cuoco.com.ar}
email:
no-reply:
name: ${NO_REPLY_NAME:Cuoco}
Expand Down