diff --git a/authorisation-adjustment-example/Controllers/AdminController.cs b/authorisation-adjustment-example/Controllers/AdminController.cs index ba0e7dbd..98e66f4c 100644 --- a/authorisation-adjustment-example/Controllers/AdminController.cs +++ b/authorisation-adjustment-example/Controllers/AdminController.cs @@ -7,8 +7,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -34,73 +34,79 @@ public IActionResult Index() { List hotelPayments = new List(); - // We fetch all hotel payments (regardless whether its authorised or not) that we have stored in our (local) repository and show it. - foreach (KeyValuePair kvp in _repository.HotelPayments) + // We fetch the latest payment update. // TODO, do not filter by datetime + foreach (var kvp in _repository.HotelPayments) { - hotelPayments.Add(kvp.Value); + hotelPayments.Add(_repository.FindLatestHotelPaymentByReference(kvp.Key)); } - hotelPayments.Add(new HotelPaymentModel() - { - Amount = 1234, - Currency = "EUR", - DateTime = DateTime.UtcNow, - PaymentMethodBrand = "scheme", - PaymentMethodType = "mc", - PspReference = "psp-1", - Reference = "ref-1", - ResultCode = "Authorised" - }); - - hotelPayments.Add(new HotelPaymentModel() - { - Amount = 5678, - Currency = "EUR", - DateTime = DateTime.UtcNow, - PaymentMethodBrand = "scheme", - PaymentMethodType = "visa", - PspReference = "psp-2", - Reference = "ref-2", - ResultCode = "Authorised" - }); - - hotelPayments.Add(new HotelPaymentModel() - { - Amount = 9876, - Currency = "EUR", - DateTime = DateTime.UtcNow, - PaymentMethodBrand = "scheme", - PaymentMethodType = "disc", - PspReference = "psp-3", - Reference = "ref-3", - ResultCode = "CAPTURE", - RefusalReason = "aaa" - }); - - - hotelPayments.Add(new HotelPaymentModel() - { - DateTime = DateTime.UtcNow, - PaymentMethodBrand = "scheme", - PaymentMethodType = "mc", - PspReference = "psp-4", - Reference = "ref-4", - ResultCode = "CAPTURE", - RefusalReason = "aaa" - }); + //hotelPayments.Add(new HotelPaymentModel() + //{ + // Amount = 1234, + // Currency = "EUR", + // DateTime = System.DateTime.UtcNow, + // PaymentMethodBrand = "mc", + // PspReference = "psp-1", + // Reference = "ref-1", + // ResultCode = "Authorised" + //}); + + //hotelPayments.Add(new HotelPaymentModel() + //{ + // Amount = 5678, + // Currency = "EUR", + // DateTime = System.DateTime.UtcNow, + // PaymentMethodBrand = "visa", + // PspReference = "psp-2", + // Reference = "ref-2", + // ResultCode = "AUTHORISATION_ADJUSTED", + // OriginalReference = "original-psp-1" + //}); + + //hotelPayments.Add(new HotelPaymentModel() + //{ + // Amount = 9876, + // Currency = "EUR", + // DateTime = System.DateTime.UtcNow, + // PaymentMethodBrand = "visa", + // PspReference = "psp-3", + // Reference = "ref-3", + // ResultCode = "CAPTURE", + // RefusalReason = "aaa", + // OriginalReference = "original-psp-1" + //}); + + + //hotelPayments.Add(new HotelPaymentModel() + //{ + // DateTime = System.DateTime.UtcNow, + // PaymentMethodBrand = "mc", + // PspReference = "psp-4", + // Reference = "ref-4", + // ResultCode = "CAPTURE", + // RefusalReason = "aaa" + //}); ViewBag.HotelPayments = hotelPayments; return View(); } - [HttpGet("admin/result/{status}/{pspReference}")] - public IActionResult Result(string pspReference, string status, [FromQuery(Name = "reason")] string refusalReason) + [Route("admin/details/{reference}")] + public IActionResult Details(string reference) + { + // We fetch all hotel payments (regardless whether its authorised/refused) that we have stored in our local repository and show it. + ViewBag.HotelPayments = _repository.FindByReference(reference).OrderBy(x=>x.DateTime).ToList(); + return View(); + } + + [HttpGet("admin/result/{status}/{reference}")] + public IActionResult Result(string reference, string status, [FromQuery(Name = "reason")] string refusalReason) { string msg; string img; switch (status) { case "received": - msg = $"Request received for {pspReference}."; + msg = $"Request received for Merchant Reference: {reference}. Wait a bit to receive the asynchronous webhook response."; img = "success"; break; default: @@ -114,11 +120,10 @@ public IActionResult Result(string pspReference, string status, [FromQuery(Name return View(); } - [HttpPost("admin/update-payment-amount")] public async Task> UpdatePaymentAmount([FromBody] UpdatePaymentAmountRequest request, CancellationToken cancellationToken = default) { - var hotelPayment = _repository.GetByPspReference(request.PspReference); + var hotelPayment = _repository.FindLatestHotelPaymentByReference(request.Reference); if (hotelPayment == null) { @@ -135,7 +140,7 @@ public async Task> UpdatePaymentAmount IndustryUsage = CreatePaymentAmountUpdateRequest.IndustryUsageEnum.DelayedCharge, }; - var response = await _modificationsService.UpdateAuthorisedAmountAsync(request.PspReference, createPaymentAmountUpdateRequest, cancellationToken: cancellationToken); + var response = await _modificationsService.UpdateAuthorisedAmountAsync(hotelPayment.GetOriginalPspReference(), createPaymentAmountUpdateRequest, cancellationToken: cancellationToken); return Ok(response); } catch (HttpClientException e) @@ -148,7 +153,7 @@ public async Task> UpdatePaymentAmount [HttpPost("admin/capture-payment")] public async Task> CapturePayment([FromBody] CreateCapturePaymentRequest request, CancellationToken cancellationToken = default) { - var hotelPayment = _repository.GetByPspReference(request.PspReference); + var hotelPayment = _repository.FindLatestHotelPaymentByReference(request.Reference); if (hotelPayment == null) { @@ -164,7 +169,7 @@ public async Task> CapturePayment([FromBody Reference = hotelPayment.Reference }; - var response = await _modificationsService.CaptureAuthorisedPaymentAsync(request.PspReference, createPaymentCaptureRequest, cancellationToken: cancellationToken); + var response = await _modificationsService.CaptureAuthorisedPaymentAsync(hotelPayment.GetOriginalPspReference(), createPaymentCaptureRequest, cancellationToken: cancellationToken); return Ok(response); // Note that the response will have a different PSPReference compared to the initial preauthorisation. } catch (HttpClientException e) @@ -177,7 +182,7 @@ public async Task> CapturePayment([FromBody [HttpPost("admin/reversal-payment")] public async Task> ReversalPayment([FromBody] CreateReversalPaymentRequest request, CancellationToken cancellationToken = default) { - var hotelPayment = _repository.GetByPspReference(request.PspReference); + var hotelPayment = _repository.FindLatestHotelPaymentByReference(request.Reference); if (hotelPayment == null) { @@ -192,7 +197,7 @@ public async Task> ReversalPayment([FromBo Reference = hotelPayment.Reference }; - var response = await _modificationsService.RefundOrCancelPaymentAsync(request.PspReference, createPaymentReversalRequest, cancellationToken: cancellationToken); + var response = await _modificationsService.RefundOrCancelPaymentAsync(hotelPayment.GetOriginalPspReference(), createPaymentReversalRequest, cancellationToken: cancellationToken); return Ok(response); } catch (HttpClientException e) diff --git a/authorisation-adjustment-example/Controllers/ApiController.cs b/authorisation-adjustment-example/Controllers/ApiController.cs index ea37a6f7..42f904fb 100644 --- a/authorisation-adjustment-example/Controllers/ApiController.cs +++ b/authorisation-adjustment-example/Controllers/ApiController.cs @@ -71,7 +71,7 @@ public async Task> SubmitAdditionalDetails( } [HttpGet("api/handleRedirect")] - public async Task HandleShoppperRedirect(string payload = null, string redirectResult = null, CancellationToken cancellationToken = default) + public async Task HandleRedirect(string payload = null, string redirectResult = null, CancellationToken cancellationToken = default) { var detailsRequest = new DetailsRequest(); if (!string.IsNullOrWhiteSpace(redirectResult)) @@ -143,7 +143,6 @@ public async Task> PreAuthorisation(PaymentRequest { { "allow3DS2", "true" }, // Required for the 3DS2 flow. { "authorisationType", "PreAuth" }, // Set `authorisationType` to `preAuth`. - { "manualCapture", "true" }, // Set `manualCapture` to `true` so we do not finalize the payment until we capture it. } }; @@ -155,17 +154,28 @@ public async Task> PreAuthorisation(PaymentRequest var hotelPayment = new HotelPaymentModel() { PspReference = response.PspReference, + OriginalReference = null, Reference = response.MerchantReference, - Amount = response.Amount.Value.HasValue ? response.Amount.Value : null, - Currency = response.Amount.Currency, - DateTime = DateTime.UtcNow, + Amount = response.Amount?.Value, + Currency = response.Amount?.Currency, + DateTime = DateTimeOffset.UtcNow, ResultCode = response.ResultCode.ToString(), RefusalReason = response.RefusalReason, PaymentMethodBrand = response.PaymentMethod?.Brand, - PaymentMethodType = response.PaymentMethod?.Type }; - _repository.Insert(hotelPayment); + if (!_repository.HotelPayments.TryGetValue(hotelPayment.Reference, out var list)) + { + // Reference does not exist, let's add it. + _repository.HotelPayments.TryAdd( + hotelPayment.Reference, /// Key: Reference. + new List() { + { + hotelPayment /// Value: . + } + }); + } + return Ok(response); } catch (Adyen.HttpClient.HttpClientException e) diff --git a/authorisation-adjustment-example/Controllers/HomeController.cs b/authorisation-adjustment-example/Controllers/HomeController.cs index 48b30b1d..c7f3c5bb 100644 --- a/authorisation-adjustment-example/Controllers/HomeController.cs +++ b/authorisation-adjustment-example/Controllers/HomeController.cs @@ -26,8 +26,8 @@ public IActionResult Preview(string id) return View(); } - [Route("checkout/{id}")] - public IActionResult Checkout(string id) + [Route("booking/{id}")] + public IActionResult Booking(string id) { ViewBag.PaymentMethod = id; ViewBag.ClientKey = _clientKey; diff --git a/authorisation-adjustment-example/Controllers/WebhookController.cs b/authorisation-adjustment-example/Controllers/WebhookController.cs index 29d3b90d..236a1636 100644 --- a/authorisation-adjustment-example/Controllers/WebhookController.cs +++ b/authorisation-adjustment-example/Controllers/WebhookController.cs @@ -1,5 +1,7 @@ +using Adyen.Model.Nexo; using Adyen.Model.Notification; using Adyen.Util; +using adyen_dotnet_authorisation_adjustment_example.Models; using adyen_dotnet_authorisation_adjustment_example.Options; using adyen_dotnet_authorisation_adjustment_example.Repositories; using Microsoft.AspNetCore.Mvc; @@ -92,29 +94,31 @@ public async Task> Webhooks(NotificationRequest notificatio private Task ProcessAuthorisationNotificationAsync(NotificationRequestItem notification) { - if (!notification.Success) - { - // Perform your business logic here, you would probably want to process the success:false event to update your backend. We log it for now. - _logger.LogInformation($"Webhook unsuccessful: {notification.Reason} \n" + - $"EventCode: {notification.EventCode} \n" + - $"Merchant Reference ::{notification.MerchantReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); - - return Task.CompletedTask; - } - if (notification.EventCode != "AUTHORISATION") { return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + var hotelPayment = new HotelPaymentModel() { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.PspReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = DateTimeOffset.Parse(notification.EventDate), + ResultCode = notification.EventCode, + RefusalReason = notification.Success ? null : notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) + { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful authorisation webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + $"PSP Reference ::{notification.PspReference} \n"); @@ -123,95 +127,104 @@ private Task ProcessAuthorisationNotificationAsync(NotificationRequestItem notif private Task ProcessAuthorisationAdjustmentNotificationAsync(NotificationRequestItem notification) { - if (!notification.Success) - { - // Perform your business logic here, you would probably want to process the success:false event to update your backend. We log it for now. - _logger.LogInformation($"Webhook unsuccessful: {notification.Reason} \n" + - $"EventCode: {notification.EventCode} \n" + - $"Merchant Reference ::{notification.MerchantReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); - - return Task.CompletedTask; - } - if (notification.EventCode != "AUTHORISATION_ADJUSTMENT") { return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + notification.AdditionalData.TryGetValue("bookingDate", out string dateTime); + + var hotelPayment = new HotelPaymentModel() { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.OriginalReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = dateTime == null ? DateTimeOffset.Parse(notification.EventDate) : DateTimeOffset.Parse(dateTime), + ResultCode = notification.EventCode, + RefusalReason = notification.Success ? null : notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) + { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful authorisation adjustment webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); + $"PSP Reference ::{notification.PspReference} \n" + + $"Original Reference ::{notification.OriginalReference} \n"); return Task.CompletedTask; } private Task ProcessCaptureNotificationAsync(NotificationRequestItem notification) { - if (!notification.Success) - { - // Perform your business logic here, you would probably want to process the success:false event to update your backend. We log it for now. - _logger.LogInformation($"Webhook unsuccessful: {notification.Reason} \n" + - $"EventCode: {notification.EventCode} \n" + - $"Merchant Reference ::{notification.MerchantReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); - - return Task.CompletedTask; - } - if (notification.EventCode != "CAPTURE") { return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + var hotelPayment = new HotelPaymentModel() { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.OriginalReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = DateTimeOffset.Parse(notification.EventDate), + ResultCode = notification.EventCode, + RefusalReason = notification.Success ? null : notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) + { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful capture webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); + $"PSP Reference ::{notification.PspReference} \n" + + $"Original Reference ::{notification.OriginalReference} \n"); return Task.CompletedTask; } private Task ProcessCaptureFailedNotificationAsync(NotificationRequestItem notification) { - if (!notification.Success) - { - // Perform your business logic here, you would probably want to process the success:false event to update your backend. We log it for now. - _logger.LogInformation($"Webhook unsuccessful: {notification.Reason} \n" + - $"EventCode: {notification.EventCode} \n" + - $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); - - return Task.CompletedTask; - } - if (notification.EventCode != "CAPTURE_FAILED") { return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + var hotelPayment = new HotelPaymentModel() { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.OriginalReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = DateTimeOffset.Parse(notification.EventDate), + ResultCode = notification.EventCode, + RefusalReason = notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) + { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful capture webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); + $"PSP Reference ::{notification.PspReference} \n" + + $"Original Reference ::{notification.OriginalReference} \n"); return Task.CompletedTask; } @@ -235,49 +248,63 @@ private Task ProcessCancelOrRefundNotificationAsync(NotificationRequestItem noti return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + var hotelPayment = new HotelPaymentModel() { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.OriginalReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = DateTimeOffset.Parse(notification.EventDate), + ResultCode = notification.EventCode, + RefusalReason = notification.Success ? null : notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) + { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful capture webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); + $"PSP Reference ::{notification.PspReference} \n" + + $"Original Reference ::{notification.OriginalReference} \n"); return Task.CompletedTask; } private Task ProcessRefundFailedNotificationAsync(NotificationRequestItem notification) { - if (!notification.Success) - { - // Perform your business logic here, you would probably want to process the success:false event to update your backend. We log it for now. - _logger.LogInformation($"Webhook unsuccessful: {notification.Reason} \n" + - $"EventCode: {notification.EventCode} \n" + - $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); - - return Task.CompletedTask; - } - if (notification.EventCode != "REFUND_FAILED") { return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + var hotelPayment = new HotelPaymentModel() + { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.OriginalReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = DateTimeOffset.Parse(notification.EventDate), + ResultCode = notification.EventCode, + RefusalReason = notification.Success ? null : notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful capture webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); + $"PSP Reference ::{notification.PspReference} \n" + + $"Original Reference ::{notification.OriginalReference} \n"); return Task.CompletedTask; } @@ -285,33 +312,34 @@ private Task ProcessRefundFailedNotificationAsync(NotificationRequestItem notifi private Task ProcessRefundedReversedNotificationAsync(NotificationRequestItem notification) { - if (!notification.Success) - { - // Perform your business logic here, you would probably want to process the success:false event to update your backend. We log it for now. - _logger.LogInformation($"Webhook unsuccessful: {notification.Reason} \n" + - $"EventCode: {notification.EventCode} \n" + - $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); - - return Task.CompletedTask; - } - if (notification.EventCode != "REFUNDED_REVERSED") { return Task.CompletedTask; } - if (!_repository.HotelPayments.TryGetValue(notification.PspReference, out Models.HotelPaymentModel model)) + var hotelPayment = new HotelPaymentModel() { + PspReference = notification.PspReference, + OriginalReference = notification.OriginalReference, + Reference = _repository.FindReferenceByPspReference(notification.OriginalReference), + Amount = notification.Amount?.Value, + Currency = notification.Amount?.Currency, + DateTime = DateTimeOffset.Parse(notification.EventDate), + ResultCode = notification.EventCode, + RefusalReason = notification.Success ? null : notification.Reason, + PaymentMethodBrand = notification.PaymentMethod + }; + + if (!_repository.Insert(hotelPayment)) + { + _logger.LogInformation($"Could not insert {notification.PspReference}"); return Task.CompletedTask; } - // Perform your business logic here, you would probably want to process the success:true event to update your backend. We log it for now. - _logger.LogInformation($"Received successful capture webhook::\n" + + _logger.LogInformation($"Received {(notification.Success ? "successful" : "unsuccessful")} {notification.EventCode} webhook::\n" + $"Merchant Reference ::{notification.MerchantReference} \n" + - $"Original Reference ::{notification.OriginalReference} \n" + - $"PSP Reference ::{notification.PspReference} \n"); + $"PSP Reference ::{notification.PspReference} \n" + + $"Original Reference ::{notification.OriginalReference} \n"); return Task.CompletedTask; } diff --git a/authorisation-adjustment-example/Models/HotelPaymentModel.cs b/authorisation-adjustment-example/Models/HotelPaymentModel.cs index 09df8340..809e5732 100644 --- a/authorisation-adjustment-example/Models/HotelPaymentModel.cs +++ b/authorisation-adjustment-example/Models/HotelPaymentModel.cs @@ -4,29 +4,50 @@ namespace adyen_dotnet_authorisation_adjustment_example.Models { public class HotelPaymentModel { - // PspReference provided by Adyen. + /// PspReference provided by Adyen, you can receive this in the response of the call. public string PspReference { get; set; } - // Reference provided by the merchant. + /// This is a `PspReference` that is referring to the initial `PspReference` of the payment. + /// In this case, it refers to the PspREference of the Pre-Authorisation payment from . + public string OriginalReference { get; set; } + + /// Reference provided by the merchant (you), we generate a random GUID when is called. public string Reference { get; set; } - // Date of payment. - public DateTime DateTime { get; set; } + /// Date of payment, the offset is stored with its timezone. + public DateTimeOffset DateTime { get; set; } - // Amount. + /// Amount. public long? Amount { get; set; } + /// Currency. public string Currency { get; set; } - // Result. + /// Result. public string ResultCode { get; set; } - public string RefusalReason { get; set; } // Populated when resultcode is not authorised. + public string RefusalReason { get; set; } // Populated when ResultCode is not authorised (for example: refused), or when a webhook is unsuccessful - // Payment method used. + /// Payment method. public string PaymentMethodBrand { get; set; } // PaymentMethod brand (e.g. `mc`). - public string PaymentMethodType { get; set; } // PaymentMethod type (e.g. `scheme`). - - #region Amount/RefusalReasons/PaymentMethod show logic + public string GetOriginalPspReference() + { + return string.IsNullOrWhiteSpace(OriginalReference) ? PspReference : OriginalReference; + } + + public bool IsEqual(HotelPaymentModel other) + { + return PspReference == other.PspReference + && OriginalReference == other.OriginalReference + && Reference == other.Reference + && DateTime.Equals(other.DateTime) + && Amount == other.Amount + && Currency == other.Currency + && ResultCode == other.ResultCode + && RefusalReason == other.RefusalReason + && PaymentMethodBrand == other.PaymentMethodBrand; + } + + #region Amount/RefusalReasons/PaymentMethod - Methods are used to show elements on frontend. public bool IsAmountShown() { return Amount != null && !string.IsNullOrWhiteSpace(Currency); @@ -37,15 +58,10 @@ public bool IsRefusalReasonShown() return !string.IsNullOrWhiteSpace(RefusalReason); } - public bool IsPaymentMethodShown() - { - return !string.IsNullOrWhiteSpace(PaymentMethodBrand) && !string.IsNullOrWhiteSpace(PaymentMethodType); - } - #endregion - #region ResultCodes logic - + #region ResultCodes - Methods are used to show elements on frontend. + public bool IsAuthorised() { return ResultCode is "Authorised" or "AUTHORISATION"; @@ -60,7 +76,6 @@ public bool IsCaptured() { return ResultCode is "CAPTURE"; } - #endregion } } \ No newline at end of file diff --git a/authorisation-adjustment-example/Models/Requests/CreateCapturePaymentRequest.cs b/authorisation-adjustment-example/Models/Requests/CreateCapturePaymentRequest.cs index 6c98dd93..a0cc0b8c 100644 --- a/authorisation-adjustment-example/Models/Requests/CreateCapturePaymentRequest.cs +++ b/authorisation-adjustment-example/Models/Requests/CreateCapturePaymentRequest.cs @@ -2,6 +2,6 @@ { public class CreateCapturePaymentRequest { - public string PspReference { get; init; } + public string Reference { get; init; } } } \ No newline at end of file diff --git a/authorisation-adjustment-example/Models/Requests/CreateReversalPaymentRequest.cs b/authorisation-adjustment-example/Models/Requests/CreateReversalPaymentRequest.cs index 5c5876f0..74ca5bc9 100644 --- a/authorisation-adjustment-example/Models/Requests/CreateReversalPaymentRequest.cs +++ b/authorisation-adjustment-example/Models/Requests/CreateReversalPaymentRequest.cs @@ -2,6 +2,6 @@ { public class CreateReversalPaymentRequest { - public string PspReference { get; init; } + public string Reference { get; init; } } } \ No newline at end of file diff --git a/authorisation-adjustment-example/Models/Requests/UpdatePaymentAmountRequest.cs b/authorisation-adjustment-example/Models/Requests/UpdatePaymentAmountRequest.cs index 3ed6fd1e..3bc5285f 100644 --- a/authorisation-adjustment-example/Models/Requests/UpdatePaymentAmountRequest.cs +++ b/authorisation-adjustment-example/Models/Requests/UpdatePaymentAmountRequest.cs @@ -2,7 +2,7 @@ { public class UpdatePaymentAmountRequest { - public string PspReference { get; init; } + public string Reference { get; init; } public long Amount { get; init; } } } \ No newline at end of file diff --git a/authorisation-adjustment-example/Properties/launchSettings.json b/authorisation-adjustment-example/Properties/launchSettings.json index 1bb7bfa9..f5240b35 100644 --- a/authorisation-adjustment-example/Properties/launchSettings.json +++ b/authorisation-adjustment-example/Properties/launchSettings.json @@ -14,7 +14,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://localhost:8080" + "applicationUrl": "https://localhost:5001;http://localhost:8080" }, "IIS Express": { "commandName": "IISExpress", diff --git a/authorisation-adjustment-example/Repositories/HotelPaymentRepository.cs b/authorisation-adjustment-example/Repositories/HotelPaymentRepository.cs index 70a06de5..2a51c536 100644 --- a/authorisation-adjustment-example/Repositories/HotelPaymentRepository.cs +++ b/authorisation-adjustment-example/Repositories/HotelPaymentRepository.cs @@ -1,72 +1,139 @@ using adyen_dotnet_authorisation_adjustment_example.Models; -using System.Collections.Concurrent; +using System; +using System.Collections.Generic; +using System.Linq; namespace adyen_dotnet_authorisation_adjustment_example.Repositories { /// - /// Acts as a local (memory) repository to store s. + /// Acts as a local (in-memory) repository to store s by . /// public interface IHotelPaymentRepository - { + { /// - /// Dictionary of all payments for the hotel bookings by . - /// Key: | Value: . + /// Dictionary of all payments for the hotel bookings by . + /// Key: | + /// Value: . /// - public ConcurrentDictionary HotelPayments { get; } + public Dictionary> HotelPayments { get; } /// /// Insert into the dictionary with the as its key. /// /// . - /// True if inserted dictionary. + /// True if inserted. bool Insert(HotelPaymentModel hotelPayment); /// - /// Gets by . + /// Gets s by . /// - /// . + /// . + /// . + IEnumerable FindByReference(string reference); + + /// + /// Gets latest version of by . + /// + /// . /// . - HotelPaymentModel GetByPspReference(string pspReference); + HotelPaymentModel FindLatestHotelPaymentByReference(string reference); + + /// + /// Finds by . + /// + /// . + /// . + string FindReferenceByPspReference(string pspReference); /// - /// Gets by . + /// Finds the initial preauthorisation . /// /// . /// . - HotelPaymentModel GetByReference(string reference); + HotelPaymentModel FindPreAuthorisationHotelPayment(string reference); } public class HotelPaymentRepository : IHotelPaymentRepository { - public ConcurrentDictionary HotelPayments { get; } + public Dictionary> HotelPayments { get; } public HotelPaymentRepository() { - HotelPayments = new ConcurrentDictionary(); + HotelPayments = new Dictionary>(); } public bool Insert(HotelPaymentModel hotelPayment) { - return HotelPayments.TryAdd(hotelPayment.PspReference, hotelPayment); + // If `Reference` is not specified, do nothing. + if (string.IsNullOrWhiteSpace(hotelPayment.Reference)) + { + return false; + } + + // Check if `Reference` is already in the list. + if (!HotelPayments.TryGetValue(hotelPayment.Reference, out var list)) + { + // `Reference` does not exist, do nothing. + return false; + } + + // Check if `PspReference` already exists. + var existingHotelPayment = list.FirstOrDefault(x => x.PspReference == hotelPayment.PspReference); + if (existingHotelPayment is null) + { + // If it doesn't exists, we add it. + list.Add(hotelPayment); + return true; + } + + // If the values are exactly the same. We consider it a duplicate, and we do not add anything to the list. + if (hotelPayment.Equals(existingHotelPayment)) + { + return false; + } + + // Add the hotel payment. + list.Add(hotelPayment); + return true; + } + + public IEnumerable FindByReference(string reference) + { + if (!HotelPayments.TryGetValue(reference, out List result)) + return Enumerable.Empty(); + + return result; } - public HotelPaymentModel GetByPspReference(string pspReference) + public HotelPaymentModel FindLatestHotelPaymentByReference(string reference) { - if (!HotelPayments.TryGetValue(pspReference, out var hotelPaymentModel)) - return null; - return hotelPaymentModel; + List result = FindByReference(reference) + .OrderBy(x=>x.DateTime) + .ToList(); + return result.LastOrDefault(); } - public HotelPaymentModel GetByReference(string reference) + public string FindReferenceByPspReference(string pspReference) { foreach (var kvp in HotelPayments) { - if (kvp.Value.Reference == reference) + foreach (HotelPaymentModel hotelPayment in kvp.Value) { - return kvp.Value; + if (hotelPayment.GetOriginalPspReference() == pspReference) + { + return hotelPayment.Reference; + } } } return null; } + + public HotelPaymentModel FindPreAuthorisationHotelPayment(string reference) + { + if (!HotelPayments.TryGetValue(reference, out List result)) + return null; + + return result.FirstOrDefault(); + } } } \ No newline at end of file diff --git a/authorisation-adjustment-example/Views/Admin/Details.cshtml b/authorisation-adjustment-example/Views/Admin/Details.cshtml new file mode 100644 index 00000000..71b99d6f --- /dev/null +++ b/authorisation-adjustment-example/Views/Admin/Details.cshtml @@ -0,0 +1,67 @@ +@using Adyen.Model.Recurring; +@using adyen_dotnet_authorisation_adjustment_example.Models; +@{ + ViewData["Title"] = "Adyen Admin Panel Details"; + List hotelPayments = ViewBag.HotelPayments; +} + +
+
+ @{ + if (hotelPayments == null || !hotelPayments.Any()) + { +

+ + No payments are stored. You can make a card payment in the Booking View. + +

+ } + else + { + @foreach(var payment in hotelPayments) + { + double amount = (payment.Amount ?? 0.0) / 100L; +
    +
  • Reference:   @payment.Reference
  • +
  • Result Code:   @payment.ResultCode
  • +
  • PspReference:   @payment.PspReference
  • + @if(!string.IsNullOrWhiteSpace(payment.OriginalReference)) + { +
  • Original PspReference:   @payment.OriginalReference
  • + } + + @if (payment.IsRefusalReasonShown()) + { +
  • + Refusal Reason:   @payment.RefusalReason +
  • + } + + @if (payment.IsAmountShown()) + { +
  • + + Payment Amount:   @payment.Currency @amount +
  • + +
  • + Payment Method Brand:   @payment.PaymentMethodBrand +
  • + } + +
  • DateTime:   @payment.DateTime
  • +
+ } + } + } +
+
+ + + + + + + + + \ No newline at end of file diff --git a/authorisation-adjustment-example/Views/Admin/Index.cshtml b/authorisation-adjustment-example/Views/Admin/Index.cshtml index 274f575f..6247bf59 100644 --- a/authorisation-adjustment-example/Views/Admin/Index.cshtml +++ b/authorisation-adjustment-example/Views/Admin/Index.cshtml @@ -1,7 +1,7 @@ @using Adyen.Model.Recurring; @using adyen_dotnet_authorisation_adjustment_example.Models; @{ - ViewData["Title"] = "Adyen Hotel Admin View"; + ViewData["Title"] = "Adyen Admin Panel"; List hotelPayments = ViewBag.HotelPayments; } @@ -9,7 +9,7 @@

ADMIN PANEL

-

The admin panel shows all payments for hotel bookings. In order to perform actions on the payments, follow the readme to ensure that you have setup your webhooks correctly to receive payment updates asynchronously.

+

The admin panel shows all payments for hotel bookings. In order to perform actions on the payments, follow the readme to ensure that you have set up your webhooks correctly to receive payment updates asynchronously.

Select a hotel payment to increase/decrease the payment amount.

Note: The default expiry period can also be extended and ensures that Adyen does not automatically expire the authorisation. You can find the tables which includes expiry information from the following supported major card schemes on the documentation page.

@@ -30,69 +30,121 @@ @foreach(var payment in hotelPayments) { double amount = (payment.Amount ?? 0.0) / 100L; -
-
    -
  • Result Code: @payment.ResultCode
  • -
  • PspReference: @payment.PspReference
  • -
  • Reference: @payment.Reference
  • +
      +
    • Reference:   @payment.Reference
    • +
    • Result Code:   @payment.ResultCode
    • +
    • PspReference:   @payment.PspReference
    • + @if(!string.IsNullOrWhiteSpace(payment.OriginalReference)) + { +
    • Original PspReference:   @payment.OriginalReference
    • + } - @if (payment.IsRefusalReasonShown()) - { -
    • - Refusal Reason: @payment.RefusalReason -
    • - } - - @if (payment.IsAmountShown()) - { -
    • - - Payment Amount: @payment.Currency @amount -
    • - - @if (payment.IsPaymentMethodShown()) - { -
    • - Payment Method Brand/Type: @payment.PaymentMethodBrand / @payment.PaymentMethodType -
    • - } - } + @if (payment.IsRefusalReasonShown()) + { +
    • + Refusal Reason:   @payment.RefusalReason +
    • + } -
    • DateTime: @payment.DateTime
    • + @if (payment.IsAmountShown()) + { +
    • + + Payment Amount:   @payment.Currency @amount +
    • - @if (payment.IsAuthorised() || payment.IsAuthorisedAdjusted()) + Payment Method Brand:   @payment.PaymentMethodBrand +
    • + } + +
    • DateTime:   @payment.DateTime
    • + +
    • + @{ + bool showAdjustButton = (payment.IsAuthorised() || payment.IsAuthorisedAdjusted()) + && !payment.IsRefusalReasonShown(); + + if (showAdjustButton) {
      Adjust amount: - +
      } -
    • + else + { +
      + Adjust amount: + + +
      + } + } + -
    • - @if (payment.IsAuthorised() || payment.IsAuthorisedAdjusted()) +
    • + @{ + if (showAdjustButton) {
      - +
      - + } + else + { +
      + + + +
      + } + } + @{ + bool showCaptureButton = (payment.IsAuthorised() || payment.IsAuthorisedAdjusted()) + && !payment.IsRefusalReasonShown(); + + if (showCaptureButton) + {
      - +
      } + else + { + +
      + + +
      + } + } + + @{ + bool showReversalButton = (payment.IsAuthorised() || payment.IsAuthorisedAdjusted() || payment.IsCaptured()) + && !payment.IsRefusalReasonShown(); -
      - - -
      -
    • -
    -
+ if (showReversalButton) + { +
+ + +
+ } + else + { +
+ + +
+ } + } + + } } } diff --git a/authorisation-adjustment-example/Views/Admin/Result.cshtml b/authorisation-adjustment-example/Views/Admin/Result.cshtml index 34720192..0f651c55 100644 --- a/authorisation-adjustment-example/Views/Admin/Result.cshtml +++ b/authorisation-adjustment-example/Views/Admin/Result.cshtml @@ -8,18 +8,15 @@ var SvgImg = ViewBag.Img + ".svg"; } @ViewBag.Img - @if (ViewBag.Status != "failed" || ViewBag.Status != "error") - { - - } +

