Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(connector): [bluesnap]Enhance currency Mapping with ConnectorCurrencyCommon Trait (#2193)

chikke srujan6db60b8cd431
diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs
index 04206dd80e..9819b91246 100644
--- a/crates/router/src/connector/bluesnap.rs
+++ b/crates/router/src/connector/bluesnap.rs
@@ -63,6 +63,10 @@ impl ConnectorCommon for Bluesnap {
"bluesnap"
}
+ fn get_currency_unit(&self) -> api::CurrencyUnit {
+ api::CurrencyUnit::Base
+ }
+
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
@@ -405,7 +409,13 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
&self,
req: &types::PaymentsCaptureRouterData,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
- let connector_req = bluesnap::BluesnapCaptureRequest::try_from(req)?;
+ let connector_router_data = bluesnap::BluesnapRouterData::try_from((
+ &self.get_currency_unit(),
+ req.request.currency,
+ req.request.amount_to_capture,
+ req,
+ ))?;
+ let connector_req = bluesnap::BluesnapCaptureRequest::try_from(&connector_router_data)?;
let bluesnap_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<bluesnap::BluesnapCaptureRequest>::encode_to_string_of_json,
@@ -584,9 +594,16 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
&self,
req: &types::PaymentsAuthorizeRouterData,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
+ let connector_router_data = bluesnap::BluesnapRouterData::try_from((
+ &self.get_currency_unit(),
+ req.request.currency,
+ req.request.amount,
+ req,
+ ))?;
match req.is_three_ds() && req.request.is_card() {
true => {
- let connector_req = bluesnap::BluesnapPaymentsTokenRequest::try_from(req)?;
+ let connector_req =
+ bluesnap::BluesnapPaymentsTokenRequest::try_from(&connector_router_data)?;
let bluesnap_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<bluesnap::BluesnapPaymentsRequest>::encode_to_string_of_json,
@@ -595,7 +612,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
Ok(Some(bluesnap_req))
}
_ => {
- let connector_req = bluesnap::BluesnapPaymentsRequest::try_from(req)?;
+ let connector_req =
+ bluesnap::BluesnapPaymentsRequest::try_from(&connector_router_data)?;
let bluesnap_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<bluesnap::BluesnapPaymentsRequest>::encode_to_string_of_json,
@@ -711,7 +729,14 @@ impl
&self,
req: &types::PaymentsCompleteAuthorizeRouterData,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
- let connector_req = bluesnap::BluesnapCompletePaymentsRequest::try_from(req)?;
+ let connector_router_data = bluesnap::BluesnapRouterData::try_from((
+ &self.get_currency_unit(),
+ req.request.currency,
+ req.request.amount,
+ req,
+ ))?;
+ let connector_req =
+ bluesnap::BluesnapCompletePaymentsRequest::try_from(&connector_router_data)?;
let bluesnap_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<bluesnap::BluesnapPaymentsRequest>::encode_to_string_of_json,
@@ -802,7 +827,13 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
&self,
req: &types::RefundsRouterData<api::Execute>,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
- let connector_req = bluesnap::BluesnapRefundRequest::try_from(req)?;
+ let connector_router_data = bluesnap::BluesnapRouterData::try_from((
+ &self.get_currency_unit(),
+ req.request.currency,
+ req.request.refund_amount,
+ req,
+ ))?;
+ let connector_req = bluesnap::BluesnapRefundRequest::try_from(&connector_router_data)?;
let bluesnap_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<bluesnap::BluesnapRefundRequest>::encode_to_string_of_json,
diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rs
index 80dc3668ff..d2e1efa527 100644
--- a/crates/router/src/connector/bluesnap/transformers.rs
+++ b/crates/router/src/connector/bluesnap/transformers.rs
@@ -21,6 +21,37 @@ use crate::{
utils::{Encode, OptionExt},
};
+#[derive(Debug, Serialize)]
+pub struct BluesnapRouterData<T> {
+ pub amount: String,
+ pub router_data: T,
+}
+
+impl<T>
+ TryFrom<(
+ &types::api::CurrencyUnit,
+ types::storage::enums::Currency,
+ i64,
+ T,
+ )> for BluesnapRouterData<T>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ (currency_unit, currency, amount, item): (
+ &types::api::CurrencyUnit,
+ types::storage::enums::Currency,
+ i64,
+ T,
+ ),
+ ) -> Result<Self, Self::Error> {
+ let amount = utils::get_amount_as_string(currency_unit, amount, currency)?;
+ Ok(Self {
+ amount,
+ router_data: item,
+ })
+ }
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BluesnapPaymentsRequest {
@@ -168,10 +199,14 @@ pub struct BluesnapPaymentsTokenRequest {
exp_date: Secret<String>,
}
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for BluesnapPaymentsTokenRequest {
+impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>>
+ for BluesnapPaymentsTokenRequest
+{
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
- match item.request.payment_method_data {
+ fn try_from(
+ item: &BluesnapRouterData<&types::PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_data {
api::PaymentMethodData::Card(ref ccard) => Ok(Self {
cc_number: ccard.card_number.clone(),
exp_date: ccard.get_expiry_date_as_mmyyyy("/"),
@@ -197,170 +232,180 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BluesnapPaymentsTokenReque
}
}
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for BluesnapPaymentsRequest {
+impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> for BluesnapPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
- let auth_mode = match item.request.capture_method {
+ fn try_from(
+ item: &BluesnapRouterData<&types::PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let auth_mode = match item.router_data.request.capture_method {
Some(enums::CaptureMethod::Manual) => BluesnapTxnType::AuthOnly,
_ => BluesnapTxnType::AuthCapture,
};
- let (payment_method, card_holder_info) = match item.request.payment_method_data.clone() {
- api::PaymentMethodData::Card(ref ccard) => Ok((
- PaymentMethodDetails::CreditCard(Card {
- card_number: ccard.card_number.clone(),
- expiration_month: ccard.card_exp_month.clone(),
- expiration_year: ccard.get_expiry_year_4_digit(),
- security_code: ccard.card_cvc.clone(),
- }),
- get_card_holder_info(item.get_billing_address()?, item.request.get_email()?)?,
- )),
- api::PaymentMethodData::Wallet(wallet_data) => match wallet_data {
- api_models::payments::WalletData::GooglePay(payment_method_data) => {
- let gpay_object = Encode::<BluesnapGooglePayObject>::encode_to_string_of_json(
- &BluesnapGooglePayObject {
- payment_method_data: utils::GooglePayWalletData::from(
- payment_method_data,
- ),
- },
- )
- .change_context(errors::ConnectorError::RequestEncodingFailed)?;
- Ok((
- PaymentMethodDetails::Wallet(BluesnapWallet {
- wallet_type: BluesnapWalletTypes::GooglePay,
- encoded_payment_token: Secret::new(
- consts::BASE64_ENGINE.encode(gpay_object),
- ),
- }),
- None,
- ))
- }
- api_models::payments::WalletData::ApplePay(payment_method_data) => {
- let apple_pay_payment_data = payment_method_data
- .get_applepay_decoded_payment_data()
- .change_context(errors::ConnectorError::RequestEncodingFailed)?;
- let apple_pay_payment_data: ApplePayEncodedPaymentData = apple_pay_payment_data
- .expose()[..]
- .as_bytes()
- .parse_struct("ApplePayEncodedPaymentData")
- .change_context(errors::ConnectorError::RequestEncodingFailed)?;
-
- let billing = item
- .address
- .billing
- .to_owned()
- .get_required_value("billing")
- .change_context(errors::ConnectorError::MissingRequiredField {
- field_name: "billing",
- })?;
-
- let billing_address = billing
- .address
- .get_required_value("billing_address")
- .change_context(errors::ConnectorError::MissingRequiredField {
- field_name: "billing",
- })?;
-
- let mut address = Vec::new();
- if let Some(add) = billing_address.line1.to_owned() {
- address.push(add)
+ let (payment_method, card_holder_info) =
+ match item.router_data.request.payment_method_data.clone() {
+ api::PaymentMethodData::Card(ref ccard) => Ok((
+ PaymentMethodDetails::CreditCard(Card {
+ card_number: ccard.card_number.clone(),
+ expiration_month: ccard.card_exp_month.clone(),
+ expiration_year: ccard.get_expiry_year_4_digit(),
+ security_code: ccard.card_cvc.clone(),
+ }),
+ get_card_holder_info(
+ item.router_data.get_billing_address()?,
+ item.router_data.request.get_email()?,
+ )?,
+ )),
+ api::PaymentMethodData::Wallet(wallet_data) => match wallet_data {
+ api_models::payments::WalletData::GooglePay(payment_method_data) => {
+ let gpay_object =
+ Encode::<BluesnapGooglePayObject>::encode_to_string_of_json(
+ &BluesnapGooglePayObject {
+ payment_method_data: utils::GooglePayWalletData::from(
+ payment_method_data,
+ ),
+ },
+ )
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+ Ok((
+ PaymentMethodDetails::Wallet(BluesnapWallet {
+ wallet_type: BluesnapWalletTypes::GooglePay,
+ encoded_payment_token: Secret::new(
+ consts::BASE64_ENGINE.encode(gpay_object),
+ ),
+ }),
+ None,
+ ))
}
- if let Some(add) = billing_address.line2.to_owned() {
- address.push(add)
+ api_models::payments::WalletData::ApplePay(payment_method_data) => {
+ let apple_pay_payment_data = payment_method_data
+ .get_applepay_decoded_payment_data()
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+ let apple_pay_payment_data: ApplePayEncodedPaymentData =
+ apple_pay_payment_data.expose()[..]
+ .as_bytes()
+ .parse_struct("ApplePayEncodedPaymentData")
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+
+ let billing = item
+ .router_data
+ .address
+ .billing
+ .to_owned()
+ .get_required_value("billing")
+ .change_context(errors::ConnectorError::MissingRequiredField {
+ field_name: "billing",
+ })?;
+
+ let billing_address = billing
+ .address
+ .get_required_value("billing_address")
+ .change_context(errors::ConnectorError::MissingRequiredField {
+ field_name: "billing",
+ })?;
+
+ let mut address = Vec::new();
+ if let Some(add) = billing_address.line1.to_owned() {
+ address.push(add)
+ }
+ if let Some(add) = billing_address.line2.to_owned() {
+ address.push(add)
+ }
+ if let Some(add) = billing_address.line3.to_owned() {
+ address.push(add)
+ }
+
+ let apple_pay_object =
+ Encode::<EncodedPaymentToken>::encode_to_string_of_json(
+ &EncodedPaymentToken {
+ token: ApplepayPaymentData {
+ payment_data: apple_pay_payment_data,
+ payment_method: payment_method_data
+ .payment_method
+ .to_owned()
+ .into(),
+ transaction_identifier: payment_method_data
+ .transaction_identifier,
+ },
+ billing_contact: BillingDetails {
+ country_code: billing_address.country,
+ address_lines: Some(address),
+ family_name: billing_address.last_name.to_owned(),
+ given_name: billing_address.first_name.to_owned(),
+ postal_code: billing_address.zip,
+ },
+ },
+ )
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+
+ Ok((
+ PaymentMethodDetails::Wallet(BluesnapWallet {
+ wallet_type: BluesnapWalletTypes::ApplePay,
+ encoded_payment_token: Secret::new(
+ consts::BASE64_ENGINE.encode(apple_pay_object),
+ ),
+ }),
+ get_card_holder_info(
+ item.router_data.get_billing_address()?,
+ item.router_data.request.get_email()?,
+ )?,
+ ))
}
- if let Some(add) = billing_address.line3.to_owned() {
- address.push(add)
+ payments::WalletData::AliPayQr(_)
+ | payments::WalletData::AliPayRedirect(_)
+ | payments::WalletData::AliPayHkRedirect(_)
+ | payments::WalletData::MomoRedirect(_)
+ | payments::WalletData::KakaoPayRedirect(_)
+ | payments::WalletData::GoPayRedirect(_)
+ | payments::WalletData::GcashRedirect(_)
+ | payments::WalletData::ApplePayRedirect(_)
+ | payments::WalletData::ApplePayThirdPartySdk(_)
+ | payments::WalletData::DanaRedirect {}
+ | payments::WalletData::GooglePayRedirect(_)
+ | payments::WalletData::GooglePayThirdPartySdk(_)
+ | payments::WalletData::MbWayRedirect(_)
+ | payments::WalletData::MobilePayRedirect(_)
+ | payments::WalletData::PaypalRedirect(_)
+ | payments::WalletData::PaypalSdk(_)
+ | payments::WalletData::SamsungPay(_)
+ | payments::WalletData::TwintRedirect {}
+ | payments::WalletData::VippsRedirect {}
+ | payments::WalletData::TouchNGoRedirect(_)
+ | payments::WalletData::WeChatPayRedirect(_)
+ | payments::WalletData::CashappQr(_)
+ | payments::WalletData::SwishQr(_)
+ | payments::WalletData::WeChatPayQr(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("bluesnap"),
+ ))
}
-
- let apple_pay_object = Encode::<EncodedPaymentToken>::encode_to_string_of_json(
- &EncodedPaymentToken {
- token: ApplepayPaymentData {
- payment_data: apple_pay_payment_data,
- payment_method: payment_method_data
- .payment_method
- .to_owned()
- .into(),
- transaction_identifier: payment_method_data.transaction_identifier,
- },
- billing_contact: BillingDetails {
- country_code: billing_address.country,
- address_lines: Some(address),
- family_name: billing_address.last_name.to_owned(),
- given_name: billing_address.first_name.to_owned(),
- postal_code: billing_address.zip,
- },
- },
- )
- .change_context(errors::ConnectorError::RequestEncodingFailed)?;
-
- Ok((
- PaymentMethodDetails::Wallet(BluesnapWallet {
- wallet_type: BluesnapWalletTypes::ApplePay,
- encoded_payment_token: Secret::new(
- consts::BASE64_ENGINE.encode(apple_pay_object),
- ),
- }),
- get_card_holder_info(
- item.get_billing_address()?,
- item.request.get_email()?,
- )?,
- ))
- }
- payments::WalletData::AliPayQr(_)
- | payments::WalletData::AliPayRedirect(_)
- | payments::WalletData::AliPayHkRedirect(_)
- | payments::WalletData::MomoRedirect(_)
- | payments::WalletData::KakaoPayRedirect(_)
- | payments::WalletData::GoPayRedirect(_)
- | payments::WalletData::GcashRedirect(_)
- | payments::WalletData::ApplePayRedirect(_)
- | payments::WalletData::ApplePayThirdPartySdk(_)
- | payments::WalletData::DanaRedirect {}
- | payments::WalletData::GooglePayRedirect(_)
- | payments::WalletData::GooglePayThirdPartySdk(_)
- | payments::WalletData::MbWayRedirect(_)
- | payments::WalletData::MobilePayRedirect(_)
- | payments::WalletData::PaypalRedirect(_)
- | payments::WalletData::PaypalSdk(_)
- | payments::WalletData::SamsungPay(_)
- | payments::WalletData::TwintRedirect {}
- | payments::WalletData::VippsRedirect {}
- | payments::WalletData::TouchNGoRedirect(_)
- | payments::WalletData::WeChatPayRedirect(_)
- | payments::WalletData::CashappQr(_)
- | payments::WalletData::SwishQr(_)
- | payments::WalletData::WeChatPayQr(_) => {
+ },
+ payments::PaymentMethodData::PayLater(_)
+ | payments::PaymentMethodData::BankRedirect(_)
+ | payments::PaymentMethodData::BankDebit(_)
+ | payments::PaymentMethodData::BankTransfer(_)
+ | payments::PaymentMethodData::Crypto(_)
+ | payments::PaymentMethodData::MandatePayment
+ | payments::PaymentMethodData::Reward
+ | payments::PaymentMethodData::Upi(_)
+ | payments::PaymentMethodData::CardRedirect(_)
+ | payments::PaymentMethodData::Voucher(_)
+ | payments::PaymentMethodData::GiftCard(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("bluesnap"),
))
}
- },
- payments::PaymentMethodData::PayLater(_)
- | payments::PaymentMethodData::BankRedirect(_)
- | payments::PaymentMethodData::BankDebit(_)
- | payments::PaymentMethodData::BankTransfer(_)
- | payments::PaymentMethodData::Crypto(_)
- | payments::PaymentMethodData::MandatePayment
- | payments::PaymentMethodData::Reward
- | payments::PaymentMethodData::Upi(_)
- | payments::PaymentMethodData::CardRedirect(_)
- | payments::PaymentMethodData::Voucher(_)
- | payments::PaymentMethodData::GiftCard(_) => {
- Err(errors::ConnectorError::NotImplemented(
- utils::get_unimplemented_payment_method_error_message("bluesnap"),
- ))
- }
- }?;
+ }?;
Ok(Self {
- amount: utils::to_currency_base_unit(item.request.amount, item.request.currency)?,
+ amount: item.amount.to_owned(),
payment_method,
- currency: item.request.currency,
+ currency: item.router_data.request.currency,
card_transaction_type: auth_mode,
three_d_secure: None,
transaction_fraud_info: Some(TransactionFraudInfo {
- fraud_session_id: item.payment_id.clone(),
+ fraud_session_id: item.router_data.payment_id.clone(),
}),
card_holder_info,
- merchant_transaction_id: Some(item.connector_request_reference_id.clone()),
+ merchant_transaction_id: Some(item.router_data.connector_request_reference_id.clone()),
})
}
}
@@ -493,10 +538,15 @@ pub struct BluesnapCompletePaymentsRequest {
merchant_transaction_id: Option<String>,
}
-impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for BluesnapCompletePaymentsRequest {
+impl TryFrom<&BluesnapRouterData<&types::PaymentsCompleteAuthorizeRouterData>>
+ for BluesnapCompletePaymentsRequest
+{
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::PaymentsCompleteAuthorizeRouterData) -> Result<Self, Self::Error> {
+ fn try_from(
+ item: &BluesnapRouterData<&types::PaymentsCompleteAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
let redirection_response: BluesnapRedirectionResponse = item
+ .router_data
.request
.redirect_response
.as_ref()
@@ -508,6 +558,7 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for BluesnapCompletePa
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let pf_token = item
+ .router_data
.request
.redirect_response
.clone()
@@ -528,13 +579,13 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for BluesnapCompletePa
.parse_struct("BluesnapThreeDsResult")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- let auth_mode = match item.request.capture_method {
+ let auth_mode = match item.router_data.request.capture_method {
Some(enums::CaptureMethod::Manual) => BluesnapTxnType::AuthOnly,
_ => BluesnapTxnType::AuthCapture,
};
Ok(Self {
- amount: utils::to_currency_base_unit(item.request.amount, item.request.currency)?,
- currency: item.request.currency,
+ amount: item.amount.to_owned(),
+ currency: item.router_data.request.currency,
card_transaction_type: auth_mode,
three_d_secure: Some(BluesnapThreeDSecureInfo {
three_d_secure_reference_id: redirection_result
@@ -545,13 +596,13 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for BluesnapCompletePa
.three_d_secure_reference_id,
}),
transaction_fraud_info: Some(TransactionFraudInfo {
- fraud_session_id: item.payment_id.clone(),
+ fraud_session_id: item.router_data.payment_id.clone(),
}),
card_holder_info: get_card_holder_info(
- item.get_billing_address()?,
- item.request.get_email()?,
+ item.router_data.get_billing_address()?,
+ item.router_data.request.get_email()?,
)?,
- merchant_transaction_id: Some(item.connector_request_reference_id.clone()),
+ merchant_transaction_id: Some(item.router_data.connector_request_reference_id.clone()),
pf_token,
})
}
@@ -610,17 +661,21 @@ pub struct BluesnapCaptureRequest {
amount: Option<String>,
}
-impl TryFrom<&types::PaymentsCaptureRouterData> for BluesnapCaptureRequest {
+impl TryFrom<&BluesnapRouterData<&types::PaymentsCaptureRouterData>> for BluesnapCaptureRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::PaymentsCaptureRouterData) -> Result<Self, Self::Error> {
+ fn try_from(
+ item: &BluesnapRouterData<&types::PaymentsCaptureRouterData>,
+ ) -> Result<Self, Self::Error> {
let card_transaction_type = BluesnapTxnType::Capture;
- let transaction_id = item.request.connector_transaction_id.to_string();
- let amount =
- utils::to_currency_base_unit(item.request.amount_to_capture, item.request.currency)?;
+ let transaction_id = item
+ .router_data
+ .request
+ .connector_transaction_id
+ .to_string();
Ok(Self {
card_transaction_type,
transaction_id,
- amount: Some(amount),
+ amount: Some(item.amount.to_owned()),
})
}
}
@@ -798,15 +853,14 @@ pub struct BluesnapRefundRequest {
reason: Option<String>,
}
-impl<F> TryFrom<&types::RefundsRouterData<F>> for BluesnapRefundRequest {
+impl<F> TryFrom<&BluesnapRouterData<&types::RefundsRouterData<F>>> for BluesnapRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
+ fn try_from(
+ item: &BluesnapRouterData<&types::RefundsRouterData<F>>,
+ ) -> Result<Self, Self::Error> {
Ok(Self {
- reason: item.request.reason.clone(),
- amount: Some(utils::to_currency_base_unit(
- item.request.refund_amount,
- item.request.currency,
- )?),
+ reason: item.router_data.request.reason.clone(),
+ amount: Some(item.amount.to_owned()),
})
}
}