-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AD-219 Enhance Error Handling for Payment and Order Placement Steps #384
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71b6e5d
AD-219 Error handling improvements.
Lukasz756 619ff19
AD-219 Error handler improvements, controllers and services fixes.
Lukasz756 de723be
AD-219 Error handler improvements. Added AdyenControllerException wit…
Lukasz756 2359d59
AD-219 Code reformat & minor fixes.
Lukasz756 1475283
AD-219 Code reformat & minor fixes.
Lukasz756 360d1c4
Merge branch 'develop' into feature/AD-219-1
Lukasz756 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...src/com/adyen/commerce/controllers/exceptionhandlers/AdyenControllerExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.adyen.commerce.controllers.exceptionhandlers; | ||
|
||
import com.adyen.commerce.exceptions.AdyenControllerException; | ||
import com.adyen.commerce.response.ErrorResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class AdyenControllerExceptionHandler { | ||
|
||
@ExceptionHandler(value = AdyenControllerException.class) | ||
public ResponseEntity<ErrorResponse> handleAdyenControllerException(AdyenControllerException exception) { | ||
return ResponseEntity.badRequest().body(exception.getErrorResponse()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...napi/acceleratoraddon/web/src/com/adyen/commerce/exceptions/AdyenControllerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.adyen.commerce.exceptions; | ||
|
||
import com.adyen.commerce.response.ErrorResponse; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AdyenControllerException extends RuntimeException { | ||
|
||
private final ErrorResponse errorResponse; | ||
|
||
public AdyenControllerException(String errorCode, List<String> invalidFields) { | ||
errorResponse = new ErrorResponse(errorCode, invalidFields); | ||
} | ||
|
||
public AdyenControllerException() { | ||
errorResponse = new ErrorResponse("checkout.error.default", new ArrayList<>()); | ||
} | ||
|
||
public AdyenControllerException(String errorCode) { | ||
errorResponse = new ErrorResponse(errorCode); | ||
} | ||
|
||
public ErrorResponse getErrorResponse() { | ||
return errorResponse; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ncheckoutaddonapi/acceleratoraddon/web/src/com/adyen/commerce/response/ErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.adyen.commerce.response; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ErrorResponse { | ||
private String errorCode; | ||
private List<String> invalidFields; | ||
|
||
public ErrorResponse(String errorCode, List<String> invalidFields) { | ||
this.errorCode = errorCode; | ||
this.invalidFields = invalidFields; | ||
} | ||
|
||
public ErrorResponse() { | ||
this.errorCode = "checkout.error.default"; | ||
this.invalidFields = new ArrayList<>(); | ||
} | ||
|
||
public ErrorResponse(String errorCode) { | ||
this.errorCode = errorCode; | ||
this.invalidFields = new ArrayList<>(); | ||
} | ||
|
||
public String getErrorCode() { | ||
return errorCode; | ||
} | ||
|
||
public List<String> getInvalidFields() { | ||
return invalidFields; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,8 @@ | |
margin-top: 30px; | ||
padding: 15px; | ||
border-radius: 12px; | ||
} | ||
|
||
.alert { | ||
scroll-margin-top: 10px; | ||
} |
22 changes: 22 additions & 0 deletions
22
...eb/webroot/_ui/responsive/common/js/adyen-checkout/src/components/common/ErrorHandler.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {AxiosError} from "axios"; | ||
import {ErrorResponse} from "../../types/errorResponse"; | ||
import {isEmpty} from "../../util/stringUtil"; | ||
import {store} from "../../store/store"; | ||
import {createDefaultResponseData, createError} from "../../util/notificationUtil"; | ||
|
||
export class ErrorHandler { | ||
|
||
public static handleError(error?: AxiosError<ErrorResponse>) { | ||
let errorResponseData | ||
if (!error) { | ||
errorResponseData = createDefaultResponseData() | ||
} else { | ||
errorResponseData = error.response.data; | ||
|
||
if (!errorResponseData || isEmpty(errorResponseData.errorCode)) { | ||
errorResponseData = createDefaultResponseData() | ||
} | ||
} | ||
store.dispatch({type: "notifications/addNotification", payload: createError(errorResponseData)}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about sample translation for DE?