refactor(connector): [Worldpayvantiv] refactor void flow and handle transaction status#8540
refactor(connector): [Worldpayvantiv] refactor void flow and handle transaction status#8540Gnanasundari24 merged 4 commits intomainfrom
Conversation
Changed Files
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe code refactors Worldpay Vantiv connector response handling by introducing strongly typed enums for response codes and payment flows, consolidating response structs, and centralizing status mapping logic. It updates request/response structures, replaces string-based logic with enums, and modifies conversion implementations to use the new status mapping functions. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Connector
participant WorldpayVantivAPI
Client->>Connector: Send payment request (Sale/Auth/Capture/Void)
Connector->>WorldpayVantivAPI: Forward request
WorldpayVantivAPI-->>Connector: Return response with response code
Connector->>Connector: Map response code to enum (WorldpayvantivResponseCode)
Connector->>Connector: Determine flow (WorldpayvantivPaymentFlow)
Connector->>Connector: Compute status via get_attempt_status/get_refund_status
alt Status is Failure
Connector-->>Client: Return error response with details
else Status is Success/Pending
Connector-->>Client: Return success response with mapped status
end
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)error: failed to get Caused by: Caused by: Caused by: Caused by: ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs (1)
1099-1099: Fix spelling inconsistency in error message.The error message uses British spelling "authorisation_response" while the rest of the codebase uses American spelling "authorization_response".
- bytes::Bytes::from("Only one of 'sale_response' or 'authorisation_response' is expected, but both were received".to_string()), + bytes::Bytes::from("Only one of 'sale_response' or 'authorization_response' is expected, but both were received".to_string()),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs(20 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: swangi-kumari
PR: juspay/hyperswitch#8199
File: crates/api_models/src/payments.rs:5633-5648
Timestamp: 2025-06-11T07:14:32.038Z
Learning: The absence of the `merchant_connector_details` field in the `PaymentsStatusRequest` struct (in `crates/api_models/src/payments.rs`) is intentional and should not be added, as per project owner guidance.
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs (1)
Learnt from: swangi-kumari
PR: juspay/hyperswitch#8199
File: crates/api_models/src/payments.rs:5633-5648
Timestamp: 2025-06-11T07:14:32.038Z
Learning: The absence of the `merchant_connector_details` field in the `PaymentsStatusRequest` struct (in `crates/api_models/src/payments.rs`) is intentional and should not be added, as per project owner guidance.
🔇 Additional comments (7)
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs (7)
18-18: LGTM! Removed unused import.
116-116: Good terminology improvement.Renaming from
voidtoauth_reversalbetter reflects the payment industry standard terminology.Also applies to: 129-129
644-645: Good consolidation of duplicate response structures.Merging
AuthorizationResponseandSaleResponseinto a singlePaymentResponsestruct reduces code duplication.Also applies to: 717-732
1193-2269: Excellent type safety improvement with comprehensive response code enum.The strongly-typed
WorldpayvantivResponseCodeenum provides better compile-time guarantees and explicit handling of all possible response codes.
2279-2655: Well-structured centralized status mapping.The
get_attempt_statusfunction provides a clean, centralized way to map response codes and flows to attempt statuses.
776-816: Excellent improvement in error handling across all response conversions.The updated response conversions now properly check for failure statuses and return detailed error responses with appropriate error codes and messages.
Also applies to: 843-883, 910-936, 1002-1082
746-746: No action needed for optionalpost_dateThe
post_datefield inAuthReversalResponseis not referenced in any downstream mapping or logic (no.post_dateusages found), and making itOption<String>only affects deserialization (missing values map toNone). This change won’t break any existing code.
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
Show resolved
Hide resolved
|
Cypress test cases blocked on #8234 |
Type of Change
Description
In this PR,
This PR integrates the Vantiv auth reversal flow as a void operation in Hyperswitch. Additionally, it handles the response status for each payment operation API call.
How did you test it?
Manual + Automatic
1. Create a Manual paymentResponse
Response
Response
Manual + void
1. Create a manual paymentResponse
Response
Checklist
cargo +nightly fmt --allcargo clippySummary by CodeRabbit
Refactor
Bug Fixes
New Features