Skip to content
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

ci(postman): add net_amount field test cases #3286

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
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";
});
});
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."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eventOrder": ["event.test.js", "event.prerequest.js"]
}
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);
},
);
}

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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eventOrder": ["event.test.js"]
}
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");
},
);
}
Loading
Loading