diff --git a/src/main/java/ch/wisv/events/core/admin/SalesExportSubmission.java b/src/main/java/ch/wisv/events/core/admin/SalesExportSubmission.java index 08b02ea2..e59bd111 100644 --- a/src/main/java/ch/wisv/events/core/admin/SalesExportSubmission.java +++ b/src/main/java/ch/wisv/events/core/admin/SalesExportSubmission.java @@ -49,7 +49,7 @@ public SalesExportSubmission() { this.month = LocalDate.now().getMonthValue()-1; } - this.includedPaymentMethods = Lists.newArrayList(PaymentMethod.IDEAL, PaymentMethod.SOFORT); + this.includedPaymentMethods = Lists.newArrayList(PaymentMethod.IDEAL, PaymentMethod.SOFORT, PaymentMethod.MOLLIE); this.freeProductsIncluded = false; diff --git a/src/main/java/ch/wisv/events/core/model/order/PaymentMethod.java b/src/main/java/ch/wisv/events/core/model/order/PaymentMethod.java index 882b9118..7ee1cc48 100644 --- a/src/main/java/ch/wisv/events/core/model/order/PaymentMethod.java +++ b/src/main/java/ch/wisv/events/core/model/order/PaymentMethod.java @@ -29,6 +29,11 @@ public enum PaymentMethod { */ SOFORT("sofort", cost -> 1.01089 * cost + 0.3025), + /** + * User paid his order via Mollie. + */ + MOLLIE("mollie", cost -> cost), + /** * User paid his order via another method. */ diff --git a/src/main/java/ch/wisv/events/webshop/controller/WebshopPaymentController.java b/src/main/java/ch/wisv/events/webshop/controller/WebshopPaymentController.java index c480ed4a..d1372429 100644 --- a/src/main/java/ch/wisv/events/webshop/controller/WebshopPaymentController.java +++ b/src/main/java/ch/wisv/events/webshop/controller/WebshopPaymentController.java @@ -86,7 +86,11 @@ public String paymentOverview(Model model, RedirectAttributes redirect, @PathVar ); } - return "webshop/payment/index"; + if (orderService.containsOnlyReservable(order)) { + return "webshop/payment/index"; + } + + return "redirect:/checkout/" + order.getPublicReference() + "/payment/mollie"; } catch (EventsException e) { redirect.addFlashAttribute(MODEL_ATTR_ERROR, e.getMessage()); @@ -117,29 +121,16 @@ public String paymentReservation(RedirectAttributes redirect, @PathVariable Stri } /** - * Payment method using iDeal. - * - * @param redirect of type RedirectAttributes - * @param key of type String - * - * @return String string - */ - @GetMapping("/ideal") - public String paymentIdeal(RedirectAttributes redirect, @PathVariable String key) { - return this.payment(redirect, key, PaymentMethod.IDEAL); - } - - /** - * Payment method using SOFORT. + * Payment method using Mollie. * * @param redirect of type RedirectAttributes * @param key of type String * * @return String string */ - @GetMapping("/sofort") - public String paymentSofort(RedirectAttributes redirect, @PathVariable String key) { - return this.payment(redirect, key, PaymentMethod.SOFORT); + @GetMapping("/mollie") + public String paymentMollie(RedirectAttributes redirect, @PathVariable String key) { + return this.payment(redirect, key, PaymentMethod.MOLLIE); } /** diff --git a/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java b/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java index 8ab5e02d..bbc7939f 100644 --- a/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java +++ b/src/main/java/ch/wisv/events/webshop/service/PaymentsServiceImpl.java @@ -25,7 +25,6 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Optional; @@ -129,14 +128,6 @@ protected PaymentRequest createMolliePaymentRequestFromOrder(Order order) { metadata.put("products", productString); - PaymentMethod method; - - if (order.getPaymentMethod() == ch.wisv.events.core.model.order.PaymentMethod.IDEAL) { - method = PaymentMethod.IDEAL; - } else { - method = PaymentMethod.SOFORT; - } - String returnUrl = clientUri + "/return/" + order.getPublicReference(); String webhookUrl = clientUri + "/api/v1/orders/status"; @@ -148,7 +139,6 @@ protected PaymentRequest createMolliePaymentRequestFromOrder(Order order) { Amount paymentAmount = Amount.builder().value(BigDecimal.valueOf(value).setScale(2, RoundingMode.CEILING)).currency("EUR").build(); return PaymentRequest.builder() - .method(Optional.of(List.of(method))) .amount(paymentAmount) .description("W.I.S.V. 'Christiaan Huygens'") .consumerName(Optional.of(order.getOwner().getName())) diff --git a/src/main/resources/static/images/icon-pay-later.jpg b/src/main/resources/static/images/icon-pay-later.jpg deleted file mode 100644 index 4f9cf4d9..00000000 Binary files a/src/main/resources/static/images/icon-pay-later.jpg and /dev/null differ diff --git a/src/main/resources/static/images/icon-pay-later.png b/src/main/resources/static/images/icon-pay-later.png new file mode 100644 index 00000000..98db2398 Binary files /dev/null and b/src/main/resources/static/images/icon-pay-later.png differ diff --git a/src/main/resources/static/images/icon-pay-now.png b/src/main/resources/static/images/icon-pay-now.png new file mode 100644 index 00000000..9d5acba5 Binary files /dev/null and b/src/main/resources/static/images/icon-pay-now.png differ diff --git a/src/main/resources/templates/webshop/payment/index.html b/src/main/resources/templates/webshop/payment/index.html index 710d3922..b9cef744 100644 --- a/src/main/resources/templates/webshop/payment/index.html +++ b/src/main/resources/templates/webshop/payment/index.html @@ -52,49 +52,18 @@

Select payment method

- +
-
IDEAL
- Online payment using your - Dutch bank. Easy, fast and secure!
- - (+ € 0,35 transaction cost) -
- - -
-
-
-
- - -
-
-
-
-
- -
-
-
-
-
SOFORT
- Predominant online banking method in - countries across Europe.
- - (+ € 0,30 + 1,1% transaction cost) +
Pay Online
- Pay now using iDeal
@@ -108,7 +77,7 @@
SOFORT
- Predominant online banking method in
- +
diff --git a/src/test/java/ch/wisv/events/webshop/controller/WebshopPaymentControllerTest.java b/src/test/java/ch/wisv/events/webshop/controller/WebshopPaymentControllerTest.java index b5556e5d..241eef18 100644 --- a/src/test/java/ch/wisv/events/webshop/controller/WebshopPaymentControllerTest.java +++ b/src/test/java/ch/wisv/events/webshop/controller/WebshopPaymentControllerTest.java @@ -37,7 +37,7 @@ public void testPaymentOverview() throws Exception { .andExpect(status().isOk()) .andExpect(view().name("webshop/payment/index")) .andExpect(model().attribute("order", order)) - .andExpect(content().string(containsString("href=\"/checkout/" + order.getPublicReference() + "/payment/ideal\""))) + .andExpect(content().string(containsString("href=\"/checkout/" + order.getPublicReference() + "/payment/mollie\""))) .andExpect(content().string(containsString("href=\"/checkout/" + order.getPublicReference() + "/payment/reservation\""))); } @@ -47,9 +47,8 @@ public void testNonReservableOrder() throws Exception { order.getOrderProducts().get(0).getProduct().setReservable(false); mockMvc.perform(get("/checkout/" + order.getPublicReference() + "/payment")) - .andExpect(status().isOk()) - .andExpect(view().name("webshop/payment/index")) - .andExpect(content().string(not(containsString("href=\"/checkout/" + order.getPublicReference() + "/payment/reservation\"")))); + .andExpect(status().is3xxRedirection()) + .andExpect(redirectedUrl("/checkout/" + order.getPublicReference() + "/payment/mollie")); } @Test @@ -201,61 +200,61 @@ public void testPaymentReservationNotSuitableForCheckout() throws Exception { public void testPaymentIdeal() throws Exception { Order order = this.createPaymentOrder(OrderStatus.ASSIGNED, "events-webshop"); - mockMvc.perform(get("/checkout/" + order.getPublicReference() + "/payment/ideal")) + mockMvc.perform(get("/checkout/" + order.getPublicReference() + "/payment/mollie")) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("https://paymentURL.com")); Order optional = orderService.getByReference(order.getPublicReference()); assertEquals(OrderStatus.PENDING, optional.getStatus()); - assertEquals(PaymentMethod.IDEAL, optional.getPaymentMethod()); + assertEquals(PaymentMethod.MOLLIE, optional.getPaymentMethod()); } @Test - public void testPaymentIdealWrongStatus() throws Exception { + public void testPaymentMollieWrongStatus() throws Exception { Order order = this.createPaymentOrder(OrderStatus.ANONYMOUS, "events-webshop"); - this.requestPaymentCheckoutException(order, "/payment/ideal", "Order is not suitable for checkout!"); + this.requestPaymentCheckoutException(order, "/payment/mollie", "Order is not suitable for checkout!"); } @Test - public void testPaymentIdealWrongCreatedBy() throws Exception { + public void testPaymentMollieWrongCreatedBy() throws Exception { Order order = this.createPaymentOrder(OrderStatus.ASSIGNED, "somebody"); - this.requestPaymentCheckoutException(order, "/payment/ideal", "Order is not suitable for checkout!"); + this.requestPaymentCheckoutException(order, "/payment/mollie", "Order is not suitable for checkout!"); } @Test - public void testPaymentIdealWrongMissingOrder() throws Exception { + public void testPaymentMollieWrongMissingOrder() throws Exception { Order order = this.createPaymentOrder(OrderStatus.ASSIGNED, "somebody"); order.setOwner(null); - this.requestPaymentCheckoutException(order, "/payment/ideal", "Order is not suitable for checkout!"); + this.requestPaymentCheckoutException(order, "/payment/mollie", "Order is not suitable for checkout!"); } @Test - public void testPaymentIdealMissingProducts() throws Exception { + public void testPaymentMollieMissingProducts() throws Exception { Order order = this.createPaymentOrder(OrderStatus.ASSIGNED, "events-webshop"); order.setOrderProducts(new ArrayList<>()); - this.requestPaymentCheckoutException(order, "/payment/ideal", "Order is not suitable for checkout!"); + this.requestPaymentCheckoutException(order, "/payment/mollie", "Order is not suitable for checkout!"); } @Test - public void testPaymentIdealNotFound() throws Exception { + public void testPaymentMollieNotFound() throws Exception { Order order = new Order(); - mockMvc.perform(get("/checkout/" + order.getPublicReference() + "/payment/ideal")) + mockMvc.perform(get("/checkout/" + order.getPublicReference() + "/payment/mollie")) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("/")) .andExpect(flash().attribute("error", "Order with reference " + order.getPublicReference() + " not found!")); } @Test - public void testPaymentIdealNotSuitableForCheckout() throws Exception { + public void testPaymentMollieNotSuitableForCheckout() throws Exception { Order order = this.createPaymentOrder(OrderStatus.PAID, "events-webshop"); - this.requestPaymentCheckoutException(order, "/payment/ideal", "Order with status PAID is not suitable for checkout"); + this.requestPaymentCheckoutException(order, "/payment/mollie", "Order with status PAID is not suitable for checkout"); } private void requestPaymentCheckoutException(Order order, String path, String error) throws Exception {