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(payouts): add audit table for payouts (#10588)
Sakil Mostak3a42b26672c7
diff --git a/crates/analytics/docs/clickhouse/scripts/api_events.sql b/crates/analytics/docs/clickhouse/scripts/api_events.sqlindex 36ad10db95..83e400b1bb 100644--- a/crates/analytics/docs/clickhouse/scripts/api_events.sql+++ b/crates/analytics/docs/clickhouse/scripts/api_events.sql@@ -2,6 +2,7 @@ CREATE TABLE api_events_queue (`merchant_id` String,`payment_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String),`payment_method_id` Nullable(String),`payment_method` Nullable(String),`payment_method_type` Nullable(String),@@ -35,6 +36,7 @@ CREATE TABLE api_events (`merchant_id` LowCardinality(String),`payment_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String),`payment_method_id` Nullable(String),`payment_method` Nullable(String),`payment_method_type` Nullable(String),@@ -106,6 +108,37 @@ CREATE TABLE api_events_audit (ORDER BY(merchant_id, payment_id) TTL inserted_at + toIntervalMonth(18) SETTINGS index_granularity = 8192;+CREATE TABLE api_events_payout_audit (+ `merchant_id` LowCardinality(String),+ `payout_id` String,+ `payment_method_id` Nullable(String),+ `payment_method` Nullable(String),+ `payment_method_type` Nullable(String),+ `customer_id` Nullable(String),+ `user_id` Nullable(String),+ `connector` Nullable(String),+ `request_id` String,+ `flow_type` LowCardinality(String),+ `api_flow` LowCardinality(String),+ `api_auth_type` LowCardinality(String),+ `request` String,+ `response` Nullable(String),+ `error` Nullable(String),+ `authentication_data` Nullable(String),+ `status_code` UInt32,+ `created_at` DateTime64(3),+ `inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),+ `latency` UInt128,+ `user_agent` String,+ `ip_addr` String,+ `hs_latency` Nullable(UInt128),+ `http_method` LowCardinality(Nullable(String)),+ `url_path` Nullable(String),+ `masked_response` Nullable(String)+) ENGINE = MergeTree PARTITION BY merchant_id+ORDER BY+ (merchant_id, payout_id) TTL inserted_at + toIntervalMonth(18) SETTINGS index_granularity = 8192;+CREATE MATERIALIZED VIEW api_events_parse_errors (`topic` String,`partition` Int64,@@ -191,10 +224,72 @@ WHERE(length(_error) = 0)AND (payment_id IS NOT NULL);+CREATE MATERIALIZED VIEW api_events_payout_audit_mv TO api_events_payout_audit (+ `merchant_id` String,+ `payout_id` String,+ `payment_method_id` Nullable(String),+ `payment_method` Nullable(String),+ `payment_method_type` Nullable(String),+ `customer_id` Nullable(String),+ `user_id` Nullable(String),+ `connector` Nullable(String),+ `request_id` String,+ `flow_type` LowCardinality(String),+ `api_flow` LowCardinality(String),+ `api_auth_type` LowCardinality(String),+ `request` String,+ `response` Nullable(String),+ `error` Nullable(String),+ `authentication_data` Nullable(String),+ `status_code` UInt32,+ `created_at` DateTime64(3),+ `inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),+ `latency` UInt128,+ `user_agent` String,+ `ip_addr` String,+ `hs_latency` Nullable(UInt128),+ `http_method` LowCardinality(Nullable(String)),+ `url_path` Nullable(String),+ `masked_response` Nullable(String)+) AS+SELECT+ merchant_id,+ payout_id,+ payment_method_id,+ payment_method,+ payment_method_type,+ customer_id,+ user_id,+ connector,+ request_id,+ flow_type,+ api_flow,+ api_auth_type,+ request,+ response,+ error,+ authentication_data,+ status_code,+ created_at_timestamp AS created_at,+ now() AS inserted_at,+ latency,+ user_agent,+ ip_addr,+ hs_latency,+ http_method,+ url_path,+ response AS masked_response+FROM+ api_events_queue+WHERE+ (length(_error) = 0)+ AND (payout_id IS NOT NULL);+CREATE MATERIALIZED VIEW api_events_mv TO api_events (`merchant_id` String,`payment_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String),`payment_method_id` Nullable(String),`payment_method` Nullable(String),`payment_method_type` Nullable(String),@@ -225,6 +320,7 @@ SELECTmerchant_id,payment_id,refund_id,+ payout_id,payment_method_id,payment_method,payment_method_type,diff --git a/crates/analytics/docs/clickhouse/scripts/connector_events.sql b/crates/analytics/docs/clickhouse/scripts/connector_events.sqlindex 33826fbaaf..f05d851102 100644--- a/crates/analytics/docs/clickhouse/scripts/connector_events.sql+++ b/crates/analytics/docs/clickhouse/scripts/connector_events.sql@@ -14,6 +14,7 @@ CREATE TABLE connector_events_queue`method` LowCardinality(String),`dispute_id` Nullable(String),`refund_id` Nullable(String)+ `payout_id` Nullable(String))ENGINE = KafkaSETTINGS kafka_broker_list = 'kafka0:29092', kafka_topic_list = 'hyperswitch-outgoing-connector-events', kafka_group_name = 'hyper', kafka_format = 'JSONEachRow', kafka_handle_error_mode = 'stream';@@ -55,6 +56,7 @@ CREATE TABLE connector_events (`method` LowCardinality(String),`dispute_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String)INDEX flowIndex flow TYPE bloom_filter GRANULARITY 1,INDEX connectorIndex connector_name TYPE bloom_filter GRANULARITY 1,INDEX statusIndex status_code TYPE bloom_filter GRANULARITY 1@@ -92,6 +94,28 @@ CREATE TABLE connector_events_audit (ORDER BY(merchant_id, payment_id) TTL inserted_at + toIntervalMonth(18) SETTINGS index_granularity = 8192;+CREATE TABLE connector_events_payout_audit (+ `merchant_id` LowCardinality(String),+ `payout_id` String,+ `connector_name` LowCardinality(String),+ `request_id` String,+ `flow` LowCardinality(String),+ `request` String,+ `response` Nullable(String),+ `masked_response` Nullable(String),+ `error` Nullable(String),+ `status_code` UInt32,+ `created_at` DateTime64(3),+ `inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),+ `latency` UInt128,+ `method` LowCardinality(String),+ INDEX flowIndex flow TYPE bloom_filter GRANULARITY 1,+ INDEX connectorIndex connector_name TYPE bloom_filter GRANULARITY 1,+ INDEX statusIndex status_code TYPE bloom_filter GRANULARITY 1+) ENGINE = MergeTree PARTITION BY merchant_id+ORDER BY+ (merchant_id, payout_id) TTL inserted_at + toIntervalMonth(18) SETTINGS index_granularity = 8192;+CREATE MATERIALIZED VIEW connector_events_audit_mv TO connector_events_audit (`merchant_id` String,`payment_id` Nullable(String),@@ -133,6 +157,43 @@ WHERE(length(_error) = 0)AND (payment_id IS NOT NULL);+CREATE MATERIALIZED VIEW connector_events_payout_audit_mv TO connector_events_payout_audit (+ `merchant_id` String,+ `payout_id` Nullable(String),+ `connector_name` LowCardinality(String),+ `request_id` String,+ `flow` LowCardinality(String),+ `request` String,+ `response` Nullable(String),+ `masked_response` Nullable(String),+ `error` Nullable(String),+ `status_code` UInt32,+ `created_at` DateTime64(3),+ `inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),+ `latency` UInt128,+ `method` LowCardinality(String)+) AS+SELECT+ merchant_id,+ payout_id,+ connector_name,+ request_id,+ flow,+ request,+ masked_response AS response,+ masked_response,+ error,+ status_code,+ created_at,+ now64() AS inserted_at,+ latency,+ method+FROM+ connector_events_queue+WHERE+ (length(_error) = 0)+ AND (payout_id IS NOT NULL);+CREATE MATERIALIZED VIEW connector_events_mv TO connector_events (`merchant_id` String,`payment_id` Nullable(String),@@ -149,7 +210,8 @@ CREATE MATERIALIZED VIEW connector_events_mv TO connector_events (`latency` UInt128,`method` LowCardinality(String),`refund_id` Nullable(String),- `dispute_id` Nullable(String)+ `dispute_id` Nullable(String),+ `payout_id` Nullable(String)) ASSELECTmerchant_id,@@ -167,7 +229,8 @@ SELECTlatency,method,refund_id,- dispute_id+ dispute_id,+ payout_idFROMconnector_events_queueWHEREdiff --git a/crates/analytics/docs/clickhouse/scripts/outgoing_webhook_events.sql b/crates/analytics/docs/clickhouse/scripts/outgoing_webhook_events.sqlindex a104bc506f..b703e06948 100644--- a/crates/analytics/docs/clickhouse/scripts/outgoing_webhook_events.sql+++ b/crates/analytics/docs/clickhouse/scripts/outgoing_webhook_events.sql@@ -5,6 +5,7 @@ CREATE TABLE outgoing_webhook_events_queue (`outgoing_webhook_event_type` LowCardinality(String),`payment_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String),`attempt_id` Nullable(String),`dispute_id` Nullable(String),`payment_method_id` Nullable(String),@@ -29,6 +30,7 @@ CREATE TABLE outgoing_webhook_events (`outgoing_webhook_event_type` LowCardinality(String),`payment_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String),`attempt_id` Nullable(String),`dispute_id` Nullable(String),`payment_method_id` Nullable(String),@@ -76,6 +78,27 @@ CREATE TABLE outgoing_webhook_events_audit (ORDER BY(merchant_id, payment_id) TTL inserted_at + toIntervalMonth(18) SETTINGS index_granularity = 8192;+CREATE TABLE outgoing_webhook_events_payout_audit (+ `merchant_id` LowCardinality(String),+ `event_id` String,+ `event_type` LowCardinality(String),+ `outgoing_webhook_event_type` LowCardinality(String),+ `payout_id` String,+ `attempt_id` Nullable(String),+ `payment_method_id` Nullable(String),+ `mandate_id` Nullable(String),+ `content` Nullable(String),+ `is_error` Bool,+ `error` Nullable(String),+ `initial_attempt_id` Nullable(String),+ `status_code` Nullable(UInt16),+ `delivery_attempt` LowCardinality(String),+ `created_at` DateTime64(3),+ `inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4)+) ENGINE = MergeTree PARTITION BY merchant_id+ORDER BY+ (merchant_id, payout_id) TTL inserted_at + toIntervalMonth(18) SETTINGS index_granularity = 8192;+CREATE MATERIALIZED VIEW outgoing_webhook_events_mv TO outgoing_webhook_events (`merchant_id` String,`event_id` String,@@ -83,6 +106,7 @@ CREATE MATERIALIZED VIEW outgoing_webhook_events_mv TO outgoing_webhook_events (`outgoing_webhook_event_type` LowCardinality(String),`payment_id` Nullable(String),`refund_id` Nullable(String),+ `payout_id` Nullable(String),`attempt_id` Nullable(String),`dispute_id` Nullable(String),`payment_method_id` Nullable(String),@@ -103,6 +127,7 @@ SELECToutgoing_webhook_event_type,payment_id,refund_id,+ payout_id,attempt_id,dispute_id,payment_method_id,@@ -165,6 +190,47 @@ WHERE(length(_error) = 0)AND (payment_id IS NOT NULL);+CREATE MATERIALIZED VIEW outgoing_webhook_events_payout_audit_mv TO outgoing_webhook_events_payout_audit (+ `merchant_id` String,+ `event_id` String,+ `event_type` LowCardinality(String),+ `outgoing_webhook_event_type` LowCardinality(String),+ `payout_id` String,+ `attempt_id` Nullable(String),+ `payment_method_id` Nullable(String),+ `mandate_id` Nullable(String),+ `content` Nullable(String),+ `is_error` Bool,+ `error` Nullable(String),+ `initial_attempt_id` Nullable(String),+ `status_code` Nullable(UInt16),+ `delivery_attempt` LowCardinality(String),+ `created_at` DateTime64(3),+ `inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4)+) AS+SELECT+ merchant_id,+ event_id,+ event_type,+ outgoing_webhook_event_type,+ payout_id,+ attempt_id,+ payment_method_id,+ mandate_id,+ content,+ is_error,+ error,+ initial_attempt_id,+ status_code,+ delivery_attempt,+ created_at_timestamp AS created_at,+ now() AS inserted_at+FROM+ outgoing_webhook_events_queue+WHERE+ (length(_error) = 0)+ AND (payout_id IS NOT NULL);+CREATE MATERIALIZED VIEW outgoing_webhook_parse_errors (`topic` String,`partition` Int64,