File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -495,9 +495,11 @@ type (
495495
496496 // ErrorResponseDetail struct
497497 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"`
501503 }
502504
503505 // 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) {
144144 }
145145}
146146
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+
147176func TestTypePayoutResponse (t * testing.T ) {
148177 response := `{
149178 "batch_header":{
You can’t perform that action at this time.
0 commit comments