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

feat(connector): mask pii information in connector request and response for stripe, aci, adyen, airwallex and authorizedotnet (#3678)

AkshayaFoiger1c6913be747b
diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs
index ed56fc5f52..fe621bccd0 100644
--- a/crates/router/src/connector/aci/transformers.rs
+++ b/crates/router/src/connector/aci/transformers.rs
@@ -3,7 +3,7 @@ use std::str::FromStr;
use api_models::enums::BankNames;
use common_utils::pii::Email;
use error_stack::report;
-use masking::Secret;
+use masking::{ExposeInterface, Secret};
use reqwest::Url;
use serde::{Deserialize, Serialize};
@@ -382,7 +382,7 @@ pub struct Instruction {
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
pub struct BankDetails {
#[serde(rename = "bankAccount.holder")]
- pub account_holder: String,
+ pub account_holder: Secret<String>,
}
#[allow(dead_code)]
@@ -657,10 +657,11 @@ impl FromStr for AciPaymentStatus {
#[serde(rename_all = "camelCase")]
pub struct AciPaymentsResponse {
id: String,
- registration_id: Option<String>,
+ registration_id: Option<Secret<String>>,
// ndc is an internal unique identifier for the request.
ndc: String,
timestamp: String,
+ // Number useful for support purposes.
build_number: String,
pub(super) result: ResultCode,
pub(super) redirect: Option<AciRedirectionData>,
@@ -734,7 +735,7 @@ impl<F, T>
.response
.registration_id
.map(|id| types::MandateReference {
- connector_mandate_id: Some(id),
+ connector_mandate_id: Some(id.expose()),
payment_method_id: None,
});
diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs
index 78c3fe6581..771ad993ac 100644
--- a/crates/router/src/connector/adyen.rs
+++ b/crates/router/src/connector/adyen.rs
@@ -7,6 +7,7 @@ use base64::Engine;
use common_utils::request::RequestContent;
use diesel_models::{enums as storage_enums, enums};
use error_stack::{IntoReport, ResultExt};
+use masking::ExposeInterface;
use ring::hmac;
use router_env::{instrument, tracing};
@@ -467,8 +468,10 @@ impl
.response
.parse_struct("AdyenCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
+
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
@@ -610,8 +613,10 @@ impl
.response
.parse_struct("AdyenPaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
+
let is_multiple_capture_sync = match data.request.sync_type {
types::SyncRequestType::MultipleCaptureSync(_) => true,
types::SyncRequestType::SinglePaymentSync => false,
@@ -1513,7 +1518,7 @@ impl api::IncomingWebhook for Adyen {
let notif_item = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
- let base64_signature = notif_item.additional_data.hmac_signature;
+ let base64_signature = notif_item.additional_data.hmac_signature.expose();
Ok(base64_signature.as_bytes().to_vec())
}
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index bcf8748bc0..a2fc7cc7ba 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -4,7 +4,7 @@ use api_models::{enums, payments, webhooks};
use cards::CardNumber;
use common_utils::ext_traits::Encode;
use error_stack::ResultExt;
-use masking::PeekInterface;
+use masking::{ExposeInterface, PeekInterface};
use reqwest::Url;
use serde::{Deserialize, Serialize};
use time::{Duration, OffsetDateTime, PrimitiveDateTime};
@@ -95,10 +95,10 @@ pub struct AdditionalData {
pub recurring_processing_model: Option<AdyenRecurringModel>,
/// Enable recurring details in dashboard to receive this ID, https://docs.adyen.com/online-payments/tokenization/create-and-use-tokens#test-and-go-live
#[serde(rename = "recurring.recurringDetailReference")]
- recurring_detail_reference: Option<String>,
+ recurring_detail_reference: Option<Secret<String>>,
#[serde(rename = "recurring.shopperReference")]
recurring_shopper_reference: Option<String>,
- network_tx_reference: Option<String>,
+ network_tx_reference: Option<Secret<String>>,
#[cfg(feature = "payouts")]
payout_eligible: Option<PayoutEligibility>,
funds_availability: Option<String>,
@@ -559,7 +559,7 @@ pub struct JCSVoucherData {
first_name: Secret<String>,
last_name: Option<Secret<String>>,
shopper_email: Email,
- telephone_number: String,
+ telephone_number: Secret<String>,
}
#[derive(Debug, Clone, Serialize)]
@@ -610,14 +610,6 @@ pub struct BacsDirectDebitData {
holder_name: Secret<String>,
}
-#[derive(Debug, Clone, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct MandateData {
- #[serde(rename = "type")]
- payment_type: PaymentType,
- stored_payment_method_id: String,
-}
-
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BancontactCardData {
@@ -680,7 +672,7 @@ impl TryFrom<&Box<payments::JCSVoucherData>> for JCSVoucherData {
first_name: jcs_data.first_name.clone(),
last_name: jcs_data.last_name.clone(),
shopper_email: jcs_data.email.clone(),
- telephone_number: jcs_data.phone_number.clone(),
+ telephone_number: Secret::new(jcs_data.phone_number.clone()),
})
}
}
@@ -1037,7 +1029,7 @@ impl TryFrom<&api_enums::BankNames> for OpenBankingUKIssuer {
pub struct BlikRedirectionData {
#[serde(rename = "type")]
payment_type: PaymentType,
- blik_code: String,
+ blik_code: Secret<String>,
}
#[derive(Debug, Clone, Serialize)]
@@ -1053,7 +1045,7 @@ pub struct BankRedirectionWithIssuer<'a> {
pub struct AdyenMandate {
#[serde(rename = "type")]
payment_type: PaymentType,
- stored_payment_method_id: String,
+ stored_payment_method_id: Secret<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -1066,7 +1058,7 @@ pub struct AdyenCard {
expiry_year: Secret<String>,
cvc: Option<Secret<String>>,
brand: Option<CardBrand>, //Mandatory for mandate using network_txns_id
- network_payment_reference: Option<String>,
+ network_payment_reference: Option<Secret<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -1149,7 +1141,7 @@ pub struct AdyenRefundRequest {
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdyenRefundResponse {
- merchant_account: String,
+ merchant_account: Secret<String>,
psp_reference: String,
payment_psp_reference: String,
reference: String,
@@ -2137,11 +2129,11 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod
api_models::payments::BankRedirectData::Blik { blik_code } => {
Ok(AdyenPaymentMethod::Blik(Box::new(BlikRedirectionData {
payment_type: PaymentType::Blik,
- blik_code: blik_code.clone().ok_or(
+ blik_code: Secret::new(blik_code.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "blik_code",
},
- )?,
+ )?),
})))
}
api_models::payments::BankRedirectData::Eps { bank_name, .. } => Ok(
@@ -2363,7 +2355,9 @@ impl<'a>
payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids) => {
let adyen_mandate = AdyenMandate {
payment_type: PaymentType::try_from(payment_method_type)?,
- stored_payment_method_id: connector_mandate_ids.get_connector_mandate_id()?,
+ stored_payment_method_id: Secret::new(
+ connector_mandate_ids.get_connector_mandate_id()?,
+ ),
};
Ok::<AdyenPaymentMethod<'_>, Self::Error>(AdyenPaymentMethod::Mandate(Box::new(
adyen_mandate,
@@ -2381,7 +2375,7 @@ impl<'a>
expiry_year: card.card_exp_year.clone(),
cvc: None,
brand: Some(brand),
- network_payment_reference: Some(network_mandate_id),
+ network_payment_reference: Some(Secret::new(network_mandate_id)),
};
Ok(AdyenPaymentMethod::AdyenCard(Box::new(adyen_card)))
}
@@ -3053,12 +3047,14 @@ pub fn get_adyen_response(
.as_ref()
.and_then(|data| data.recurring_detail_reference.to_owned())
.map(|mandate_id| types::MandateReference {
- connector_mandate_id: Some(mandate_id),
+ connector_mandate_id: Some(mandate_id.expose()),
payment_method_id: None,
});
- let network_txn_id = response
- .additional_data
- .and_then(|additional_data| additional_data.network_tx_reference);
+ let network_txn_id = response.additional_data.and_then(|additional_data| {
+ additional_data
+ .network_tx_reference
+ .map(|network_tx_id| network_tx_id.expose())
+ });
let payments_response_data = types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(response.psp_reference),
@@ -3333,7 +3329,7 @@ pub fn get_redirection_error_response(
pub fn get_qr_metadata(
response: &QrCodeResponseResponse,
) -> errors::CustomResult<Option<serde_json::Value>, errors::ConnectorError> {
- let image_data = crate_utils::QrImage::new_from_data(response.action.qr_code_data.to_owned())
+ let image_data = crate_utils::QrImage::new_from_data(response.action.qr_code_data.clone())
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
let image_data_url = Url::parse(image_data.data.clone().as_str()).ok();
@@ -3655,7 +3651,7 @@ impl TryFrom<&AdyenRouterData<&types::PaymentsCaptureRouterData>> for AdyenCaptu
#[derive(Default, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdyenCaptureResponse {
- merchant_account: String,
+ merchant_account: Secret<String>,
payment_psp_reference: String,
psp_reference: String,
reference: String,
@@ -3813,7 +3809,7 @@ pub enum DisputeStatus {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdyenAdditionalDataWH {
- pub hmac_signature: String,
+ pub hmac_signature: Secret<String>,
pub dispute_status: Option<DisputeStatus>,
pub chargeback_reason_code: Option<String>,
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
diff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rs
index a788a4a2ab..defc6a339f 100644
--- a/crates/router/src/connector/airwallex.rs
+++ b/crates/router/src/connector/airwallex.rs
@@ -522,8 +522,10 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
.response
.parse_struct("airwallex AirwallexPaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
+
types::PaymentsSyncRouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
diff --git a/crates/router/src/connector/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rs
index 692458715f..767d1c8a6e 100644
--- a/crates/router/src/connector/airwallex/transformers.rs
+++ b/crates/router/src/connector/airwallex/transformers.rs
@@ -1,5 +1,5 @@
use error_stack::{IntoReport, ResultExt};
-use masking::PeekInterface;
+use masking::{ExposeInterface, PeekInterface};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use url::Url;
@@ -416,10 +416,10 @@ pub enum AirwallexNextActionStage {
#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
pub struct AirwallexRedirectFormData {
#[serde(rename = "JWT")]
- jwt: Option<String>,
+ jwt: Option<Secret<String>>,
#[serde(rename = "threeDSMethodData")]
- three_ds_method_data: Option<String>,
- token: Option<String>,
+ three_ds_method_data: Option<Secret<String>>,
+ token: Option<Secret<String>>,
provider: Option<String>,
version: Option<String>,
}
@@ -439,7 +439,7 @@ pub struct AirwallexPaymentsResponse {
id: String,
amount: Option<f32>,
//ID of the PaymentConsent related to this PaymentIntent
- payment_consent_id: Option<String>,
+ payment_consent_id: Option<Secret<String>>,
next_action: Option<AirwallexPaymentsNextAction>,
}
@@ -450,7 +450,7 @@ pub struct AirwallexPaymentsSyncResponse {
id: String,
amount: Option<f32>,
//ID of the PaymentConsent related to this PaymentIntent
- payment_consent_id: Option<String>,
+ payment_consent_id: Option<Secret<String>>,
next_action: Option<AirwallexPaymentsNextAction>,
}
@@ -464,18 +464,27 @@ fn get_redirection_form(
//Some form fields might be empty based on the authentication type by the connector
(
"JWT".to_string(),
- response_url_data.data.jwt.unwrap_or_default(),
+ response_url_data
+ .data
+ .jwt
+ .map(|jwt| jwt.expose())
+ .unwrap_or_default(),
),
(
"threeDSMethodData".to_string(),
response_url_data
.data
.three_ds_method_data
+ .map(|three_ds_method_data| three_ds_method_data.expose())
.unwrap_or_default(),
),
(
"token".to_string(),
- response_url_data.data.token.unwrap_or_default(),
+ response_url_data
+ .data
+ .token
+ .map(|token: Secret<String>| token.expose())
+ .unwrap_or_default(),
),
(
"provider".to_string(),
diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs
index 04704a9091..ba232c01bb 100644
--- a/crates/router/src/connector/authorizedotnet.rs
+++ b/crates/router/src/connector/authorizedotnet.rs
@@ -212,8 +212,10 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
let response: authorizedotnet::AuthorizedotnetPaymentsResponse = intermediate_response
.parse_struct("AuthorizedotnetPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
+
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
@@ -353,7 +355,6 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
))?;
let connector_req =
authorizedotnet::CreateTransactionRequest::try_from(&connector_router_data)?;
-
Ok(RequestContent::Json(Box::new(connector_req)))
}
@@ -400,8 +401,10 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
let response: authorizedotnet::AuthorizedotnetPaymentsResponse = intermediate_response
.parse_struct("AuthorizedotnetPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
+
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs
index bc5bfe86ca..eb5f13881f 100644
--- a/crates/router/src/connector/authorizedotnet/transformers.rs
+++ b/crates/router/src/connector/authorizedotnet/transformers.rs
@@ -3,7 +3,7 @@ use common_utils::{
ext_traits::{Encode, ValueExt},
};
use error_stack::{IntoReport, ResultExt};
-use masking::{PeekInterface, Secret, StrongSecret};
+use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret};
use serde::{Deserialize, Serialize};
use crate::{
@@ -119,7 +119,7 @@ pub struct PayPalDetails {
#[serde(rename_all = "camelCase")]
pub struct WalletDetails {
pub data_descriptor: WalletMethod,
- pub data_value: String,
+ pub data_value: Secret<String>,
}
#[derive(Serialize, Debug, Deserialize)]
@@ -147,14 +147,12 @@ fn get_pm_and_subsequent_auth_detail(
.to_owned()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(
- original_network_trans_id,
- )) => {
+ Some(api_models::payments::MandateReferenceId::NetworkMandateId(network_trans_id)) => {
let processing_options = Some(ProcessingOptions {
is_subsequent_auth: true,
});
let subseuent_auth_info = Some(SubsequentAuthInformation {
- original_network_trans_id,
+ original_network_trans_id: Secret::new(network_trans_id),
reason: Reason::Resubmission,
});
match item.router_data.request.payment_method_data {
@@ -225,7 +223,7 @@ pub struct ProcessingOptions {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubsequentAuthInformation {
- original_network_trans_id: String,
+ original_network_trans_id: Secret<String>,
// original_auth_amount: String, Required for Discover, Diners Club, JCB, and China Union Pay transactions.
reason: Reason,
}
@@ -474,8 +472,8 @@ pub struct AuthorizedotnetTransactionResponse {
response_code: AuthorizedotnetPaymentStatus,
#[serde(rename = "transId")]
transaction_id: String,
- network_trans_id: Option<String>,
- pub(super) account_number: Option<String>,
+ network_trans_id: Option<Secret<String>>,
+ pub(super) account_number: Option<Secret<String>>,
pub(super) errors: Option<Vec<ErrorMessage>>,
secure_acceptance: Option<SecureAcceptance>,
}
@@ -487,8 +485,8 @@ pub struct RefundResponse {
#[serde(rename = "transId")]
transaction_id: String,
#[allow(dead_code)]
- network_trans_id: Option<String>,
- pub account_number: Option<String>,
+ network_trans_id: Option<Secret<String>>,
+ pub account_number: Option<Secret<String>>,
pub errors: Option<Vec<ErrorMessage>>,
}
@@ -518,8 +516,8 @@ pub struct VoidResponse {
response_code: AuthorizedotnetVoidStatus,
#[serde(rename = "transId")]
transaction_id: String,
- network_trans_id: Option<String>,
- pub account_number: Option<String>,
+ network_trans_id: Option<Secret<String>>,
+ pub account_number: Option<Secret<String>>,
pub errors: Option<Vec<ErrorMessage>>,
}
@@ -581,7 +579,7 @@ impl<F, T>
.account_number
.as_ref()
.map(|acc_no| {
- construct_refund_payment_details(acc_no.clone()).encode_to_value()
+ construct_refund_payment_details(acc_no.clone().expose()).encode_to_value()
})
.transpose()
.change_context(errors::ConnectorError::MissingRequiredField {
@@ -604,7 +602,10 @@ impl<F, T>
redirection_data,
mandate_reference: None,
connector_metadata: metadata,
- network_txn_id: transaction_response.network_trans_id.clone(),
+ network_txn_id: transaction_response
+ .network_trans_id
+ .clone()
+ .map(|network_trans_id| network_trans_id.expose()),
connector_response_reference_id: Some(
transaction_response.transaction_id.clone(),
),
@@ -656,7 +657,7 @@ impl<F, T>
.account_number
.as_ref()
.map(|acc_no| {
- construct_refund_payment_details(acc_no.clone()).encode_to_value()
+ construct_refund_payment_details(acc_no.clone().expose()).encode_to_value()
})
.transpose()
.change_context(errors::ConnectorError::MissingRequiredField {
@@ -673,7 +674,10 @@ impl<F, T>
redirection_data: None,
mandate_reference: None,
connector_metadata: metadata,
- network_txn_id: transaction_response.network_trans_id.clone(),
+ network_txn_id: transaction_response
+ .network_trans_id
+ .clone()
+ .map(|network_trans_id| network_trans_id.expose()),
connector_response_reference_id: Some(
transaction_response.transaction_id.clone(),
),
@@ -1152,13 +1156,13 @@ fn get_wallet_data(
api_models::payments::WalletData::GooglePay(_) => {
Ok(PaymentDetails::OpaqueData(WalletDetails {
data_descriptor: WalletMethod::Googlepay,
- data_value: wallet_data.get_encoded_wallet_token()?,
+ data_value: Secret::new(wallet_data.get_encoded_wallet_token()?),
}))
}
api_models::payments::WalletData::ApplePay(applepay_token) => {
Ok(PaymentDetails::OpaqueData(WalletDetails {
data_descriptor: WalletMethod::Applepay,
- data_value: applepay_token.payment_data.clone(),
+ data_value: Secret::new(applepay_token.payment_data.clone()),
}))
}
api_models::payments::WalletData::PaypalRedirect(_) => {
@@ -1215,7 +1219,7 @@ pub struct Paypal {
#[derive(Debug, Serialize, Deserialize)]
pub struct PaypalQueryParams {
#[serde(rename = "PayerID")]
- payer_id: String,
+ payer_id: Secret<String>,
}
impl TryFrom<&AuthorizedotnetRouterData<&types::PaymentsCompleteAuthorizeRouterData>>
@@ -1232,12 +1236,11 @@ impl TryFrom<&AuthorizedotnetRouterData<&types::PaymentsCompleteAuthorizeRouterD
.as_ref()
.and_then(|redirect_response| redirect_response.params.as_ref())
.ok_or(errors::ConnectorError::ResponseDeserializationFailed)?;
- let payer_id: Secret<String> = Secret::new(
+ let payer_id: Secret<String> =
serde_urlencoded::from_str::<PaypalQueryParams>(params.peek())
.into_report()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?
- .payer_id,
- );
+ .payer_id;
let transaction_type = match item.router_data.request.capture_method {
Some(enums::CaptureMethod::Manual) => TransactionType::ContinueAuthorization,
_ => TransactionType::ContinueCapture,
diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs
index b85725c249..389e773da5 100644
--- a/crates/router/src/connector/stripe.rs
+++ b/crates/router/src/connector/stripe.rs
@@ -1708,7 +1708,7 @@ impl
fn handle_response(
&self,
data: &types::RetrieveFileRouterData,
- _event_builder: Option<&mut ConnectorEvent>,
+ event_builder: Option<&mut ConnectorEvent>,
res: types::Response,
) -> CustomResult<
types::RouterData<
@@ -1719,7 +1719,10 @@ impl
errors::ConnectorError,
> {
let response = res.response;
- router_env::logger::info!(connector_response=?response);
+
+ event_builder.map(|event| event.set_response_body(&serde_json::json!({"connector_response_type": "file", "status_code": res.status_code})));
+ router_env::logger::info!(connector_response_type=?"file");
+
Ok(types::RetrieveFileRouterData {
response: Ok(types::RetrieveFileResponse {
file_data: response.to_vec(),
@@ -1737,6 +1740,7 @@ impl
.response
.parse_struct("ErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs
index 7c7a534f1c..d08f28d1a8 100644
--- a/crates/router/src/connector/stripe/transformers.rs
+++ b/crates/router/src/connector/stripe/transformers.rs
@@ -188,7 +188,7 @@ pub struct TokenRequest {
#[derive(Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct StripeTokenResponse {
- pub id: String,
+ pub id: Secret<String>,
pub object: String,
}
@@ -198,7 +198,7 @@ pub struct CustomerRequest {
pub email: Option<Email>,
pub phone: Option<Secret<String>>,
pub name: Option<Secret<String>>,
- pub source: Option<String>,
+ pub source: Option<Secret<String>>,
}
#[derive(Debug, Eq, PartialEq, Deserialize, Serialize)]
@@ -324,7 +324,7 @@ pub struct StripeBlik {
#[serde(rename = "payment_method_data[type]")]
pub payment_method_data_type: StripePaymentMethodType,
#[serde(rename = "payment_method_options[blik][code]")]
- pub code: String,
+ pub code: Secret<String>,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
@@ -499,7 +499,7 @@ pub struct StripeApplePay {
pub pk_token: Secret<String>,
pub pk_token_instrument_name: String,
pub pk_token_payment_network: String,
- pub pk_token_transaction_id: String,
+ pub pk_token_transaction_id: Secret<String>,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
@@ -547,7 +547,7 @@ pub enum WechatClient {
#[derive(Debug, Eq, PartialEq, Serialize)]
pub struct GooglepayPayment {
#[serde(rename = "payment_method_data[card][token]")]
- pub token: String,
+ pub token: Secret<String>,
#[serde(rename = "payment_method_data[type]")]
pub payment_method_types: StripePaymentMethodType,
}
@@ -1536,9 +1536,9 @@ impl TryFrom<(&payments::WalletData, Option<types::PaymentMethodToken>)>
.payment_method
.network
.to_owned(),
- pk_token_transaction_id: applepay_data
- .transaction_identifier
- .to_owned(),
+ pk_token_transaction_id: Secret::new(
+ applepay_data.transaction_identifier.to_owned(),
+ ),
})));
};
let pmd = apple_pay_decrypt_data
@@ -1611,11 +1611,11 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData {
payments::BankRedirectData::Blik { blik_code } => Ok(Self::BankRedirect(
StripeBankRedirectData::StripeBlik(Box::new(StripeBlik {
payment_method_data_type,
- code: blik_code.clone().ok_or(
+ code: Secret::new(blik_code.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "blik_code",
},
- )?,
+ )?),
})),
)),
payments::BankRedirectData::Eps { bank_name, .. } => Ok(Self::BankRedirect(
@@ -2042,7 +2042,7 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for CustomerRequest {
email: item.request.email.to_owned(),
phone: item.request.phone.to_owned(),
name: item.request.name.to_owned(),
- source: item.request.preprocessing_id.to_owned(),
+ source: item.request.preprocessing_id.to_owned().map(Secret::new),
})
}
}
@@ -2096,8 +2096,8 @@ pub struct PaymentIntentResponse {
pub status: StripePaymentStatus,
pub client_secret: Option<Secret<String>>,
pub created: i32,
- pub customer: Option<String>,
- pub payment_method: Option<String>,
+ pub customer: Option<Secret<String>>,
+ pub payment_method: Option<Secret<String>>,
pub description: Option<String>,
pub statement_descriptor: Option<String>,
pub statement_descriptor_suffix: Option<String>,
@@ -2206,7 +2206,7 @@ pub struct StripeCharge {
#[derive(Deserialize, Clone, Debug, Serialize)]
pub struct StripeBankRedirectDetails {
#[serde(rename = "generated_sepa_debit")]
- attached_payment_method: Option<String>,
+ attached_payment_method: Option<Secret<String>>,
}
impl Deref for PaymentIntentSyncResponse {
@@ -2308,7 +2308,7 @@ pub struct SetupIntentResponse {
pub object: String,
pub status: StripePaymentStatus, // Change to SetupStatus
pub client_secret: Secret<String>,
- pub customer: Option<String>,
+ pub customer: Option<Secret<String>>,
pub payment_method: Option<String>,
pub statement_descriptor: Option<String>,
pub statement_descriptor_suffix: Option<String>,
@@ -2327,7 +2327,7 @@ impl ForeignFrom<(Option<StripePaymentMethodOptions>, String)> for types::Mandat
connector_mandate_id: payment_method_options.and_then(|options| match options {
StripePaymentMethodOptions::Card {
mandate_options, ..
- } => mandate_options.map(|mandate_options| mandate_options.reference),
+ } => mandate_options.map(|mandate_options| mandate_options.reference.expose()),
StripePaymentMethodOptions::Klarna {}
| StripePaymentMethodOptions::Affirm {}
| StripePaymentMethodOptions::AfterpayClearpay {}
@@ -2369,7 +2369,10 @@ impl<F, T>
});
let mandate_reference = item.response.payment_method.map(|pm| {
- types::MandateReference::foreign_from((item.response.payment_method_options, pm))
+ types::MandateReference::foreign_from((
+ item.response.payment_method_options,
+ pm.expose(),
+ ))
});
//Note: we might have to call retrieve_setup_intent to get the network_transaction_id in case its not sent in PaymentIntentResponse
@@ -2488,14 +2491,19 @@ impl<F, T>
Some(StripeChargeEnum::ChargeObject(charge)) => {
match charge.payment_method_details {
Some(StripePaymentMethodDetailsResponse::Bancontact { bancontact }) => {
- bancontact.attached_payment_method.unwrap_or(pm)
- }
- Some(StripePaymentMethodDetailsResponse::Ideal { ideal }) => {
- ideal.attached_payment_method.unwrap_or(pm)
- }
- Some(StripePaymentMethodDetailsResponse::Sofort { sofort }) => {
- sofort.attached_payment_method.unwrap_or(pm)
+ bancontact
+ .attached_payment_method
+ .map(|attached_payment_method| attached_payment_method.expose())
+ .unwrap_or(pm.expose())
}
+ Some(StripePaymentMethodDetailsResponse::Ideal { ideal }) => ideal
+ .attached_payment_method
+ .map(|attached_payment_method| attached_payment_method.expose())
+ .unwrap_or(pm.expose()),
+ Some(StripePaymentMethodDetailsResponse::Sofort { sofort }) => sofort
+ .attached_payment_method
+ .map(|attached_payment_method| attached_payment_method.expose())
+ .unwrap_or(pm.expose()),
Some(StripePaymentMethodDetailsResponse::Blik)
| Some(StripePaymentMethodDetailsResponse::Eps)
| Some(StripePaymentMethodDetailsResponse::Fpx)
@@ -2513,10 +2521,10 @@ impl<F, T>
| Some(StripePaymentMethodDetailsResponse::Wechatpay)
| Some(StripePaymentMethodDetailsResponse::Alipay)
| Some(StripePaymentMethodDetailsResponse::CustomerBalance)
- | None => pm,
+ | None => pm.expose(),
}
}
- Some(StripeChargeEnum::ChargeId(_)) | None => pm,
+ Some(StripeChargeEnum::ChargeId(_)) | None => pm.expose(),
},
))
});
@@ -2751,17 +2759,17 @@ pub struct StripeFinanicalInformation {
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct SepaFinancialDetails {
- pub account_holder_name: String,
- pub bic: String,
- pub country: String,
- pub iban: String,
+ pub account_holder_name: Secret<String>,
+ pub bic: Secret<String>,
+ pub country: Secret<String>,
+ pub iban: Secret<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct BacsFinancialDetails {
- pub account_holder_name: String,
- pub account_number: String,
- pub sort_code: String,
+ pub account_holder_name: Secret<String>,
+ pub account_number: Secret<String>,
+ pub sort_code: Secret<String>,
}
// REFUND :
@@ -2962,7 +2970,7 @@ pub struct StripeBillingAddress {
#[derive(Debug, Clone, serde::Deserialize, Eq, PartialEq)]
pub struct StripeRedirectResponse {
pub payment_intent: Option<String>,
- pub payment_intent_client_secret: Option<String>,
+ pub payment_intent_client_secret: Option<Secret<String>>,
pub source_redirect_slug: Option<String>,
pub redirect_status: Option<StripePaymentStatus>,
pub source_type: Option<Secret<String>>,
@@ -3036,7 +3044,7 @@ pub struct LatestPaymentAttempt {
// pub struct Card
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default, Eq, PartialEq)]
pub struct StripeMandateOptions {
- reference: String, // Extendable, But only important field to be captured
+ reference: Secret<String>, // Extendable, But only important field to be captured
}
/// Represents the capture request body for stripe connector.
#[derive(Debug, Serialize, Clone, Copy)]
@@ -3238,7 +3246,7 @@ impl<F, T>
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(types::PaymentsResponseData::TokenizationResponse {
- token: item.response.id,
+ token: item.response.id.expose(),
}),
..item.data
})
@@ -3619,7 +3627,7 @@ pub struct Evidence {
#[serde(rename = "evidence[access_activity_log]")]
pub access_activity_log: Option<String>,
#[serde(rename = "evidence[billing_address]")]
- pub billing_address: Option<String>,
+ pub billing_address: Option<Secret<String>>,
#[serde(rename = "evidence[cancellation_policy]")]
pub cancellation_policy: Option<String>,
#[serde(rename = "evidence[cancellation_policy_disclosure]")]
@@ -3629,17 +3637,17 @@ pub struct Evidence {
#[serde(rename = "evidence[customer_communication]")]
pub customer_communication: Option<String>,
#[serde(rename = "evidence[customer_email_address]")]
- pub customer_email_address: Option<String>,
+ pub customer_email_address: Option<Secret<String, pii::EmailStrategy>>,
#[serde(rename = "evidence[customer_name]")]
- pub customer_name: Option<String>,
+ pub customer_name: Option<Secret<String>>,
#[serde(rename = "evidence[customer_purchase_ip]")]
- pub customer_purchase_ip: Option<String>,
+ pub customer_purchase_ip: Option<Secret<String, pii::IpAddress>>,
#[serde(rename = "evidence[customer_signature]")]
- pub customer_signature: Option<String>,
+ pub customer_signature: Option<Secret<String>>,
#[serde(rename = "evidence[product_description]")]
pub product_description: Option<String>,
#[serde(rename = "evidence[receipt]")]
- pub receipt: Option<String>,
+ pub receipt: Option<Secret<String>>,
#[serde(rename = "evidence[refund_policy]")]
pub refund_policy: Option<String>,
#[serde(rename = "evidence[refund_policy_disclosure]")]
@@ -3651,15 +3659,15 @@ pub struct Evidence {
#[serde(rename = "evidence[service_documentation]")]
pub service_documentation: Option<String>,
#[serde(rename = "evidence[shipping_address]")]
- pub shipping_address: Option<String>,
+ pub shipping_address: Option<Secret<String>>,
#[serde(rename = "evidence[shipping_carrier]")]
pub shipping_carrier: Option<String>,
#[serde(rename = "evidence[shipping_date]")]
pub shipping_date: Option<String>,
#[serde(rename = "evidence[shipping_documentation]")]
- pub shipping_documentation: Option<String>,
+ pub shipping_documentation: Option<Secret<String>>,
#[serde(rename = "evidence[shipping_tracking_number]")]
- pub shipping_tracking_number: Option<String>,
+ pub shipping_tracking_number: Option<Secret<String>>,
#[serde(rename = "evidence[uncategorized_file]")]
pub uncategorized_file: Option<String>,
#[serde(rename = "evidence[uncategorized_text]")]
@@ -3708,31 +3716,46 @@ impl TryFrom<&types::SubmitEvidenceRouterData> for Evidence {
let submit_evidence_request_data = item.request.clone();
Ok(Self {
access_activity_log: submit_evidence_request_data.access_activity_log,
- billing_address: submit_evidence_request_data.billing_address,
+ billing_address: submit_evidence_request_data
+ .billing_address
+ .map(Secret::new),
cancellation_policy: submit_evidence_request_data.cancellation_policy_provider_file_id,
cancellation_policy_disclosure: submit_evidence_request_data
.cancellation_policy_disclosure,
cancellation_rebuttal: submit_evidence_request_data.cancellation_rebuttal,
customer_communication: submit_evidence_request_data
.customer_communication_provider_file_id,
- customer_email_address: submit_evidence_request_data.customer_email_address,
- customer_name: submit_evidence_request_data.customer_name,
- customer_purchase_ip: submit_evidence_request_data.customer_purchase_ip,
- customer_signature: submit_evidence_request_data.customer_signature_provider_file_id,
+ customer_email_address: submit_evidence_request_data
+ .customer_email_address
+ .map(Secret::new),
+ customer_name: submit_evidence_request_data.customer_name.map(Secret::new),
+ customer_purchase_ip: submit_evidence_request_data
+ .customer_purchase_ip
+ .map(Secret::new),
+ customer_signature: submit_evidence_request_data
+ .customer_signature_provider_file_id
+ .map(Secret::new),
product_description: submit_evidence_request_data.product_description,
- receipt: submit_evidence_request_data.receipt_provider_file_id,
+ receipt: submit_evidence_request_data
+ .receipt_provider_file_id
+ .map(Secret::new),
refund_policy: submit_evidence_request_data.refund_policy_provider_file_id,
refund_policy_disclosure: submit_evidence_request_data.refund_policy_disclosure,
refund_refusal_explanation: submit_evidence_request_data.refund_refusal_explanation,
service_date: submit_evidence_request_data.service_date,
service_documentation: submit_evidence_request_data
.service_documentation_provider_file_id,
- shipping_address: submit_evidence_request_data.shipping_address,
+ shipping_address: submit_evidence_request_data
+ .shipping_address
+ .map(Secret::new),
shipping_carrier: submit_evidence_request_data.shipping_carrier,
shipping_date: submit_evidence_request_data.shipping_date,
shipping_documentation: submit_evidence_request_data
- .shipping_documentation_provider_file_id,
- shipping_tracking_number: submit_evidence_request_data.shipping_tracking_number,
+ .shipping_documentation_provider_file_id
+ .map(Secret::new),
+ shipping_tracking_number: submit_evidence_request_data
+ .shipping_tracking_number
+ .map(Secret::new),
uncategorized_file: submit_evidence_request_data.uncategorized_file_provider_file_id,
uncategorized_text: submit_evidence_request_data.uncategorized_text,
submit: true,