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

fix(payment-methods): fix external sdk token flow (#11779)

Prasunna Soppac7842e0ea040
diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
index 9d4354dfc0..59721b15ec 100644
--- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
+++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
@@ -1310,6 +1310,7 @@ impl ConnectorSpecifications for Authorizedotnet {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/dwolla.rs b/crates/hyperswitch_connectors/src/connectors/dwolla.rs
index a9087c5820..3ce4bca52c 100644
--- a/crates/hyperswitch_connectors/src/connectors/dwolla.rs
+++ b/crates/hyperswitch_connectors/src/connectors/dwolla.rs
@@ -1016,6 +1016,7 @@ impl ConnectorSpecifications for Dwolla {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/facilitapay.rs b/crates/hyperswitch_connectors/src/connectors/facilitapay.rs
index a40816f5bc..79b8e7cc44 100644
--- a/crates/hyperswitch_connectors/src/connectors/facilitapay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/facilitapay.rs
@@ -977,6 +977,7 @@ impl ConnectorSpecifications for Facilitapay {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/finix.rs b/crates/hyperswitch_connectors/src/connectors/finix.rs
index 6c9513bf30..2999d68c34 100644
--- a/crates/hyperswitch_connectors/src/connectors/finix.rs
+++ b/crates/hyperswitch_connectors/src/connectors/finix.rs
@@ -1094,6 +1094,7 @@ impl ConnectorSpecifications for Finix {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs
index fe765a4640..d7564b8cdd 100644
--- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs
+++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs
@@ -961,6 +961,7 @@ impl ConnectorSpecifications for Gocardless {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs
index 286ff4c32c..357b1299a8 100644
--- a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs
+++ b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault.rs
@@ -86,7 +86,7 @@ impl ConnectorIntegration<ExternalVaultCreateFlow, VaultRequestData, VaultRespon
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
- "{}/v2/payment-method-sessions",
+ "{}/payment-method-sessions",
self.base_url(connectors)
))
}
@@ -273,7 +273,7 @@ impl ConnectorIntegration<CreateConnectorCustomer, ConnectorCustomerData, Paymen
_req: &ConnectorCustomerRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Ok(format!("{}/v2/customers", self.base_url(connectors)))
+ Ok(format!("{}/customers", self.base_url(connectors)))
}
fn get_request_body(
@@ -499,6 +499,7 @@ impl webhooks::IncomingWebhook for HyperswitchVault {
impl ConnectorSpecifications for HyperswitchVault {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault/transformers.rs b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault/transformers.rs
index e5e586d54c..430b47f0c1 100644
--- a/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/hyperswitch_vault/transformers.rs
@@ -16,6 +16,7 @@ use crate::{types::ResponseRouterData, utils};
#[derive(Default, Debug, Serialize)]
pub struct HyperswitchVaultCreateRequest {
customer_id: String,
+ storage_type: common_enums::StorageType,
}
impl TryFrom<&VaultRouterData<ExternalVaultCreateFlow>> for HyperswitchVaultCreateRequest {
@@ -26,7 +27,11 @@ impl TryFrom<&VaultRouterData<ExternalVaultCreateFlow>> for HyperswitchVaultCrea
.connector_customer_id
.clone()
.ok_or_else(utils::missing_field_err("connector_customer"))?;
- Ok(Self { customer_id })
+
+ Ok(Self {
+ customer_id,
+ storage_type: common_enums::StorageType::Persistent,
+ })
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/payload.rs b/crates/hyperswitch_connectors/src/connectors/payload.rs
index c9a2e219fc..8b9552dd6c 100644
--- a/crates/hyperswitch_connectors/src/connectors/payload.rs
+++ b/crates/hyperswitch_connectors/src/connectors/payload.rs
@@ -1259,6 +1259,7 @@ impl ConnectorSpecifications for Payload {
}
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
#[cfg(feature = "v1")]
diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rs
index c973fe8bf3..a7ef9706b4 100644
--- a/crates/hyperswitch_connectors/src/connectors/stax.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stax.rs
@@ -1037,6 +1037,7 @@ impl ConnectorSpecifications for Stax {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe.rs b/crates/hyperswitch_connectors/src/connectors/stripe.rs
index c531279745..c90c47a364 100644
--- a/crates/hyperswitch_connectors/src/connectors/stripe.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stripe.rs
@@ -3339,6 +3339,7 @@ impl ConnectorSpecifications for Stripe {
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
true
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index 95f2546ffd..e88aa948c1 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -520,6 +520,7 @@ pub trait ConnectorSpecifications {
/// Connectors should override this method if they require to create a connector customer
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
_payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
false
diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
index 6f01c8abb7..6a734744fd 100644
--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
@@ -801,12 +801,19 @@ impl ConnectorSpecifications for ConnectorEnum {
/// Check if connector requires create customer call
fn should_call_connector_customer(
&self,
+ #[cfg(feature = "v1")]
payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> bool {
+ #[cfg(feature = "v1")]
match self {
Self::Old(connector) => connector.should_call_connector_customer(payment_attempt),
Self::New(connector) => connector.should_call_connector_customer(payment_attempt),
}
+ #[cfg(feature = "v2")]
+ match self {
+ Self::Old(connector) => connector.should_call_connector_customer(),
+ Self::New(connector) => connector.should_call_connector_customer(),
+ }
}
fn should_call_tokenization_before_setup_mandate(&self) -> bool {
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index b843cc93ba..b693866806 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -7576,7 +7576,6 @@ where
customers::should_call_connector_create_customer(
&connector,
customer,
- payment_data.get_payment_attempt(),
merchant_connector_account,
);
@@ -12742,7 +12741,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {
}
fn get_creds_identifier(&self) -> Option<&str> {
- todo!()
+ None
}
fn get_token(&self) -> Option<&str> {
diff --git a/crates/router/src/core/payments/customers.rs b/crates/router/src/core/payments/customers.rs
index cb79d998e5..bf05b0b691 100644
--- a/crates/router/src/core/payments/customers.rs
+++ b/crates/router/src/core/payments/customers.rs
@@ -109,15 +109,12 @@ pub fn should_call_connector_create_customer<'a>(
pub fn should_call_connector_create_customer<'a>(
connector: &api::ConnectorData,
customer: &'a Option<domain::Customer>,
- payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
merchant_connector_account: &domain::MerchantConnectorAccountTypeDetails,
) -> (bool, Option<&'a str>) {
// Check if create customer is required for the connector
match merchant_connector_account {
domain::MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(_) => {
- let connector_needs_customer = connector
- .connector
- .should_call_connector_customer(payment_attempt);
+ let connector_needs_customer = connector.connector.should_call_connector_customer();
if connector_needs_customer {
let connector_customer_details = customer
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index d933b2e26e..75cad8e23e 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -1330,10 +1330,6 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>(
.clone()
.and_then(|tax| tax.get_default_tax_amount());
- let payment_attempt = payment_data.get_payment_attempt();
- let payment_method = Some(payment_attempt.payment_method_type);
- let payment_method_type = payment_attempt.payment_method_subtype;
-
// TODO: few fields are repeated in both routerdata and request
let request = types::PaymentsSessionData {
amount: payment_data
@@ -1362,8 +1358,8 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>(
metadata: payment_data.payment_intent.metadata,
order_tax_amount,
shipping_cost: payment_data.payment_intent.amount_details.shipping_cost,
- payment_method,
- payment_method_type,
+ payment_method: None,
+ payment_method_type: None,
split_payments: payment_data.payment_intent.split_payments,
};
@@ -1381,7 +1377,7 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>(
attempt_id: "".to_string(),
status: enums::AttemptStatus::Started,
payment_method: enums::PaymentMethod::Wallet,
- payment_method_type,
+ payment_method_type: Some(enums::PaymentMethodType::GooglePay),
connector_auth_type: auth_type,
description: payment_data
.payment_intent
diff --git a/crates/router/src/core/payments/vault_session.rs b/crates/router/src/core/payments/vault_session.rs
index 431d099044..6140cf3afc 100644
--- a/crates/router/src/core/payments/vault_session.rs
+++ b/crates/router/src/core/payments/vault_session.rs
@@ -176,7 +176,6 @@ where
customers::should_call_connector_create_customer(
&connector,
customer,
- payment_data.get_payment_attempt(),
merchant_connector_account_type,
);