-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): add columns unified error code and error message in refund table #6933
base: main
Are you sure you want to change the base?
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -484,6 +493,7 @@ impl AppState { | |||
opensearch_client: Arc::clone(&self.opensearch_client), | |||
grpc_client: Arc::clone(&self.grpc_client), | |||
theme_storage_client: self.theme_storage_client.clone(), | |||
request_headers: None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added locale
in SessionState
@SanchithHegde @jarnura
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdb39d3
to
77d5295
Compare
@@ -147,12 +147,6 @@ pub struct Browser { | |||
user_agent: String, | |||
} | |||
|
|||
#[derive(Debug, Serialize)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
77d5295
to
b7b57f0
Compare
let (payment_link, payment_link_details, payment_link_config) = form_payment_link_data( | ||
&state, | ||
merchant_account, | ||
key_store, | ||
merchant_id, | ||
payment_id, | ||
locale, | ||
Some(state.clone().locale), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need not pass locale here since form_payment_link_data()
already accepts SessionState
, the function can be updated to access state.locale
as needed.
@@ -396,17 +393,15 @@ pub async fn initiate_payment_link_flow( | |||
key_store: domain::MerchantKeyStore, | |||
merchant_id: common_utils::id_type::MerchantId, | |||
payment_id: common_utils::id_type::PaymentId, | |||
request_headers: &header::HeaderMap, | |||
_request_headers: &header::HeaderMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the unused request_headers
argument here and in get_payment_link_status()
(both v1
and v2
features).
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::ErrorUpdate
unified_code and unified_message is saved in DB, and in/refunds
response and/retrieve
response unified message is shown according to the locale passed in headers.This PR introduces
locale
inSessionState
This 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
Output: We get unified message in locale
Checklist
cargo +nightly fmt --all
cargo clippy