Commit b7d3cfd 1 parent d94b350 commit b7d3cfd Copy full SHA for b7d3cfd
File tree 2 files changed +34
-3
lines changed
2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -495,9 +495,11 @@ type (
495
495
496
496
// ErrorResponseDetail struct
497
497
ErrorResponseDetail struct {
498
- Field string `json:"field"`
499
- Issue string `json:"issue"`
500
- Links []Link `json:"link"`
498
+ Field string `json:"field"`
499
+ Issue string `json:"issue"`
500
+ Name string `json:"name"`
501
+ Message string `json:"message"`
502
+ Links []Link `json:"link"`
501
503
}
502
504
503
505
// ErrorResponse https://developer.paypal.com/docs/api/errors/
Original file line number Diff line number Diff line change @@ -144,6 +144,35 @@ func TestTypeErrorResponseTwo(t *testing.T) {
144
144
}
145
145
}
146
146
147
+ func TestTypeErrorResponseThree (t * testing.T ) {
148
+ response := `{
149
+ "name": "BUSINESS_ERROR",
150
+ "debug_id": "[REDACTED]",
151
+ "message": "Business error",
152
+ "information_link": "https://developer.paypal.com/webapps/developer/docs/api/#BUSINESS_ERROR",
153
+ "details": [
154
+ {
155
+ "name": "TOKEN_NOT_FOUND",
156
+ "message": "Not Found: Invalid BA-Token Identifier"
157
+ }
158
+ ]
159
+ }`
160
+
161
+ i := & ErrorResponse {}
162
+ err := json .Unmarshal ([]byte (response ), i )
163
+ if err != nil {
164
+ t .Errorf ("ErrorResponse Unmarshal failed" )
165
+ }
166
+
167
+ if i .Name != "BUSINESS_ERROR" ||
168
+ i .Message != "Business error" ||
169
+ len (i .Details ) != 1 ||
170
+ i .Details [0 ].Name != "TOKEN_NOT_FOUND" ||
171
+ i .Details [0 ].Message != "Not Found: Invalid BA-Token Identifier" {
172
+ t .Errorf ("ErrorResponse decoded result is incorrect, Given: %v" , i )
173
+ }
174
+ }
175
+
147
176
func TestTypePayoutResponse (t * testing.T ) {
148
177
response := `{
149
178
"batch_header":{
You can’t perform that action at this time.
0 commit comments