Skip to content

Commit

Permalink
Merge branch 'main' into pm-details-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshayaFoiger authored Dec 20, 2024
2 parents 9fa021b + 492fd87 commit 07f8a1c
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 38 deletions.
16 changes: 16 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -14671,6 +14671,7 @@
"id",
"status",
"amount",
"customer_id",
"connector",
"client_secret",
"created",
Expand All @@ -14692,6 +14693,13 @@
"amount": {
"$ref": "#/components/schemas/ConfirmIntentAmountDetailsResponse"
},
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
"example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
"connector": {
"type": "string",
"description": "The connector used for the payment",
Expand Down Expand Up @@ -16416,6 +16424,7 @@
"id",
"status",
"amount",
"customer_id",
"client_secret",
"created"
],
Expand All @@ -16433,6 +16442,13 @@
"amount": {
"$ref": "#/components/schemas/ConfirmIntentAmountDetailsResponse"
},
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
"example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
"connector": {
"type": "string",
"description": "The connector used for the payment",
Expand Down
8 changes: 5 additions & 3 deletions crates/api_models/src/events/customer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};

use crate::customers::{CustomerDeleteResponse, CustomerRequest, CustomerResponse};
use crate::customers::{
CustomerDeleteResponse, CustomerRequest, CustomerResponse, CustomerUpdateRequestInternal,
};

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerDeleteResponse {
Expand Down Expand Up @@ -55,7 +57,7 @@ impl ApiEventMetric for CustomerResponse {
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal {
impl ApiEventMetric for CustomerUpdateRequestInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
customer_id: self.customer_id.clone(),
Expand All @@ -64,7 +66,7 @@ impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal {
}

#[cfg(all(feature = "v2", feature = "customer_v2"))]
impl ApiEventMetric for crate::customers::CustomerUpdateRequestInternal {
impl ApiEventMetric for CustomerUpdateRequestInternal {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
customer_id: Some(self.id.clone()),
Expand Down
18 changes: 18 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4803,6 +4803,15 @@ pub struct PaymentsConfirmIntentResponse {
/// Amount related information for this payment and attempt
pub amount: ConfirmIntentAmountDetailsResponse,

/// The identifier for the customer
#[schema(
min_length = 32,
max_length = 64,
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,

/// The connector used for the payment
#[schema(example = "stripe")]
pub connector: String,
Expand Down Expand Up @@ -4872,6 +4881,15 @@ pub struct PaymentsRetrieveResponse {
/// Amount related information for this payment and attempt
pub amount: ConfirmIntentAmountDetailsResponse,

/// The identifier for the customer
#[schema(
min_length = 32,
max_length = 64,
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,

/// The connector used for the payment
#[schema(example = "stripe")]
pub connector: Option<String>,
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/dynamic_routing_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct DynamicRoutingStatsNew {
pub payment_status: common_enums::AttemptStatus,
pub conclusive_classification: common_enums::SuccessBasedRoutingConclusiveState,
pub created_at: time::PrimitiveDateTime,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
}

#[derive(Clone, Debug, Eq, PartialEq, Queryable, Selectable, Insertable)]
Expand All @@ -38,4 +39,5 @@ pub struct DynamicRoutingStats {
pub payment_status: common_enums::AttemptStatus,
pub conclusive_classification: common_enums::SuccessBasedRoutingConclusiveState,
pub created_at: time::PrimitiveDateTime,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
}
2 changes: 2 additions & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ diesel::table! {
payment_status -> AttemptStatus,
conclusive_classification -> SuccessBasedRoutingConclusiveState,
created_at -> Timestamp,
#[max_length = 64]
payment_method_type -> Nullable<Varchar>,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ diesel::table! {
payment_status -> AttemptStatus,
conclusive_classification -> SuccessBasedRoutingConclusiveState,
created_at -> Timestamp,
#[max_length = 64]
payment_method_type -> Nullable<Varchar>,
}
}

Expand Down
10 changes: 5 additions & 5 deletions crates/router/src/core/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ pub async fn delete_customer(
) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {
let db = &*state.store;
let key_manager_state = &(&state).into();
id.fetch_domain_model_and_update_and_generate_delete_customer_response(
id.redact_customer_details_and_generate_response(
db,
&key_store,
&merchant_account,
Expand All @@ -585,7 +585,7 @@ pub async fn delete_customer(
))]
#[async_trait::async_trait]
impl CustomerDeleteBridge for id_type::GlobalCustomerId {
async fn fetch_domain_model_and_update_and_generate_delete_customer_response<'a>(
async fn redact_customer_details_and_generate_response<'a>(
&'a self,
db: &'a dyn StorageInterface,
key_store: &'a domain::MerchantKeyStore,
Expand Down Expand Up @@ -717,7 +717,7 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {

#[async_trait::async_trait]
trait CustomerDeleteBridge {
async fn fetch_domain_model_and_update_and_generate_delete_customer_response<'a>(
async fn redact_customer_details_and_generate_response<'a>(
&'a self,
db: &'a dyn StorageInterface,
key_store: &'a domain::MerchantKeyStore,
Expand All @@ -742,7 +742,7 @@ pub async fn delete_customer(
let db = &*state.store;
let key_manager_state = &(&state).into();
customer_id
.fetch_domain_model_and_update_and_generate_delete_customer_response(
.redact_customer_details_and_generate_response(
db,
&key_store,
&merchant_account,
Expand All @@ -759,7 +759,7 @@ pub async fn delete_customer(
))]
#[async_trait::async_trait]
impl CustomerDeleteBridge for id_type::CustomerId {
async fn fetch_domain_model_and_update_and_generate_delete_customer_response<'a>(
async fn redact_customer_details_and_generate_response<'a>(
&'a self,
db: &'a dyn StorageInterface,
key_store: &'a domain::MerchantKeyStore,
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@ where
id: payment_intent.id.clone(),
status: payment_intent.status,
amount,
customer_id: payment_intent.customer_id.clone(),
connector,
client_secret: payment_intent.client_secret.clone(),
created: payment_intent.created_at,
Expand Down Expand Up @@ -1311,6 +1312,7 @@ where
id: payment_intent.id.clone(),
status: payment_intent.status,
amount,
customer_id: payment_intent.customer_id.clone(),
connector,
billing: payment_address
.get_payment_billing()
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/routing/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ pub async fn push_metrics_with_update_window_for_success_based_routing(
amount: payment_attempt.get_total_amount(),
success_based_routing_connector: first_success_based_connector.to_string(),
payment_connector: payment_connector.to_string(),
payment_method_type: payment_attempt.payment_method_type,
currency: payment_attempt.currency,
payment_method: payment_attempt.payment_method,
capture_method: payment_attempt.capture_method,
Expand Down
9 changes: 6 additions & 3 deletions cypress-tests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from "cypress";
import "cypress-mochawesome-reporter/plugin.js";
import mochawesome from "cypress-mochawesome-reporter/plugin.js";

let globalState;

Expand All @@ -10,7 +10,9 @@ const reportName = process.env.REPORT_NAME || `${connectorId}_report`;

export default defineConfig({
e2e: {
setupNodeEvents(on) {
setupNodeEvents(on, config) {
mochawesome(on);

on("task", {
setGlobalState: (val) => {
return (globalState = val || {});
Expand All @@ -26,6 +28,8 @@ export default defineConfig({
return null;
},
});

return config;
},
experimentalRunAllSpecs: true,

Expand All @@ -43,6 +47,5 @@ export default defineConfig({
chromeWebSecurity: false,
defaultCommandTimeout: 10000,
pageLoadTimeout: 20000,

screenshotsFolder: screenshotsFolderName,
});
44 changes: 22 additions & 22 deletions cypress-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions cypress-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"author": "Hyperswitch",
"license": "ISC",
"devDependencies": {
"@eslint/js": "^9.16.0",
"cypress": "^13.16.0",
"@eslint/js": "^9.17.0",
"cypress": "^13.17.0",
"cypress-mochawesome-reporter": "^3.8.2",
"eslint": "^9.16.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.13.0",
"globals": "^15.14.0",
"jsqr": "^1.4.0",
"prettier": "^3.4.1"
"prettier": "^3.4.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE dynamic_routing_stats
DROP COLUMN IF EXISTS payment_method_type;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Your SQL goes here
ALTER TABLE dynamic_routing_stats
ADD COLUMN IF NOT EXISTS payment_method_type VARCHAR(64);

0 comments on commit 07f8a1c

Please sign in to comment.