feat(core): add columns unified error code and error message in refund table#6933
feat(core): add columns unified error code and error message in refund table#6933Gnanasundari24 merged 2 commits intomainfrom
Conversation
eeb84de to
b28bd29
Compare
migrations/2024-12-24-115958_add-unified-code-and-message-in-refunds/up.sql
Outdated
Show resolved
Hide resolved
f1f9c43 to
d5df68d
Compare
c767aca to
243cdbf
Compare
kashif-m
left a comment
There was a problem hiding this comment.
Needs one change for storing the unified message in refunds table.
crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs
Outdated
Show resolved
Hide resolved
migrations/2024-12-24-115958_add-unified-code-and-message-in-refunds/up.sql
Outdated
Show resolved
Hide resolved
crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs
Outdated
Show resolved
Hide resolved
crates/router/src/routes/app.rs
Outdated
There was a problem hiding this comment.
We may be able to pass HeaderMap to get_session_state() itself and have the field populated here. Then we need not have it as an Option either.
@jarnura What do you think, should the business logic have access to request headers (they can be accessed from SessionState), or should the request header information not leak to the business logic at all, but only be handled in the route handler layer?
There was a problem hiding this comment.
yes, we can handle in get_session_state(), AppState won't related to a session any more since its a global application state and header is session specific one. So lets not leak that information in AppState
There was a problem hiding this comment.
added locale in SessionState
@SanchithHegde @jarnura
There was a problem hiding this comment.
fdb39d3 to
77d5295
Compare
77d5295 to
b7b57f0
Compare
782d3b5 to
66d841f
Compare
66d841f to
fbbfdf3
Compare
fbbfdf3 to
ba20a77
Compare
| theme: payment_link_config.theme.clone(), | ||
| return_url: return_url.clone(), | ||
| locale: locale.clone(), | ||
| locale: Some(state.clone().locale), |
There was a problem hiding this comment.
do we need to clone the whole state, it can be state.locale.clone() right!
| hide_card_nickname_field: payment_link_config.hide_card_nickname_field, | ||
| show_card_form_by_default: payment_link_config.show_card_form_by_default, | ||
| locale, | ||
| locale: Some(state.clone().locale), |
…r-verifyurl-in-redirection-handler * 'main' of github.com:juspay/hyperswitch: (30 commits) test(cypress): add test for In Memory Cache (juspay#6961) chore(version): 2025.01.09.1 fix(dummyconnector): add tenant id in dummyconnector requests (juspay#7008) chore(version): 2025.01.09.0 fix(cypress): backup and restore sessions when using user apis (juspay#6978) feat(users): handle edge features for users in tenancy (juspay#6990) chore(dynamic-fields): [Worldpay] update dynamic fields for payments (juspay#7002) chore(version): 2025.01.08.0 fix: consider status of payment method before filtering wallets in list pm (juspay#7004) feat(core): add columns unified error code and error message in refund table (juspay#6933) feat(connector): [Fiuu] Consume transaction id for error cases for Fiuu (juspay#6998) docs(cypress): update cypress documentation (juspay#6956) chore(version): 2025.01.07.0 chore(keymanager): add tenant-id to keymanager requests (juspay#6968) ci(cypress): Add Session Token Testcases (juspay#6683) Ci(Cypress): Add PML test and Dynamic Fields Test for Novalnet (juspay#6544) chore(version): 2025.01.06.0 ci(cypress): fix adyen sofort in cypress (juspay#6984) chore: add migrations for Currency type in DB (juspay#6980) chore(version): 2025.01.03.0 ...
…d-memory-cache * 'main' of github.com:juspay/hyperswitch: test(cypress): add test for In Memory Cache (#6961) chore(version): 2025.01.09.1 fix(dummyconnector): add tenant id in dummyconnector requests (#7008) chore(version): 2025.01.09.0 fix(cypress): backup and restore sessions when using user apis (#6978) feat(users): handle edge features for users in tenancy (#6990) chore(dynamic-fields): [Worldpay] update dynamic fields for payments (#7002) chore(version): 2025.01.08.0 fix: consider status of payment method before filtering wallets in list pm (#7004) feat(core): add columns unified error code and error message in refund table (#6933) feat(connector): [Fiuu] Consume transaction id for error cases for Fiuu (#6998) docs(cypress): update cypress documentation (#6956)

Type of Change
Description
unified_code and unified_message columns already exists for payment_attempt table, this PR adds unified_code and unified_message in refund table. During
RefundUpdate::ErrorUpdateunified_code and unified_message is saved in DB, and in/refundsresponse and/retrieveresponse unified message is shown according to the locale passed in headers.This PR introduces
localeinSessionStateThis PR introduces
refund_flow(Flow identifier used for performing GSM operations)
Additional Changes
Motivation and Context
How did you test it?
We can test this flow by manually trigger a failure for refunds.
Steps:
1) Make card payment via Fiuu
cURL
curl --location --request POST 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_k6hN6WS14LcwHh4Q7bKCcTDRBwPRUnfQpraO5c7dW6oWiAFOmK8pdWfHlmg6adrt' \ --data-raw '{ "amount":1000, "currency": "MYR", "confirm": true, "payment_link" : false, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 1000, "customer_id": "exampel3rewfdsvc2", "phone": "999999999", "phone_country_code": "+1", "description": "Its my first payment request", "authentication_type": "three_ds", "return_url": "https://google.com", "payment_method": "card", "payment_method_type": "credit", "payment_method_data": { "card": { "card_number": "5105105105105100", "card_exp_month": "12", "card_exp_year": "2030", "card_holder_name": "Max Mustermann", "card_cvc": "444" } }, "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": "103.77.139.95", "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

2)Update DB with following commands to make captured amount greater than the real captured amount
3)Update gateway_status_map and unified_translations table
4)a) Make refunds call with locale "zh-Hant"
cURL
Response

Output: We get translated unified message
4)b)Make refunds call with no locale
cURL
curl --location --request POST 'http://localhost:8080/refunds' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_k6hN6WS14LcwHh4Q7bKCcTDRBwPRUnfQpraO5c7dW6oWiAFOmK8pdWfHlmg6adrt' \ --data-raw '{ "payment_id": "pay_FBXuXJ8A2WdhcwYueQCY", "amount": 3000, "reason": "Customer returned product", "refund_type": "instant", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" } }'Response

Output: We get unified message in english
5)Make refunds retrieve call
cURL
curl --location --request GET 'http://localhost:8080/refunds/ref_rbIPXQW2jgCxEGEu56U7' \ --header 'Accept: application/json' \ --header 'Accept-Language: zh-Hant' \ --header 'api-key: dev_6ix25ZzUaYWPasgWCdTkb8PVZCJEe1X6ABALYbHQxPJT9xOAREiuxXlOAuYdlYAb' \ --header 'Content-Type: text/plain' \ --data-raw '{ "name": "", "description": null, "expiration": "2023-09-23T01:02:03.000Z" }'Response
![Uploading Screenshot 2024-12-27 at 16.31.20.png…]()
Output: We get unified message in locale
Checklist
cargo +nightly fmt --allcargo clippy