Skip to content

Conversation

mrudulvajpayee4935
Copy link
Contributor

@mrudulvajpayee4935 mrudulvajpayee4935 commented Apr 3, 2025

Type of Change

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

Description

Nexixpay does not send error_code and error_message in case of failure responses. We will store NO_ERROR_CODE and nexixpay operation result as error_message in this case in our DB. This is sent in outgoing webhooks to the merchants.
Possible values of error messages:

  1. Declined
  2. DeniedByRisk
  3. ThreedsFailed
  4. Failed

Additional Changes

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

Motivation and Context

Currently error_code and error_message goes null in case of webhooks to merchants for nexixpay. We need to pass NO_ERROR_CODE and nexixpay operation result as error_message as connector doesn't sends us any message or code.

How did you test it?

Curls to test:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_nRAnqXGtbt60CdOO7rfovzh4MdEAIiaqnWc78AdQIx4yWnDXIKetpkjGFOvwFPcb' \
--data-raw '{
    "amount": 3596,
    "currency": "EUR",
    "amount_to_capture": 3596,
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": { 
        "card": {
            "card_number": "4742158750987704",
            "card_exp_month": "12",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "861"
        }
    },

    "confirm": true,
    "profile_id": "pro_PBNVTjuDfM7y2MyljTkG",
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "setup_future_usage": "off_session", 
    "customer": {
        "id": "customer123",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "9999999999",
        "phone_country_code": "+1"
    },
    "customer_id": "customer123",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IT",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IT",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 3545,
            "account_name": "transaction_processing"
        }
    ],
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "128.0.0.1"
    },
    "customer_acceptance": {
          "acceptance_type": "online",
          "accepted_at":"1963-05-03T04:07:52.723Z",
          "online": {
            "ip_address":"127.0.0.1",
            "user_agent": "amet irure esse"
          }
    },
    
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "payment_link": false,
    "payment_link_config": {
        "theme": "",
        "logo": "",
        "seller_name": "",
        "sdk_layout": "",
        "display_sdk_only": false,
        "enabled_saved_payment_method": false
    },
    "payment_type": "normal", 
    "request_incremental_authorization": false,
    "merchant_order_reference_id": "test_ord",
    "session_expiry": 900   
}'

Webhook for failed payment via nexixpay:

