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(applepay): add payment processing detail input type for simplified flow (#14225)
Nithin N7c6512d2b165
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex db7fd4bdc6..b42993c5c5 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -33731,6 +33731,14 @@},"additionalProperties": false},+ "PaymentProcessingDetailInputType": {+ "type": "string",+ "description": "Specifies how the Apple Pay payment processing details are supplied.",+ "enum": [+ "raw",+ "link_hierarchical_resource"+ ]+ },"PaymentProcessingDetails": {"type": "object","required": [@@ -46235,6 +46243,14 @@}],"nullable": true+ },+ "payment_processing_detail_input_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentProcessingDetailInputType"+ }+ ],+ "nullable": true}}}diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex ba980ec99f..904f2dee0d 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -25071,6 +25071,14 @@}}},+ "PaymentProcessingDetailInputType": {+ "type": "string",+ "description": "Specifies how the Apple Pay payment processing details are supplied.",+ "enum": [+ "raw",+ "link_hierarchical_resource"+ ]+ },"PaymentProcessingDetails": {"type": "object","required": [@@ -33439,6 +33447,14 @@}],"nullable": true+ },+ "payment_processing_detail_input_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentProcessingDetailInputType"+ }+ ],+ "nullable": true}}}diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 95635acef5..569a0df631 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -10641,6 +10641,11 @@ pub struct SessionTokenInfo {pub merchant_business_country: Option<api_enums::CountryAlpha2>,#[serde(flatten)]pub payment_processing_details_at: Option<PaymentProcessingDetailsAt>,+ /// Optional in the request, always populated (defaults to `raw`) in the response+ #[serde(serialize_with = "serialize_payment_processing_detail_input_type")]+ #[schema(value_type = Option<PaymentProcessingDetailInputType>)]+ #[smithy(value_type = "Option<PaymentProcessingDetailInputType>")]+ pub payment_processing_detail_input_type: Option<PaymentProcessingDetailInputType>,}#[derive(@@ -10676,6 +10681,29 @@ pub struct PaymentProcessingDetails {pub payment_processing_certificate_key: Secret<String>,}+/// Specifies how the Apple Pay payment processing details are supplied.+#[derive(+ Debug,+ Clone,+ Copy,+ Default,+ PartialEq,+ Eq,+ serde::Serialize,+ serde::Deserialize,+ ToSchema,+ SmithyModel,+)]+#[serde(rename_all = "snake_case")]+#[smithy(namespace = "com.hyperswitch.smithy.types")]+pub enum PaymentProcessingDetailInputType {+ /// The payment processing certificates are supplied as raw values.+ #[default]+ Raw,+ /// The payment processing certificates are linked from an organization level resource.+ LinkHierarchicalResource,+}+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct SessionTokenForSimplifiedApplePay {pub initiative_context: String,@@ -10683,6 +10711,23 @@ pub struct SessionTokenForSimplifiedApplePay {pub merchant_business_country: Option<api_enums::CountryAlpha2>,}+/// Serializes the payment processing detail input type in its unwrapped form, so that the response+/// always carries a concrete value even when it was not provided in the request.+// serde's `serialize_with` requires the function to accept a reference to the field.+#[allow(clippy::trivially_copy_pass_by_ref)]+fn serialize_payment_processing_detail_input_type<S>(+ payment_processing_detail_input_type: &Option<PaymentProcessingDetailInputType>,+ serializer: S,+) -> Result<S::Ok, S::Error>+where+ S: Serializer,+{+ Serialize::serialize(+ &payment_processing_detail_input_type.unwrap_or_default(),+ serializer,+ )+}+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]pub struct GooglePayWalletDetails {pub google_pay: GooglePayDetails,diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex cbd7247032..0aff896be9 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -643,6 +643,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::ScheduledExpirationTime,api_models::payments::BoletoAdditionalDetails,api_models::payments::PaymentProcessingDetailsAt,+ api_models::payments::PaymentProcessingDetailInputType,api_models::payments::ApplepayInitiative,api_models::payments::PaymentProcessingDetails,api_models::payments::PaymentMethodDataResponseWithBilling,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex ce8993edfa..0382e26131 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -535,6 +535,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::ScheduledExpirationTime,api_models::payments::BoletoAdditionalDetails,api_models::payments::PaymentProcessingDetailsAt,+ api_models::payments::PaymentProcessingDetailInputType,api_models::payments::ApplepayInitiative,api_models::payments::PaymentProcessingDetails,api_models::payments::PaymentMethodDataResponseWithBilling,diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 383a2d132e..25ba5843de 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -13706,11 +13706,13 @@ pub async fn payment_external_authentication<F: Clone + Sync>(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to call authentication authenticate flow")?} else {- crate::core::unified_authentication_service::authentication_authenticate_core(- state.clone(),- platform.clone(),- authenticate_req,- services::api::AuthFlow::Client,+ Box::pin(+ crate::core::unified_authentication_service::authentication_authenticate_core(+ state.clone(),+ platform.clone(),+ authenticate_req,+ services::api::AuthFlow::Client,+ ),).await?.get_json_body()diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rsindex f38d7461bb..4b0114c21c 100644--- a/crates/router/src/db/merchant_connector_account.rs+++ b/crates/router/src/db/merchant_connector_account.rs@@ -248,6 +248,8 @@ mod merchant_connector_account_cache_tests {additional_merchant_data: None,version: common_types::consts::API_VERSION,connector_webhook_registration_details: None,+ apple_pay_certificates: None,+ apple_pay_certificates_encrypted: None,};db.insert_merchant_connector_account(mca.clone(), &merchant_key)diff --git a/crates/storage_impl/src/merchant_connector_account.rs b/crates/storage_impl/src/merchant_connector_account.rsindex 7c44fbd251..4893a60516 100644--- a/crates/storage_impl/src/merchant_connector_account.rs+++ b/crates/storage_impl/src/merchant_connector_account.rs@@ -735,12 +735,14 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {storage::MerchantConnectorAccountUpdateInternal,),) -> Result<(), error_stack::Report<StorageError>> {- Conversion::convert(merchant_connector_account)- .await- .change_context(StorageError::EncryptionError)?- .update(connection, mca_update)- .await- .map_err(|error| report!(StorageError::from(error)))?;+ Box::pin(+ Conversion::convert(merchant_connector_account)+ .await+ .change_context(StorageError::EncryptionError)?+ .update(connection, mca_update),+ )+ .await+ .map_err(|error| report!(StorageError::from(error)))?;Ok(())}@@ -849,23 +851,25 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {let update_call = || async {let conn = pg_accounts_connection_write(self).await?;- Conversion::convert(this)- .await- .change_context(Self::Error::EncryptionError)?- .update(&conn, merchant_connector_account)- .await- .map_err(|error| report!(Self::Error::from(error)))- .async_and_then(|item| async {- item.convert(- self.get_keymanager_state()- .attach_printable("Missing KeyManagerState")?,- key_store.key.get_inner(),- key_store.merchant_id.clone().into(),- )+ Box::pin(+ Conversion::convert(this).await- .change_context(Self::Error::DecryptionError)- })+ .change_context(Self::Error::EncryptionError)?+ .update(&conn, merchant_connector_account),+ )+ .await+ .map_err(|error| report!(Self::Error::from(error)))+ .async_and_then(|item| async {+ item.convert(+ self.get_keymanager_state()+ .attach_printable("Missing KeyManagerState")?,+ key_store.key.get_inner(),+ key_store.merchant_id.clone().into(),+ ).await+ .change_context(Self::Error::DecryptionError)+ })+ .await};#[cfg(feature = "accounts_cache")]@@ -929,25 +933,27 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {let update_call = || async {let conn = pg_accounts_connection_write(self).await?;- Conversion::convert(this)- .await- .change_context(Self::Error::EncryptionError)?- .update(&conn, merchant_connector_account)- .await- .map_err(|error| report!(Self::Error::from(error)))- .async_and_then(|item| async {- item.convert(- self.get_keymanager_state()- .attach_printable("Missing KeyManagerState")?,- key_store.key.get_inner(),- common_utils::types::keymanager::Identifier::Merchant(- key_store.merchant_id.clone(),- ),- )+ Box::pin(+ Conversion::convert(this).await- .change_context(Self::Error::DecryptionError)- })+ .change_context(Self::Error::EncryptionError)?+ .update(&conn, merchant_connector_account),+ )+ .await+ .map_err(|error| report!(Self::Error::from(error)))+ .async_and_then(|item| async {+ item.convert(+ self.get_keymanager_state()+ .attach_printable("Missing KeyManagerState")?,+ key_store.key.get_inner(),+ common_utils::types::keymanager::Identifier::Merchant(+ key_store.merchant_id.clone(),+ ),+ ).await+ .change_context(Self::Error::DecryptionError)+ })+ .await};#[cfg(feature = "accounts_cache")]