From 62e7545c5125c8dd7c74c1b25fe29e6a1f869511 Mon Sep 17 00:00:00 2001 From: Tess Stoddard Date: Tue, 26 May 2026 19:22:19 -0600 Subject: [PATCH] fix: revert version endpoint changes for payments and recurring payments --- .../accessor/payment/PaymentBaseAccessor.java | 11 ----- .../payment/RecurringPaymentBaseAccessor.java | 11 ----- .../web/controller/PaymentsController.java | 15 ++----- .../RecurringPaymentsController.java | 17 ++------ .../controller/PaymentsControllerTest.groovy | 21 +-------- .../RecurringPaymentsControllerTest.groovy | 43 +------------------ 6 files changed, 9 insertions(+), 109 deletions(-) diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java index bf4eb852..abb294e8 100644 --- a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java +++ b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java @@ -194,17 +194,6 @@ public AccessorResponse> list() { throw new AccessorMethodNotImplementedException(); } - /** - * List all payments - Version 20260427 - * - * @return - */ - @GatewayAPI - @API(description = "List all payments version 20260427") - public AccessorResponse> list20260427() { - throw new AccessorMethodNotImplementedException(); - } - /** * Accessor for bill operations * diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/RecurringPaymentBaseAccessor.java b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/RecurringPaymentBaseAccessor.java index 67f104ae..a8895df4 100644 --- a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/RecurringPaymentBaseAccessor.java +++ b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/RecurringPaymentBaseAccessor.java @@ -67,17 +67,6 @@ public AccessorResponse> frequencies() { throw new AccessorMethodNotImplementedException(); } - /** - * List all recurring payments - Version 20260427 - * - * @return - */ - @GatewayAPI - @API(description = "List all recurring payments verion 20260427") - public AccessorResponse> list20260427() { - throw new AccessorMethodNotImplementedException(); - } - /** * List all recurring payments * diff --git a/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java b/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java index 824d9019..0f49df8b 100644 --- a/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java +++ b/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java @@ -90,19 +90,10 @@ public final ResponseEntity createPayment(@RequestBody Payment paymentR return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); } - @SuppressWarnings("MagicNumber") @RequestMapping(value = "/payments", method = RequestMethod.GET) - public final ResponseEntity getPaymentList(HttpServletRequest request) { - return versioned(request) - .defaultVersion(MdxList.class, MdxList.class, payments -> { - AccessorResponse> response = gateway().payments().list(); - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); - }) - .version(20260427, MdxList.class, MdxList.class, payments -> { - AccessorResponse> response = gateway().payments().list20260427(); - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); - }) - .execute(); + public final ResponseEntity> getPaymentList() { + AccessorResponse> response = gateway().payments().list(); + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); } @RequestMapping(value = "/payments/{id}", method = RequestMethod.GET) diff --git a/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/RecurringPaymentsController.java b/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/RecurringPaymentsController.java index f02c9e2c..4aa2fab5 100644 --- a/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/RecurringPaymentsController.java +++ b/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/RecurringPaymentsController.java @@ -13,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import jakarta.servlet.http.HttpServletRequest; - @RestController @RequestMapping(value = "{clientId}", produces = BaseController.MDX_MEDIA) public class RecurringPaymentsController extends BaseController { @@ -25,19 +23,10 @@ public final ResponseEntity> getRecurringPaymentFrequencies() return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); } - @SuppressWarnings("MagicNumber") @RequestMapping(value = "/users/{userId}/recurring_payments", method = RequestMethod.GET) - public final ResponseEntity getRecurringPayments(HttpServletRequest request) { - return versioned(request) - .defaultVersion(MdxList.class, MdxList.class, recurringPayments -> { - AccessorResponse> response = gateway().payments().recurring().list(); - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); - }) - .version(20260427, MdxList.class, MdxList.class, recurringPayments -> { - AccessorResponse> response = gateway().payments().recurring().list20260427(); - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); - }) - .execute(); + public final ResponseEntity> getRecurringPayments() { + AccessorResponse> response = gateway().payments().recurring().list(); + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); } @RequestMapping(value = "/users/{userId}/recurring_payments", method = RequestMethod.POST, consumes = MDX_MEDIA) diff --git a/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy b/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy index ed2187a8..21e0fa88 100644 --- a/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy +++ b/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy @@ -68,11 +68,11 @@ class PaymentsControllerTest extends Specification { BaseController.setGateway(gateway) def payment = new Payment() - def payments = new MdxList().tap { add(payment) } + def payments = new MdxList<>().tap { add(payment) } when: Mockito.doReturn(new AccessorResponse>().withResult(payments)).when(paymentGateway).list() - def response = subject.getPaymentList(buildRequest(null, "application/vnd.mx.mdx.v6+json")) + def response = subject.getPaymentList() then: HttpStatus.OK == response.getStatusCode() @@ -80,23 +80,6 @@ class PaymentsControllerTest extends Specification { verify(paymentGateway).list() || true } - def "getPayments v20260427 interacts with gateway"() { - given: - BaseController.setGateway(gateway) - - def payment = new Payment() - def payments = new MdxList().tap { add(payment) } - - when: - Mockito.doReturn(new AccessorResponse>().withResult(payments)).when(paymentGateway).list20260427() - def response = subject.getPaymentList(buildRequest(null, "application/vnd.mx.mdx.v6+json;version=20260427")) - - then: - HttpStatus.OK == response.getStatusCode() - response.getBody() == payments - verify(paymentGateway).list20260427() || true - } - def "createPayment interacts with gateway"() { given: BaseController.setGateway(gateway) diff --git a/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/RecurringPaymentsControllerTest.groovy b/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/RecurringPaymentsControllerTest.groovy index 440a56b8..bad4a1b7 100644 --- a/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/RecurringPaymentsControllerTest.groovy +++ b/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/RecurringPaymentsControllerTest.groovy @@ -1,20 +1,14 @@ package com.mx.path.model.mdx.web.controller -import static org.mockito.Mockito.mock import static org.mockito.Mockito.spy import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.mx.path.core.context.Session import com.mx.path.gateway.accessor.AccessorResponse import com.mx.path.gateway.api.Gateway import com.mx.path.gateway.api.payment.PaymentGateway import com.mx.path.gateway.api.payment.RecurringPaymentGateway import com.mx.path.model.mdx.model.Frequency import com.mx.path.model.mdx.model.MdxList -import com.mx.path.model.mdx.model.Resources import com.mx.path.model.mdx.model.payment.RecurringPayment import org.mockito.Mockito @@ -22,24 +16,17 @@ import org.springframework.http.HttpStatus import spock.lang.Specification -import jakarta.servlet.http.HttpServletRequest - class RecurringPaymentsControllerTest extends Specification { RecurringPaymentsController subject Gateway gateway PaymentGateway paymentGateway RecurringPaymentGateway recurringPaymentGateway - Gson gson def setup() { subject = new RecurringPaymentsController() recurringPaymentGateway = spy(RecurringPaymentGateway.builder().build()) paymentGateway = PaymentGateway.builder().recurring(recurringPaymentGateway).build() gateway = Gateway.builder().payments(paymentGateway).build() - - GsonBuilder builder = new GsonBuilder() - Resources.registerResources(builder) - gson = builder.create() } def cleanup() { @@ -71,29 +58,13 @@ class RecurringPaymentsControllerTest extends Specification { when: Mockito.doReturn(new AccessorResponse>().withResult(recurringPayments)).when(recurringPaymentGateway).list() - def response = subject.getRecurringPayments(buildRequest(null, "application/vnd.mx.mdx.v6+json")) + def response = subject.getRecurringPayments() then: verify(recurringPaymentGateway).list() || true response.getBody() == recurringPayments } - def "index recurring payments v20260427 invokes gateway"() { - given: - RecurringPayment recurringPayment = new RecurringPayment() - MdxList recurringPayments = new MdxList<>() - recurringPayments.add(recurringPayment) - BaseController.setGateway(gateway) - - when: - Mockito.doReturn(new AccessorResponse>().withResult(recurringPayments)).when(recurringPaymentGateway).list20260427() - def response = subject.getRecurringPayments(buildRequest(null, "application/vnd.mx.mdx.v6+json;version=20260427")) - - then: - verify(recurringPaymentGateway).list20260427() || true - response.getBody() == recurringPayments - } - def "get recurring payment invokes gateway"() { given: RecurringPayment recurringPayment = new RecurringPayment() @@ -155,16 +126,4 @@ class RecurringPaymentsControllerTest extends Specification { verify(recurringPaymentGateway).cancel(recurringPayment.id) || true HttpStatus.NO_CONTENT == response.getStatusCode() } - - def buildRequest(Object body, String contentType) { - HttpServletRequest request = mock(HttpServletRequest.class) - when(request.getReader()).thenReturn(new BufferedReader(new StringReader(gson.toJson(body)))) - if (Session.current() != null) { - when(request.getHeader("mx-session-key")).thenReturn(Session.current().getId()) - } - when(request.getHeaders("Content-Type")).thenReturn(Collections.enumeration([contentType])) - when(request.getHeaders("Accept")).thenReturn(Collections.enumeration([contentType])) - - return request - } }