@ViewBag.Msg

@if (ViewBag.Status == "error") { -

- Please review response in console and refer to - Response handling. -

+

+ Please review response in console and refer to + refusal reasons. +

} - Return to Admin View + Return to Admin Panel
diff --git a/authorisation-adjustment-example/Views/Home/Checkout.cshtml b/authorisation-adjustment-example/Views/Home/Booking.cshtml similarity index 93% rename from authorisation-adjustment-example/Views/Home/Checkout.cshtml rename to authorisation-adjustment-example/Views/Home/Booking.cshtml index 90b4dba1..a3b9660d 100644 --- a/authorisation-adjustment-example/Views/Home/Checkout.cshtml +++ b/authorisation-adjustment-example/Views/Home/Booking.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Adyen Checkout Cart"; + ViewData["Title"] = "Adyen Booking Cart"; } @* Hidden divs with data passed from the server *@ diff --git a/authorisation-adjustment-example/Views/Home/Preview.cshtml b/authorisation-adjustment-example/Views/Home/Preview.cshtml index 279f3256..ac7c2f66 100644 --- a/authorisation-adjustment-example/Views/Home/Preview.cshtml +++ b/authorisation-adjustment-example/Views/Home/Preview.cshtml @@ -1,9 +1,9 @@ @{ - ViewData["Title"] = "Adyen Checkout Preview"; + ViewData["Title"] = "Adyen Booking Preview"; }
-

