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
revert: refactor(merchant_account): add back `api_key` field for backward compatibility (#761) (#1062)
Sanchith Hegdef481abb8551f
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex 9bf375182d..1d6155b08c 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -1,5 +1,5 @@use common_utils::pii;-use masking::{Secret, StrongSecret};+use masking::Secret;use serde::{Deserialize, Serialize};use url;use utoipa::ToSchema;@@ -18,10 +18,6 @@ pub struct MerchantAccountCreate {#[schema(example = "NewAge Retailer")]pub merchant_name: Option<String>,- /// API key that will be used for server side API access- #[schema(value_type = Option<String>, example = "Ah2354543543523")]- pub api_key: Option<StrongSecret<String>>,-/// Merchant related detailspub merchant_details: Option<MerchantDetails>,@@ -155,10 +151,6 @@ pub struct MerchantAccountResponse {#[schema(example = "NewAge Retailer")]pub merchant_name: Option<String>,- /// API key that will be used for server side API access- #[schema(value_type = Option<String>, example = "Ah2354543543523")]- pub api_key: Option<StrongSecret<String>>,-/// The URL to redirect after the completion of the operation#[schema(max_length = 255, example = "https://www.example.com/success")]pub return_url: Option<String>,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex a23e9d36d6..f32d92298e 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -1,19 +1,17 @@use api_models::admin::PrimaryBusinessDetails;use common_utils::ext_traits::ValueExt;-use error_stack::{report, FutureExt, IntoReport, ResultExt};-use masking::Secret; //PeekInterface+use error_stack::{report, FutureExt, ResultExt};+use masking::Secret;use storage_models::{enums, merchant_account};use uuid::Uuid;use crate::{consts,core::{- api_keys,errors::{self, RouterResponse, RouterResult, StorageErrorExt},payments::helpers,},db::StorageInterface,- routes::AppState,services::api as service_api,types::{self, api,@@ -58,38 +56,11 @@ fn get_primary_business_details(}pub async fn create_merchant_account(- state: &AppState,+ db: &dyn StorageInterface,req: api::MerchantAccountCreate,) -> RouterResponse<api::MerchantAccountResponse> {- let db = &*state.store;let publishable_key = Some(create_merchant_publishable_key());- let api_key_request = api::CreateApiKeyRequest {- name: "Default API key".into(),- description: Some(- "An API key created by default when a user signs up on the HyperSwitch dashboard"- .into(),- ),- expiration: api::ApiKeyExpiration::Never,- };- let api_key = match api_keys::create_api_key(- db,- &state.conf.api_keys,- #[cfg(feature = "kms")]- &state.conf.kms,- api_key_request,- req.merchant_id.clone(),- )- .await?- {- service_api::ApplicationResponse::Json(api::CreateApiKeyResponse { api_key, .. }) => {- Ok(api_key)- }- _ => Err(errors::ApiErrorResponse::InternalServerError)- .into_report()- .attach_printable("Unexpected create API key response"),- }?;-let primary_business_details = utils::Encode::<Vec<PrimaryBusinessDetails>>::encode_to_value(&get_primary_business_details(&req),)@@ -132,7 +103,6 @@ pub async fn create_merchant_account(let merchant_account = storage::MerchantAccountNew {merchant_id: req.merchant_id,merchant_name: req.merchant_name,- api_key: Some(api_key),merchant_details,return_url: req.return_url.map(|a| a.to_string()),webhook_details,diff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rsindex eb0bd093a8..4d3b84cfe4 100644--- a/crates/router/src/db/merchant_account.rs+++ b/crates/router/src/db/merchant_account.rs@@ -179,7 +179,6 @@ impl MerchantAccountInterface for MockDb {#[allow(clippy::as_conversions)]id: accounts.len() as i32,merchant_id: merchant_account.merchant_id,- api_key: merchant_account.api_key,return_url: merchant_account.return_url,enable_payment_response_hash: merchant_account.enable_payment_response_hashdiff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex 1880801368..cf73f4d536 100644--- a/crates/router/src/routes/admin.rs+++ b/crates/router/src/routes/admin.rs@@ -35,7 +35,7 @@ pub async fn merchant_account_create(state.get_ref(),&req,json_payload.into_inner(),- |state, _, req| create_merchant_account(state, req),+ |state, _, req| create_merchant_account(&*state.store, req),&auth::AdminApiAuth,).awaitdiff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rsindex 0a49d01e1a..70f9df7805 100644--- a/crates/router/src/types/api/admin.rs+++ b/crates/router/src/types/api/admin.rs@@ -22,7 +22,6 @@ impl ForeignTryFrom<storage::MerchantAccount> for MerchantAccountResponse {Ok(Self {merchant_id: item.merchant_id,merchant_name: item.merchant_name,- api_key: item.api_key,return_url: item.return_url,enable_payment_response_hash: item.enable_payment_response_hash,payment_response_hash_key: item.payment_response_hash_key,diff --git a/crates/storage_models/src/merchant_account.rs b/crates/storage_models/src/merchant_account.rsindex c34f67705d..27446ec69b 100644--- a/crates/storage_models/src/merchant_account.rs+++ b/crates/storage_models/src/merchant_account.rs@@ -1,6 +1,5 @@use common_utils::pii;use diesel::{AsChangeset, Identifiable, Insertable, Queryable};-use masking::StrongSecret;use crate::{enums as storage_enums, schema::merchant_account};@@ -34,7 +33,6 @@ pub struct MerchantAccount {pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,pub primary_business_details: serde_json::Value,- pub api_key: Option<StrongSecret<String>>,pub intent_fulfillment_time: Option<i64>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,@@ -58,7 +56,6 @@ pub struct MerchantAccountNew {pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,pub primary_business_details: serde_json::Value,- pub api_key: Option<StrongSecret<String>>,pub intent_fulfillment_time: Option<i64>,}diff --git a/crates/storage_models/src/schema.rs b/crates/storage_models/src/schema.rsindex cec6853450..3cbcb4abc1 100644--- a/crates/storage_models/src/schema.rs+++ b/crates/storage_models/src/schema.rs@@ -248,7 +248,6 @@ diesel::table! {metadata -> Nullable<Jsonb>,routing_algorithm -> Nullable<Json>,primary_business_details -> Json,- api_key -> Nullable<Varchar>,intent_fulfillment_time -> Nullable<Int8>,created_at -> Timestamp,modified_at -> Timestamp,diff --git a/migrations/2023-03-16-132604_merchant_account_temp_add_api_key/down.sql b/migrations/2023-03-16-132604_merchant_account_temp_add_api_key/down.sqldeleted file mode 100644index 2289944c88..0000000000--- a/migrations/2023-03-16-132604_merchant_account_temp_add_api_key/down.sql+++ /dev/null@@ -1 +0,0 @@-ALTER TABLE merchant_account DROP COLUMN api_key;diff --git a/migrations/2023-03-16-132604_merchant_account_temp_add_api_key/up.sql b/migrations/2023-03-16-132604_merchant_account_temp_add_api_key/up.sqldeleted file mode 100644index 8143ee1a88..0000000000--- a/migrations/2023-03-16-132604_merchant_account_temp_add_api_key/up.sql+++ /dev/null@@ -1,2 +0,0 @@-ALTER TABLE merchant_account-ADD COLUMN api_key VARCHAR(128);