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(core/connector): [Peachpayments] Add card_on_file_transaction_type to PeachPayments Metadata (#13130)

Anurag6e2423b32a01
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 1bb09f65b9..2c826a701b 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -37695,6 +37695,15 @@
}
}
},
+ "PeachpaymentsCardOnFileTransactionType": {
+ "type": "string",
+ "enum": [
+ "one_off",
+ "customer_initiated_transaction",
+ "merchant_initiated_mandate",
+ "merchant_initiated_transaction"
+ ]
+ },
"PeachpaymentsData": {
"type": "object",
"properties": {
@@ -37702,6 +37711,14 @@
"type": "string",
"description": "A numeric reference number supplied by the system retaining the original source information and used to assist in locating that information or a copy thereof.",
"nullable": true
+ },
+ "card_on_file_transaction_type": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PeachpaymentsCardOnFileTransactionType"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index c36e50f404..cf09aaf17b 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -26719,6 +26719,15 @@
}
}
},
+ "PeachpaymentsCardOnFileTransactionType": {
+ "type": "string",
+ "enum": [
+ "one_off",
+ "customer_initiated_transaction",
+ "merchant_initiated_mandate",
+ "merchant_initiated_transaction"
+ ]
+ },
"PeachpaymentsData": {
"type": "object",
"properties": {
@@ -26726,6 +26735,14 @@
"type": "string",
"description": "A numeric reference number supplied by the system retaining the original source information and used to assist in locating that information or a copy thereof.",
"nullable": true
+ },
+ "card_on_file_transaction_type": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PeachpaymentsCardOnFileTransactionType"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index b97443888a..dfd0ca2a4e 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -10074,7 +10074,27 @@ pub enum ApplePayCombinedMetadata {
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct PeachpaymentsData {
/// A numeric reference number supplied by the system retaining the original source information and used to assist in locating that information or a copy thereof.
+ #[schema(value_type = Option<String>)]
+ #[smithy(value_type = "Option<String>")]
pub rrn: Option<String>,
+ /// Indicates the card-on-file transaction classification to use for Peach Payments when recurring_details.card_with_limited_data is supplied.
+ #[schema(value_type = Option<PeachpaymentsCardOnFileTransactionType>)]
+ #[smithy(value_type = "Option<PeachpaymentsCardOnFileTransactionType>")]
+ pub card_on_file_transaction_type: Option<PeachpaymentsCardOnFileTransactionType>,
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]
+#[serde(rename_all = "snake_case")]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
+pub enum PeachpaymentsCardOnFileTransactionType {
+ /// One-off card payment without CVV.
+ OneOff,
+ /// Card without CVV where the customer is present — telephone sales where the customer reads the card, hospitality pre-auth, etc.
+ CustomerInitiatedTransaction,
+ /// Card without CVV where the customer is not present — backoffice recurring setup, merchant loading credentials on behalf of the customer.
+ MerchantInitiatedMandate,
+ /// Merchant-initiated charge where the merchant holds the card credentials.
+ MerchantInitiatedTransaction,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
diff --git a/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs b/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs
index 42212c72fe..a3188c56fe 100644
--- a/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs
@@ -35,6 +35,7 @@ use crate::{
},
};
+const CHARGE_METHOD: &str = "ecommerce_card_payment_only";
const CONNECTOR: &str = "Peachpayments";
pub struct PeachpaymentsRouterData<T> {
@@ -62,8 +63,6 @@ impl TryFrom<&Option<pii::SecretSerdeValue>> for PeachPaymentsConnectorMetadataO
}
}
-const CHARGE_METHOD: &str = "ecommerce_card_payment_only";
-
// Card Gateway API Transaction Request
#[derive(Debug, Serialize, PartialEq)]
#[serde(rename_all = "camelCase")]
@@ -508,6 +507,8 @@ impl
)),
};
+ let peachpayments_data = get_peachpayments_data(item);
+
let ecommerce_data = EcommercePaymentOnlyTransactionData::NetworkToken(
EcommerceNetworkTokenPaymentOnlyTransactionData {
merchant_information,
@@ -523,7 +524,7 @@ impl
},
mode: CofMode::Initial,
},
- rrn: item.router_data.request.rrn.clone(),
+ rrn: get_rrn(&peachpayments_data),
pre_auth_inc_ext_capture_flow: get_transaction_operations(item),
trace_id: None,
transaction_link_id: None,
@@ -581,13 +582,15 @@ impl TryFrom<(&PeachpaymentsRouterData<&PaymentsAuthorizeRouterData>, Card)>
None
};
+ let peachpayments_data = get_peachpayments_data(item);
+
let ecommerce_data =
EcommercePaymentOnlyTransactionData::Card(EcommerceCardPaymentOnlyTransactionData {
merchant_information,
routing_reference,
card,
amount: get_amount_details(item),
- rrn: item.router_data.request.rrn.clone(),
+ rrn: get_rrn(&peachpayments_data),
pre_auth_inc_ext_capture_flow: get_transaction_operations(item),
cof_data,
trace_id: None,
@@ -635,28 +638,36 @@ impl
eci: card_with_limited_details.eci.clone(),
};
- let cof_data = if item.router_data.request.is_cit_mandate_payment() {
- Some(CardOnFileData {
- cof_type: get_cof_type(item),
- source: CofSource::Cit,
- mode: CofMode::Initial,
- })
- } else if item.router_data.request.setup_future_usage
- == Some(storage_enums::FutureUsage::OffSession)
- {
- Some(CardOnFileData {
- cof_type: get_cof_type(item),
- source: CofSource::Mit,
- mode: CofMode::Initial,
- })
- } else if item.router_data.payment_method_type.is_some() {
- Some(CardOnFileData {
- cof_type: get_cof_type(item),
- source: CofSource::Mit,
- mode: CofMode::Subsequent,
- })
- } else {
- None
+ let peachpayments_data = get_peachpayments_data(item);
+
+ let card_on_file_transaction_type = peachpayments_data
+ .as_ref()
+ .and_then(|peachpayments| peachpayments.card_on_file_transaction_type.clone());
+
+ let cof_data = match card_on_file_transaction_type {
+ Some(api_models::payments::PeachpaymentsCardOnFileTransactionType::OneOff)
+ | None => None,
+ Some(api_models::payments::PeachpaymentsCardOnFileTransactionType::CustomerInitiatedTransaction) => {
+ Some(CardOnFileData {
+ cof_type: get_cof_type(item),
+ source: CofSource::Cit,
+ mode: CofMode::Initial,
+ })
+ },
+ Some(api_models::payments::PeachpaymentsCardOnFileTransactionType::MerchantInitiatedMandate) => {
+ Some(CardOnFileData {
+ cof_type: get_cof_type(item),
+ source: CofSource::Mit,
+ mode: CofMode::Initial,
+ })
+ },
+ Some(api_models::payments::PeachpaymentsCardOnFileTransactionType::MerchantInitiatedTransaction) => {
+ Some(CardOnFileData {
+ cof_type: get_cof_type(item),
+ source: CofSource::Mit,
+ mode: CofMode::Subsequent,
+ })
+ },
};
let trace_id = item
@@ -672,7 +683,7 @@ impl
routing_reference,
card,
amount: get_amount_details(item),
- rrn: item.router_data.request.rrn.clone(),
+ rrn: get_rrn(&peachpayments_data),
pre_auth_inc_ext_capture_flow: get_transaction_operations(item),
cof_data,
trace_id,
@@ -732,13 +743,15 @@ impl
let transaction_link_id = item.router_data.request.get_optional_transaction_link_id();
+ let peachpayments_data = get_peachpayments_data(item);
+
let ecommerce_data =
EcommercePaymentOnlyTransactionData::Card(EcommerceCardPaymentOnlyTransactionData {
merchant_information,
routing_reference,
card,
amount: get_amount_details(item),
- rrn: item.router_data.request.rrn.clone(),
+ rrn: get_rrn(&peachpayments_data),
pre_auth_inc_ext_capture_flow: get_transaction_operations(item),
cof_data,
trace_id,
@@ -794,6 +807,8 @@ impl
let transaction_link_id = item.router_data.request.get_optional_transaction_link_id();
+ let peachpayments_data = get_peachpayments_data(item);
+
let ecommerce_data = EcommercePaymentOnlyTransactionData::NetworkToken(
EcommerceNetworkTokenPaymentOnlyTransactionData {
merchant_information,
@@ -805,7 +820,7 @@ impl
source: CofSource::Mit,
mode: CofMode::Subsequent,
},
- rrn: item.router_data.request.rrn.clone(),
+ rrn: get_rrn(&peachpayments_data),
pre_auth_inc_ext_capture_flow: get_transaction_operations(item),
trace_id,
transaction_link_id,
@@ -849,6 +864,22 @@ fn get_amount_details(
}
}
+fn get_peachpayments_data(
+ item: &PeachpaymentsRouterData<&PaymentsAuthorizeRouterData>,
+) -> Option<api_models::payments::PeachpaymentsData> {
+ item.router_data
+ .request
+ .connector_intent_metadata
+ .as_ref()
+ .and_then(|metadata| metadata.peachpayments.clone())
+}
+
+fn get_rrn(peachpayments_data: &Option<api_models::payments::PeachpaymentsData>) -> Option<String> {
+ peachpayments_data
+ .as_ref()
+ .and_then(|peachpayments| peachpayments.rrn.clone())
+}
+
fn get_cof_type(item: &PeachpaymentsRouterData<&PaymentsAuthorizeRouterData>) -> CofType {
match item.router_data.request.mit_category.as_ref() {
Some(MitCategory::Recurring) => CofType::Recurring,
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 98cb75571d..628e83fcd0 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -7725,7 +7725,6 @@ pub(crate) fn convert_setup_mandate_router_data_to_authorize_router_data(
.request
.partner_merchant_identifier_details
.clone(),
- rrn: None,
feature_metadata: None,
installment_details: None,
connector_intent_metadata: None,
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index e4fd9cb411..60e8ce8a23 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -150,7 +150,6 @@ pub struct PaymentsAuthorizeData {
pub tokenization: Option<common_enums::Tokenization>,
pub partner_merchant_identifier_details:
Option<common_types::payments::PartnerMerchantIdentifierDetails>,
- pub rrn: Option<String>,
pub feature_metadata: Option<api_models::payments::FeatureMetadata>,
pub installment_details: Option<common_types::payments::InstallmentData>,
// Contains the connector specific metadata coming from payments request
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 749f029f06..df4389ad85 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -798,6 +798,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::HyperswitchVaultData,
api_models::payments::VgsVaultData,
api_models::payments::ProxyCardData,
+ api_models::payments::PeachpaymentsCardOnFileTransactionType,
api_models::payment_methods::RequiredFieldInfo,
api_models::payment_methods::DefaultPaymentMethod,
api_models::payment_methods::MaskedBankDetails,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 5933e6b7c3..e481cb98fe 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -752,6 +752,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::PenaltyDetail,
api_models::payments::CollectionActions,
api_models::payments::ProtestRules,
+ api_models::payments::PeachpaymentsCardOnFileTransactionType,
api_models::payouts::CardPayout,
api_models::payouts::Wallet,
api_models::payouts::Paypal,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 6c2b4f2b6c..be6392e892 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -428,11 +428,6 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
.and_then(|noon| noon.order_category.clone())
});
- let rrn = connector_metadata
- .as_ref()
- .and_then(|metadata| metadata.peachpayments.as_ref())
- .and_then(|peachpaymentsdata| peachpaymentsdata.rrn.clone());
-
// TODO: few fields are repeated in both routerdata and request
let request = types::PaymentsAuthorizeData {
payment_method_data: payment_data
@@ -502,7 +497,6 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
is_stored_credential: None,
billing_descriptor: None,
partner_merchant_identifier_details: None,
- rrn,
feature_metadata: None,
installment_details: None,
connector_intent_metadata: None,
@@ -5077,13 +5071,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
let shipping_cost = payment_data.payment_intent.amount_details.shipping_cost;
- let rrn = payment_data
- .payment_intent
- .connector_metadata
- .as_ref()
- .and_then(|metadata| metadata.peachpayments.as_ref())
- .and_then(|peachpaymentsdata| peachpaymentsdata.rrn.clone());
-
Ok(Self {
payment_method_data: payment_method_data
.unwrap_or(domain::PaymentMethodData::Card(domain::Card::default())),
@@ -5141,7 +5128,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
is_stored_credential: None,
billing_descriptor: None,
partner_merchant_identifier_details: None,
- rrn,
feature_metadata: None,
installment_details: None,
connector_intent_metadata: None,
@@ -5220,11 +5206,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
let merchant_config_currency =
braintree_metadata.and_then(|braintree| braintree.merchant_config_currency);
- let rrn = connector_metadata
- .as_ref()
- .and_then(|metadata| metadata.peachpayments.as_ref())
- .and_then(|peachpaymentsdata| peachpaymentsdata.rrn.clone());
-
let order_details = additional_data
.payment_data
.payment_intent
@@ -5416,7 +5397,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
partner_merchant_identifier_details: payment_data
.payment_intent
.partner_merchant_identifier_details,
- rrn,
feature_metadata,
installment_details: payment_data.payment_attempt.installment_data.clone(),
connector_intent_metadata,
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 8c7bb9c31e..8000ffb960 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -1435,7 +1435,6 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {
.request
.partner_merchant_identifier_details
.clone(),
- rrn: None,
feature_metadata: None,
installment_details: None,
connector_intent_metadata: None,
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index 9b96b3957c..12589e5e86 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -74,7 +74,6 @@ impl VerifyConnectorData {
billing_descriptor: None,
tokenization: None,
partner_merchant_identifier_details: None,
- rrn: None,
feature_metadata: None,
installment_details: None,
connector_intent_metadata: None,
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index ae35bf5e0e..f833541f77 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -1031,7 +1031,6 @@ impl Default for PaymentAuthorizeType {
billing_descriptor: None,
tokenization: None,
partner_merchant_identifier_details: None,
- rrn: None,
feature_metadata: None,
installment_details: None,
connector_intent_metadata: None,