{
    "merchant_id": "merchant_1743678217",
    "event_id": "evt_0195fbf468957b539666947e6762e0af",
    "event_type": "payment_failed",
    "content": {
        "type": "payment_details",
        "object": {
            "payment_id": "pay_LOrSTDvs2fs1rntR8Bv7",
            "merchant_id": "merchant_1743678217",
            "status": "failed",
            "amount": 3596,
            "net_amount": 3596,
            "shipping_cost": null,
            "amount_capturable": 3596,
            "amount_received": null,
            "connector": "nexixpay",
            "client_secret": "pay_LOrSTDvs2fs1rntR8Bv7_secret_ZAC52wYDhKokuUvZjKws",
            "created": "2025-04-03T14:00:35.887Z",
            "currency": "EUR",
            "customer_id": "customer123",
            "customer": {
                "id": "customer123",
                "name": "John Doe",
                "email": "[email protected]",
                "phone": "9999999999",
                "phone_country_code": "+1"
            },
            "description": "Its my first payment request",
            "refunds": null,
            "disputes": null,
            "mandate_id": null,
            "mandate_data": null,
            "setup_future_usage": "off_session",
            "off_session": null,
            "capture_on": null,
            "capture_method": "manual",
            "payment_method": "card",
            "payment_method_data": {
                "card": {
                    "last4": "7704",
                    "card_type": null,
                    "card_network": null,
                    "card_issuer": null,
                    "card_issuing_country": null,
                    "card_isin": "474215",
                    "card_extended_bin": null,
                    "card_exp_month": "12",
                    "card_exp_year": "30",
                    "card_holder_name": "joseph Doe",
                    "payment_checks": null,
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": "token_r5dkurdxxncdiAxecZp2",
            "shipping": {
                "address": {
                    "city": "San Fransico",
                    "country": "IT",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "[email protected]"
            },
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "IT",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "[email protected]"
            },
            "order_details": [
                {
                    "brand": null,
                    "amount": 3545,
                    "category": null,
                    "quantity": 1,
                    "tax_rate": null,
                    "product_id": null,
                    "product_name": "Apple iphone 15",
                    "product_type": null,
                    "sub_category": null,
                    "product_img_link": null,
                    "product_tax_code": null,
                    "total_tax_amount": null,
                    "requires_shipping": null
                }
            ],
            "email": "[email protected]",
            "name": "John Doe",
            "phone": "9999999999",
            "return_url": "https://google.com/",
            "authentication_type": "three_ds",
            "statement_descriptor_name": "joseph",
            "statement_descriptor_suffix": "JS",
            "next_action": null,
            "cancellation_reason": null,
            "error_code": "No error code",
            "error_message": "ThreedsFailed",
            "unified_code": "UE_9000",
            "unified_message": "Something went wrong",
            "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": true,
            "connector_transaction_id": "pay_LOrSTDvs2fs1rntR8Bv7_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": {
                "apple_pay": null,
                "airwallex": null,
                "noon": {
                    "order_category": "pay"
                },
                "braintree": null
            },
            "feature_metadata": null,
            "reference_id": "pay_LOrSTDvs2fs1rntR8Bv7_1",
            "payment_link": null,
            "profile_id": "pro_9rN5ntPWxQFSDMxRHEZ5",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_bB3eKYzBDOgKte0bcmKl",
            "incremental_authorization_allowed": false,
            "authorization_count": null,
            "incremental_authorizations": null,
            "external_authentication_details": null,
            "external_3ds_authentication_attempted": false,
            "expires_on": "2025-04-03T14:15:35.887Z",
            "fingerprint": null,
            "browser_info": {
                "language": "nl-NL",
                "time_zone": 0,
                "ip_address": "128.0.0.1",
                "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
                "color_depth": 24,
                "java_enabled": true,
                "screen_width": 1536,
                "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                "screen_height": 723,
                "java_script_enabled": true
            },
            "payment_method_id": "pm_stzSPzwuoRaFMpPpYb9r",
            "payment_method_status": "inactive",
            "updated": "2025-04-03T14:00:53.638Z",
            "split_payments": null,
            "frm_metadata": null,
            "extended_authorization_applied": null,
            "capture_before": null,
            "merchant_order_reference_id": "test_ord",
            "order_tax_amount": null,
            "connector_mandate_id": "6Hj8lx8blnGI3EMXRX",
            "card_discovery": "manual",
            "issuer_error_code": null,
            "issuer_error_message": null
        }
    },
    "timestamp": "2025-04-03T14:00:53.654Z"
}

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

@mrudulvajpayee4935 mrudulvajpayee4935 added A-connector-compatibility Area: Connector compatibility C-bug Category: Bug labels Apr 3, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 added this to the April 2025 Release milestone Apr 3, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 self-assigned this Apr 3, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 requested a review from a team as a code owner April 3, 2025 07:43
Copy link

semanticdiff-com bot commented Apr 3, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs  68% smaller

kashif-m
kashif-m previously approved these changes Apr 3, 2025
dgeee13
dgeee13 previously approved these changes Apr 3, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 dismissed stale reviews from dgeee13 and kashif-m via b193cfe April 3, 2025 10:08
@mrudulvajpayee4935 mrudulvajpayee4935 force-pushed the handle-error-code-and-message branch from 3834d56 to b193cfe Compare April 3, 2025 10:08
dgeee13
dgeee13 previously approved these changes Apr 3, 2025
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Apr 3, 2025
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu left a comment

Choose a reason for hiding this comment

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

We can populate operation_result in error message as well

deepanshu-iiitu
deepanshu-iiitu previously approved these changes Apr 3, 2025
dgeee13
dgeee13 previously approved these changes Apr 3, 2025
kashif-m
kashif-m previously approved these changes Apr 3, 2025
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Apr 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 4, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 force-pushed the handle-error-code-and-message branch from 7043541 to 8e1a3a9 Compare April 4, 2025 11:35
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Apr 4, 2025
Merged via the queue into main with commit f532b70 Apr 4, 2025
16 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the handle-error-code-and-message branch April 4, 2025 13:26
pixincreate added a commit that referenced this pull request Apr 4, 2025
…acilitapay-pix-pmt

* 'main' of github.com:juspay/hyperswitch: (33 commits)
  fix(connector): [Nexixpay] handle error code and message in failure response (#7713)
  fix(connector): [Coingate] Fix Wasm Changes  (#7716)
  fix(config): add billing payment sync configs in different environments (#7708)
  chore(dashboard): update dashboard toml (#7703)
  chore(postman): update auth for payment connectors in postman collection (#7702)
  feat(connector): [BANKOFAMERICA] Enable SamsungPay In Dashboard (#7677)
  feat(session): Added dpa_client_id, provider to click to pay session response (#7683)
  feat(core): add network error related columns in payment attempt [v2] (#7706)
  chore(version): 2025.04.04.0
  refactor(accounts): move accounts related tables to accounts schema (#7626)
  revert: implement `NameType` for name validation (#6734) (#7717)
  fix(errors): Entry not found error as 4xx instead of 5xx (#7712)
  refactor(analytics): default config for forex_enabled (#7695)
  refactor(core): made provider field in ctp_service_details backward compatible (#7705)
  refactor(openapi): modify profile-delete auth to AdminAPIKey in API doc (#7697)
  fix: web-docker pull from docker hub (#7700)
  ci(cypress): fix iatapay upi payments (#7698)
  docs: Updated next steps after deployment setup on Readme (#7686)
  chore(version): 2025.04.03.0
  fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, BITPAY, HELCIM, PAYBOX] Replaced lazystatic macros with LazyLock (#7524)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-compatibility Area: Connector compatibility C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Nexixpay]: handle error_code and error_message in failure responses of nexixpay
5 participants