-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: validate refund amount with amount_captured instead of amount (#…
- Loading branch information
1 parent
d28c82c
commit be13d15
Showing
31 changed files
with
538 additions
and
24 deletions.
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
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
8 changes: 8 additions & 0 deletions
8
...tripe/Flow Testcases/Variation Cases/Scenario10-Refund exceeds amount captured/.meta.json
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,8 @@ | ||
{ | ||
"childrenOrder": [ | ||
"Payments - Create", | ||
"Payments - Capture", | ||
"Payments - Retrieve", | ||
"Refunds - Create" | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...ation Cases/Scenario10-Refund exceeds amount captured/Payments - Capture/.event.meta.json
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,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
94 changes: 94 additions & 0 deletions
94
...ariation Cases/Scenario10-Refund exceeds amount captured/Payments - Capture/event.test.js
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,94 @@ | ||
// Validate status 2xx | ||
pm.test("[POST]::/payments/:id/capture - Status code is 2xx", function () { | ||
pm.response.to.be.success; | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test( | ||
"[POST]::/payments/:id/capture - Content-Type is application/json", | ||
function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include( | ||
"application/json", | ||
); | ||
}, | ||
); | ||
|
||
// Validate if response has JSON Body | ||
pm.test("[POST]::/payments/:id/capture - Response has JSON Body", function () { | ||
pm.response.to.have.jsonBody(); | ||
}); | ||
|
||
// Set response object as internal variable | ||
let jsonData = {}; | ||
try { | ||
jsonData = pm.response.json(); | ||
} catch (e) {} | ||
|
||
// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id | ||
if (jsonData?.payment_id) { | ||
pm.collectionVariables.set("payment_id", jsonData.payment_id); | ||
console.log( | ||
"- use {{payment_id}} as collection variable for value", | ||
jsonData.payment_id, | ||
); | ||
} else { | ||
console.log( | ||
"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined.", | ||
); | ||
} | ||
|
||
// pm.collectionVariables - Set mandate_id as variable for jsonData.mandate_id | ||
if (jsonData?.mandate_id) { | ||
pm.collectionVariables.set("mandate_id", jsonData.mandate_id); | ||
console.log( | ||
"- use {{mandate_id}} as collection variable for value", | ||
jsonData.mandate_id, | ||
); | ||
} else { | ||
console.log( | ||
"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined.", | ||
); | ||
} | ||
|
||
// pm.collectionVariables - Set client_secret as variable for jsonData.client_secret | ||
if (jsonData?.client_secret) { | ||
pm.collectionVariables.set("client_secret", jsonData.client_secret); | ||
console.log( | ||
"- use {{client_secret}} as collection variable for value", | ||
jsonData.client_secret, | ||
); | ||
} else { | ||
console.log( | ||
"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined.", | ||
); | ||
} | ||
|
||
// Response body should have value "succeeded" for "status" | ||
if (jsonData?.status) { | ||
pm.test( | ||
"[POST]:://payments/:id/capture - Content check if value for 'status' matches 'partially_captured'", | ||
function () { | ||
pm.expect(jsonData.status).to.eql("partially_captured"); | ||
}, | ||
); | ||
} | ||
|
||
// Response body should have value "6540" for "amount" | ||
if (jsonData?.amount) { | ||
pm.test( | ||
"[post]:://payments/:id/capture - Content check if value for 'amount' matches '6540'", | ||
function () { | ||
pm.expect(jsonData.amount).to.eql(6540); | ||
}, | ||
); | ||
} | ||
|
||
// Response body should have value "6000" for "amount_received" | ||
if (jsonData?.amount_received) { | ||
pm.test( | ||
"[POST]::/payments:id/capture - Content check if value for 'amount_received' matches '6000'", | ||
function () { | ||
pm.expect(jsonData.amount_received).to.eql(6000); | ||
}, | ||
); | ||
} |
39 changes: 39 additions & 0 deletions
39
...Variation Cases/Scenario10-Refund exceeds amount captured/Payments - Capture/request.json
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,39 @@ | ||
{ | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"amount_to_capture": 6000, | ||
"statement_descriptor_name": "Joseph", | ||
"statement_descriptor_suffix": "JS" | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{baseUrl}}/payments/:id/capture", | ||
"host": ["{{baseUrl}}"], | ||
"path": ["payments", ":id", "capture"], | ||
"variable": [ | ||
{ | ||
"key": "id", | ||
"value": "{{payment_id}}", | ||
"description": "(Required) unique payment id" | ||
} | ||
] | ||
}, | ||
"description": "To capture the funds for an uncaptured payment" | ||
} |
1 change: 1 addition & 0 deletions
1
...ariation Cases/Scenario10-Refund exceeds amount captured/Payments - Capture/response.json
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 @@ | ||
[] |
3 changes: 3 additions & 0 deletions
3
...iation Cases/Scenario10-Refund exceeds amount captured/Payments - Create/.event.meta.json
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,3 @@ | ||
{ | ||
"eventOrder": ["event.test.js"] | ||
} |
71 changes: 71 additions & 0 deletions
71
...Variation Cases/Scenario10-Refund exceeds amount captured/Payments - Create/event.test.js
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,71 @@ | ||
// Validate status 2xx | ||
pm.test("[POST]::/payments - Status code is 2xx", function () { | ||
pm.response.to.be.success; | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test("[POST]::/payments - Content-Type is application/json", function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include( | ||
"application/json", | ||
); | ||
}); | ||
|
||
// Validate if response has JSON Body | ||
pm.test("[POST]::/payments - Response has JSON Body", function () { | ||
pm.response.to.have.jsonBody(); | ||
}); | ||
|
||
// Set response object as internal variable | ||
let jsonData = {}; | ||
try { | ||
jsonData = pm.response.json(); | ||
} catch (e) {} | ||
|
||
// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id | ||
if (jsonData?.payment_id) { | ||
pm.collectionVariables.set("payment_id", jsonData.payment_id); | ||
console.log( | ||
"- use {{payment_id}} as collection variable for value", | ||
jsonData.payment_id, | ||
); | ||
} else { | ||
console.log( | ||
"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined.", | ||
); | ||
} | ||
|
||
// pm.collectionVariables - Set mandate_id as variable for jsonData.mandate_id | ||
if (jsonData?.mandate_id) { | ||
pm.collectionVariables.set("mandate_id", jsonData.mandate_id); | ||
console.log( | ||
"- use {{mandate_id}} as collection variable for value", | ||
jsonData.mandate_id, | ||
); | ||
} else { | ||
console.log( | ||
"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined.", | ||
); | ||
} | ||
|
||
// pm.collectionVariables - Set client_secret as variable for jsonData.client_secret | ||
if (jsonData?.client_secret) { | ||
pm.collectionVariables.set("client_secret", jsonData.client_secret); | ||
console.log( | ||
"- use {{client_secret}} as collection variable for value", | ||
jsonData.client_secret, | ||
); | ||
} else { | ||
console.log( | ||
"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined.", | ||
); | ||
} | ||
|
||
// Response body should have value "requires_capture" for "status" | ||
if (jsonData?.status) { | ||
pm.test( | ||
"[POST]::/payments - Content check if value for 'status' matches 'requires_capture'", | ||
function () { | ||
pm.expect(jsonData.status).to.eql("requires_capture"); | ||
}, | ||
); | ||
} |
Oops, something went wrong.