fix(connector): [Braintree] Consume merchant_account_id and merchant_config_currency in payment requests (#7408)

Co-authored-by: Debarshi Gupta <debarshi.gupta@Debarshi-Gupta-CM92YWDXFD.local>
This commit is contained in:
DEEPANSHU BANSAL
2025-03-05 16:30:28 +05:30
committed by GitHub
parent 38bb7676be
commit 00d69bd924
16 changed files with 229 additions and 11 deletions

View File

@ -304,6 +304,8 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
integrity_object: None,
shipping_cost: payment_data.payment_intent.amount_details.shipping_cost,
additional_payment_method_data: None,
merchant_account_id: None,
merchant_config_currency: None,
};
let connector_mandate_request_reference_id = payment_data
.payment_attempt
@ -3038,6 +3040,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
.payment_data
.payment_intent
.connector_metadata
.clone()
.map(|cm| {
cm.parse_value::<api_models::payments::ConnectorMetadata>("ConnectorMetadata")
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -3046,6 +3049,25 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
.transpose()?
.and_then(|cm| cm.noon.and_then(|noon| noon.order_category));
let braintree_metadata = additional_data
.payment_data
.payment_intent
.connector_metadata
.clone()
.map(|cm| {
cm.parse_value::<api_models::payments::ConnectorMetadata>("ConnectorMetadata")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed parsing ConnectorMetadata")
})
.transpose()?
.and_then(|cm| cm.braintree);
let merchant_account_id = braintree_metadata
.as_ref()
.and_then(|braintree| braintree.merchant_account_id.clone());
let merchant_config_currency =
braintree_metadata.and_then(|braintree| braintree.merchant_config_currency);
let order_details = additional_data
.payment_data
.payment_intent
@ -3185,6 +3207,8 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
integrity_object: None,
additional_payment_method_data,
shipping_cost,
merchant_account_id,
merchant_config_currency,
})
}
}
@ -4037,6 +4061,23 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
attempt,
connector_name,
));
let braintree_metadata = payment_data
.payment_intent
.connector_metadata
.clone()
.map(|cm| {
cm.parse_value::<api_models::payments::ConnectorMetadata>("ConnectorMetadata")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed parsing ConnectorMetadata")
})
.transpose()?
.and_then(|cm| cm.braintree);
let merchant_account_id = braintree_metadata
.as_ref()
.and_then(|braintree| braintree.merchant_account_id.clone());
let merchant_config_currency =
braintree_metadata.and_then(|braintree| braintree.merchant_config_currency);
Ok(Self {
setup_future_usage: payment_data.payment_intent.setup_future_usage,
mandate_id: payment_data.mandate_id.clone(),
@ -4060,6 +4101,8 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
complete_authorize_url,
metadata: payment_data.payment_intent.metadata,
customer_acceptance: payment_data.customer_acceptance,
merchant_account_id,
merchant_config_currency,
})
}
}

View File

@ -107,6 +107,8 @@ pub async fn construct_relay_refund_router_data<F>(
split_refunds: None,
integrity_object: None,
refund_status: common_enums::RefundStatus::from(relay_record.status),
merchant_account_id: None,
merchant_config_currency: None,
},
response: Err(ErrorResponse::default()),

View File

@ -338,6 +338,23 @@ pub async fn construct_refund_router_data<'a, F>(
let connector_refund_id = refund.get_optional_connector_refund_id().cloned();
let braintree_metadata = payment_intent
.connector_metadata
.clone()
.map(|cm| {
cm.parse_value::<api_models::payments::ConnectorMetadata>("ConnectorMetadata")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed parsing ConnectorMetadata")
})
.transpose()?
.and_then(|cm| cm.braintree);
let merchant_account_id = braintree_metadata
.as_ref()
.and_then(|braintree| braintree.merchant_account_id.clone());
let merchant_config_currency =
braintree_metadata.and_then(|braintree| braintree.merchant_config_currency);
let router_data = types::RouterData {
flow: PhantomData,
merchant_id: merchant_account.get_id().clone(),
@ -376,6 +393,8 @@ pub async fn construct_refund_router_data<'a, F>(
split_refunds,
integrity_object: None,
refund_status: refund.refund_status,
merchant_account_id,
merchant_config_currency,
},
response: Ok(types::RefundsResponseData {

View File

@ -1588,6 +1588,7 @@ pub fn build_redirection_form(
client_token,
card_token,
bin,
acs_url,
} => {
maud::html! {
(maud::DOCTYPE)
@ -1664,7 +1665,7 @@ pub fn build_redirection_form(
}} else {{
// console.log(payload);
var f = document.createElement('form');
f.action=window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/braintree\");
f.action=\"{acs_url}\";
var i = document.createElement('input');
i.type = 'hidden';
f.method='POST';

View File

@ -905,6 +905,8 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {
integrity_object: None,
additional_payment_method_data: None,
shipping_cost: data.request.shipping_cost,
merchant_account_id: None,
merchant_config_currency: None,
}
}
}

View File

@ -60,6 +60,8 @@ impl VerifyConnectorData {
integrity_object: None,
additional_payment_method_data: None,
shipping_cost: None,
merchant_account_id: None,
merchant_config_currency: None,
}
}

View File

@ -406,6 +406,8 @@ pub trait ConnectorActions: Connector {
split_refunds: None,
integrity_object: None,
refund_status: enums::RefundStatus::Pending,
merchant_account_id: None,
merchant_config_currency: None,
}),
payment_info,
);
@ -980,6 +982,8 @@ impl Default for PaymentAuthorizeType {
merchant_order_reference_id: None,
additional_payment_method_data: None,
shipping_cost: None,
merchant_account_id: None,
merchant_config_currency: None,
};
Self(data)
}
@ -1069,6 +1073,8 @@ impl Default for PaymentRefundType {
split_refunds: None,
integrity_object: None,
refund_status: enums::RefundStatus::Pending,
merchant_account_id: None,
merchant_config_currency: None,
};
Self(data)
}