Skip to content

refactor(connector): [itau] refactor error reason and code mapping for itau#5718

Merged
likhinbopanna merged 3 commits intomainfrom
itau_error_message_fix
Aug 28, 2024
Merged

refactor(connector): [itau] refactor error reason and code mapping for itau#5718
likhinbopanna merged 3 commits intomainfrom
itau_error_message_fix

Conversation

@srujanchikke
Copy link
Contributor

Type of Change

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

Description

Previously error code is mapped to status code and error reason was not populated with complete Itau error message .This PR fixes this issue.

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?

create a failed payment with itau bank as connector.

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Accept-Language: pt' \
--header 'api-key: dev_YIuwtNJjD1B53fObhypkm3QhyIK0YrBOfNv7q3Kk3vEYC4d14puZckhktJYxzVFS' \
--data-raw '{
    "amount": 1001,
    "currency": "USD",
    "confirm": true,
    "payment_link": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 1001,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "payment_method": "bank_transfer",
    "payment_method_type": "pix",
    "payment_method_data": {
        "bank_transfer": {
            "pix": {
                "pix_key": "a1f4102e-a446-4a57-bcce-6fa48899c1d",
                "cnpj": "74469027417312",
                "cpf": "10599054689"
            }
        },
        "billing": {
            "address": {
                "line1": "1467",
                "line2": "CA",
                "line3": "CA",
                "city": "San Fransico",
                "state": "California",
                "zip": "94122",
                "country": "US",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "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,
        "ip_address": "127.2.2.0",
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true
    },
    
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

response :

{
    "payment_id": "pay_Hw2TlDRgVxrZk0qDkHDY",
    "merchant_id": "merchant_1724746292",
    "status": "failed",
    "amount": 1001,
    "net_amount": 1001,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "itaubank",
    "client_secret": "pay_Hw2TlDRgVxrZk0qDkHDY_secret_llhTtdEiYdbuqqKeUazd",
    "created": "2024-08-27T10:45:46.355Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "bank_transfer",
    "payment_method_data": {
        "bank_transfer": {},
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "CA",
                "line3": "CA",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": null
        }
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": "Cobrança inválida.",
    "error_message": " razao - O campo cob.chave não respeita o schema., propriedade - chave, valor - a1f4102e-a446-4a57-bcce-6fa48899c1d;",
    "unified_code": "UE_000",
    "unified_message": "Algo deu errado",
    "payment_experience": null,
    "payment_method_type": "pix",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1724755546,
        "expires": 1724759146,
        "secret": "epk_ea4d8e44d3804ab590668123ce91c5ef"
    },
    "manual_retry_allowed": true,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_XzGmgtNZmGoW7EBdXOzr",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_H3VuLu4F0mdSxr4Y4rt4",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-08-27T11:00:46.354Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "127.2.2.0",
        "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": null,
    "payment_method_status": null,
    "updated": "2024-08-27T10:45:49.851Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": 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

@srujanchikke srujanchikke self-assigned this Aug 27, 2024
@srujanchikke srujanchikke requested a review from a team as a code owner August 27, 2024 10:54
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 27, 2024

Review changes with SemanticDiff.

Analyzed 2 of 2 files.

Overall, the semantic diff is 19% smaller than the GitHub diff.

Filename Status
✔️ crates/router/src/connector/itaubank.rs 23.4% smaller
✔️ crates/router/src/connector/itaubank/transformers.rs Analyzed

@srujanchikke srujanchikke added A-connector-integration Area: Connector integration S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Aug 27, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit f024ffb Aug 28, 2024
@likhinbopanna likhinbopanna deleted the itau_error_message_fix branch August 28, 2024 07:57
pixincreate added a commit that referenced this pull request Aug 28, 2024
* 'main' of github.com:juspay/hyperswitch:
  feat(connector): [FISERVEMEA] Integrate cards (#5672)
  ci(cypress): Add routing testcases (#5571)
  fix(router): skip external three_ds flow for recurring payments (#5730)
  refactor(customer_v2): fixed customer_v2 create panic issue (#5699)
  feat(user_roles): support switch for new hierarchy (#5692)
  refactor(router): add domain type for merchant_connector_account id (#5685)
  refactor(cypress_tests): handle api keys check in api key list call (#5719)
  feat(connector): [NEXIXPAY] Add template code (#5684)
  refactor(connector): [itau] refactor error reason and code mapping for itau (#5718)
  fix(core): fix merchant connector account create for v2  (#5716)
  chore(version): 2024.08.28.0
  fix(routing): fix routing routes to deserialise correctly (#5724)
  feat(euclid): add a new variant in payment type i.e ppt_mandate (#5681)
  feat(core): Add mTLS certificates for each request (#5636)
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Sep 1, 2024
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.

5 participants