Checkout Details

+

Booking Details

  • @@ -16,7 +16,7 @@ diff --git a/authorisation-adjustment-example/wwwroot/css/site.css b/authorisation-adjustment-example/wwwroot/css/site.css index a1a8d7ce..879971ba 100644 --- a/authorisation-adjustment-example/wwwroot/css/site.css +++ b/authorisation-adjustment-example/wwwroot/css/site.css @@ -42,7 +42,6 @@ a:hover { left: 0; margin-bottom: 24px; padding: 14px 26px; - position: fixed; text-align: center; top: 0; width: 100%; @@ -92,10 +91,7 @@ a:hover { /* Index page */ .main-container { - margin: auto; max-width: 1048px; - padding: 16px 16px; - display: flex; flex-direction: column; } @@ -438,15 +434,19 @@ a:hover { } .adminList { - display: inline-block; - background-color: #f4ffc8; - padding: 12px 12px 12px 12px; + display: inline-grid; + background-color: #f6ffd4; + padding: 12px 8px 12px 8px; list-style-type: decimal; border: 2px solid #0e0e0e; + border-radius: 8px; + margin-right: 12px; } .adminList li { + display: flex; list-style-type: none; + padding: 4px 64px 4px 4px; } .display-flex { @@ -457,7 +457,7 @@ a:hover { .adjustSubmitButton { background-color: #dbae00; color: white; - padding: 8px 12px; + padding: 6px 32px 6px 32px; margin: 10px; border: none; cursor: pointer; @@ -468,11 +468,19 @@ a:hover { .adjustSubmitButton:hover { background-color: #dbae00; - border: 2px solid #b69100; + border: 2px solid #db7900; border-radius: 8px; transition: border-color 0.15s linear; } +.adjustSubmitButton:disabled, +adjustSubmitButton[disabled=disabled] { + border: 2px solid #cccccc; + background-color: #cccccc; + color: #999999; + pointer-events: none; +} + .adjustAmountText { padding: 4px; border: 1px solid #ccc; @@ -481,15 +489,24 @@ a:hover { outline: none; } +.adjustAmountText:disabled, +adjustAmountText[disabled=disabled] { + border: 2px solid #cccccc; + background-color: #cccccc; + color: #999999; + pointer-events: none; +} + .adjustAmountText:focus { border: 2px solid #dbae00; } + /* `Extend`/`Capture`/`Reversal` submit button */ .submitButton { background-color: #0abf53; color: white; - padding: 8px 12px; + padding: 6px 24px 6px 24px; margin: 10px; border: none; cursor: pointer; @@ -505,4 +522,36 @@ a:hover { transition: border-color 0.15s linear; } -/* end Admin panel view */ \ No newline at end of file +.submitButton:disabled, +submitButton[disabled=disabled]{ + border: 2px solid #cccccc; + background-color: #cccccc; + color: #999999; + pointer-events: none; +} + +/* end Admin panel view */ + +/* start Admin panel details view */ + +.details-panel-payment-container { + background-color: #fafff3; + padding: 64px 4px 16px 4px; +} + +.detailsList { + display: grid; + background-color: #f6ffd4; + padding: 12px 8px 12px 8px; + list-style-type: decimal; + border: 2px solid #0e0e0e; + border-radius: 8px; + margin-right: 12px; +} + +.detailsList li { + list-style-type: none; + padding: 4px 64px 4px 4px; +} + +/* end Admin panel details view*/ \ No newline at end of file diff --git a/authorisation-adjustment-example/wwwroot/images/musicnote.svg b/authorisation-adjustment-example/wwwroot/images/musicnote.svg index cdd8196c..a05050d9 100644 --- a/authorisation-adjustment-example/wwwroot/images/musicnote.svg +++ b/authorisation-adjustment-example/wwwroot/images/musicnote.svg @@ -1,4 +1,5 @@ - - + + + \ No newline at end of file diff --git a/authorisation-adjustment-example/wwwroot/images/mymusic-logo.svg b/authorisation-adjustment-example/wwwroot/images/mymusic-logo.svg index 0d5de7e4..fbbdba3f 100644 --- a/authorisation-adjustment-example/wwwroot/images/mymusic-logo.svg +++ b/authorisation-adjustment-example/wwwroot/images/mymusic-logo.svg @@ -1,20 +1,20 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/authorisation-adjustment-example/wwwroot/js/adminpanel-capturePayment-bindings.js b/authorisation-adjustment-example/wwwroot/js/adminpanel-capturePayment-bindings.js index fa5c01dc..a49971b2 100644 --- a/authorisation-adjustment-example/wwwroot/js/adminpanel-capturePayment-bindings.js +++ b/authorisation-adjustment-example/wwwroot/js/adminpanel-capturePayment-bindings.js @@ -11,17 +11,17 @@ async function sendPostRequest(url, data) { return await res.json(); } -// Captures payment of the given pspReference -async function sendCapturePaymentRequest(pspReference) { +// Captures payment of the given reference +async function sendCapturePaymentRequest(reference) { try { - const res = await sendPostRequest("/admin/capture-payment", { pspReference: pspReference}); + const res = await sendPostRequest("/admin/capture-payment", { reference: reference}); console.log(res); switch (res.status) { case "received": - window.location.href = "admin/result/received/" + pspReference; + window.location.href = "admin/result/received/" + reference; break; default: - window.location.href = "admin/result/error" + pspReference; + window.location.href = "admin/result/error" + reference; break; }; } catch (error) { @@ -38,9 +38,9 @@ function bindCapturePaymentFormButtons() { event.preventDefault(); var formData = new FormData(event.target); - var pspReference = formData.get('pspReference'); + var reference = formData.get('reference'); - await sendCapturePaymentRequest(pspReference); + await sendCapturePaymentRequest(reference); }); } } diff --git a/authorisation-adjustment-example/wwwroot/js/adminpanel-reversalPayment-bindings.js b/authorisation-adjustment-example/wwwroot/js/adminpanel-reversalPayment-bindings.js index c0d4543f..12e3b385 100644 --- a/authorisation-adjustment-example/wwwroot/js/adminpanel-reversalPayment-bindings.js +++ b/authorisation-adjustment-example/wwwroot/js/adminpanel-reversalPayment-bindings.js @@ -11,17 +11,17 @@ async function sendPostRequest(url, data) { return await res.json(); } -// Captures payment of the given pspReference -async function sendReversalPaymentRequest(pspReference) { +// Captures payment of the given reference +async function sendReversalPaymentRequest(reference) { try { - const res = await sendPostRequest("/admin/reversal-payment", { pspReference: pspReference}); + const res = await sendPostRequest("/admin/reversal-payment", { reference: reference}); console.log(res); switch (res.status) { case "received": - window.location.href = "admin/result/received/" + pspReference; + window.location.href = "admin/result/received/" + reference; break; default: - window.location.href = "admin/result/error" + pspReference; + window.location.href = "admin/result/error" + reference; break; }; } catch (error) { @@ -38,9 +38,9 @@ function bindReversalPaymentFormButtons() { event.preventDefault(); var formData = new FormData(event.target); - var pspReference = formData.get('pspReference'); + var reference = formData.get('reference'); - await sendReversalPaymentRequest(pspReference); + await sendReversalPaymentRequest(reference); }); } } diff --git a/authorisation-adjustment-example/wwwroot/js/adminpanel-updatePaymentAmount-bindings.js b/authorisation-adjustment-example/wwwroot/js/adminpanel-updatePaymentAmount-bindings.js index 89f0d98c..d57be34f 100644 --- a/authorisation-adjustment-example/wwwroot/js/adminpanel-updatePaymentAmount-bindings.js +++ b/authorisation-adjustment-example/wwwroot/js/adminpanel-updatePaymentAmount-bindings.js @@ -11,17 +11,17 @@ async function sendPostRequest(url, data) { return await res.json(); } -// Updates payment amount of the given pspReference -async function sendUpdatePaymentAmountRequest(pspReference, amount) { +// Updates payment amount of the given reference +async function sendUpdatePaymentAmountRequest(reference, amount) { try { - const res = await sendPostRequest("/admin/update-payment-amount", { pspReference: pspReference, amount: amount}); + const res = await sendPostRequest("/admin/update-payment-amount", { reference: reference, amount: amount}); console.log(res); switch (res.status) { case "received": - window.location.href = "admin/result/received/" + pspReference; + window.location.href = "admin/result/received/" + reference; break; default: - window.location.href = "admin/result/error" + pspReference; + window.location.href = "admin/result/error" + reference; break; }; } catch (error) { @@ -39,9 +39,9 @@ function bindUpdatePaymentAmountFormButtons() { var formData = new FormData(event.target); var amount = formData.get('amount') * 100; // Multiple by 100, so that `12.34` EUR becomes `1234` in minor units - var pspReference = formData.get('pspReference'); + var reference = formData.get('reference'); - await sendUpdatePaymentAmountRequest(pspReference, amount); + await sendUpdatePaymentAmountRequest(reference, amount); }); } } @@ -56,9 +56,9 @@ function bindExtendPaymentFormButtons() { var formData = new FormData(event.target); var amount = formData.get('amount') * 100; // Multiple by 100, so that `12.34` EUR becomes `1234` in minor units - var pspReference = formData.get('pspReference'); + var reference = formData.get('reference'); - await sendUpdatePaymentAmountRequest(pspReference, amount); + await sendUpdatePaymentAmountRequest(reference, amount); }); } } diff --git a/authorisation-adjustment-example/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css b/authorisation-adjustment-example/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css index 68b84f84..7efa179f 100644 --- a/authorisation-adjustment-example/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css +++ b/authorisation-adjustment-example/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css @@ -17,8 +17,8 @@ html { .container { width: 100%; - padding-right: 15px; - padding-left: 15px; + padding-right: 16px; + padding-left: 16px; margin-right: auto; margin-left: auto; }