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

feat(cypress): add corner cases #5481

Merged
merged 7 commits into from
Aug 1, 2024
Merged

feat(cypress): add corner cases #5481

merged 7 commits into from
Aug 1, 2024

Conversation

pixincreate
Copy link
Member

@pixincreate pixincreate commented Jul 30, 2024

Type of Change

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

Description

This PR adds variation cases where Hyperswitch is known to get 4xx response. This is added as a part of regression test.

Tests include, but not limited to:

  • Invalid Card info
    • Invalid card number length
    • Invalid card expiry month
    • Invalid card expiry year
    • Invalid Card CVV
  • Confirm a payment without PMD
  • Capture greater amount
  • Capture successful payment
  • Void successful payment

To accommodate the changes for above, slight refactoring has been done to the configs where I've removed payment_method from confirm_body in fixtures and moved them to individual connector level configs.

This also adds a check to 4xx error body where we validate whether the error response is an object or a string (required for invalid card length).

This also forced me to fix issues with data trans connector.

This enhancement will be done in multiple PRs as I do not want to make it complicated unnecessarily.

Additional Changes

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

Motivation and Context

NIL

How did you test it?

Corner cases
image

Adyen Bank of America Bluesnap Cybersource Iatapay
image image image image image
NMI PayPal Stripe Trustpay
image image image image

There happens to be an issue with NMI:

image
expected 'amount_to_capture is greater than amount' to equal 'This Payment could not be captured because it has a capture_method of manual. The expected state is manual_multiple'

It should expect capture_method to be manual and should not be limited to manual_multiple

Checklist

  • I formatted the code prettier . --write
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

…ypress

* 'main' of github.com:juspay/hyperswitch:
  fix(connector): [Pix] convert data type of pix fields  (#5476)
  feat(connector): [BAMBORA, BITPAY, STAX] Move connector to hyperswitch_connectors (#5450)
  refactor(configs): include env for cybersource in integration_test (#5474)
@pixincreate pixincreate added A-CI-CD Area: Continuous Integration/Deployment S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Jul 30, 2024
@pixincreate pixincreate added this to the July 2024 Release milestone Jul 30, 2024
@pixincreate pixincreate self-assigned this Jul 30, 2024
@pixincreate pixincreate requested review from a team as code owners July 30, 2024 14:24
});

it("[Payment create] Invalid card number", () => {
let data = getConnectorDetails(globalState.get("commons"))["card_pm"][
Copy link
Member Author

Choose a reason for hiding this comment

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

Using commons in here is intentional since we expect these to run against regardless of connector

@@ -2,8 +2,6 @@
"client_secret": "",
"return_url": "https://hyperswitch.io",
"confirm": true,
"payment_method": "card",
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for removing payment method from fixtures and adding individually to each configs? Otherwise LGTM

Copy link
Member Author

Choose a reason for hiding this comment

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

For corner cases, especially for confirm payment w/o pmd, we're not supposed to pass any payment_method info. With payment_method being existent in confirm_body fixture, it is being supplied in the request resulting in failures.
To over come this, I had to remove it from fixtures which resulted in other tests to fail forcing me to add at config level.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Aug 1, 2024
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Aug 1, 2024
Merged via the queue into main with commit c0f4577 Aug 1, 2024
30 checks passed
@Gnanasundari24 Gnanasundari24 deleted the variation-cypress branch August 1, 2024 10:17
pixincreate added a commit that referenced this pull request Aug 5, 2024
* 'main' of github.com:juspay/hyperswitch: (37 commits)
  fix(connector): Fixed status mapping for Plaid (#5525)
  feat(core): accept profile_id in merchant_account, connectors and customers core functions (#5505)
  refactor(auth): Pass `profile_id` from the auth to core functions (#5520)
  refactor(routing): Refactor api v2 routes for deactivating and retrieving the routing config (#5478)
  refactor(cypress): pass `connector_type` externally (#5522)
  refactor(router): refactor merchant_connector update v2 flow (#5484)
  feat(router): add accept language header middleware  (#5500)
  chore(version): 2024.08.05.0
  chore(postman): update Postman collection files
  fix(pm_auth): Added mca status check in pml (#5421)
  refactor(payment_methods): List the Payment Methods for Merchant , based on the connector  type (#4909)
  fix(router): [Iatapay] make error status and error message optional (#5382)
  chore(version): 2024.08.02.0
  feat(business_profile): introduce domain models for business profile v1 and v2 APIs (#5497)
  feat(auth): Add `profile_id` in `AuthenticationData` (#5492)
  feat(core): accept business profile in core functions for payments, refund, payout and disputes (#5498)
  refactor(router): domain and diesel model changes for merchant_connector_account create v2 flow (#5462)
  fix(open_payment_links): send displaySavedPaymentMethods as false explicitly for open payment links (#5501)
  refactor(role): determine level of role entity (#5488)
  feat(cypress): add corner cases (#5481)
  ...
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.

4 participants