Skip to content

refactor(connector): [Worldpayvantiv] refactor void flow and handle transaction status#8540

Merged
Gnanasundari24 merged 4 commits intomainfrom
vantiv-auth-reversal
Jul 4, 2025
Merged

refactor(connector): [Worldpayvantiv] refactor void flow and handle transaction status#8540
Gnanasundari24 merged 4 commits intomainfrom
vantiv-auth-reversal

Conversation

@AkshayaFoiger
Copy link
Contributor

@AkshayaFoiger AkshayaFoiger commented Jul 3, 2025

Type of Change

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

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 payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_yd2YxRScbTZYwkJGCv6YdgFo3Hj2th1v8scxfbq8WdMo3EsTgxgTd4FbRLixw71c' \
--data '{
    "amount": 10010,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    
    "billing": {
        "address": {
            "line1": "1 Main St.",
            "city": "Burlington",
            "state": "MA",
            "zip": "01803-3747",
            "country": "US",
            "first_name": "John",
            "last_name": "Smith"
        }
    },
    "customer_id": "hyperswitch_sdk_demo_id",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4457010000000009", 
            "card_exp_month": "01",
            "card_exp_year": "50",
            
            "card_cvc": "349"
        }
    }
  
}'

Response

{"payment_id":"pay_6YXspDzY74yrbQxWKOu7","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"processing","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":10010,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_6YXspDzY74yrbQxWKOu7_secret_gYyYRcM8ymCqQMB82Uja","created":"2025-07-04T05:56:31.522Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"hyperswitch_sdk_demo_id","created_at":1751608591,"expires":1751612191,"secret":"epk_905883c1f76a4d28ae7eae0dcaf3fb78"},"manual_retry_allowed":false,"connector_transaction_id":"84085100190610345","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_6YXspDzY74yrbQxWKOu7","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:11:31.522Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T05:56:32.969Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Do a Psync
{"payment_id":"pay_6YXspDzY74yrbQxWKOu7","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"requires_capture","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":10010,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_6YXspDzY74yrbQxWKOu7_secret_gYyYRcM8ymCqQMB82Uja","created":"2025-07-04T05:56:31.522Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"84085100190610345","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_6YXspDzY74yrbQxWKOu7","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:11:31.522Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T05:57:17.828Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Capture the payment
curl --location 'http://localhost:8080/payments/pay_6YXspDzY74yrbQxWKOu7/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_yd2YxRScbTZYwkJGCv6YdgFo3Hj2th1v8scxfbq8WdMo3EsTgxgTd4FbRLixw71c' \
--data '{
    "amount_to_capture": 5050,
    "statement_descriptor_name": "Joseph",
    "statement_descriptor_suffix": "JS"
}'

Response

{"payment_id":"pay_6YXspDzY74yrbQxWKOu7","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"processing","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":10010,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_6YXspDzY74yrbQxWKOu7_secret_gYyYRcM8ymCqQMB82Uja","created":"2025-07-04T05:56:31.522Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"84085100190610832","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_6YXspDzY74yrbQxWKOu7","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:11:31.522Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T05:57:43.231Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Psync
{"payment_id":"pay_6YXspDzY74yrbQxWKOu7","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"partially_captured","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":0,"amount_received":5050,"connector":"worldpayvantiv","client_secret":"pay_6YXspDzY74yrbQxWKOu7_secret_gYyYRcM8ymCqQMB82Uja","created":"2025-07-04T05:56:31.522Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"84085100190610832","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_6YXspDzY74yrbQxWKOu7","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:11:31.522Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T06:00:35.658Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Refund
curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_yd2YxRScbTZYwkJGCv6YdgFo3Hj2th1v8scxfbq8WdMo3EsTgxgTd4FbRLixw71c' \
--data '{
    "payment_id": "pay_6YXspDzY74yrbQxWKOu7",
    
    "reason": "Customer returned product",
    "refund_type": "instant"
   
}'

Response

{"refund_id":"ref_qF1qKdazK2JatWkVMv0z","payment_id":"pay_6YXspDzY74yrbQxWKOu7","amount":5050,"currency":"USD","status":"pending","reason":"Customer returned product","metadata":null,"error_message":null,"error_code":null,"unified_code":null,"unified_message":null,"created_at":"2025-07-04T06:01:20.414Z","updated_at":"2025-07-04T06:01:23.253Z","connector":"worldpayvantiv","profile_id":"pro_sFS1d84BWdVLMu7kZqTD","merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","split_refunds":null,"issuer_error_code":null,"issuer_error_message":null}
  1. Rsync
{"refund_id":"ref_qF1qKdazK2JatWkVMv0z","payment_id":"pay_6YXspDzY74yrbQxWKOu7","amount":5050,"currency":"USD","status":"succeeded","reason":"Customer returned product","metadata":null,"error_message":null,"error_code":null,"unified_code":null,"unified_message":null,"created_at":"2025-07-04T06:01:20.414Z","updated_at":"2025-07-04T06:02:22.239Z","connector":"worldpayvantiv","profile_id":"pro_sFS1d84BWdVLMu7kZqTD","merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","split_refunds":null,"issuer_error_code":null,"issuer_error_message":null}
Manual + void 1. Create a manual payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_yd2YxRScbTZYwkJGCv6YdgFo3Hj2th1v8scxfbq8WdMo3EsTgxgTd4FbRLixw71c' \
--data '{
    "amount": 10010,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    
    "billing": {
        "address": {
            "line1": "1 Main St.",
            "city": "Burlington",
            "state": "MA",
            "zip": "01803-3747",
            "country": "US",
            "first_name": "John",
            "last_name": "Smith"
        }
    },
    "customer_id": "hyperswitch_sdk_demo_id",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4457010000000009", 
            "card_exp_month": "01",
            "card_exp_year": "50",
            
            "card_cvc": "349"
        }
    }
}'

Response

{"payment_id":"pay_oNK70vq9NRoqeKYKDt3j","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"processing","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":10010,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_oNK70vq9NRoqeKYKDt3j_secret_FebjFqDGdVVFh6PvASqS","created":"2025-07-04T06:03:35.536Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"hyperswitch_sdk_demo_id","created_at":1751609015,"expires":1751612615,"secret":"epk_ef3aaaec15674040b7592b9dcfee3819"},"manual_retry_allowed":false,"connector_transaction_id":"83997139235674030","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_oNK70vq9NRoqeKYKDt3j","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:18:35.536Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T06:03:37.189Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Psync
{"payment_id":"pay_oNK70vq9NRoqeKYKDt3j","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"requires_capture","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":10010,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_oNK70vq9NRoqeKYKDt3j_secret_FebjFqDGdVVFh6PvASqS","created":"2025-07-04T06:03:35.536Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"83997139235674030","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_oNK70vq9NRoqeKYKDt3j","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:18:35.536Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T06:04:27.227Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Void the payment
curl --location 'http://localhost:8080/payments/pay_oNK70vq9NRoqeKYKDt3j/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_yd2YxRScbTZYwkJGCv6YdgFo3Hj2th1v8scxfbq8WdMo3EsTgxgTd4FbRLixw71c' \
--data '{"cancellation_reason":"requested_by_customer"}'

Response

{"payment_id":"pay_oNK70vq9NRoqeKYKDt3j","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"processing","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":0,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_oNK70vq9NRoqeKYKDt3j_secret_FebjFqDGdVVFh6PvASqS","created":"2025-07-04T06:03:35.536Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":"requested_by_customer","error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"84085100190649665","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_oNK70vq9NRoqeKYKDt3j","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:18:35.536Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T06:05:01.379Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}
  1. Psync
{"payment_id":"pay_oNK70vq9NRoqeKYKDt3j","merchant_id":"postman_merchant_GHAction_aad3d97c-40fb-4f4c-bc2a-dd683b156d5a","status":"cancelled","amount":10010,"net_amount":10010,"shipping_cost":null,"amount_capturable":0,"amount_received":null,"connector":"worldpayvantiv","client_secret":"pay_oNK70vq9NRoqeKYKDt3j_secret_FebjFqDGdVVFh6PvASqS","created":"2025-07-04T06:03:35.536Z","currency":"USD","customer_id":"hyperswitch_sdk_demo_id","customer":{"id":"hyperswitch_sdk_demo_id","name":null,"email":null,"phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":null,"off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"0009","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"445701","card_extended_bin":null,"card_exp_month":"01","card_exp_year":"50","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"Burlington","country":"US","line1":"1 Main St.","line2":null,"line3":null,"zip":"01803-3747","state":"MA","first_name":"John","last_name":"Smith"},"phone":null,"email":null},"order_details":null,"email":null,"name":null,"phone":null,"return_url":null,"authentication_type":"no_three_ds","statement_descriptor_name":null,"statement_descriptor_suffix":null,"next_action":null,"cancellation_reason":"requested_by_customer","error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"payment_experience":null,"payment_method_type":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":null,"manual_retry_allowed":false,"connector_transaction_id":"84085100190649665","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"pay_oNK70vq9NRoqeKYKDt3j","payment_link":null,"profile_id":"pro_sFS1d84BWdVLMu7kZqTD","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_bpcDnKfJlT6NY9v7PGYZ","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-07-04T06:18:35.536Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-07-04T06:05:32.568Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null,"card_discovery":"manual","force_3ds_challenge":false,"force_3ds_challenge_trigger":false,"issuer_error_code":null,"issuer_error_message":null,"is_iframe_redirection_enabled":null,"whole_connector_response":null}

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

Summary by CodeRabbit

  • Refactor

    • Improved handling of Worldpay Vantiv connector responses with clearer status mapping and more robust response code management.
    • Unified payment response structures for easier interpretation of transaction outcomes.
  • Bug Fixes

    • Enhanced error detection and reporting for failed transactions, ensuring accurate status updates.
  • New Features

    • Introduced detailed response code mapping for more precise transaction status tracking.

@AkshayaFoiger AkshayaFoiger self-assigned this Jul 3, 2025
@AkshayaFoiger AkshayaFoiger requested a review from a team as a code owner July 3, 2025 07:53
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jul 3, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs  5% smaller
  crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs  0% smaller

@AkshayaFoiger AkshayaFoiger added A-connector-integration Area: Connector integration C-refactor Category: Refactor labels Jul 4, 2025
@AkshayaFoiger
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jul 4, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jul 4, 2025

Walkthrough

The 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

File(s) Change Summary
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs Refactored response handling: replaced void with auth_reversal, merged auth/sale responses into PaymentResponse, added enums for response codes and flows, centralized status mapping, updated conversion logic, removed unused imports, and adjusted optional fields.

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
Loading

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)
Updating crates.io index
Updating git repository `https://github.com/juspay/scylla-rust-driver.git`

error: failed to get scylla as a dependency of package masking v0.1.0 (/crates/masking)

Caused by:
failed to load source for dependency scylla

Caused by:
Unable to update https://github.com/juspay/scylla-rust-driver.git?rev=5700aa2847b25437cdd4fcf34d707aa90dca8b89#5700aa28

Caused by:
failed to create directory /usr/local/git/db/scylla-rust-driver-ef0999119a3c6829

Caused by:
Permission denied (os error 13)

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between c275e13 and c9d380b.

📒 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 void to auth_reversal better reflects the payment industry standard terminology.

Also applies to: 129-129


644-645: Good consolidation of duplicate response structures.

Merging AuthorizationResponse and SaleResponse into a single PaymentResponse struct reduces code duplication.

Also applies to: 717-732


1193-2269: Excellent type safety improvement with comprehensive response code enum.

The strongly-typed WorldpayvantivResponseCode enum provides better compile-time guarantees and explicit handling of all possible response codes.


2279-2655: Well-structured centralized status mapping.

The get_attempt_status function 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 optional post_date

The post_date field in AuthReversalResponse is not referenced in any downstream mapping or logic (no .post_date usages found), and making it Option<String> only affects deserialization (missing values map to None). This change won’t break any existing code.

@AkshayaFoiger
Copy link
Contributor Author

Cypress test cases blocked on #8234

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 4, 2025
Merged via the queue into main with commit 41291e5 Jul 4, 2025
17 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the vantiv-auth-reversal branch July 4, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-connector-integration Area: Connector integration C-refactor Category: Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants