-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(postman): add net_amount field test cases (#3286)
- Loading branch information
1 parent
6f58b4e
commit 19a605e
Showing
22 changed files
with
693 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...Testcases/Happy Cases/Scenario28-Create payment by configuring surcharge rules/.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,9 @@ | ||
{ | ||
"childrenOrder": [ | ||
"upsert Surcharge rules", | ||
"Payments - Create", | ||
"List Payment Methods for a Merchant", | ||
"Payments - Confirm", | ||
"Payments - Retrieve" | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...yment by configuring surcharge rules/List Payment Methods for a Merchant/.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,5 @@ | ||
{ | ||
"eventOrder": [ | ||
"event.test.js" | ||
] | ||
} |
51 changes: 51 additions & 0 deletions
51
... payment by configuring surcharge rules/List Payment Methods for a Merchant/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,51 @@ | ||
// Validate status 2xx | ||
pm.test("[GET]::/payment_methods/:merchant_id - Status code is 2xx", function () { | ||
pm.response.to.be.success; | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test("[GET]::/payment_methods/:merchant_id - Content-Type is application/json", function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include("application/json"); | ||
}); | ||
|
||
// Parse the response body as JSON | ||
var responseBody = pm.response.json(); | ||
|
||
// Check if "payment_methods" array contains a "payment_method" with the value "card" | ||
pm.test("[GET]::/payment_methods/:merchant_id -Content Check if payment_method matches 'card'", function () { | ||
var paymentMethods = responseBody.payment_methods; | ||
var cardPaymentMethod = paymentMethods.find(function (method) { | ||
return method.payment_method == "card"; | ||
}); | ||
}); | ||
|
||
// Check if "payment_methods" array contains a "payment_method" with the value "pay_later" | ||
pm.test("[GET]::/payment_methods/:merchant_id -Content Check if payment_method matches 'pay_later'", function () { | ||
var paymentMethods = responseBody.payment_methods; | ||
var cardPaymentMethod = paymentMethods.find(function (method) { | ||
return method.payment_method == "pay_later"; | ||
}); | ||
}); | ||
// Check if "payment_methods" array contains a "payment_method" with the value "wallet" | ||
pm.test("[GET]::/payment_methods/:merchant_id -Content Check if payment_method matches 'wallet'", function () { | ||
var paymentMethods = responseBody.payment_methods; | ||
var cardPaymentMethod = paymentMethods.find(function (method) { | ||
return method.payment_method == "wallet"; | ||
}); | ||
}); | ||
|
||
// Check if "payment_methods" array contains a "payment_method" with the value "bank_debit" | ||
pm.test("[GET]::/payment_methods/:merchant_id -Content Check if payment_method matches 'bank_debit'", function () { | ||
var paymentMethods = responseBody.payment_methods; | ||
var cardPaymentMethod = paymentMethods.find(function (method) { | ||
return method.payment_method == "bank_debit"; | ||
}); | ||
}); | ||
|
||
// Check if "payment_methods" array contains a "payment_method" with the value "bank_transfer" | ||
pm.test("[GET]::/payment_methods/:merchant_id -Content Check if payment_method matches 'bank_transfer'", function () { | ||
var paymentMethods = responseBody.payment_methods; | ||
var cardPaymentMethod = paymentMethods.find(function (method) { | ||
return method.payment_method == "bank_transfer"; | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
...e payment by configuring surcharge rules/List Payment Methods for a Merchant/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,52 @@ | ||
{ | ||
"auth": { | ||
"type": "apikey", | ||
"apikey": [ | ||
{ | ||
"key": "value", | ||
"value": "{{publishable_key}}", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "key", | ||
"value": "api-key", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "in", | ||
"value": "header", | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"method": "GET", | ||
"header": [ | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "x-feature", | ||
"value": "router-custom", | ||
"type": "text", | ||
"disabled": true | ||
} | ||
], | ||
"url": { | ||
"raw": "{{baseUrl}}/account/payment_methods?client_secret={{client_secret}}", | ||
"host": [ | ||
"{{baseUrl}}" | ||
], | ||
"path": [ | ||
"account", | ||
"payment_methods" | ||
], | ||
"query": [ | ||
{ | ||
"key": "client_secret", | ||
"value": "{{client_secret}}" | ||
} | ||
] | ||
}, | ||
"description": "To filter and list the applicable payment methods for a particular merchant id." | ||
} |
1 change: 1 addition & 0 deletions
1
... payment by configuring surcharge rules/List Payment Methods for a Merchant/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
...nario28-Create payment by configuring surcharge rules/Payments - Confirm/.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", "event.prerequest.js"] | ||
} |
Empty file.
89 changes: 89 additions & 0 deletions
89
...Scenario28-Create payment by configuring surcharge rules/Payments - Confirm/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,89 @@ | ||
// Validate status 2xx | ||
pm.test("[POST]::/payments/:id/confirm - Status code is 2xx", function () { | ||
pm.response.to.be.success; | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test( | ||
"[POST]::/payments/:id/confirm - 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/confirm - 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.", | ||
); | ||
} | ||
|
||
if (jsonData?.net_amount) { | ||
pm.test( | ||
"[POST]::/payments:id/confirm - Content check if value for 'amount' matches '5020'", | ||
function () { | ||
pm.expect(jsonData.net_amount).to.eql(5020); | ||
}, | ||
); | ||
} | ||
|
||
if (jsonData?.surcharge_details) { | ||
pm.test( | ||
"[POST]::/payments:id/confirm - Content check if value for 'surcharge_details.surcharge_amount' matches '10'", | ||
function () { | ||
pm.expect(jsonData.surcharge_details.surcharge_amount).to.eql(10); | ||
}, | ||
); | ||
pm.test( | ||
"[POST]::/payments:id/confirm - Content check if value for 'surcharge_details.tax_amount' matches '10'", | ||
function () { | ||
pm.expect(jsonData.surcharge_details.tax_amount).to.eql(10); | ||
}, | ||
); | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
.../Scenario28-Create payment by configuring surcharge rules/Payments - Confirm/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,68 @@ | ||
{ | ||
"auth": { | ||
"type": "apikey", | ||
"apikey": [ | ||
{ | ||
"key": "value", | ||
"value": "{{publishable_key}}", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "key", | ||
"value": "api-key", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "in", | ||
"value": "header", | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"payment_method": "card", | ||
"payment_method_data": { | ||
"card": { | ||
"card_number": "4242424242424242", | ||
"card_exp_month": "10", | ||
"card_exp_year": "25", | ||
"card_holder_name": "joseph Doe", | ||
"card_cvc": "123", | ||
"card_network": "Visa" | ||
} | ||
}, | ||
"client_secret": "{{client_secret}}" | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{baseUrl}}/payments/:id/confirm", | ||
"host": ["{{baseUrl}}"], | ||
"path": ["payments", ":id", "confirm"], | ||
"variable": [ | ||
{ | ||
"key": "id", | ||
"value": "{{payment_id}}", | ||
"description": "(Required) unique payment id" | ||
} | ||
] | ||
}, | ||
"description": "This API is to confirm the payment request and forward payment to the payment processor. This API provides more granular control upon when the API is forwarded to the payment processor. Alternatively you can confirm the payment within the Payments-Create API" | ||
} |
1 change: 1 addition & 0 deletions
1
...Scenario28-Create payment by configuring surcharge rules/Payments - Confirm/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
...enario28-Create payment by configuring surcharge rules/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"] | ||
} |
81 changes: 81 additions & 0 deletions
81
.../Scenario28-Create payment by configuring surcharge rules/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,81 @@ | ||
// 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_payment_method" for "status" | ||
if (jsonData?.status) { | ||
pm.test( | ||
"[POST]::/payments - Content check if value for 'status' matches 'requires_payment_method'", | ||
function () { | ||
pm.expect(jsonData.status).to.eql("requires_payment_method"); | ||
}, | ||
); | ||
} | ||
|
||
// Amount must be equal to 5020 | ||
if (jsonData?.status) { | ||
pm.test( | ||
"[POST]::/payments - Content check if value for 'status' matches 'requires_payment_method'", | ||
function () { | ||
pm.expect(jsonData.status).to.eql("requires_payment_method"); | ||
}, | ||
); | ||
} |
Oops, something went wrong.