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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(connector): [Globalpay] Mask PII data (#3840)
AkshayaFoiger13f6d6c10ce4
diff --git a/crates/router/src/connector/globalpay/requests.rs b/crates/router/src/connector/globalpay/requests.rsindex ee62e8c2c2..1e5413bc83 100644--- a/crates/router/src/connector/globalpay/requests.rs+++ b/crates/router/src/connector/globalpay/requests.rs@@ -41,7 +41,7 @@ pub struct GlobalpayPaymentsRequest {/// Indicates whether the Merchant or the Payer initiated the creation of a transaction.pub initiator: Option<Initiator>,/// Indicates the source IP Address of the system used to create the transaction.- pub ip_address: Option<String>,+ pub ip_address: Option<Secret<String, common_utils::pii::IpAddress>>,/// Indicates the language the transaction was executed in. In the format ISO-639-1 (alpha-2)/// or ISO-639-1 (alpha-2)_ISO-3166(alpha-2)pub language: Option<Language>,@@ -80,8 +80,8 @@ pub struct GlobalpayPaymentsRequest {#[derive(Debug, Serialize)]pub struct GlobalpayRefreshTokenRequest {pub app_id: Secret<String>,- pub nonce: String,- pub secret: String,+ pub nonce: Secret<String>,+ pub secret: Secret<String>,pub grant_type: String,}@@ -106,10 +106,10 @@ pub struct Device {/// Describes the receipts a device prints when processing a transaction.pub print_receipt_mode: Option<PrintReceiptMode>,/// The sequence number from the device used to align with processing platform.- pub sequence_number: Option<String>,+ pub sequence_number: Option<Secret<String>>,/// A unique identifier for the physical device. This value persists with the device even if/// it is repurposed.- pub serial_number: Option<String>,+ pub serial_number: Option<Secret<String>>,/// The time from the device in ISO8601 formatpub time: Option<String>,}@@ -209,15 +209,15 @@ pub struct PaymentMethod {/// Indicates whether to execute the fingerprint signature functionality.pub fingerprint_mode: Option<FingerprintMode>,/// Specify the first name of the owner of the payment method.- pub first_name: Option<String>,+ pub first_name: Option<Secret<String>>,/// Unique Global Payments generated id used to reference a stored payment method on the/// Global Payments system. Often referred to as the payment method token. This value can be/// used instead of payment method details such as a card number and expiry date.- pub id: Option<String>,+ pub id: Option<Secret<String>>,/// Specify the surname of the owner of the payment method.- pub last_name: Option<String>,+ pub last_name: Option<Secret<String>>,/// The full name of the owner of the payment method.- pub name: Option<String>,+ pub name: Option<Secret<String>>,/// Contains the value a merchant wishes to appear on the payer's payment method statement/// for this transactionpub narrative: Option<String>,@@ -274,11 +274,11 @@ pub struct ThreeDs {pub struct BankTransfer {/// The number or reference for the payer's bank account.- pub account_number: Option<String>,+ pub account_number: Option<Secret<String>>,pub bank: Option<Bank>,/// The number or reference for the check- pub check_reference: Option<String>,+ pub check_reference: Option<Secret<String>>,/// The type of bank account associated with the payer's bank account.pub number_type: Option<NumberType>,/// Indicates how the transaction was authorized by the merchant.@@ -289,7 +289,7 @@ pub struct BankTransfer {pub struct Bank {pub address: Option<Address>,/// The local identifier code for the bank.- pub code: Option<String>,+ pub code: Option<Secret<String>>,/// The name of the bank.pub name: Option<String>,}@@ -297,17 +297,17 @@ pub struct Bank {#[derive(Debug, Serialize, Deserialize)]pub struct Address {/// Merchant defined field common to all transactions that are part of the same order.- pub city: Option<String>,+ pub city: Option<Secret<String>>,/// The country in ISO-3166-1(alpha-2 code) format.pub country: Option<String>,/// First line of the address.- pub line_1: Option<String>,+ pub line_1: Option<Secret<String>>,/// Second line of the address.- pub line_2: Option<String>,+ pub line_2: Option<Secret<String>>,/// Third line of the address.- pub line_3: Option<String>,+ pub line_3: Option<Secret<String>>,/// The city or town of the address.- pub postal_code: Option<String>,+ pub postal_code: Option<Secret<String>>,/// The state or region of the address. ISO 3166-2 minus the country code itself. For/// example, US Illinois = IL, or in the case of GB counties Wiltshire = WI or Aberdeenshire/// = ABD@@ -319,7 +319,7 @@ pub struct Card {/// The card providers description of their card product.pub account_type: Option<String>,/// Code generated when the card is successfully authorized.- pub authcode: Option<String>,+ pub authcode: Option<Secret<String>>,/// First line of the address associated with the card.pub avs_address: Option<String>,/// Postal code of the address associated with the card.@@ -340,11 +340,11 @@ pub struct Card {/// The the card account number used to authorize the transaction. Also known as PAN.pub number: cards::CardNumber,/// Contains the pin block info, relating to the pin code the Payer entered.- pub pin_block: Option<String>,+ pub pin_block: Option<Secret<String>>,/// The full card tag data for an EMV/chip card transaction.- pub tag: Option<String>,+ pub tag: Option<Secret<String>>,/// Data from magnetic stripe of a card- pub track: Option<String>,+ pub track: Option<Secret<String>>,}#[derive(Debug, Serialize, Deserialize)]@@ -358,7 +358,7 @@ pub struct DigitalWallet {#[derive(Debug, Serialize, Deserialize)]pub struct Encryption {/// The encryption info used when sending encrypted card data to Global Payments.- pub info: Option<String>,+ pub info: Option<Secret<String>>,/// The encryption method used when sending encrypted card data to Global Payments.pub method: Option<Method>,/// The version of encryption being used.diff --git a/crates/router/src/connector/globalpay/response.rs b/crates/router/src/connector/globalpay/response.rsindex 201297c399..7d5efadaff 100644--- a/crates/router/src/connector/globalpay/response.rs+++ b/crates/router/src/connector/globalpay/response.rs@@ -6,9 +6,9 @@ use super::requests;#[derive(Debug, Serialize, Deserialize)]pub struct GlobalpayPaymentsResponse {/// A unique identifier for the merchant account set by Global Payments.- pub account_id: Option<String>,+ pub account_id: Option<Secret<String>>,/// A meaningful label for the merchant account set by Global Payments.- pub account_name: Option<String>,+ pub account_name: Option<Secret<String>>,/// Information about the Action executed.pub action: Option<Action>,/// The amount to transfer between Payer and Merchant for a SALE or a REFUND. It is always@@ -37,7 +37,7 @@ pub struct GlobalpayPaymentsResponse {/// A unique identifier for the merchant set by Global Payments.pub merchant_id: Option<String>,/// A meaningful label for the merchant set by Global Payments.- pub merchant_name: Option<String>,+ pub merchant_name: Option<Secret<String>>,pub payment_method: Option<PaymentMethod>,/// Merchant defined field to reference the transaction.pub reference: Option<String>,@@ -55,12 +55,12 @@ pub struct GlobalpayPaymentsResponse {#[derive(Debug, Serialize, Deserialize)]pub struct Action {/// The id of the app that was used to create the token.- pub app_id: Option<String>,+ pub app_id: Option<Secret<String>>,/// The name of the app the user gave to the application.- pub app_name: Option<String>,+ pub app_name: Option<Secret<String>>,/// A unique identifier for the object created by Global Payments. The first 3 characters/// identifies the resource an id relates to.- pub id: Option<String>,+ pub id: Option<Secret<String>>,/// The result of the action executed.pub result_code: Option<ResultCode>,/// Global Payments time indicating when the object was created in ISO-8601 format.@@ -117,7 +117,7 @@ pub struct PaymentMethod {/// for that merchant. If the payment method is seen again this same value is generated. For/// cards the primary account number is checked only. The expiry date or the CVV is not used/// for this check.- pub fingerprint: Option<String>,+ pub fingerprint: Option<Secret<String>>,/// If enabled, this field indicates whether the payment method has been seen before or is/// new./// * EXISTS - Indicates that the payment method was seen on the platform before by this@@ -128,7 +128,7 @@ pub struct PaymentMethod {/// Unique Global Payments generated id used to reference a stored payment method on the/// Global Payments system. Often referred to as the payment method token. This value can be/// used instead of payment method details such as a card number and expiry date.- pub id: Option<String>,+ pub id: Option<Secret<String>>,/// Result message from the payment method provider corresponding to the result code.pub message: Option<String>,/// Result code from the payment method provider.@@ -148,7 +148,7 @@ pub struct Apm {/// transaction.pub provider: Option<ApmProvider>,/// A name of the payer from the payment method system.- pub provider_payer_name: Option<String>,+ pub provider_payer_name: Option<Secret<String>>,/// The time the payment method provider created the transaction at on their system.pub provider_time_created: Option<String>,/// The reference the payment method provider created for the transaction.@@ -162,28 +162,28 @@ pub struct Apm {pub redirect_url: Option<String>,/// A string generated by the payment method to represent the session created on the payment/// method's platform to facilitate the creation of a transaction.- pub session_token: Option<String>,+ pub session_token: Option<Secret<String>>,pub payment_description: Option<String>,}#[derive(Debug, Serialize, Deserialize)]pub struct Bank {/// The local identifier of the bank account.- pub account_number: Option<String>,+ pub account_number: Option<Secret<String>>,/// The local identifier of the bank.- pub code: Option<String>,+ pub code: Option<Secret<String>>,/// The international identifier of the bank account.- pub iban: Option<String>,+ pub iban: Option<Secret<String>>,/// The international identifier code for the bank.- pub identifier_code: Option<String>,+ pub identifier_code: Option<Secret<String>>,/// The name associated with the bank account- pub name: Option<String>,+ pub name: Option<Secret<String>>,}#[derive(Debug, Serialize, Deserialize)]pub struct Mandate {/// The reference to identify the mandate.- pub code: Option<String>,+ pub code: Option<Secret<String>>,}/// Information outlining the degree of authentication executed related to a transaction.@@ -205,7 +205,7 @@ pub struct BankTransfer {/// The last 4 characters of the local reference for a bank account number.pub masked_number_last4: Option<String>,/// The name of the bank.- pub name: Option<String>,+ pub name: Option<Secret<String>>,/// The type of bank account associated with the payer's bank account.pub number_type: Option<NumberType>,}@@ -213,7 +213,7 @@ pub struct BankTransfer {#[derive(Debug, Serialize, Deserialize)]pub struct Card {/// Code generated when the card is successfully authorized.- pub authcode: Option<String>,+ pub authcode: Option<Secret<String>>,/// The recommended AVS action to be taken by the agent processing the card transaction.pub avs_action: Option<String>,/// The result of the AVS address check.@@ -223,7 +223,7 @@ pub struct Card {/// Indicates the card brand that issued the card.pub brand: Option<Brand>,/// The unique reference created by the brands/schemes to uniquely identify the transaction.- pub brand_reference: Option<String>,+ pub brand_reference: Option<Secret<String>>,/// The time returned by the card brand indicating when the transaction was processed on/// their system.pub brand_time_reference: Option<String>,@@ -235,7 +235,7 @@ pub struct Card {pub provider: Option<ProviderClass>,/// The card EMV tag response data from the card issuer for a contactless or chip card/// transaction.- pub tag_response: Option<String>,+ pub tag_response: Option<Secret<String>>,}/// The result codes directly from the card issuer.diff --git a/crates/router/src/connector/globalpay/transformers.rs b/crates/router/src/connector/globalpay/transformers.rsindex 3124501bd6..1e41094625 100644--- a/crates/router/src/connector/globalpay/transformers.rs+++ b/crates/router/src/connector/globalpay/transformers.rs@@ -1,6 +1,6 @@use common_utils::crypto::{self, GenerateDigest};use error_stack::{IntoReport, ResultExt};-use masking::{PeekInterface, Secret};+use masking::{ExposeInterface, PeekInterface, Secret};use rand::distributions::DistString;use serde::{Deserialize, Serialize};use url::Url;@@ -164,8 +164,8 @@ impl TryFrom<&types::RefreshTokenRouterData> for GlobalpayRefreshTokenRequest {Ok(Self {app_id: globalpay_auth.app_id,- nonce,- secret,+ nonce: Secret::new(nonce),+ secret: Secret::new(secret),grant_type: "client_credentials".to_string(),})}@@ -215,7 +215,7 @@ fn get_payment_response(.as_ref().and_then(|card| card.brand_reference.to_owned()).map(|id| types::MandateReference {- connector_mandate_id: Some(id),+ connector_mandate_id: Some(id.expose()),payment_method_id: None,})});