mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
fix: refund fix with connector_metadata (#330)
This commit is contained in:
@ -3,13 +3,13 @@ use std::marker::PhantomData;
|
||||
use error_stack::ResultExt;
|
||||
use router_env::{instrument, tracing};
|
||||
|
||||
use super::payments::{helpers, PaymentAddress};
|
||||
use super::payments::PaymentAddress;
|
||||
use crate::{
|
||||
consts,
|
||||
core::errors::{self, RouterResult},
|
||||
routes::AppState,
|
||||
types::{
|
||||
self, api,
|
||||
self,
|
||||
storage::{self, enums},
|
||||
},
|
||||
utils::{generate_id, OptionExt, ValueExt},
|
||||
@ -22,7 +22,6 @@ pub async fn construct_refund_router_data<'a, F>(
|
||||
connector_id: &str,
|
||||
merchant_account: &storage::MerchantAccount,
|
||||
money: (i64, enums::Currency),
|
||||
payment_method_data: Option<&'a api::PaymentMethod>,
|
||||
payment_intent: &'a storage::PaymentIntent,
|
||||
payment_attempt: &storage::PaymentAttempt,
|
||||
refund: &'a storage::Refund,
|
||||
@ -48,17 +47,6 @@ pub async fn construct_refund_router_data<'a, F>(
|
||||
let payment_method_type = payment_attempt
|
||||
.payment_method
|
||||
.get_required_value("payment_method_type")?;
|
||||
let payment_method_data = match payment_method_data.cloned() {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
let (pm, _) = helpers::Vault::get_payment_method_data_from_locker(
|
||||
state,
|
||||
&payment_attempt.attempt_id,
|
||||
)
|
||||
.await?;
|
||||
pm.get_required_value("payment_method_data")?
|
||||
}
|
||||
};
|
||||
|
||||
let router_data = types::RouterData {
|
||||
flow: PhantomData,
|
||||
@ -80,11 +68,11 @@ pub async fn construct_refund_router_data<'a, F>(
|
||||
amount_captured: payment_intent.amount_captured,
|
||||
request: types::RefundsData {
|
||||
refund_id: refund.refund_id.clone(),
|
||||
payment_method_data,
|
||||
connector_transaction_id: refund.connector_transaction_id.clone(),
|
||||
refund_amount: refund.refund_amount,
|
||||
currency,
|
||||
amount,
|
||||
connector_metadata: payment_attempt.connector_metadata.clone(),
|
||||
reason: refund.refund_reason.clone(),
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user