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
feat(connector): [Stripe, Adyen, Checkout] Add reference ID support for retries (#1735)
Sai Harsha Vardhan9ba8ec348b1e
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 462d4d3818..62e4bac31a 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -1712,7 +1712,7 @@ impl<'a>amount,merchant_account: auth_type.merchant_account,payment_method,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),return_url,shopper_interaction,recurring_processing_model,@@ -1751,7 +1751,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::Card)> for AdyenPayamount,merchant_account: auth_type.merchant_account,payment_method,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),return_url,shopper_interaction,recurring_processing_model,@@ -1800,7 +1800,7 @@ impl<'a>amount,merchant_account: auth_type.merchant_account,payment_method,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),return_url,browser_info,shopper_interaction,@@ -1852,7 +1852,7 @@ impl<'a>amount,merchant_account: auth_type.merchant_account,payment_method,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),return_url,shopper_interaction,recurring_processing_model,@@ -1937,7 +1937,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::WalletData)>amount,merchant_account: auth_type.merchant_account,payment_method,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),return_url,shopper_interaction,recurring_processing_model,@@ -1986,7 +1986,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::PayLaterData)>amount,merchant_account: auth_type.merchant_account,payment_method,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),return_url,shopper_interaction,recurring_processing_model,@@ -2013,7 +2013,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for AdyenCancelRequest {let auth_type = AdyenAuthType::try_from(&item.connector_auth_type)?;Ok(Self {merchant_account: auth_type.merchant_account,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),})}}@@ -2096,7 +2096,7 @@ pub fn get_adyen_response(mandate_reference,connector_metadata: None,network_txn_id,- connector_response_reference_id: None,+ connector_response_reference_id: Some(response.merchant_reference),};Ok((status, error, payments_response_data))}@@ -2236,7 +2236,7 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for AdyenCaptureRequest {let auth_type = AdyenAuthType::try_from(&item.connector_auth_type)?;Ok(Self {merchant_account: auth_type.merchant_account,- reference: item.payment_id.to_string(),+ reference: item.connector_request_reference_id.clone(),amount: Amount {currency: item.request.currency.to_string(),value: item.request.amount_to_capture,diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rsindex 1f246d2657..ed366b3449 100644--- a/crates/router/src/connector/checkout/transformers.rs+++ b/crates/router/src/connector/checkout/transformers.rs@@ -148,6 +148,7 @@ pub struct PaymentsRequest {#[serde(flatten)]pub return_url: ReturnUrl,pub capture: bool,+ pub reference: String,}#[derive(Debug, Serialize)]@@ -246,6 +247,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaymentsRequest {three_ds,return_url,capture,+ reference: item.connector_request_reference_id.clone(),})}}@@ -323,6 +325,7 @@ pub struct PaymentsResponse {#[serde(rename = "_links")]links: Links,balances: Option<Balances>,+ reference: Option<String>,}#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize)]@@ -347,12 +350,14 @@ impl TryFrom<types::PaymentsResponseRouterData<PaymentsResponse>>item.data.request.capture_method,)),response: Ok(types::PaymentsResponseData::TransactionResponse {- resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data,mandate_reference: None,connector_metadata: None,network_txn_id: None,- connector_response_reference_id: None,+ connector_response_reference_id: Some(+ item.response.reference.unwrap_or(item.response.id),+ ),}),..item.data})@@ -376,12 +381,14 @@ impl TryFrom<types::PaymentsSyncResponseRouterData<PaymentsResponse>>item.response.balances,)),response: Ok(types::PaymentsResponseData::TransactionResponse {- resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data,mandate_reference: None,connector_metadata: None,network_txn_id: None,- connector_response_reference_id: None,+ connector_response_reference_id: Some(+ item.response.reference.unwrap_or(item.response.id),+ ),}),..item.data})diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rsindex 45f7ffcd0f..9d9906f0a2 100644--- a/crates/router/src/connector/stripe/transformers.rs+++ b/crates/router/src/connector/stripe/transformers.rs@@ -1262,7 +1262,7 @@ impl TryFrom<&payments::GooglePayWalletData> for StripePaymentMethodData {impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaymentIntentRequest {type Error = error_stack::Report<errors::ConnectorError>;fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {- let metadata_order_id = item.payment_id.to_string();+ let metadata_order_id = item.connector_request_reference_id.clone();let metadata_txn_id = format!("{}_{}_{}", item.merchant_id, item.payment_id, "1");let metadata_txn_uuid = Uuid::new_v4().to_string(); //Fetch autogenerated txn_uuid from Database.@@ -1498,7 +1498,7 @@ fn get_payment_method_type_for_saved_payment_method_payment(impl TryFrom<&types::VerifyRouterData> for SetupIntentRequest {type Error = error_stack::Report<errors::ConnectorError>;fn try_from(item: &types::VerifyRouterData) -> Result<Self, Self::Error> {- let metadata_order_id = item.payment_id.to_string();+ let metadata_order_id = item.connector_request_reference_id.clone();let metadata_txn_id = format!("{}_{}_{}", item.merchant_id, item.payment_id, "1");let metadata_txn_uuid = Uuid::new_v4().to_string();@@ -1887,12 +1887,12 @@ impl<F, T>// statement_descriptor_suffix: item.response.statement_descriptor_suffix.map(|x| x.as_str()),// three_ds_form,response: Ok(types::PaymentsResponseData::TransactionResponse {- resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data,mandate_reference,connector_metadata,network_txn_id,- connector_response_reference_id: None,+ connector_response_reference_id: Some(item.response.id),}),amount_captured: item.response.amount_received,..item.data@@ -2010,7 +2010,7 @@ impl<F, T>mandate_reference,connector_metadata,network_txn_id: None,- connector_response_reference_id: None,+ connector_response_reference_id: Some(item.response.id.clone()),}),Err,);@@ -2046,12 +2046,12 @@ impl<F, T>Ok(Self {status: enums::AttemptStatus::from(item.response.status),response: Ok(types::PaymentsResponseData::TransactionResponse {- resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data,mandate_reference,connector_metadata: None,network_txn_id: Option::foreign_from(item.response.latest_attempt),- connector_response_reference_id: None,+ connector_response_reference_id: Some(item.response.id),}),..item.data})@@ -2538,12 +2538,12 @@ impl<F, T> TryFrom<types::ResponseRouterData<F, ChargesResponse, T, types::PaymeOk(Self {status: enums::AttemptStatus::from(item.response.status),response: Ok(types::PaymentsResponseData::TransactionResponse {- resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()),redirection_data: None,mandate_reference: None,connector_metadata: Some(connector_metadata),network_txn_id: None,- connector_response_reference_id: None,+ connector_response_reference_id: Some(item.response.id),}),..item.data})