From 430490d809ce5f30c8e64b14d465d941b6f2401a Mon Sep 17 00:00:00 2001 From: Kwok He Chu <105217051+Kwok-he-Chu@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:03:32 +0100 Subject: [PATCH] Format expiry date nicely --- .../main/java/com/adyen/checkout/model/PaymentModel.java | 4 ++++ .../main/java/com/adyen/checkout/web/AdminController.java | 7 ------- .../src/main/resources/templates/admin/index.html | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/authorisation-adjustment-example/src/main/java/com/adyen/checkout/model/PaymentModel.java b/authorisation-adjustment-example/src/main/java/com/adyen/checkout/model/PaymentModel.java index 800123f..33adaa4 100644 --- a/authorisation-adjustment-example/src/main/java/com/adyen/checkout/model/PaymentModel.java +++ b/authorisation-adjustment-example/src/main/java/com/adyen/checkout/model/PaymentModel.java @@ -31,6 +31,10 @@ public long getDaysUntilExpiry() { return ChronoUnit.DAYS.between(bookingDate, expiryDate); } + public String getFormattedExpiryDate() { + return expiryDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + } + public String getMerchantReference() { return merchantReference; } diff --git a/authorisation-adjustment-example/src/main/java/com/adyen/checkout/web/AdminController.java b/authorisation-adjustment-example/src/main/java/com/adyen/checkout/web/AdminController.java index 47d0f8a..380b8c5 100644 --- a/authorisation-adjustment-example/src/main/java/com/adyen/checkout/web/AdminController.java +++ b/authorisation-adjustment-example/src/main/java/com/adyen/checkout/web/AdminController.java @@ -94,9 +94,7 @@ public ResponseEntity capturePayment(@RequestBody Captur paymentCaptureRequest.setAmount(amount); var response = modificationsApi.captureAuthorisedPayment(payment.getPspReference(), paymentCaptureRequest); - log.info(response.toJson()); - return ResponseEntity.ok(response); } catch (Exception e) { log.error(e.getMessage()); @@ -124,9 +122,7 @@ public ResponseEntity updatePaymentAmount(@RequestB paymentAmountUpdateRequest.setAmount(a); var response = modificationsApi.updateAuthorisedAmount(payment.getPspReference(), paymentAmountUpdateRequest); - log.info(response.toJson()); - return ResponseEntity.ok(response); } catch (Exception e) { log.error(e.getMessage()); @@ -147,11 +143,8 @@ public ResponseEntity reversalPayment(@RequestBody Reve paymentReversalRequest.setMerchantAccount(applicationProperty.getMerchantAccount()); paymentReversalRequest.setReference(payment.getMerchantReference()); - var response = modificationsApi.refundOrCancelPayment(payment.getPspReference(), paymentReversalRequest); - log.info(response.toJson()); - return ResponseEntity.ok(response); } catch (Exception e) { log.error(e.getMessage()); diff --git a/authorisation-adjustment-example/src/main/resources/templates/admin/index.html b/authorisation-adjustment-example/src/main/resources/templates/admin/index.html index ac601a2..2dfd3b7 100644 --- a/authorisation-adjustment-example/src/main/resources/templates/admin/index.html +++ b/authorisation-adjustment-example/src/main/resources/templates/admin/index.html @@ -22,7 +22,7 @@

ADMIN PANEL

  • Amount:  
  • PaymentMethodBrand:  
  • -
  • Expiry Date:   +
  • Expiry Date:     (   days until expiry)