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

chore(postman): postman tests fixes #7159

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

arindam-sahoo
Copy link
Contributor

@arindam-sahoo arindam-sahoo commented Jan 31, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Connector:adyen_uk

image

Note: The Sofort Test Cases are removed in PR #7099 after being deprecated by adyen connector.

Connector:bluesnap

image

Connector:cybersource

Before
image

After
image

Connector:nmi

Before
image

After
image

Connector: paypal

image

Connector: stripe

Failing too inconsistently. Different number of test cases are failing. It is not even the same test cases each time it fails.

Connector: trustpay

Before
image
After
image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

Copy link

semanticdiff-com bot commented Jan 31, 2025

Review changes with  SemanticDiff

@arindam-sahoo arindam-sahoo self-assigned this Jan 31, 2025
@arindam-sahoo arindam-sahoo changed the title cybersource postman checks fixes chore(postman): postman checks fixes Jan 31, 2025
@arindam-sahoo arindam-sahoo changed the title chore(postman): postman checks fixes chore(postman): postman tests fixes Jan 31, 2025
@arindam-sahoo arindam-sahoo added the A-CI-CD Area: Continuous Integration/Deployment label Jan 31, 2025
@@ -48,6 +48,7 @@
},
"test_mode": false,
"disabled": false,
"metadata": {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the metadata field, it responds like the following
image

I tried creating the Payment Connector in the dashboard and saw that even passing {} as the value of the metadata field works, so added the "metadata": {},

@arindam-sahoo arindam-sahoo linked an issue Feb 1, 2025 that may be closed by this pull request
function () {
pm.expect(jsonData.status).to.eql("succeeded");
pm.expect(jsonData.status).to.eql("processing");
Copy link
Contributor Author

@arindam-sahoo arindam-sahoo Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual Captures are staying in processing state.
image
Even sending PSync Request also responds processing as the status.

@@ -51,7 +51,7 @@
"card_number": "4111111111111111",
"card_exp_month": "03",
"card_exp_year": "2030",
"card_holder_name": "CLBRW1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a string without space between considers it as the first name and responds in the following way
image
With the following error details
image

@@ -51,7 +51,7 @@
"card_number": "4111111111111111",
"card_exp_month": "03",
"card_exp_year": "2030",
"card_holder_name": "CLBRW1",
"card_holder_name": "Juspay Hyperswitch",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a space in the string solves the issue,
image

if (jsonData?.amount) {
pm.test(
"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 0'",
function () {
pm.expect(jsonData.amount_capturable).to.eql(0);
pm.expect(jsonData.amount_capturable).to.eql(jsonData.amount);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the reason that Payments Captured Manually are staying in processing, the amount_capturable will be equal to the full amount.

pm.response.to.be.success;
// Validate status 4xx
pm.test("[POST]::/refunds - Status code is 4xx", function () {
pm.response.to.have.status(400);
Copy link
Contributor Author

@arindam-sahoo arindam-sahoo Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Payments - Retrieve-copy responding the status as processing, this is the error responded by Refunds - Create

@@ -24,6 +24,13 @@ if (jsonData?.refund_id) {
jsonData.refund_id,
);
} else {
pm.collectionVariables.set("refund_id", null);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the reason that Refunds are not able to get created because of the above mentioned reason, the value of refund_id could not be set using:

pm.collectionVariables.set("refund_id", jsonData.refund_id);

So, it takes the most recent value of refund_id which it gets from /postman/collection-dir/cybersource/Flow Testcases/Happy Cases/Scenario9-Add card flow/Refunds - Create/request.json.

pm.test(
"[POST]::/refunds - Content check if 'error.message' matches 'This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured'",
function () {
pm.expect(jsonData.error.message).to.eql("This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapped the error message accordingly for not being able to create a refund.

@@ -40,7 +27,7 @@ if (jsonData?.status) {
}

// Response body should have value "6540" for "amount"
if (jsonData?.status) {
if (jsonData?.status && pm.collectionVariables.get("refund_id") !== null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion was failing due to the refund_id issue in the Refunds - Create. Because it was assigned with the refund_id value of Scenario9-Add card flow/Refunds - Create which had the amount of 600, the assertion in this conditional statement was failing expecting it to be 540 according to the request created in Scenario11-Save card payment with manual capture

@@ -40,7 +40,7 @@
"card": {
"card_number": "4242424242424242",
"card_exp_month": "01",
"card_exp_year": "25",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

January 2025 is no more a valid expiration.

@@ -40,7 +40,7 @@
"card": {
"card_number": "4242424242424242",
"card_exp_month": "01",
"card_exp_year": "25",
"card_exp_year": "35",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, changed it to January 2035.

pm.test(
"[POST]::/refunds - Content check if value for 'error.message' matches 'Refund does not exist in our records.'",
function () {
pm.expect(jsonData.error.message).to.eql("Refund does not exist in our records.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an assertion to check the Error Message.

@@ -36,7 +36,7 @@ if (jsonData?.error?.message) {
pm.test(
"[POST]::/payments/:id/confirm - Content check if value for 'error.reason' matches ' mandate payment is not supported by nmi'" ,
function () {
pm.expect(jsonData.error.reason).to.eql(" mandate payment is not supported by nmi");
pm.expect(jsonData.error.reason).to.eql("credit mandate payment is not supported by nmi");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image


// Add a delay of 10 seconds after the last
setTimeout(function () {
console.log("Delay of 10 seconds completed.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refunds were failing with

"error_message": "unspecified error",
"error_code": "No error code",
"unified_code": "UE_9000",
"unified_message": "Something went wrong"

because of immediate refund of payment confirmed, giving a delay ensures successful Refund.

@arindam-sahoo arindam-sahoo marked this pull request as ready for review February 3, 2025 07:14
@arindam-sahoo arindam-sahoo requested a review from a team as a code owner February 3, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CI-CD Area: Continuous Integration/Deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postman Connector Integration Tests Failing
1 participant