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

feat(events): add APIs to list webhook events and webhook delivery attempts (#4131)

Sanchith Hegde14e1bbaf071d
diff --git a/Cargo.lock b/Cargo.lock
index 33327b7158..4d8d1e8c6a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -80,7 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
dependencies = [
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -118,7 +118,7 @@ dependencies = [
"parse-size",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -255,7 +255,7 @@ dependencies = [
"actix-router",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -566,7 +566,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -577,7 +577,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -1600,7 +1600,7 @@ dependencies = [
"proc-macro-crate 2.0.0",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
"syn_derive",
]
@@ -1922,7 +1922,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2355,7 +2355,7 @@ dependencies = [
"proc-macro2",
"quote",
"strsim",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2377,7 +2377,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
dependencies = [
"darling_core 0.20.3",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2545,7 +2545,7 @@ dependencies = [
"diesel_table_macro_syntax",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2575,7 +2575,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5"
dependencies = [
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2632,7 +2632,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2981,7 +2981,7 @@ checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e"
dependencies = [
"frunk_proc_macro_helpers",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -2993,7 +2993,7 @@ dependencies = [
"frunk_core",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -3005,7 +3005,7 @@ dependencies = [
"frunk_core",
"frunk_proc_macro_helpers",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -3118,7 +3118,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -4480,7 +4480,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -4766,7 +4766,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -4856,7 +4856,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -4998,9 +4998,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.76"
+version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
+checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
dependencies = [
"unicode-ident",
]
@@ -5683,7 +5683,7 @@ dependencies = [
"serde",
"serde_json",
"strum 0.24.1",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6077,7 +6077,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6141,7 +6141,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6191,7 +6191,7 @@ dependencies = [
"darling 0.20.3",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6216,7 +6216,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6604,7 +6604,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6626,9 +6626,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.48"
+version = "2.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
+checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032"
dependencies = [
"proc-macro2",
"quote",
@@ -6644,7 +6644,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6752,7 +6752,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -6764,7 +6764,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
"test-case-core",
]
@@ -6844,7 +6844,7 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -7034,7 +7034,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -7364,7 +7364,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -7635,7 +7635,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
@@ -7793,7 +7793,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
"wasm-bindgen-shared",
]
@@ -7827,7 +7827,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -8201,7 +8201,7 @@ checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.53",
]
[[package]]
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml
index f073212ed5..94202935c5 100644
--- a/crates/api_models/Cargo.toml
+++ b/crates/api_models/Cargo.toml
@@ -32,7 +32,7 @@ serde_json = "1.0.108"
strum = { version = "0.25", features = ["derive"] }
time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] }
url = { version = "2.4.0", features = ["serde"] }
-utoipa = { version = "3.3.0", features = ["preserve_order"] }
+utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] }
frunk = "0.4.1"
frunk_core = "0.4.1"
diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs
index 1ea79ff6fe..cc991d7a6b 100644
--- a/crates/api_models/src/lib.rs
+++ b/crates/api_models/src/lib.rs
@@ -35,4 +35,5 @@ pub mod user;
pub mod user_role;
pub mod verifications;
pub mod verify_connector;
+pub mod webhook_events;
pub mod webhooks;
diff --git a/crates/api_models/src/user_role.rs b/crates/api_models/src/user_role.rs
index 411bf823a2..2e3d60024d 100644
--- a/crates/api_models/src/user_role.rs
+++ b/crates/api_models/src/user_role.rs
@@ -31,6 +31,7 @@ pub enum Permission {
UsersRead,
UsersWrite,
MerchantAccountCreate,
+ WebhookEventRead,
}
#[derive(Debug, serde::Serialize)]
diff --git a/crates/api_models/src/webhook_events.rs b/crates/api_models/src/webhook_events.rs
new file mode 100644
index 0000000000..8eed5cb03f
--- /dev/null
+++ b/crates/api_models/src/webhook_events.rs
@@ -0,0 +1,145 @@
+use common_enums::{EventClass, EventType, WebhookDeliveryAttempt};
+use masking::Secret;
+use serde::{Deserialize, Serialize};
+use time::PrimitiveDateTime;
+use utoipa::ToSchema;
+
+/// The constraints to apply when filtering events.
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct EventListConstraints {
+ /// Filter events created after the specified time.
+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]
+ pub created_after: Option<PrimitiveDateTime>,
+
+ /// Filter events created before the specified time.
+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]
+ pub created_before: Option<PrimitiveDateTime>,
+
+ /// Include at most the specified number of events.
+ pub limit: Option<u16>,
+
+ /// Include events after the specified offset.
+ pub offset: Option<u16>,
+
+ /// Filter all events associated with the specified object identifier (Payment Intent ID,
+ /// Refund ID, etc.)
+ pub object_id: Option<String>,
+}
+
+#[derive(Debug)]
+pub enum EventListConstraintsInternal {
+ GenericFilter {
+ created_after: Option<PrimitiveDateTime>,
+ created_before: Option<PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ },
+ ObjectIdFilter {
+ object_id: String,
+ },
+}
+
+/// The response body for each item when listing events.
+#[derive(Debug, Serialize, ToSchema)]
+pub struct EventListItemResponse {
+ /// The identifier for the Event.
+ #[schema(max_length = 64, example = "evt_018e31720d1b7a2b82677d3032cab959")]
+ pub event_id: String,
+
+ /// The identifier for the Merchant Account.
+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]
+ pub merchant_id: String,
+
+ /// The identifier for the Business Profile.
+ #[schema(max_length = 64, example = "SqB0zwDGR5wHppWf0bx7GKr1f2")]
+ pub profile_id: String,
+
+ /// The identifier for the object (Payment Intent ID, Refund ID, etc.)
+ #[schema(max_length = 64, example = "QHrfd5LUDdZaKtAjdJmMu0dMa1")]
+ pub object_id: String,
+
+ /// Specifies the type of event, which includes the object and its status.
+ pub event_type: EventType,
+
+ /// Specifies the class of event (the type of object: Payment, Refund, etc.)
+ pub event_class: EventClass,
+
+ /// Indicates whether the webhook delivery attempt was successful.
+ pub is_delivery_successful: bool,
+
+ /// The identifier for the initial delivery attempt. This will be the same as `event_id` for
+ /// the initial delivery attempt.
+ #[schema(max_length = 64, example = "evt_018e31720d1b7a2b82677d3032cab959")]
+ pub initial_attempt_id: String,
+
+ /// Time at which the event was created.
+ #[schema(example = "2022-09-10T10:11:12Z")]
+ #[serde(with = "common_utils::custom_serde::iso8601")]
+ pub created: PrimitiveDateTime,
+}
+
+/// The response body for retrieving an event.
+#[derive(Debug, Serialize, ToSchema)]
+pub struct EventRetrieveResponse {
+ #[serde(flatten)]
+ pub event_information: EventListItemResponse,
+
+ /// The request information (headers and body) sent in the webhook.
+ pub request: OutgoingWebhookRequestContent,
+
+ /// The response information (headers, body and status code) received for the webhook sent.
+ pub response: OutgoingWebhookResponseContent,
+
+ /// Indicates the type of delivery attempt.
+ pub delivery_attempt: Option<WebhookDeliveryAttempt>,
+}
+
+/// The request information (headers and body) sent in the webhook.
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct OutgoingWebhookRequestContent {
+ /// The request body sent in the webhook.
+ #[schema(value_type = String)]
+ #[serde(alias = "payload")]
+ pub body: Secret<String>,
+
+ /// The request headers sent in the webhook.
+ #[schema(
+ value_type = Vec<(String, String)>,
+ example = json!([["content-type", "application/json"], ["content-length", "1024"]]))
+ ]
+ pub headers: Vec<(String, Secret<String>)>,
+}
+
+/// The response information (headers, body and status code) received for the webhook sent.
+#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema)]
+pub struct OutgoingWebhookResponseContent {
+ /// The response body received for the webhook sent.
+ #[schema(value_type = String)]
+ #[serde(alias = "payload")]
+ pub body: Secret<String>,
+
+ /// The response headers received for the webhook sent.
+ #[schema(
+ value_type = Vec<(String, String)>,
+ example = json!([["content-type", "application/json"], ["content-length", "1024"]]))
+ ]
+ pub headers: Vec<(String, Secret<String>)>,
+
+ /// The HTTP status code for the webhook sent.
+ #[schema(example = 200)]
+ pub status_code: u16,
+}
+
+#[derive(Debug, serde::Serialize)]
+pub struct EventListRequestInternal {
+ pub merchant_id: String,
+ pub constraints: EventListConstraints,
+}
+
+impl common_utils::events::ApiEventMetric for EventListRequestInternal {
+ fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
+ Some(common_utils::events::ApiEventsType::Events {
+ merchant_id: self.merchant_id.clone(),
+ })
+ }
+}
diff --git a/crates/common_enums/Cargo.toml b/crates/common_enums/Cargo.toml
index 86e89a1bfd..30da73c57d 100644
--- a/crates/common_enums/Cargo.toml
+++ b/crates/common_enums/Cargo.toml
@@ -17,7 +17,7 @@ diesel = { version = "2.1.0", features = ["postgres"] }
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
strum = { version = "0.25", features = ["derive"] }
-utoipa = { version = "3.3.0", features = ["preserve_order"] }
+utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] }
# First party crates
router_derive = { version = "0.1.0", path = "../router_derive" }
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index a1156366d3..89ca80e72b 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -14,6 +14,7 @@ pub mod diesel_exports {
DbPaymentMethodIssuerCode as PaymentMethodIssuerCode, DbPaymentType as PaymentType,
DbRefundStatus as RefundStatus,
DbRequestIncrementalAuthorization as RequestIncrementalAuthorization,
+ DbWebhookDeliveryAttempt as WebhookDeliveryAttempt,
};
}
@@ -1032,6 +1033,28 @@ impl Currency {
}
}
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "db_enum")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum EventClass {
+ Payments,
+ Refunds,
+ Disputes,
+ Mandates,
+}
+
#[derive(
Clone,
Copy,
@@ -1070,6 +1093,27 @@ pub enum EventType {
MandateRevoked,
}
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "db_enum")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum WebhookDeliveryAttempt {
+ InitialAttempt,
+ AutomaticRetry,
+ ManualRetry,
+}
+
// TODO: This decision about using KV mode or not,
// should be taken at a top level rather than pushing it down to individual functions via an enum.
#[derive(
diff --git a/crates/common_utils/src/crypto.rs b/crates/common_utils/src/crypto.rs
index 2cf586dca6..1a29f043e0 100644
--- a/crates/common_utils/src/crypto.rs
+++ b/crates/common_utils/src/crypto.rs
@@ -11,7 +11,7 @@ use ring::{
use crate::{
errors::{self, CustomResult},
- pii::{self, EncryptionStratergy},
+ pii::{self, EncryptionStrategy},
};
#[derive(Clone, Debug)]
@@ -104,7 +104,7 @@ pub trait DecodeMessage {
fn decode_message(
&self,
_secret: &[u8],
- _msg: Secret<Vec<u8>, EncryptionStratergy>,
+ _msg: Secret<Vec<u8>, EncryptionStrategy>,
) -> CustomResult<Vec<u8>, errors::CryptoError>;
}
@@ -148,7 +148,7 @@ impl DecodeMessage for NoAlgorithm {
fn decode_message(
&self,
_secret: &[u8],
- msg: Secret<Vec<u8>, EncryptionStratergy>,
+ msg: Secret<Vec<u8>, EncryptionStrategy>,
) -> CustomResult<Vec<u8>, errors::CryptoError> {
Ok(msg.expose())
}
@@ -271,7 +271,7 @@ impl DecodeMessage for GcmAes256 {
fn decode_message(
&self,
secret: &[u8],
- msg: Secret<Vec<u8>, EncryptionStratergy>,
+ msg: Secret<Vec<u8>, EncryptionStrategy>,
) -> CustomResult<Vec<u8>, errors::CryptoError> {
let msg = msg.expose();
let key = UnboundKey::new(&aead::AES_256_GCM, secret)
@@ -413,7 +413,7 @@ pub fn generate_cryptographically_secure_random_bytes<const N: usize>() -> [u8;
#[derive(Debug, Clone)]
pub struct Encryptable<T: Clone> {
inner: T,
- encrypted: Secret<Vec<u8>, EncryptionStratergy>,
+ encrypted: Secret<Vec<u8>, EncryptionStrategy>,
}
impl<T: Clone, S: masking::Strategy<T>> Encryptable<Secret<T, S>> {
@@ -422,7 +422,7 @@ impl<T: Clone, S: masking::Strategy<T>> Encryptable<Secret<T, S>> {
///
pub fn new(
masked_data: Secret<T, S>,
- encrypted_data: Secret<Vec<u8>, EncryptionStratergy>,
+ encrypted_data: Secret<Vec<u8>, EncryptionStrategy>,
) -> Self {
Self {
inner: masked_data,
@@ -452,7 +452,7 @@ impl<T: Clone> Encryptable<T> {
/// Get the inner encrypted data while consuming self
///
#[inline]
- pub fn into_encrypted(self) -> Secret<Vec<u8>, EncryptionStratergy> {
+ pub fn into_encrypted(self) -> Secret<Vec<u8>, EncryptionStrategy> {
self.encrypted
}
}
diff --git a/crates/common_utils/src/events.rs b/crates/common_utils/src/events.rs
index e755e0f9c4..a6d065d3e6 100644
--- a/crates/common_utils/src/events.rs
+++ b/crates/common_utils/src/events.rs
@@ -53,6 +53,9 @@ pub enum ApiEventsType {
Dispute {
dispute_id: String,
},
+ Events {
+ merchant_id: String,
+ },
}
impl ApiEventMetric for serde_json::Value {}
diff --git a/crates/common_utils/src/pii.rs b/crates/common_utils/src/pii.rs
index 066962af1d..110a7eb952 100644
--- a/crates/common_utils/src/pii.rs
+++ b/crates/common_utils/src/pii.rs
@@ -147,14 +147,18 @@ where
/// Strategy for Encryption
#[derive(Debug)]
-pub enum EncryptionStratergy {}
+pub enum EncryptionStrategy {}
-impl<T> Strategy<T> for EncryptionStratergy
+impl<T> Strategy<T> for EncryptionStrategy
where
T: AsRef<[u8]>,
{
fn fmt(value: &T, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
- write!(fmt, "*** Encrypted {} of bytes ***", value.as_ref().len())
+ write!(
+ fmt,
+ "*** Encrypted data of length {} bytes ***",
+ value.as_ref().len()
+ )
}
}
diff --git a/crates/connector_configs/Cargo.toml b/crates/connector_configs/Cargo.toml
index e1601f0c79..7966e6a5af 100644
--- a/crates/connector_configs/Cargo.toml
+++ b/crates/connector_configs/Cargo.toml
@@ -2,7 +2,7 @@
name = "connector_configs"
description = "Connector Integration Dashboard"
version = "0.1.0"
-edition.workspace = true
+edition.workspace = true
rust-version.workspace = true
license.workspace = true
@@ -19,4 +19,4 @@ api_models = { version = "0.1.0", path = "../api_models", package = "api_models"
serde = { version = "1.0.193", features = ["derive"] }
serde_with = "3.4.0"
toml = "0.7.3"
-utoipa = { version = "3.3.0", features = ["preserve_order"] }
\ No newline at end of file
+utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] }
diff --git a/crates/diesel_models/src/encryption.rs b/crates/diesel_models/src/encryption.rs
index acb8b5f13e..375259491c 100644
--- a/crates/diesel_models/src/encryption.rs
+++ b/crates/diesel_models/src/encryption.rs
@@ -1,4 +1,4 @@
-use common_utils::pii::EncryptionStratergy;
+use common_utils::pii::EncryptionStrategy;
use diesel::{
backend::Backend,
deserialize::{self, FromSql, Queryable},
@@ -11,7 +11,7 @@ use masking::Secret;
#[diesel(sql_type = diesel::sql_types::Binary)]
#[repr(transparent)]
pub struct Encryption {
- inner: Secret<Vec<u8>, EncryptionStratergy>,
+ inner: Secret<Vec<u8>, EncryptionStrategy>,
}
impl<T: Clone> From<common_utils::crypto::Encryptable<T>> for Encryption {
@@ -21,17 +21,17 @@ impl<T: Clone> From<common_utils::crypto::Encryptable<T>> for Encryption {
}
impl Encryption {
- pub fn new(item: Secret<Vec<u8>, EncryptionStratergy>) -> Self {
+ pub fn new(item: Secret<Vec<u8>, EncryptionStrategy>) -> Self {
Self { inner: item }
}
#[inline]
- pub fn into_inner(self) -> Secret<Vec<u8>, EncryptionStratergy> {
+ pub fn into_inner(self) -> Secret<Vec<u8>, EncryptionStrategy> {
self.inner
}
#[inline]
- pub fn get_inner(&self) -> &Secret<Vec<u8>, EncryptionStratergy> {
+ pub fn get_inner(&self) -> &Secret<Vec<u8>, EncryptionStrategy> {
&self.inner
}
}
@@ -39,17 +39,17 @@ impl Encryption {
impl<DB> FromSql<sql_types::Binary, DB> for Encryption
where
DB: Backend,
- Secret<Vec<u8>, EncryptionStratergy>: FromSql<sql_types::Binary, DB>,
+ Secret<Vec<u8>, EncryptionStrategy>: FromSql<sql_types::Binary, DB>,
{
fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
- <Secret<Vec<u8>, EncryptionStratergy>>::from_sql(bytes).map(Self::new)
+ <Secret<Vec<u8>, EncryptionStrategy>>::from_sql(bytes).map(Self::new)
}
}
impl<DB> ToSql<sql_types::Binary, DB> for Encryption
where
DB: Backend,
- Secret<Vec<u8>, EncryptionStratergy>: ToSql<sql_types::Binary, DB>,
+ Secret<Vec<u8>, EncryptionStrategy>: ToSql<sql_types::Binary, DB>,
{
fn to_sql<'b>(
&'b self,
@@ -62,9 +62,9 @@ where
impl<DB> Queryable<sql_types::Binary, DB> for Encryption
where
DB: Backend,
- Secret<Vec<u8>, EncryptionStratergy>: FromSql<sql_types::Binary, DB>,
+ Secret<Vec<u8>, EncryptionStrategy>: FromSql<sql_types::Binary, DB>,
{
- type Row = Secret<Vec<u8>, EncryptionStratergy>;
+ type Row = Secret<Vec<u8>, EncryptionStrategy>;
fn build(row: Self::Row) -> deserialize::Result<Self> {
Ok(Self { inner: row })
}
diff --git a/crates/diesel_models/src/enums.rs b/crates/diesel_models/src/enums.rs
index 0310944de7..865524c645 100644
--- a/crates/diesel_models/src/enums.rs
+++ b/crates/diesel_models/src/enums.rs
@@ -19,6 +19,7 @@ pub mod diesel_exports {
DbRequestIncrementalAuthorization as RequestIncrementalAuthorization,
DbRoleScope as RoleScope, DbRoutingAlgorithmKind as RoutingAlgorithmKind,
DbTransactionType as TransactionType, DbUserStatus as UserStatus,
+ DbWebhookDeliveryAttempt as WebhookDeliveryAttempt,
};
}
pub use common_enums::*;
@@ -48,27 +49,6 @@ pub enum RoutingAlgorithmKind {
Advanced,
}
-#[derive(
- Clone,
- Copy,
- Debug,
- Eq,
- PartialEq,
- serde::Deserialize,
- serde::Serialize,
- strum::Display,
- strum::EnumString,
-)]
-#[diesel_enum(storage_type = "db_enum")]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum EventClass {
- Payments,
- Refunds,
- Disputes,
- Mandates,
-}
-
#[derive(
Clone,
Copy,
diff --git a/crates/diesel_models/src/events.rs b/crates/diesel_models/src/events.rs
index c327cead12..cae82165e2 100644
--- a/crates/diesel_models/src/events.rs
+++ b/crates/diesel_models/src/events.rs
@@ -22,6 +22,7 @@ pub struct EventNew {
pub initial_attempt_id: Option<String>,
pub request: Option<Encryption>,
pub response: Option<Encryption>,
+ pub delivery_attempt: Option<storage_enums::WebhookDeliveryAttempt>,
}
#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
@@ -51,4 +52,5 @@ pub struct Event {
pub initial_attempt_id: Option<String>,
pub request: Option<Encryption>,
pub response: Option<Encryption>,
+ pub delivery_attempt: Option<storage_enums::WebhookDeliveryAttempt>,
}
diff --git a/crates/diesel_models/src/query/events.rs b/crates/diesel_models/src/query/events.rs
index 7e519490dc..0fc856d600 100644
--- a/crates/diesel_models/src/query/events.rs
+++ b/crates/diesel_models/src/query/events.rs
@@ -1,4 +1,6 @@
-use diesel::{associations::HasTable, ExpressionMethods};
+use diesel::{
+ associations::HasTable, BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods,
+};
use super::generics;
use crate::{
@@ -14,16 +16,197 @@ impl EventNew {
}
impl Event {
- pub async fn find_by_event_id(conn: &PgPooledConn, event_id: &str) -> StorageResult<Self> {
+ pub async fn find_by_merchant_id_event_id(
+ conn: &PgPooledConn,
+ merchant_id: &str,
+ event_id: &str,
+ ) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
- dsl::event_id.eq(event_id.to_owned()),
+ dsl::merchant_id
+ .eq(merchant_id.to_owned())
+ .and(dsl::event_id.eq(event_id.to_owned())),
+ )
+ .await
+ }
+
+ pub async fn list_initial_attempts_by_merchant_id_primary_object_id(
+ conn: &PgPooledConn,
+ merchant_id: &str,
+ primary_object_id: &str,
+ ) -> StorageResult<Vec<Self>> {
+ generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(
+ conn,
+ dsl::event_id
+ .nullable()
+ .eq(dsl::initial_attempt_id) // Filter initial attempts only
+ .and(dsl::merchant_id.eq(merchant_id.to_owned()))
+ .and(dsl::primary_object_id.eq(primary_object_id.to_owned())),
+ None,
+ None,
+ Some(dsl::created_at.desc()),
+ )
+ .await
+ }
+
+ pub async fn list_initial_attempts_by_merchant_id_constraints(
+ conn: &PgPooledConn,
+ merchant_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ ) -> StorageResult<Vec<Self>> {
+ use async_bb8_diesel::AsyncRunQueryDsl;
+ use diesel::{debug_query, pg::Pg, QueryDsl};
+ use error_stack::{IntoReport, ResultExt};
+ use router_env::logger;
+
+ use super::generics::db_metrics::{track_database_call, DatabaseOperation};
+ use crate::errors::DatabaseError;
+
+ let mut query = Self::table()
+ .filter(
+ dsl::event_id
+ .nullable()
+ .eq(dsl::initial_attempt_id) // Filter initial attempts only
+ .and(dsl::merchant_id.eq(merchant_id.to_owned())),
+ )
+ .order(dsl::created_at.desc())
+ .into_boxed();
+
+ if let Some(created_after) = created_after {
+ query = query.filter(dsl::created_at.ge(created_after));
+ }
+
+ if let Some(created_before) = created_before {
+ query = query.filter(dsl::created_at.le(created_before));
+ }
+
+ if let Some(limit) = limit {
+ query = query.limit(limit);
+ }
+
+ if let Some(offset) = offset {
+ query = query.offset(offset);
+ }
+
+ logger::debug!(query = %debug_query::<Pg, _>(&query).to_string());
+
+ track_database_call::<Self, _, _>(query.get_results_async(conn), DatabaseOperation::Filter)
+ .await
+ .into_report()
+ .change_context(DatabaseError::Others) // Query returns empty Vec when no records are found
+ .attach_printable("Error filtering events by constraints")
+ }
+
+ pub async fn list_by_merchant_id_initial_attempt_id(
+ conn: &PgPooledConn,
+ merchant_id: &str,
+ initial_attempt_id: &str,
+ ) -> StorageResult<Vec<Self>> {
+ generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(
+ conn,
+ dsl::merchant_id
+ .eq(merchant_id.to_owned())
+ .and(dsl::initial_attempt_id.eq(initial_attempt_id.to_owned())),
+ None,
+ None,
+ Some(dsl::created_at.desc()),
+ )
+ .await
+ }
+
+ pub async fn list_initial_attempts_by_profile_id_primary_object_id(
+ conn: &PgPooledConn,
+ profile_id: &str,
+ primary_object_id: &str,
+ ) -> StorageResult<Vec<Self>> {
+ generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(
+ conn,
+ dsl::event_id
+ .nullable()
+ .eq(dsl::initial_attempt_id) // Filter initial attempts only
+ .and(dsl::business_profile_id.eq(profile_id.to_owned()))
+ .and(dsl::primary_object_id.eq(primary_object_id.to_owned())),
+ None,
+ None,
+ Some(dsl::created_at.desc()),
+ )
+ .await
+ }
+
+ pub async fn list_initial_attempts_by_profile_id_constraints(
+ conn: &PgPooledConn,
+ profile_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ ) -> StorageResult<Vec<Self>> {
+ use async_bb8_diesel::AsyncRunQueryDsl;
+ use diesel::{debug_query, pg::Pg, QueryDsl};
+ use error_stack::{IntoReport, ResultExt};
+ use router_env::logger;
+
+ use super::generics::db_metrics::{track_database_call, DatabaseOperation};
+ use crate::errors::DatabaseError;
+
+ let mut query = Self::table()
+ .filter(
+ dsl::event_id
+ .nullable()
+ .eq(dsl::initial_attempt_id) // Filter initial attempts only
+ .and(dsl::business_profile_id.eq(profile_id.to_owned())),
+ )
+ .order(dsl::created_at.desc())
+ .into_boxed();
+
+ if let Some(created_after) = created_after {
+ query = query.filter(dsl::created_at.ge(created_after));
+ }
+
+ if let Some(created_before) = created_before {
+ query = query.filter(dsl::created_at.le(created_before));
+ }
+
+ if let Some(limit) = limit {
+ query = query.limit(limit);
+ }
+
+ if let Some(offset) = offset {
+ query = query.offset(offset);
+ }
+
+ logger::debug!(query = %debug_query::<Pg, _>(&query).to_string());
+
+ track_database_call::<Self, _, _>(query.get_results_async(conn), DatabaseOperation::Filter)
+ .await
+ .into_report()
+ .change_context(DatabaseError::Others) // Query returns empty Vec when no records are found
+ .attach_printable("Error filtering events by constraints")
+ }
+
+ pub async fn list_by_profile_id_initial_attempt_id(
+ conn: &PgPooledConn,
+ profile_id: &str,
+ initial_attempt_id: &str,
+ ) -> StorageResult<Vec<Self>> {
+ generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(
+ conn,
+ dsl::business_profile_id
+ .eq(profile_id.to_owned())
+ .and(dsl::initial_attempt_id.eq(initial_attempt_id.to_owned())),
+ None,
+ None,
+ Some(dsl::created_at.desc()),
)
.await
}
- pub async fn update(
+ pub async fn update_by_merchant_id_event_id(
conn: &PgPooledConn,
+ merchant_id: &str,
event_id: &str,
event: EventUpdateInternal,
) -> StorageResult<Self> {
@@ -32,7 +215,13 @@ impl Event {
_,
_,
_,
- >(conn, dsl::event_id.eq(event_id.to_owned()), event)
+ >(
+ conn,
+ dsl::merchant_id
+ .eq(merchant_id.to_owned())
+ .and(dsl::event_id.eq(event_id.to_owned())),
+ event,
+ )
.await
}
}
diff --git a/crates/diesel_models/src/query/generics.rs b/crates/diesel_models/src/query/generics.rs
index a1dd40cd40..27c3d8706a 100644
--- a/crates/diesel_models/src/query/generics.rs
+++ b/crates/diesel_models/src/query/generics.rs
@@ -22,10 +22,7 @@ use diesel::{
use error_stack::{report, IntoReport, ResultExt};
use router_env::logger;
-use crate::{
- errors::{self},
- PgPooledConn, StorageResult,
-};
+use crate::{errors, PgPooledConn, StorageResult};
pub mod db_metrics {
use router_env::opentelemetry::KeyValue;
@@ -279,7 +276,7 @@ where
.await
.into_report()
.change_context(errors::DatabaseError::Others)
- .attach_printable_lazy(|| "Error while deleting")
+ .attach_printable("Error while deleting")
.and_then(|result| match result {
n if n > 0 => {
logger::debug!("{n} records deleted");
@@ -315,7 +312,7 @@ where
.await
.into_report()
.change_context(errors::DatabaseError::Others)
- .attach_printable_lazy(|| "Error while deleting")
+ .attach_printable("Error while deleting")
.and_then(|result| {
result.first().cloned().ok_or_else(|| {
report!(errors::DatabaseError::NotFound)
@@ -390,7 +387,7 @@ where
DieselError::NotFound => err.change_context(errors::DatabaseError::NotFound),
_ => err.change_context(errors::DatabaseError::Others),
})
- .attach_printable_lazy(|| "Error finding record by predicate")
+ .attach_printable("Error finding record by predicate")
}
pub async fn generic_find_one<T, P, R>(conn: &PgPooledConn, predicate: P) -> StorageResult<R>
@@ -454,7 +451,7 @@ where
.await
.into_report()
.change_context(errors::DatabaseError::NotFound)
- .attach_printable_lazy(|| "Error filtering records by predicate")
+ .attach_printable("Error filtering records by predicate")
}
fn to_optional<T>(arg: StorageResult<T>) -> StorageResult<Option<T>> {
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 70befe77e5..8e8bf48a53 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -381,6 +381,7 @@ diesel::table! {
initial_attempt_id -> Nullable<Varchar>,
request -> Nullable<Bytea>,
response -> Nullable<Bytea>,
+ delivery_attempt -> Nullable<WebhookDeliveryAttempt>,
}
}
diff --git a/crates/euclid/Cargo.toml b/crates/euclid/Cargo.toml
index d30d63d094..256ed78451 100644
--- a/crates/euclid/Cargo.toml
+++ b/crates/euclid/Cargo.toml
@@ -16,7 +16,7 @@ serde = { version = "1.0.193", features = ["derive", "rc"] }
serde_json = "1.0.108"
strum = { version = "0.25", features = ["derive"] }
thiserror = "1.0.43"
-utoipa = { version = "3.3.0", features = ["preserve_order"] }
+utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] }
# First party dependencies
common_enums = { version = "0.1.0", path = "../common_enums" }
diff --git a/crates/openapi/Cargo.toml b/crates/openapi/Cargo.toml
index 20d35a8a3d..330f5ed890 100644
--- a/crates/openapi/Cargo.toml
+++ b/crates/openapi/Cargo.toml
@@ -8,7 +8,7 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-utoipa = { version = "3.3.0", features = ["preserve_order", "time"] }
serde_json = "1.0.96"
+utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order", "time"] }
api_models = { version = "0.1.0", path = "../api_models", features = ["frm", "payouts", "openapi"] }
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 549353accb..c8e89f2ee7 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -53,6 +53,7 @@ Never share your secret api keys. Keep them guarded and secure.
),
tags(
(name = "Merchant Account", description = "Create and manage merchant accounts"),
+ (name = "Business Profile", description = "Create and manage business profiles"),
(name = "Merchant Connector Account", description = "Create and manage merchant connector accounts"),
(name = "Payments", description = "Create and manage one-time payments, recurring payments and mandates"),
(name = "Refunds", description = "Create and manage refunds for successful payments"),
@@ -64,6 +65,7 @@ Never share your secret api keys. Keep them guarded and secure.
(name = "Payouts", description = "Create and manage payouts"),
(name = "payment link", description = "Create payment link"),
(name = "Routing", description = "Create and manage routing configurations"),
+ (name = "Event", description = "Manage events"),
),
// The paths will be displayed in the same order as they are registered here
paths(
@@ -109,6 +111,7 @@ Never share your secret api keys. Keep them guarded and secure.
// Routes for mandates
routes::mandates::get_mandate,
routes::mandates::revoke_mandate,
+ routes::mandates::customers_mandates_list,
//Routes for customers
routes::customers::customers_create,
@@ -116,14 +119,13 @@ Never share your secret api keys. Keep them guarded and secure.
routes::customers::customers_list,
routes::customers::customers_update,
routes::customers::customers_delete,
- routes::customers::customers_mandates_list,
- routes::customers::default_payment_method_set_api,
//Routes for payment methods
routes::payment_method::create_payment_method_api,
routes::payment_method::list_payment_method_api,
routes::payment_method::list_customer_payment_method_api,
routes::payment_method::list_customer_payment_method_api_client,
+ routes::payment_method::default_payment_method_set_api,
routes::payment_method::payment_method_retrieve_api,
routes::payment_method::payment_method_update_api,
routes::payment_method::payment_method_delete_api,
@@ -131,9 +133,9 @@ Never share your secret api keys. Keep them guarded and secure.
// Routes for Business Profile
routes::business_profile::business_profile_create,
routes::business_profile::business_profiles_list,
+ routes::business_profile::business_profiles_retrieve,
routes::business_profile::business_profiles_update,
routes::business_profile::business_profiles_delete,
- routes::business_profile::business_profiles_retrieve,
// Routes for disputes
routes::disputes::retrieve_dispute,
@@ -170,7 +172,11 @@ Never share your secret api keys. Keep them guarded and secure.
routes::api_keys::api_key_create,
routes::api_keys::api_key_retrieve,
routes::api_keys::api_key_update,
- routes::api_keys::api_key_revoke
+ routes::api_keys::api_key_revoke,
+
+ // Routes for events
+ routes::webhook_events::list_initial_webhook_delivery_attempts,
+ routes::webhook_events::list_webhook_delivery_attempts,
),
components(schemas(
api_models::refunds::RefundRequest,
@@ -434,6 +440,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::FrmMessage,
api_models::webhooks::OutgoingWebhook,
api_models::webhooks::OutgoingWebhookContent,
+ api_models::enums::EventClass,
api_models::enums::EventType,
api_models::enums::DecoupledAuthenticationType,
api_models::enums::AuthenticationStatus,
@@ -483,7 +490,12 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::blocklist::BlocklistResponse,
api_models::blocklist::ToggleBlocklistResponse,
api_models::blocklist::ListBlocklistQuery,
- api_models::enums::BlocklistDataKind
+ api_models::enums::BlocklistDataKind,
+ api_models::webhook_events::EventListItemResponse,
+ api_models::webhook_events::EventRetrieveResponse,
+ api_models::webhook_events::OutgoingWebhookRequestContent,
+ api_models::webhook_events::OutgoingWebhookResponseContent,
+ api_models::enums::WebhookDeliveryAttempt,
)),
modifiers(&SecurityAddon)
)]
diff --git a/crates/openapi/src/routes.rs b/crates/openapi/src/routes.rs
index 5a18229595..bf6182e495 100644
--- a/crates/openapi/src/routes.rs
+++ b/crates/openapi/src/routes.rs
@@ -15,12 +15,9 @@ pub mod payments;
pub mod payouts;
pub mod refunds;
pub mod routing;
+pub mod webhook_events;
-pub use customers::*;
-pub use mandates::*;
-pub use merchant_account::*;
-pub use merchant_connector_account::*;
-pub use payment_method::*;
-pub use payments::*;
-pub use refunds::*;
-pub use routing::*;
+pub use self::{
+ customers::*, mandates::*, merchant_account::*, merchant_connector_account::*,
+ payment_method::*, payments::*, refunds::*, routing::*, webhook_events::*,
+};
diff --git a/crates/openapi/src/routes/customers.rs b/crates/openapi/src/routes/customers.rs
index 6a6f41d98c..2794ee7310 100644
--- a/crates/openapi/src/routes/customers.rs
+++ b/crates/openapi/src/routes/customers.rs
@@ -95,45 +95,8 @@ pub async fn customers_delete() {}
(status = 200, description = "Customers retrieved", body = Vec<CustomerResponse>),
(status = 400, description = "Invalid Data"),
),
- tag = "Customers List",
+ tag = "Customers",
operation_id = "List all Customers for a Merchant",
security(("api_key" = []))
)]
pub async fn customers_list() {}
-
-/// Customers - Mandates List
-///
-/// Lists all the mandates for a particular customer id.
-#[utoipa::path(
- post,
- path = "/customers/{customer_id}/mandates",
- responses(
- (status = 200, description = "List of retrieved mandates for a customer", body = Vec<MandateResponse>),
- (status = 400, description = "Invalid Data"),
- ),
- tag = "Customers Mandates List",
- operation_id = "List all Mandates for a Customer",
- security(("api_key" = []))
-)]
-pub async fn customers_mandates_list() {}
-
-/// Customers - Set Default Payment Method
-///
-/// Set the Payment Method as Default for the Customer.
-#[utoipa::path(
- get,
- path = "/{customer_id}/payment_methods/{payment_method_id}/default",
- params (
- ("customer_id" = String,Path, description ="The unique identifier for the Customer"),
- ("payment_method_id" = String,Path, description = "The unique identifier for the Payment Method"),
- ),
- responses(
- (status = 200, description = "Payment Method has been set as default", body =CustomerDefaultPaymentMethodResponse ),
- (status = 400, description = "Payment Method has already been set as default for that customer"),
- (status = 404, description = "Payment Method not found for the customer")
- ),
- tag = "Customer Set Default Payment Method",
- operation_id = "Set the Payment Method as Default",
- security(("ephemeral_key" = []))
-)]
-pub async fn default_payment_method_set_api() {}
diff --git a/crates/openapi/src/routes/mandates.rs b/crates/openapi/src/routes/mandates.rs
index c61e2eb2f5..e638070637 100644
--- a/crates/openapi/src/routes/mandates.rs
+++ b/crates/openapi/src/routes/mandates.rs
@@ -59,3 +59,19 @@ pub async fn revoke_mandate() {}
security(("api_key" = []))
)]
pub async fn retrieve_mandates_list() {}
+
+/// Mandates - Customer Mandates List
+///
+/// Lists all the mandates for a particular customer id.
+#[utoipa::path(
+ post,
+ path = "/customers/{customer_id}/mandates",
+ responses(
+ (status = 200, description = "List of retrieved mandates for a customer", body = Vec<MandateResponse>),
+ (status = 400, description = "Invalid Data"),
+ ),
+ tag = "Mandates",
+ operation_id = "List Mandates for a Customer",
+ security(("api_key" = []))
+)]
+pub async fn customers_mandates_list() {}
diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs
index c92cee6a7f..07e6cc3590 100644
--- a/crates/openapi/src/routes/payment_method.rs
+++ b/crates/openapi/src/routes/payment_method.rs
@@ -171,3 +171,24 @@ pub async fn payment_method_update_api() {}
security(("api_key" = []))
)]
pub async fn payment_method_delete_api() {}
+
+/// Payment Method - Set Default Payment Method for Customer
+///
+/// Set the Payment Method as Default for the Customer.
+#[utoipa::path(
+ get,
+ path = "/{customer_id}/payment_methods/{payment_method_id}/default",
+ params (
+ ("customer_id" = String,Path, description ="The unique identifier for the Customer"),
+ ("payment_method_id" = String,Path, description = "The unique identifier for the Payment Method"),
+ ),
+ responses(
+ (status = 200, description = "Payment Method has been set as default", body =CustomerDefaultPaymentMethodResponse ),
+ (status = 400, description = "Payment Method has already been set as default for that customer"),
+ (status = 404, description = "Payment Method not found for the customer")
+ ),
+ tag = "Payment Methods",
+ operation_id = "Set the Payment Method as Default",
+ security(("ephemeral_key" = []))
+)]
+pub async fn default_payment_method_set_api() {}
diff --git a/crates/openapi/src/routes/webhook_events.rs b/crates/openapi/src/routes/webhook_events.rs
new file mode 100644
index 0000000000..129cfa5650
--- /dev/null
+++ b/crates/openapi/src/routes/webhook_events.rs
@@ -0,0 +1,70 @@
+/// Events - List
+///
+/// List all Events associated with a Merchant Account.
+#[utoipa::path(
+ get,
+ path = "/events/{merchant_id}",
+ params(
+ (
+ "merchant_id" = String,
+ Path,
+ description = "The unique identifier for the Merchant Account"
+ ),
+ (
+ "created_after" = Option<PrimitiveDateTime>,
+ Query,
+ description = "Only include Events created after the specified time. \
+ Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
+ ),
+ (
+ "created_before" = Option<PrimitiveDateTime>,
+ Query,
+ description = "Only include Events created before the specified time. \
+ Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
+ ),
+ (
+ "limit" = Option<i64>,
+ Query,
+ description = "The maximum number of Events to include in the response. \
+ Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
+ ),
+ (
+ "offset" = Option<i64>,
+ Query,
+ description = "The number of Events to skip when retrieving the list of Events.
+ Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
+ ),
+ (
+ "object_id" = Option<String>,
+ Query,
+ description = "Only include Events associated with the specified object (Payment Intent ID, Refund ID, etc.). \
+ Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified."
+ ),
+ ),
+ responses(
+ (status = 200, description = "List of Events retrieved successfully", body = Vec<EventListItemResponse>),
+ ),
+ tag = "Event",
+ operation_id = "List all Events associated with a Merchant Account",
+ security(("admin_api_key" = []))
+)]
+pub fn list_initial_webhook_delivery_attempts() {}
+
+/// Events - Delivery Attempt List
+///
+/// List all delivery attempts for the specified Event.
+#[utoipa::path(
+ get,
+ path = "/events/{merchant_id}/{event_id}/attempts",
+ params(
+ ("merchant_id" = String, Path, description = "The unique identifier for the Merchant Account"),
+ ("event_id" = String, Path, description = "The unique identifier for the Event"),
+ ),
+ responses(
+ (status = 200, description = "List of delivery attempts retrieved successfully", body = Vec<EventRetrieveResponse>),
+ ),
+ tag = "Event",
+ operation_id = "List all delivery attempts for an Event",
+ security(("admin_api_key" = []))
+)]
+pub fn list_webhook_delivery_attempts() {}
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 629dcc86d4..df3097d9e5 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -96,7 +96,7 @@ time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] }
tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] }
unicode-segmentation = "1.10.1"
url = { version = "2.4.0", features = ["serde"] }
-utoipa = { version = "3.3.0", features = ["preserve_order", "time"] }
+utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order", "time"] }
uuid = { version = "1.7.0", features = ["v4"] }
validator = "0.16.0"
x509-parser = "0.15.0"
diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rs
index c1f8b5e9c7..60f4391bdf 100644
--- a/crates/router/src/compatibility/stripe/errors.rs
+++ b/crates/router/src/compatibility/stripe/errors.rs
@@ -120,6 +120,9 @@ pub enum StripeErrorCode {
#[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such payout")]
PayoutNotFound,
+ #[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such event")]
+ EventNotFound,
+
#[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "Duplicate payout request")]
DuplicatePayout { payout_id: String },
@@ -518,6 +521,7 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
errors::ApiErrorResponse::MandateNotFound => Self::MandateNotFound,
errors::ApiErrorResponse::ApiKeyNotFound => Self::ApiKeyNotFound,
errors::ApiErrorResponse::PayoutNotFound => Self::PayoutNotFound,
+ errors::ApiErrorResponse::EventNotFound => Self::EventNotFound,
errors::ApiErrorResponse::MandateValidationFailed { reason } => {
Self::PaymentIntentMandateInvalid { message: reason }
}
@@ -656,6 +660,7 @@ impl actix_web::ResponseError for StripeErrorCode {
| Self::MandateNotFound
| Self::ApiKeyNotFound
| Self::PayoutNotFound
+ | Self::EventNotFound
| Self::DuplicateMerchantAccount
| Self::DuplicateMerchantConnectorAccount { .. }
| Self::DuplicatePaymentMethod
diff --git a/crates/router/src/core/api_keys.rs b/crates/router/src/core/api_keys.rs
index a2fcacb3b3..738d9d0c87 100644
--- a/crates/router/src/core/api_keys.rs
+++ b/crates/router/src/core/api_keys.rs
@@ -257,7 +257,7 @@ pub async fn retrieve_api_key(
.find_api_key_by_merchant_id_key_id_optional(merchant_id, key_id)
.await
.change_context(errors::ApiErrorResponse::InternalServerError) // If retrieve failed
- .attach_printable("Failed to retrieve new API key")?
+ .attach_printable("Failed to retrieve API key")?
.ok_or(report!(errors::ApiErrorResponse::ApiKeyNotFound))?; // If retrieve returned `None`
Ok(ApplicationResponse::Json(api_key.foreign_into()))
diff --git a/crates/router/src/core/errors/api_error_response.rs b/crates/router/src/core/errors/api_error_response.rs
index 46c90d776d..3fc93e4e73 100644
--- a/crates/router/src/core/errors/api_error_response.rs
+++ b/crates/router/src/core/errors/api_error_response.rs
@@ -172,6 +172,8 @@ pub enum ApiErrorResponse {
ApiKeyNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payout does not exist in our records")]
PayoutNotFound,
+ #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Event does not exist in our records")]
+ EventNotFound,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Invalid mandate id passed from connector")]
MandateSerializationFailed,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Unable to parse the mandate identifier passed from connector")]
diff --git a/crates/router/src/core/errors/transformers.rs b/crates/router/src/core/errors/transformers.rs
index ce5253051e..b570dda437 100644
--- a/crates/router/src/core/errors/transformers.rs
+++ b/crates/router/src/core/errors/transformers.rs
@@ -182,6 +182,9 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
Self::PayoutNotFound => {
AER::NotFound(ApiError::new("HE", 2, "Payout does not exist in our records", None))
}
+ Self::EventNotFound => {
+ AER::NotFound(ApiError::new("HE", 2, "Event does not exist in our records", None))
+ }
Self::ReturnUrlUnavailable => AER::NotFound(ApiError::new("HE", 3, "Return URL is not configured and not passed in payments request", None)),
Self::RefundNotPossible { connector } => {
AER::BadRequest(ApiError::new("HE", 3, format!("This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard"), None))
diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs
index 0a2d9cd144..6049c8c508 100644
--- a/crates/router/src/core/webhooks.rs
+++ b/crates/router/src/core/webhooks.rs
@@ -1,11 +1,14 @@
pub mod types;
pub mod utils;
+#[cfg(feature = "olap")]
+pub mod webhook_events;
use std::{str::FromStr, time::Instant};
use actix_web::FromRequest;
use api_models::{
payments::HeaderPayload,
+ webhook_events::{OutgoingWebhookRequestContent, OutgoingWebhookResponseContent},
webhooks::{self, WebhookResponseTracker},
};
use common_utils::{
@@ -669,7 +672,7 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
content: api::OutgoingWebhookContent,
primary_object_created_at: Option<time::PrimitiveDateTime>,
) -> CustomResult<(), errors::ApiErrorResponse> {
- let delivery_attempt = types::WebhookDeliveryAttempt::InitialAttempt;
+ let delivery_attempt = enums::WebhookDeliveryAttempt::InitialAttempt;
let idempotent_event_id =
utils::get_idempotent_event_id(&primary_object_id, event_type, delivery_attempt);
let webhook_url_result = get_webhook_url_from_business_profile(&business_profile);
@@ -734,6 +737,7 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
.attach_printable("Failed to encrypt outgoing webhook request content")?,
),
response: None,
+ delivery_attempt: Some(delivery_attempt),
};
let event_insert_result = state
@@ -801,8 +805,8 @@ pub(crate) async fn trigger_webhook_and_raise_event(
business_profile: diesel_models::business_profile::BusinessProfile,
merchant_key_store: &domain::MerchantKeyStore,
event: domain::Event,
- request_content: types::OutgoingWebhookRequestContent,
- delivery_attempt: types::WebhookDeliveryAttempt,
+ request_content: OutgoingWebhookRequestContent,
+ delivery_attempt: enums::WebhookDeliveryAttempt,
content: Option<api::OutgoingWebhookContent>,
process_tracker: Option<storage::ProcessTracker>,
) {
@@ -833,8 +837,8 @@ async fn trigger_webhook_to_merchant(
business_profile: diesel_models::business_profile::BusinessProfile,
merchant_key_store: &domain::MerchantKeyStore,
event: domain::Event,
- request_content: types::OutgoingWebhookRequestContent,
- delivery_attempt: types::WebhookDeliveryAttempt,
+ request_content: OutgoingWebhookRequestContent,
+ delivery_attempt: enums::WebhookDeliveryAttempt,
process_tracker: Option<storage::ProcessTracker>,
) -> CustomResult<(), errors::WebhooksFlowError> {
let webhook_url = match (
@@ -875,7 +879,7 @@ async fn trigger_webhook_to_merchant(
.attach_default_headers()
.headers(headers)
.set_body(RequestContent::RawBytes(
- request_content.payload.expose().into_bytes(),
+ request_content.body.expose().into_bytes(),
))
.build();
@@ -896,7 +900,7 @@ async fn trigger_webhook_to_merchant(
let api_client_error_handler =
|client_error: error_stack::Report<errors::ApiClientError>,
- delivery_attempt: types::WebhookDeliveryAttempt| {
+ delivery_attempt: enums::WebhookDeliveryAttempt| {
let error =
client_error.change_context(errors::WebhooksFlowError::CallToMerchantFailed);
logger::error!(
@@ -907,6 +911,7 @@ async fn trigger_webhook_to_merchant(
};
let update_event_in_storage = |state: AppState,
merchant_key_store: domain::MerchantKeyStore,
+ merchant_id: String,
event_id: String,
response: reqwest::Response| async move {
let status_code = response.status();
@@ -931,7 +936,7 @@ async fn trigger_webhook_to_merchant(
)
})
.collect::<Vec<_>>();
- let response_payload = response
+ let response_body = response
.text()
.await
.map(Secret::from)
@@ -939,8 +944,8 @@ async fn trigger_webhook_to_merchant(
logger::warn!("Response contains non-UTF-8 characters: {error:?}");
Secret::from(String::from("Non-UTF-8 response body"))
});
- let response_to_store = types::OutgoingWebhookResponseContent {
- payload: response_payload,
+ let response_to_store = OutgoingWebhookResponseContent {
+ body: response_body,
headers: response_headers,
status_code: status_code.as_u16(),
};
@@ -964,7 +969,12 @@ async fn trigger_webhook_to_merchant(
};
state
.store
- .update_event(event_id, event_update, &merchant_key_store)
+ .update_event_by_merchant_id_event_id(
+ &merchant_id,
+ &event_id,
+ event_update,
+ &merchant_key_store,
+ )
.await
.change_context(errors::WebhooksFlowError::WebhookEventUpdationFailed)
};
@@ -992,7 +1002,7 @@ async fn trigger_webhook_to_merchant(
}
};
let error_response_handler = |merchant_id: String,
- delivery_attempt: types::WebhookDeliveryAttempt,
+ delivery_attempt: enums::WebhookDeliveryAttempt,
status_code: u16,
log_message: &'static str| {
metrics::WEBHOOK_OUTGOING_NOT_RECEIVED_COUNT.add(
@@ -1006,13 +1016,14 @@ async fn trigger_webhook_to_merchant(
};
match delivery_attempt {
- types::WebhookDeliveryAttempt::InitialAttempt => match response {
+ enums::WebhookDeliveryAttempt::InitialAttempt => match response {
Err(client_error) => api_client_error_handler(client_error, delivery_attempt),
Ok(response) => {
let status_code = response.status();
let _updated_event = update_event_in_storage(
state.clone(),
merchant_key_store.clone(),
+ business_profile.merchant_id.clone(),
event_id.clone(),
response,
)
@@ -1036,7 +1047,7 @@ async fn trigger_webhook_to_merchant(
}
}
},
- types::WebhookDeliveryAttempt::AutomaticRetry => {
+ enums::WebhookDeliveryAttempt::AutomaticRetry => {
let process_tracker = process_tracker
.get_required_value("process_tracker")
.change_context(errors::WebhooksFlowError::OutgoingWebhookRetrySchedulingFailed)
@@ -1060,6 +1071,7 @@ async fn trigger_webhook_to_merchant(
let _updated_event = update_event_in_storage(
state.clone(),
merchant_key_store.clone(),
+ business_profile.merchant_id.clone(),
event_id.clone(),
response,
)
@@ -1094,6 +1106,10 @@ async fn trigger_webhook_to_merchant(
}
}
}
+ enums::WebhookDeliveryAttempt::ManualRetry => {
+ // Will be updated when manual retry is implemented
+ Err(errors::WebhooksFlowError::NotReceivedByMerchant).into_report()?
+ }
}
Ok(())
@@ -1717,12 +1733,12 @@ pub(crate) fn get_outgoing_webhook_request(
merchant_account: &domain::MerchantAccount,
outgoing_webhook: api::OutgoingWebhook,
payment_response_hash_key: Option<&str>,
-) -> CustomResult<types::OutgoingWebhookRequestContent, errors::WebhooksFlowError> {
+) -> CustomResult<OutgoingWebhookRequestContent, errors::WebhooksFlowError> {
#[inline]
fn get_outgoing_webhook_request_inner<WebhookType: types::OutgoingWebhookType>(
outgoing_webhook: api::OutgoingWebhook,
payment_response_hash_key: Option<&str>,
- ) -> CustomResult<types::OutgoingWebhookRequestContent, errors::WebhooksFlowError> {
+ ) -> CustomResult<OutgoingWebhookRequestContent, errors::WebhooksFlowError> {
let mut headers = vec![(
reqwest::header::CONTENT_TYPE.to_string(),
mime::APPLICATION_JSON.essence_str().into(),
@@ -1737,8 +1753,8 @@ pub(crate) fn get_outgoing_webhook_request(
WebhookType::add_webhook_header(&mut headers, signature)
}
- Ok(types::OutgoingWebhookRequestContent {
- payload: outgoing_webhooks_signature.payload,
+ Ok(OutgoingWebhookRequestContent {
+ body: outgoing_webhooks_signature.payload,
headers: headers
.into_iter()
.map(|(name, value)| (name, Secret::new(value.into_inner())))
diff --git a/crates/router/src/core/webhooks/types.rs b/crates/router/src/core/webhooks/types.rs
index d376b2fbdf..7559f692b1 100644
--- a/crates/router/src/core/webhooks/types.rs
+++ b/crates/router/src/core/webhooks/types.rs
@@ -56,12 +56,6 @@ impl OutgoingWebhookType for webhooks::OutgoingWebhook {
}
}
-#[derive(Debug, Clone, Copy)]
-pub(crate) enum WebhookDeliveryAttempt {
- InitialAttempt,
- AutomaticRetry,
-}
-
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct OutgoingWebhookTrackingData {
pub(crate) merchant_id: String,
@@ -72,16 +66,3 @@ pub(crate) struct OutgoingWebhookTrackingData {
pub(crate) primary_object_type: enums::EventObjectType,
pub(crate) initial_attempt_id: Option<String>,
}
-
-#[derive(Debug, serde::Serialize, serde::Deserialize)]
-pub(crate) struct OutgoingWebhookRequestContent {
- pub(crate) payload: Secret<String>,
- pub(crate) headers: Vec<(String, Secret<String>)>,
-}
-
-#[derive(Debug, serde::Serialize, serde::Deserialize)]
-pub(crate) struct OutgoingWebhookResponseContent {
- pub(crate) payload: Secret<String>,
- pub(crate) headers: Vec<(String, Secret<String>)>,
- pub(crate) status_code: u16,
-}
diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rs
index 8afaf8c8fe..739d7b20fd 100644
--- a/crates/router/src/core/webhooks/utils.rs
+++ b/crates/router/src/core/webhooks/utils.rs
@@ -126,16 +126,16 @@ pub async fn construct_webhook_router_data<'a>(
pub(crate) fn get_idempotent_event_id(
primary_object_id: &str,
event_type: crate::types::storage::enums::EventType,
- delivery_attempt: super::types::WebhookDeliveryAttempt,
+ delivery_attempt: crate::types::storage::enums::WebhookDeliveryAttempt,
) -> String {
- use super::types::WebhookDeliveryAttempt;
+ use crate::types::storage::enums::WebhookDeliveryAttempt;
const EVENT_ID_SUFFIX_LENGTH: usize = 8;
let common_prefix = format!("{primary_object_id}_{event_type}");
match delivery_attempt {
WebhookDeliveryAttempt::InitialAttempt => common_prefix,
- WebhookDeliveryAttempt::AutomaticRetry => {
+ WebhookDeliveryAttempt::AutomaticRetry | WebhookDeliveryAttempt::ManualRetry => {
common_utils::generate_id(EVENT_ID_SUFFIX_LENGTH, &common_prefix)
}
}
diff --git a/crates/router/src/core/webhooks/webhook_events.rs b/crates/router/src/core/webhooks/webhook_events.rs
new file mode 100644
index 0000000000..ebb73b387d
--- /dev/null
+++ b/crates/router/src/core/webhooks/webhook_events.rs
@@ -0,0 +1,119 @@
+use error_stack::ResultExt;
+use router_env::{instrument, tracing};
+
+use crate::{
+ core::errors::{self, RouterResponse, StorageErrorExt},
+ routes::AppState,
+ services::ApplicationResponse,
+ types::{api, transformers::ForeignTryFrom},
+};
+
+const INITIAL_DELIVERY_ATTEMPTS_LIST_MAX_LIMIT: i64 = 100;
+
+#[instrument(skip(state))]
+pub async fn list_initial_delivery_attempts(
+ state: AppState,
+ merchant_id: String,
+ constraints: api::webhook_events::EventListConstraints,
+) -> RouterResponse<Vec<api::webhook_events::EventListItemResponse>> {
+ let constraints =
+ api::webhook_events::EventListConstraintsInternal::foreign_try_from(constraints)?;
+
+ let store = state.store.as_ref();
+
+ // This would handle verifying that the merchant ID actually exists
+ let key_store = store
+ .get_merchant_key_store_by_merchant_id(
+ &merchant_id,
+ &store.get_master_key().to_vec().into(),
+ )
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
+
+ let events = match constraints {
+ api_models::webhook_events::EventListConstraintsInternal::ObjectIdFilter { object_id } => {
+ store
+ .list_initial_events_by_merchant_id_primary_object_id(
+ &merchant_id,
+ &object_id,
+ &key_store,
+ )
+ .await
+ }
+ api_models::webhook_events::EventListConstraintsInternal::GenericFilter {
+ created_after,
+ created_before,
+ limit,
+ offset,
+ } => {
+ let limit = match limit {
+ Some(limit) if limit <= INITIAL_DELIVERY_ATTEMPTS_LIST_MAX_LIMIT => Ok(Some(limit)),
+ Some(limit) if limit > INITIAL_DELIVERY_ATTEMPTS_LIST_MAX_LIMIT => Err(
+ errors::ApiErrorResponse::InvalidRequestData{
+ message: format!("`limit` must be a number less than {INITIAL_DELIVERY_ATTEMPTS_LIST_MAX_LIMIT}")
+ }
+ ),
+ _ => Ok(Some(INITIAL_DELIVERY_ATTEMPTS_LIST_MAX_LIMIT)),
+ }?;
+ let offset = match offset {
+ Some(offset) if offset > 0 => Some(offset),
+ _ => None,
+ };
+
+ store
+ .list_initial_events_by_merchant_id_constraints(
+ &merchant_id,
+ created_after,
+ created_before,
+ limit,
+ offset,
+ &key_store,
+ )
+ .await
+ }
+ }
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to list events with specified constraints")?;
+
+ Ok(ApplicationResponse::Json(
+ events
+ .into_iter()
+ .map(api::webhook_events::EventListItemResponse::try_from)
+ .collect::<Result<Vec<_>, _>>()?,
+ ))
+}
+
+#[instrument(skip(state))]
+pub async fn list_delivery_attempts(
+ state: AppState,
+ merchant_id: &str,
+ initial_attempt_id: &str,
+) -> RouterResponse<Vec<api::webhook_events::EventRetrieveResponse>> {
+ let store = state.store.as_ref();
+
+ // This would handle verifying that the merchant ID actually exists
+ let key_store = store
+ .get_merchant_key_store_by_merchant_id(merchant_id, &store.get_master_key().to_vec().into())
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
+
+ let events = store
+ .list_events_by_merchant_id_initial_attempt_id(merchant_id, initial_attempt_id, &key_store)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to list delivery attempts for initial event")?;
+
+ if events.is_empty() {
+ Err(error_stack::report!(
+ errors::ApiErrorResponse::EventNotFound
+ ))
+ .attach_printable("No delivery attempts found with the specified `initial_attempt_id`")
+ } else {
+ Ok(ApplicationResponse::Json(
+ events
+ .into_iter()
+ .map(api::webhook_events::EventRetrieveResponse::try_from)
+ .collect::<Result<Vec<_>, _>>()?,
+ ))
+ }
+}
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index 99c11b63bd..f3df727802 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -27,15 +27,65 @@ where
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError>;
- async fn find_event_by_event_id(
+ async fn find_event_by_merchant_id_event_id(
&self,
+ merchant_id: &str,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError>;
- async fn update_event(
+ async fn list_initial_events_by_merchant_id_primary_object_id(
&self,
- event_id: String,
+ merchant_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError>;
+
+ async fn list_initial_events_by_merchant_id_constraints(
+ &self,
+ merchant_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError>;
+
+ async fn list_events_by_merchant_id_initial_attempt_id(
+ &self,
+ merchant_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError>;
+
+ async fn list_initial_events_by_profile_id_primary_object_id(
+ &self,
+ profile_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError>;
+
+ async fn list_initial_events_by_profile_id_constraints(
+ &self,
+ profile_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError>;
+
+ async fn list_events_by_profile_id_initial_attempt_id(
+ &self,
+ profile_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError>;
+
+ async fn update_event_by_merchant_id_event_id(
+ &self,
+ merchant_id: &str,
+ event_id: &str,
event: domain::EventUpdate,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError>;
@@ -64,13 +114,14 @@ impl EventInterface for Store {
}
#[instrument(skip_all)]
- async fn find_event_by_event_id(
+ async fn find_event_by_merchant_id_event_id(
&self,
+ merchant_id: &str,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
let conn = connection::pg_connection_read(self).await?;
- storage::Event::find_by_event_id(&conn, event_id)
+ storage::Event::find_by_merchant_id_event_id(&conn, merchant_id, event_id)
.await
.map_err(Into::into)
.into_report()?
@@ -80,14 +131,209 @@ impl EventInterface for Store {
}
#[instrument(skip_all)]
- async fn update_event(
+ async fn list_initial_events_by_merchant_id_primary_object_id(
+ &self,
+ merchant_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let conn = connection::pg_connection_read(self).await?;
+ storage::Event::list_initial_attempts_by_merchant_id_primary_object_id(
+ &conn,
+ merchant_id,
+ primary_object_id,
+ )
+ .await
+ .map_err(Into::into)
+ .into_report()
+ .async_and_then(|events| async {
+ let mut domain_events = Vec::with_capacity(events.len());
+ for event in events.into_iter() {
+ domain_events.push(
+ event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?,
+ );
+ }
+ Ok(domain_events)
+ })
+ .await
+ }
+
+ #[instrument(skip_all)]
+ async fn list_initial_events_by_merchant_id_constraints(
+ &self,
+ merchant_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let conn = connection::pg_connection_read(self).await?;
+ storage::Event::list_initial_attempts_by_merchant_id_constraints(
+ &conn,
+ merchant_id,
+ created_after,
+ created_before,
+ limit,
+ offset,
+ )
+ .await
+ .map_err(Into::into)
+ .into_report()
+ .async_and_then(|events| async {
+ let mut domain_events = Vec::with_capacity(events.len());
+ for event in events.into_iter() {
+ domain_events.push(
+ event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?,
+ );
+ }
+ Ok(domain_events)
+ })
+ .await
+ }
+
+ #[instrument(skip_all)]
+ async fn list_events_by_merchant_id_initial_attempt_id(
+ &self,
+ merchant_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let conn = connection::pg_connection_read(self).await?;
+ storage::Event::list_by_merchant_id_initial_attempt_id(
+ &conn,
+ merchant_id,
+ initial_attempt_id,
+ )
+ .await
+ .map_err(Into::into)
+ .into_report()
+ .async_and_then(|events| async {
+ let mut domain_events = Vec::with_capacity(events.len());
+ for event in events.into_iter() {
+ domain_events.push(
+ event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?,
+ );
+ }
+ Ok(domain_events)
+ })
+ .await
+ }
+
+ #[instrument(skip_all)]
+ async fn list_initial_events_by_profile_id_primary_object_id(
+ &self,
+ profile_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let conn = connection::pg_connection_read(self).await?;
+ storage::Event::list_initial_attempts_by_profile_id_primary_object_id(
+ &conn,
+ profile_id,
+ primary_object_id,
+ )
+ .await
+ .map_err(Into::into)
+ .into_report()
+ .async_and_then(|events| async {
+ let mut domain_events = Vec::with_capacity(events.len());
+ for event in events.into_iter() {
+ domain_events.push(
+ event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?,
+ );
+ }
+ Ok(domain_events)
+ })
+ .await
+ }
+
+ #[instrument(skip_all)]
+ async fn list_initial_events_by_profile_id_constraints(
+ &self,
+ profile_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let conn = connection::pg_connection_read(self).await?;
+ storage::Event::list_initial_attempts_by_profile_id_constraints(
+ &conn,
+ profile_id,
+ created_after,
+ created_before,
+ limit,
+ offset,
+ )
+ .await
+ .map_err(Into::into)
+ .into_report()
+ .async_and_then(|events| async {
+ let mut domain_events = Vec::with_capacity(events.len());
+ for event in events.into_iter() {
+ domain_events.push(
+ event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?,
+ );
+ }
+ Ok(domain_events)
+ })
+ .await
+ }
+
+ #[instrument(skip_all)]
+ async fn list_events_by_profile_id_initial_attempt_id(
+ &self,
+ profile_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let conn = connection::pg_connection_read(self).await?;
+ storage::Event::list_by_profile_id_initial_attempt_id(&conn, profile_id, initial_attempt_id)
+ .await
+ .map_err(Into::into)
+ .into_report()
+ .async_and_then(|events| async {
+ let mut domain_events = Vec::with_capacity(events.len());
+ for event in events.into_iter() {
+ domain_events.push(
+ event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?,
+ );
+ }
+ Ok(domain_events)
+ })
+ .await
+ }
+
+ #[instrument(skip_all)]
+ async fn update_event_by_merchant_id_event_id(
&self,
- event_id: String,
+ merchant_id: &str,
+ event_id: &str,
event: domain::EventUpdate,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
- storage::Event::update(&conn, &event_id, event.into())
+ storage::Event::update_by_merchant_id_event_id(&conn, merchant_id, event_id, event.into())
.await
.map_err(Into::into)
.into_report()?
@@ -118,15 +364,18 @@ impl EventInterface for MockDb {
.change_context(errors::StorageError::DecryptionError)
}
- async fn find_event_by_event_id(
+ async fn find_event_by_merchant_id_event_id(
&self,
+ merchant_id: &str,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
let locked_events = self.events.lock().await;
locked_events
.iter()
- .find(|event| event.event_id == event_id)
+ .find(|event| {
+ event.merchant_id == Some(merchant_id.to_owned()) && event.event_id == event_id
+ })
.cloned()
.async_map(|event| async {
event
@@ -138,22 +387,271 @@ impl EventInterface for MockDb {
.transpose()?
.ok_or(
errors::StorageError::ValueNotFound(format!(
- "No event available with event_id = {event_id}"
+ "No event available with merchant_id = {merchant_id} and event_id = {event_id}"
))
.into(),
)
}
- async fn update_event(
+ async fn list_initial_events_by_merchant_id_primary_object_id(
+ &self,
+ merchant_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let locked_events = self.events.lock().await;
+ let events = locked_events
+ .iter()
+ .filter(|event| {
+ event.merchant_id == Some(merchant_id.to_owned())
+ && event.initial_attempt_id.as_ref() == Some(&event.event_id)
+ && event.primary_object_id == primary_object_id
+ })
+ .cloned()
+ .collect::<Vec<_>>();
+
+ let mut domain_events = Vec::with_capacity(events.len());
+
+ for event in events {
+ let domain_event = event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?;
+ domain_events.push(domain_event);
+ }
+
+ Ok(domain_events)
+ }
+
+ async fn list_initial_events_by_merchant_id_constraints(
+ &self,
+ merchant_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let locked_events = self.events.lock().await;
+ let events_iter = locked_events.iter().filter(|event| {
+ let mut check = event.merchant_id == Some(merchant_id.to_owned())
+ && event.initial_attempt_id.as_ref() == Some(&event.event_id);
+
+ if let Some(created_after) = created_after {
+ check = check && (event.created_at >= created_after);
+ }
+
+ if let Some(created_before) = created_before {
+ check = check && (event.created_at <= created_before);
+ }
+
+ check
+ });
+
+ let offset: usize = if let Some(offset) = offset {
+ if offset < 0 {
+ Err(errors::StorageError::MockDbError)?;
+ }
+ offset
+ .try_into()
+ .map_err(|_| errors::StorageError::MockDbError)?
+ } else {
+ 0
+ };
+
+ let limit: usize = if let Some(limit) = limit {
+ if limit < 0 {
+ Err(errors::StorageError::MockDbError)?;
+ }
+ limit
+ .try_into()
+ .map_err(|_| errors::StorageError::MockDbError)?
+ } else {
+ usize::MAX
+ };
+
+ let events = events_iter
+ .skip(offset)
+ .take(limit)
+ .cloned()
+ .collect::<Vec<_>>();
+ let mut domain_events = Vec::with_capacity(events.len());
+
+ for event in events {
+ let domain_event = event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?;
+ domain_events.push(domain_event);
+ }
+
+ Ok(domain_events)
+ }
+
+ async fn list_events_by_merchant_id_initial_attempt_id(
+ &self,
+ merchant_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let locked_events = self.events.lock().await;
+ let events = locked_events
+ .iter()
+ .filter(|event| {
+ event.merchant_id == Some(merchant_id.to_owned())
+ && event.initial_attempt_id == Some(initial_attempt_id.to_owned())
+ })
+ .cloned()
+ .collect::<Vec<_>>();
+ let mut domain_events = Vec::with_capacity(events.len());
+
+ for event in events {
+ let domain_event = event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?;
+ domain_events.push(domain_event);
+ }
+
+ Ok(domain_events)
+ }
+
+ async fn list_initial_events_by_profile_id_primary_object_id(
+ &self,
+ profile_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let locked_events = self.events.lock().await;
+ let events = locked_events
+ .iter()
+ .filter(|event| {
+ event.business_profile_id == Some(profile_id.to_owned())
+ && event.initial_attempt_id.as_ref() == Some(&event.event_id)
+ && event.primary_object_id == primary_object_id
+ })
+ .cloned()
+ .collect::<Vec<_>>();
+
+ let mut domain_events = Vec::with_capacity(events.len());
+
+ for event in events {
+ let domain_event = event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?;
+ domain_events.push(domain_event);
+ }
+
+ Ok(domain_events)
+ }
+
+ async fn list_initial_events_by_profile_id_constraints(
+ &self,
+ profile_id: &str,
+ created_after: Option<time::PrimitiveDateTime>,
+ created_before: Option<time::PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let locked_events = self.events.lock().await;
+ let events_iter = locked_events.iter().filter(|event| {
+ let mut check = event.business_profile_id == Some(profile_id.to_owned())
+ && event.initial_attempt_id.as_ref() == Some(&event.event_id);
+
+ if let Some(created_after) = created_after {
+ check = check && (event.created_at >= created_after);
+ }
+
+ if let Some(created_before) = created_before {
+ check = check && (event.created_at <= created_before);
+ }
+
+ check
+ });
+
+ let offset: usize = if let Some(offset) = offset {
+ if offset < 0 {
+ Err(errors::StorageError::MockDbError)?;
+ }
+ offset
+ .try_into()
+ .map_err(|_| errors::StorageError::MockDbError)?
+ } else {
+ 0
+ };
+
+ let limit: usize = if let Some(limit) = limit {
+ if limit < 0 {
+ Err(errors::StorageError::MockDbError)?;
+ }
+ limit
+ .try_into()
+ .map_err(|_| errors::StorageError::MockDbError)?
+ } else {
+ usize::MAX
+ };
+
+ let events = events_iter
+ .skip(offset)
+ .take(limit)
+ .cloned()
+ .collect::<Vec<_>>();
+ let mut domain_events = Vec::with_capacity(events.len());
+
+ for event in events {
+ let domain_event = event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?;
+ domain_events.push(domain_event);
+ }
+
+ Ok(domain_events)
+ }
+
+ async fn list_events_by_profile_id_initial_attempt_id(
&self,
- event_id: String,
+ profile_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ let locked_events = self.events.lock().await;
+ let events = locked_events
+ .iter()
+ .filter(|event| {
+ event.business_profile_id == Some(profile_id.to_owned())
+ && event.initial_attempt_id == Some(initial_attempt_id.to_owned())
+ })
+ .cloned()
+ .collect::<Vec<_>>();
+ let mut domain_events = Vec::with_capacity(events.len());
+
+ for event in events {
+ let domain_event = event
+ .convert(merchant_key_store.key.get_inner())
+ .await
+ .change_context(errors::StorageError::DecryptionError)?;
+ domain_events.push(domain_event);
+ }
+
+ Ok(domain_events)
+ }
+
+ async fn update_event_by_merchant_id_event_id(
+ &self,
+ merchant_id: &str,
+ event_id: &str,
event: domain::EventUpdate,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
let mut locked_events = self.events.lock().await;
let event_to_update = locked_events
.iter_mut()
- .find(|e| e.event_id == event_id)
+ .find(|event| {
+ event.merchant_id == Some(merchant_id.to_owned()) && event.event_id == event_id
+ })
.ok_or(errors::StorageError::MockDbError)?;
match event {
@@ -238,6 +736,7 @@ mod tests {
initial_attempt_id: Some(event_id.into()),
request: None,
response: None,
+ delivery_attempt: Some(enums::WebhookDeliveryAttempt::InitialAttempt),
},
&merchant_key_store,
)
@@ -247,8 +746,9 @@ mod tests {
assert_eq!(event1.event_id, event_id);
let updated_event = mockdb
- .update_event(
- event_id.into(),
+ .update_event_by_merchant_id_event_id(
+ merchant_id,
+ event_id,
domain::EventUpdate::UpdateResponse {
is_webhook_notified: true,
response: None,
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index a65a6ca462..dc8b9b791d 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -493,24 +493,128 @@ impl EventInterface for KafkaStore {
.await
}
- async fn find_event_by_event_id(
+ async fn find_event_by_merchant_id_event_id(
&self,
+ merchant_id: &str,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
self.diesel_store
- .find_event_by_event_id(event_id, merchant_key_store)
+ .find_event_by_merchant_id_event_id(merchant_id, event_id, merchant_key_store)
.await
}
- async fn update_event(
+ async fn list_initial_events_by_merchant_id_primary_object_id(
&self,
- event_id: String,
+ merchant_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ self.diesel_store
+ .list_initial_events_by_merchant_id_primary_object_id(
+ merchant_id,
+ primary_object_id,
+ merchant_key_store,
+ )
+ .await
+ }
+
+ async fn list_initial_events_by_merchant_id_constraints(
+ &self,
+ merchant_id: &str,
+ created_after: Option<PrimitiveDateTime>,
+ created_before: Option<PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ self.diesel_store
+ .list_initial_events_by_merchant_id_constraints(
+ merchant_id,
+ created_after,
+ created_before,
+ limit,
+ offset,
+ merchant_key_store,
+ )
+ .await
+ }
+
+ async fn list_events_by_merchant_id_initial_attempt_id(
+ &self,
+ merchant_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ self.diesel_store
+ .list_events_by_merchant_id_initial_attempt_id(
+ merchant_id,
+ initial_attempt_id,
+ merchant_key_store,
+ )
+ .await
+ }
+
+ async fn list_initial_events_by_profile_id_primary_object_id(
+ &self,
+ profile_id: &str,
+ primary_object_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ self.diesel_store
+ .list_initial_events_by_profile_id_primary_object_id(
+ profile_id,
+ primary_object_id,
+ merchant_key_store,
+ )
+ .await
+ }
+
+ async fn list_initial_events_by_profile_id_constraints(
+ &self,
+ profile_id: &str,
+ created_after: Option<PrimitiveDateTime>,
+ created_before: Option<PrimitiveDateTime>,
+ limit: Option<i64>,
+ offset: Option<i64>,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ self.diesel_store
+ .list_initial_events_by_profile_id_constraints(
+ profile_id,
+ created_after,
+ created_before,
+ limit,
+ offset,
+ merchant_key_store,
+ )
+ .await
+ }
+
+ async fn list_events_by_profile_id_initial_attempt_id(
+ &self,
+ profile_id: &str,
+ initial_attempt_id: &str,
+ merchant_key_store: &domain::MerchantKeyStore,
+ ) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
+ self.diesel_store
+ .list_events_by_profile_id_initial_attempt_id(
+ profile_id,
+ initial_attempt_id,
+ merchant_key_store,
+ )
+ .await
+ }
+
+ async fn update_event_by_merchant_id_event_id(
+ &self,
+ merchant_id: &str,
+ event_id: &str,
event: domain::EventUpdate,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
self.diesel_store
- .update_event(event_id, event, merchant_key_store)
+ .update_event_by_merchant_id_event_id(merchant_id, event_id, event, merchant_key_store)
.await
}
}
diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs
index 97d981c68e..cc4adca77c 100644
--- a/crates/router/src/lib.rs
+++ b/crates/router/src/lib.rs
@@ -140,11 +140,8 @@ pub fn mk_app(
.service(routes::PaymentLink::server(state.clone()))
.service(routes::User::server(state.clone()))
.service(routes::ConnectorOnboarding::server(state.clone()))
- }
-
- #[cfg(feature = "olap")]
- {
- server_app = server_app.service(routes::Verify::server(state.clone()));
+ .service(routes::Verify::server(state.clone()))
+ .service(routes::WebhookEvents::server(state.clone()));
}
#[cfg(feature = "payouts")]
diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs
index 0d7c903b06..bf335a5e71 100644
--- a/crates/router/src/routes.rs
+++ b/crates/router/src/routes.rs
@@ -21,6 +21,7 @@ pub mod fraud_check;
pub mod gsm;
pub mod health;
pub mod lock_utils;
+pub mod locker_migration;
pub mod mandates;
pub mod metrics;
pub mod payment_link;
@@ -28,6 +29,8 @@ pub mod payment_methods;
pub mod payments;
#[cfg(feature = "payouts")]
pub mod payouts;
+#[cfg(any(feature = "olap", feature = "oltp"))]
+pub mod pm_auth;
#[cfg(feature = "recon")]
pub mod recon;
pub mod refunds;
@@ -41,13 +44,9 @@ pub mod user_role;
pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
-pub mod webhooks;
-
-pub mod locker_migration;
-#[cfg(any(feature = "olap", feature = "oltp"))]
-pub mod pm_auth;
#[cfg(feature = "olap")]
-pub use app::{Blocklist, Routing};
+pub mod webhook_events;
+pub mod webhooks;
#[cfg(feature = "dummy_connector")]
pub use self::app::DummyConnector;
@@ -57,13 +56,13 @@ pub use self::app::Forex;
pub use self::app::Payouts;
#[cfg(all(feature = "olap", feature = "recon"))]
pub use self::app::Recon;
-#[cfg(feature = "olap")]
-pub use self::app::Verify;
pub use self::app::{
ApiKeys, AppState, BusinessProfile, Cache, Cards, Configs, ConnectorOnboarding, Customers,
Disputes, EphemeralKey, Files, Gsm, Health, Mandates, MerchantAccount,
MerchantConnectorAccount, PaymentLink, PaymentMethods, Payments, Refunds, User, Webhooks,
};
+#[cfg(feature = "olap")]
+pub use self::app::{Blocklist, Routing, Verify, WebhookEvents};
#[cfg(feature = "stripe")]
pub use super::compatibility::stripe::StripeApis;
#[cfg(feature = "olap")]
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 7d6b6c8ad2..7c513881ed 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -34,7 +34,7 @@ use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_ve
#[cfg(feature = "olap")]
use super::{
admin::*, api_keys::*, connector_onboarding::*, disputes::*, files::*, gsm::*, payment_link::*,
- user::*, user_role::*,
+ user::*, user_role::*, webhook_events::*,
};
use super::{cache::*, health::*};
#[cfg(any(feature = "olap", feature = "oltp"))]
@@ -1217,3 +1217,19 @@ impl ConnectorOnboarding {
.service(web::resource("/reset_tracking_id").route(web::post().to(reset_tracking_id)))
}
}
+
+#[cfg(feature = "olap")]
+pub struct WebhookEvents;
+
+#[cfg(feature = "olap")]
+impl WebhookEvents {
+ pub fn server(config: AppState) -> Scope {
+ web::scope("/events/{merchant_id}")
+ .app_data(web::Data::new(config))
+ .service(web::resource("").route(web::get().to(list_initial_webhook_delivery_attempts)))
+ .service(
+ web::resource("/{event_id}/attempts")
+ .route(web::get().to(list_webhook_delivery_attempts)),
+ )
+ }
+}
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index 43802d2445..4826a72f9d 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -133,7 +133,10 @@ impl From<Flow> for ApiIdentifier {
| Flow::RefundsUpdate
| Flow::RefundsList => Self::Refunds,
- Flow::FrmFulfillment | Flow::IncomingWebhookReceive => Self::Webhooks,
+ Flow::FrmFulfillment
+ | Flow::IncomingWebhookReceive
+ | Flow::WebhookEventInitialDeliveryAttemptList
+ | Flow::WebhookEventDeliveryAttemptList => Self::Webhooks,
Flow::ApiKeyCreate
| Flow::ApiKeyRetrieve
diff --git a/crates/router/src/routes/webhook_events.rs b/crates/router/src/routes/webhook_events.rs
new file mode 100644
index 0000000000..de4892a1f9
--- /dev/null
+++ b/crates/router/src/routes/webhook_events.rs
@@ -0,0 +1,80 @@
+use actix_web::{web, HttpRequest, Responder};
+use router_env::{instrument, tracing, Flow};
+
+use crate::{
+ core::{api_locking, webhooks::webhook_events},
+ routes::AppState,
+ services::{api, authentication as auth, authorization::permissions::Permission},
+ types::api::webhook_events::{EventListConstraints, EventListRequestInternal},
+};
+
+#[instrument(skip_all, fields(flow = ?Flow::WebhookEventInitialDeliveryAttemptList))]
+pub async fn list_initial_webhook_delivery_attempts(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+ path: web::Path<String>,
+ query: web::Query<EventListConstraints>,
+) -> impl Responder {
+ let flow = Flow::WebhookEventInitialDeliveryAttemptList;
+ let merchant_id = path.into_inner();
+ let constraints = query.into_inner();
+
+ let request_internal = EventListRequestInternal {
+ merchant_id: merchant_id.clone(),
+ constraints,
+ };
+
+ api::server_wrap(
+ flow,
+ state,
+ &req,
+ request_internal,
+ |state, _, request_internal| {
+ webhook_events::list_initial_delivery_attempts(
+ state,
+ request_internal.merchant_id,
+ request_internal.constraints,
+ )
+ },
+ auth::auth_type(
+ &auth::AdminApiAuth,
+ &auth::JWTAuthMerchantFromRoute {
+ merchant_id,
+ required_permission: Permission::WebhookEventRead,
+ },
+ req.headers(),
+ ),
+ api_locking::LockAction::NotApplicable,
+ )
+ .await
+}
+
+#[instrument(skip_all, fields(flow = ?Flow::WebhookEventDeliveryAttemptList))]
+pub async fn list_webhook_delivery_attempts(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+ path: web::Path<(String, String)>,
+) -> impl Responder {
+ let flow = Flow::WebhookEventDeliveryAttemptList;
+ let (merchant_id, initial_event_id) = path.into_inner();
+
+ api::server_wrap(
+ flow,
+ state,
+ &req,
+ (&merchant_id, &initial_event_id),
+ |state, _, (merchant_id, initial_event_id)| {
+ webhook_events::list_delivery_attempts(state, merchant_id, initial_event_id)
+ },
+ auth::auth_type(
+ &auth::AdminApiAuth,
+ &auth::JWTAuthMerchantFromRoute {
+ merchant_id: merchant_id.clone(),
+ required_permission: Permission::WebhookEventRead,
+ },
+ req.headers(),
+ ),
+ api_locking::LockAction::NotApplicable,
+ )
+ .await
+}
diff --git a/crates/router/src/services/authorization/permission_groups.rs b/crates/router/src/services/authorization/permission_groups.rs
index 246a4ce91d..33647eb9a3 100644
--- a/crates/router/src/services/authorization/permission_groups.rs
+++ b/crates/router/src/services/authorization/permission_groups.rs
@@ -73,11 +73,12 @@ pub static USERS_MANAGE: [Permission; 2] =
pub static MERCHANT_DETAILS_VIEW: [Permission; 1] = [Permission::MerchantAccountRead];
-pub static MERCHANT_DETAILS_MANAGE: [Permission; 4] = [
+pub static MERCHANT_DETAILS_MANAGE: [Permission; 5] = [
Permission::MerchantAccountWrite,
Permission::ApiKeyRead,
Permission::ApiKeyWrite,
Permission::MerchantAccountRead,
+ Permission::WebhookEventRead,
];
pub static ORGANIZATION_MANAGE: [Permission; 2] = [
diff --git a/crates/router/src/services/authorization/permissions.rs b/crates/router/src/services/authorization/permissions.rs
index edf9a40915..b5ba72df05 100644
--- a/crates/router/src/services/authorization/permissions.rs
+++ b/crates/router/src/services/authorization/permissions.rs
@@ -30,6 +30,7 @@ pub enum Permission {
UsersRead,
UsersWrite,
MerchantAccountCreate,
+ WebhookEventRead,
}
impl Permission {
@@ -39,7 +40,7 @@ impl Permission {
Self::PaymentWrite => "Create payment, download payments data",
Self::RefundRead => "View all refunds",
Self::RefundWrite => "Create refund, download refunds data",
- Self::ApiKeyRead => "View API keys (masked generated for the system",
+ Self::ApiKeyRead => "View API keys",
Self::ApiKeyWrite => "Create and update API keys",
Self::MerchantAccountRead => "View merchant account details",
Self::MerchantAccountWrite => {
@@ -67,6 +68,7 @@ impl Permission {
Self::UsersRead => "View all the users for a merchant",
Self::UsersWrite => "Invite users, assign and update roles",
Self::MerchantAccountCreate => "Create merchant account",
+ Self::WebhookEventRead => "View webhook events",
}
}
}
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 5f8c9a96f1..cd9eee46ee 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -21,6 +21,8 @@ pub mod refunds;
pub mod routing;
#[cfg(feature = "olap")]
pub mod verify_connector;
+#[cfg(feature = "olap")]
+pub mod webhook_events;
pub mod webhooks;
use std::{fmt::Debug, str::FromStr};
diff --git a/crates/router/src/types/api/webhook_events.rs b/crates/router/src/types/api/webhook_events.rs
new file mode 100644
index 0000000000..44f9bc7c80
--- /dev/null
+++ b/crates/router/src/types/api/webhook_events.rs
@@ -0,0 +1,5 @@
+pub use api_models::webhook_events::{
+ EventListConstraints, EventListConstraintsInternal, EventListItemResponse,
+ EventListRequestInternal, EventRetrieveResponse, OutgoingWebhookRequestContent,
+ OutgoingWebhookResponseContent,
+};
diff --git a/crates/router/src/types/domain/event.rs b/crates/router/src/types/domain/event.rs
index 4d86a908e6..1c39be5a3d 100644
--- a/crates/router/src/types/domain/event.rs
+++ b/crates/router/src/types/domain/event.rs
@@ -1,6 +1,6 @@
use common_utils::crypto::OptionalEncryptableSecretString;
use diesel_models::{
- enums::{EventClass, EventObjectType, EventType},
+ enums::{EventClass, EventObjectType, EventType, WebhookDeliveryAttempt},
events::EventUpdateInternal,
};
use error_stack::ResultExt;
@@ -27,6 +27,7 @@ pub struct Event {
pub initial_attempt_id: Option<String>,
pub request: OptionalEncryptableSecretString,
pub response: OptionalEncryptableSecretString,
+ pub delivery_attempt: Option<WebhookDeliveryAttempt>,
}
#[derive(Debug)]
@@ -72,6 +73,7 @@ impl super::behaviour::Conversion for Event {
initial_attempt_id: self.initial_attempt_id,
request: self.request.map(Into::into),
response: self.response.map(Into::into),
+ delivery_attempt: self.delivery_attempt,
})
}
@@ -104,6 +106,7 @@ impl super::behaviour::Conversion for Event {
.response
.async_lift(|inner| types::decrypt(inner, key.peek()))
.await?,
+ delivery_attempt: item.delivery_attempt,
})
}
.await
@@ -128,6 +131,7 @@ impl super::behaviour::Conversion for Event {
initial_attempt_id: self.initial_attempt_id,
request: self.request.map(Into::into),
response: self.response.map(Into::into),
+ delivery_attempt: self.delivery_attempt,
})
}
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 2062867ca9..29774be91a 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -1132,3 +1132,114 @@ impl ForeignFrom<storage::GatewayStatusMap> for gsm_api_types::GsmResponse {
}
}
}
+
+#[cfg(feature = "olap")]
+impl ForeignTryFrom<api_types::webhook_events::EventListConstraints>
+ for api_types::webhook_events::EventListConstraintsInternal
+{
+ type Error = error_stack::Report<errors::ApiErrorResponse>;
+
+ fn foreign_try_from(
+ item: api_types::webhook_events::EventListConstraints,
+ ) -> Result<Self, Self::Error> {
+ if item.object_id.is_some()
+ && (item.created_after.is_some()
+ || item.created_before.is_some()
+ || item.limit.is_some()
+ || item.offset.is_some())
+ {
+ return Err(report!(errors::ApiErrorResponse::PreconditionFailed {
+ message:
+ "Either only `object_id` must be specified, or one or more of \
+ `created_after`, `created_before`, `limit` and `offset` must be specified"
+ .to_string()
+ }));
+ }
+
+ match item.object_id {
+ Some(object_id) => Ok(Self::ObjectIdFilter { object_id }),
+ None => Ok(Self::GenericFilter {
+ created_after: item.created_after,
+ created_before: item.created_before,
+ limit: item.limit.map(i64::from),
+ offset: item.offset.map(i64::from),
+ }),
+ }
+ }
+}
+
+#[cfg(feature = "olap")]
+impl TryFrom<domain::Event> for api_models::webhook_events::EventListItemResponse {
+ type Error = error_stack::Report<errors::ApiErrorResponse>;
+
+ fn try_from(item: domain::Event) -> Result<Self, Self::Error> {
+ use crate::utils::OptionExt;
+
+ // We only allow retrieving events with merchant_id, business_profile_id
+ // and initial_attempt_id populated.
+ // We cannot retrieve events with only some of these fields populated.
+ let merchant_id = item
+ .merchant_id
+ .get_required_value("merchant_id")
+ .change_context(errors::ApiErrorResponse::InternalServerError)?;
+ let profile_id = item
+ .business_profile_id
+ .get_required_value("business_profile_id")
+ .change_context(errors::ApiErrorResponse::InternalServerError)?;
+ let initial_attempt_id = item
+ .initial_attempt_id
+ .get_required_value("initial_attempt_id")
+ .change_context(errors::ApiErrorResponse::InternalServerError)?;
+
+ Ok(Self {
+ event_id: item.event_id,
+ merchant_id,
+ profile_id,
+ object_id: item.primary_object_id,
+ event_type: item.event_type,
+ event_class: item.event_class,
+ is_delivery_successful: item.is_webhook_notified,
+ initial_attempt_id,
+ created: item.created_at,
+ })
+ }
+}
+
+#[cfg(feature = "olap")]
+impl TryFrom<domain::Event> for api_models::webhook_events::EventRetrieveResponse {
+ type Error = error_stack::Report<errors::ApiErrorResponse>;
+
+ fn try_from(item: domain::Event) -> Result<Self, Self::Error> {
+ use crate::utils::OptionExt;
+
+ // We only allow retrieving events with all required fields in `EventListItemResponse`, and
+ // `request` and `response` populated.
+ // We cannot retrieve events with only some of these fields populated.
+ let event_information =
+ api_models::webhook_events::EventListItemResponse::try_from(item.clone())?;
+
+ let request = item
+ .request
+ .get_required_value("request")
+ .change_context(errors::ApiErrorResponse::InternalServerError)?
+ .peek()
+ .parse_struct("OutgoingWebhookRequestContent")
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to parse webhook event request information")?;
+ let response = item
+ .response
+ .get_required_value("response")
+ .change_context(errors::ApiErrorResponse::InternalServerError)?
+ .peek()
+ .parse_struct("OutgoingWebhookResponseContent")
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to parse webhook event response information")?;
+
+ Ok(Self {
+ event_information,
+ request,
+ response,
+ delivery_attempt: item.delivery_attempt,
+ })
+ }
+}
diff --git a/crates/router/src/utils/ext_traits.rs b/crates/router/src/utils/ext_traits.rs
index a04eec290c..ed18a9abdf 100644
--- a/crates/router/src/utils/ext_traits.rs
+++ b/crates/router/src/utils/ext_traits.rs
@@ -85,27 +85,6 @@ where
}
}
-#[allow(dead_code)]
-/// Merge two `serde_json::Value` instances. Will need to be updated to handle merging arrays.
-pub(crate) fn merge_json_values(a: &mut serde_json::Value, b: &serde_json::Value) {
- // Reference: https://github.com/serde-rs/json/issues/377#issuecomment-341490464
- // See also (for better implementations):
- // - https://github.com/marirs/serde-json-utils
- // - https://github.com/jmfiaschi/json_value_merge
- use serde_json::Value;
-
- match (a, b) {
- (&mut Value::Object(ref mut a), Value::Object(b)) => {
- for (k, v) in b {
- merge_json_values(a.entry(k.clone()).or_insert(Value::Null), v);
- }
- }
- (a, b) => {
- *a = b.clone();
- }
- }
-}
-
pub trait ValidateCall<T, F> {
fn validate_opt(self, func: F) -> CustomResult<(), errors::ValidationError>;
}
@@ -121,12 +100,3 @@ where
}
}
}
-
-// pub fn validate_address(address: &serde_json::Value) -> CustomResult<(), errors::ValidationError> {
-// if let Err(err) = serde_json::from_value::<AddressDetails>(address.clone()) {
-// return Err(report!(errors::ValidationError::InvalidValue {
-// message: format!("Invalid address: {err}")
-// }));
-// }
-// Ok(())
-// }
diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rs
index 8c2c293da9..fa9eba8c27 100644
--- a/crates/router/src/utils/user_role.rs
+++ b/crates/router/src/utils/user_role.rs
@@ -43,6 +43,7 @@ impl From<Permission> for user_role_api::Permission {
Permission::UsersRead => Self::UsersRead,
Permission::UsersWrite => Self::UsersWrite,
Permission::MerchantAccountCreate => Self::MerchantAccountCreate,
+ Permission::WebhookEventRead => Self::WebhookEventRead,
}
}
}
diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rs
index 7066c2ad19..0a9a103a05 100644
--- a/crates/router/src/workflows/outgoing_webhook_retry.rs
+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs
@@ -1,5 +1,6 @@
use api_models::{
enums::EventType,
+ webhook_events::OutgoingWebhookRequestContent,
webhooks::{OutgoingWebhook, OutgoingWebhookContent},
};
use common_utils::ext_traits::{StringExt, ValueExt};
@@ -13,10 +14,7 @@ use scheduler::{
};
use crate::{
- core::webhooks::{
- self as webhooks_core,
- types::{OutgoingWebhookRequestContent, OutgoingWebhookTrackingData},
- },
+ core::webhooks::{self as webhooks_core, types::OutgoingWebhookTrackingData},
db::StorageInterface,
errors, logger,
routes::AppState,
@@ -33,7 +31,7 @@ impl ProcessTrackerWorkflow<AppState> for OutgoingWebhookRetryWorkflow {
state: &'a AppState,
process: storage::ProcessTracker,
) -> Result<(), errors::ProcessTrackerError> {
- let delivery_attempt = webhooks_core::types::WebhookDeliveryAttempt::AutomaticRetry;
+ let delivery_attempt = storage::enums::WebhookDeliveryAttempt::AutomaticRetry;
let tracking_data: OutgoingWebhookTrackingData = process
.tracking_data
.clone()
@@ -59,8 +57,12 @@ impl ProcessTrackerWorkflow<AppState> for OutgoingWebhookRetryWorkflow {
let initial_event = match &tracking_data.initial_attempt_id {
Some(initial_attempt_id) => {
- db.find_event_by_event_id(initial_attempt_id, &key_store)
- .await?
+ db.find_event_by_merchant_id_event_id(
+ &business_profile.merchant_id,
+ initial_attempt_id,
+ &key_store,
+ )
+ .await?
}
// Tracking data inserted by old version of application, fetch event using old event ID
// format
@@ -69,7 +71,12 @@ impl ProcessTrackerWorkflow<AppState> for OutgoingWebhookRetryWorkflow {
"{}_{}",
tracking_data.primary_object_id, tracking_data.event_type
);
- db.find_event_by_event_id(&old_event_id, &key_store).await?
+ db.find_event_by_merchant_id_event_id(
+ &business_profile.merchant_id,
+ &old_event_id,
+ &key_store,
+ )
+ .await?
}
};
@@ -89,6 +96,7 @@ impl ProcessTrackerWorkflow<AppState> for OutgoingWebhookRetryWorkflow {
initial_attempt_id: Some(initial_event.event_id.clone()),
request: initial_event.request,
response: None,
+ delivery_attempt: Some(delivery_attempt),
};
let event = db
@@ -112,7 +120,7 @@ impl ProcessTrackerWorkflow<AppState> for OutgoingWebhookRetryWorkflow {
&key_store,
event,
request_content,
- webhooks_core::types::WebhookDeliveryAttempt::AutomaticRetry,
+ storage::enums::WebhookDeliveryAttempt::AutomaticRetry,
None,
Some(process),
)
@@ -164,7 +172,7 @@ impl ProcessTrackerWorkflow<AppState> for OutgoingWebhookRetryWorkflow {
&key_store,
event,
request_content,
- webhooks_core::types::WebhookDeliveryAttempt::AutomaticRetry,
+ storage::enums::WebhookDeliveryAttempt::AutomaticRetry,
Some(content),
Some(process),
)
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index b521acbdcd..363a41ad43 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -390,6 +390,10 @@ pub enum Flow {
CreateRole,
/// Update Role
UpdateRole,
+ /// List initial webhook delivery attempts
+ WebhookEventInitialDeliveryAttemptList,
+ /// List delivery attempts for a webhook event
+ WebhookEventDeliveryAttemptList,
}
///
diff --git a/migrations/2024-03-16-170320_add_events_indexes/down.sql b/migrations/2024-03-16-170320_add_events_indexes/down.sql
new file mode 100644
index 0000000000..1f46c70bff
--- /dev/null
+++ b/migrations/2024-03-16-170320_add_events_indexes/down.sql
@@ -0,0 +1,13 @@
+DROP INDEX events_merchant_id_event_id_index;
+
+DROP INDEX events_merchant_id_initial_attempt_id_index;
+
+DROP INDEX events_merchant_id_initial_events_index;
+
+DROP INDEX events_business_profile_id_initial_attempt_id_index;
+
+DROP INDEX events_business_profile_id_initial_events_index;
+
+ALTER TABLE events DROP COLUMN delivery_attempt;
+
+DROP TYPE "WebhookDeliveryAttempt";
diff --git a/migrations/2024-03-16-170320_add_events_indexes/up.sql b/migrations/2024-03-16-170320_add_events_indexes/up.sql
new file mode 100644
index 0000000000..e42efabeaa
--- /dev/null
+++ b/migrations/2024-03-16-170320_add_events_indexes/up.sql
@@ -0,0 +1,21 @@
+CREATE UNIQUE INDEX events_merchant_id_event_id_index ON events (merchant_id, event_id);
+
+CREATE INDEX events_merchant_id_initial_attempt_id_index ON events (merchant_id, initial_attempt_id);
+
+CREATE INDEX events_merchant_id_initial_events_index ON events (merchant_id, (event_id = initial_attempt_id));
+
+CREATE INDEX events_business_profile_id_initial_attempt_id_index ON events (business_profile_id, initial_attempt_id);
+
+CREATE INDEX events_business_profile_id_initial_events_index ON events (
+ business_profile_id,
+ (event_id = initial_attempt_id)
+);
+
+CREATE TYPE "WebhookDeliveryAttempt" AS ENUM (
+ 'initial_attempt',
+ 'automatic_retry',
+ 'manual_retry'
+);
+
+ALTER TABLE events
+ADD COLUMN delivery_attempt "WebhookDeliveryAttempt" DEFAULT NULL;
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 10bf5b3543..28b8f9ef79 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -20,167 +20,286 @@
}
],
"paths": {
- "/account/payment_methods": {
- "get": {
+ "/payments": {
+ "post": {
"tags": [
- "Payment Methods"
+ "Payments"
],
- "summary": "List payment methods for a Merchant",
- "description": "List payment methods for a Merchant\n\nLists the applicable payment methods for a particular Merchant ID.\nUse the client secret and publishable key authorization to list all relevant payment methods of the merchant for the payment corresponding to the client secret.",
- "operationId": "List all Payment Methods for a Merchant",
- "parameters": [
- {
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "accepted_country",
- "in": "query",
- "description": "The two-letter ISO currency code",
- "required": true,
- "schema": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- {
- "name": "accepted_currency",
- "in": "path",
- "description": "The three-letter ISO currency code",
- "required": true,
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Currency"
+ "summary": "Payments - Create",
+ "description": "Payments - Create\n\n**Creates a payment object when amount and currency are passed.** This API is also used to create a mandate by passing the `mandate_object`.\n\nTo completely process a payment you will have to create a payment, attach a payment method, confirm and capture funds.\n\nDepending on the user journey you wish to achieve, you may opt to complete all the steps in a single request by attaching a payment method, setting `confirm=true` and `capture_method = automatic` in the *Payments/Create API* request or you could use the following sequence of API requests to achieve the same:\n\n1. Payments - Create\n\n2. Payments - Update\n\n3. Payments - Confirm\n\n4. Payments - Capture.\n\nUse the client secret returned in this API along with your publishable key to make subsequent API calls from your client",
+ "operationId": "Create a Payment",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentsCreateRequest"
+ },
+ "examples": {
+ "Create a 3DS payment": {
+ "value": {
+ "amount": 6540,
+ "authentication_type": "three_ds",
+ "currency": "USD"
+ }
+ },
+ "Create a manual capture payment": {
+ "value": {
+ "amount": 6540,
+ "billing": {
+ "address": {
+ "city": "San Fransico",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "Doe",
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "state": "California",
+ "zip": "94122"
+ },
+ "phone": {
+ "country_code": "+91",
+ "number": "8056594427"
+ }
+ },
+ "currency": "USD",
+ "customer": {
+ "id": "cus_abcdefgh"
+ }
+ }
+ },
+ "Create a payment and save the card": {
+ "value": {
+ "amount": 6540,
+ "authentication_type": "no_three_ds",
+ "confirm": true,
+ "currency": "USD",
+ "customer_id": "StripeCustomer123",
+ "payment_method": "card",
+ "payment_method_data": {
+ "card": {
+ "card_cvc": "123",
+ "card_exp_month": "10",
+ "card_exp_year": "25",
+ "card_holder_name": "joseph Doe",
+ "card_number": "4242424242424242"
+ }
+ },
+ "setup_future_usage": "off_session"
+ }
+ },
+ "Create a payment using an already saved card's token": {
+ "value": {
+ "amount": 6540,
+ "card_cvc": "123",
+ "client_secret": "{{client_secret}}",
+ "confirm": true,
+ "currency": "USD",
+ "payment_method": "card",
+ "payment_token": "{{payment_token}}"
+ }
+ },
+ "Create a payment with customer details and metadata": {
+ "value": {
+ "amount": 6540,
+ "currency": "USD",
+ "customer": {
+ "email": "[email protected]",
+ "id": "cus_abcdefgh",
+ "name": "John Dough",
+ "phone": "9999999999"
+ },
+ "description": "Its my first payment request",
+ "metadata": {
+ "udf1": "some-value",
+ "udf2": "some-value"
+ },
+ "payment_id": "abcdefghijklmnopqrstuvwxyz",
+ "statement_descriptor_name": "joseph",
+ "statement_descriptor_suffix": "JS"
+ }
+ },
+ "Create a payment with minimal fields": {
+ "value": {
+ "amount": 6540,
+ "currency": "USD"
+ }
+ },
+ "Create a recurring payment with mandate_id": {
+ "value": {
+ "amount": 6540,
+ "authentication_type": "no_three_ds",
+ "confirm": true,
+ "currency": "USD",
+ "customer_id": "StripeCustomer",
+ "mandate_id": "{{mandate_id}}",
+ "off_session": true
+ }
+ },
+ "Create a setup mandate payment": {
+ "value": {
+ "amount": 6540,
+ "authentication_type": "no_three_ds",
+ "confirm": true,
+ "currency": "USD",
+ "customer_acceptance": {
+ "acceptance_type": "offline",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ },
+ "customer_id": "StripeCustomer123",
+ "mandate_data": {
+ "customer_acceptance": {
+ "acceptance_type": "offline",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ },
+ "mandate_type": {
+ "single_use": {
+ "amount": 6540,
+ "currency": "USD"
+ }
+ }
+ },
+ "payment_method": "card",
+ "payment_method_data": {
+ "card": {
+ "card_cvc": "123",
+ "card_exp_month": "10",
+ "card_exp_year": "25",
+ "card_holder_name": "joseph Doe",
+ "card_number": "4242424242424242"
+ }
+ },
+ "setup_future_usage": "off_session"
+ }
+ }
}
}
},
- {
- "name": "minimum_amount",
- "in": "query",
- "description": "The minimum amount accepted for processing by the particular payment method.",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "maximum_amount",
- "in": "query",
- "description": "The maximum amount accepted for processing by the particular payment method.",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "recurring_payment_enabled",
- "in": "query",
- "description": "Indicates whether the payment method is eligible for recurring payments",
- "required": true,
- "schema": {
- "type": "boolean"
- }
- },
- {
- "name": "installment_payment_enabled",
- "in": "query",
- "description": "Indicates whether the payment method is eligible for installment payments",
- "required": true,
- "schema": {
- "type": "boolean"
- }
- }
- ],
+ "required": true
+ },
"responses": {
"200": {
- "description": "Payment Methods retrieved",
+ "description": "Payment created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentMethodListResponse"
+ "$ref": "#/components/schemas/PaymentsResponse"
}
}
}
},
"400": {
- "description": "Invalid Data"
- },
- "404": {
- "description": "Payment Methods does not exist in records"
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
"api_key": []
- },
- {
- "publishable_key": []
}
]
}
},
- "/account/{account_id}/business_profile": {
- "get": {
+ "/payments/{payment_id}": {
+ "post": {
"tags": [
- "Business Profile"
+ "Payments"
],
- "summary": "Business Profile - List",
- "description": "Business Profile - List\n\nLists all the *business profiles* under a merchant",
- "operationId": "List Business Profiles",
+ "summary": "Payments - Update",
+ "description": "Payments - Update\n\nTo update the properties of a *PaymentIntent* object. This may include attaching a payment method, or attaching customer object or metadata fields after the Payment is created",
+ "operationId": "Update a Payment",
"parameters": [
{
- "name": "account_id",
+ "name": "payment_id",
"in": "path",
- "description": "Merchant Identifier",
+ "description": "The identifier for payment",
"required": true,
"schema": {
"type": "string"
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentsUpdateRequest"
+ },
+ "examples": {
+ "Update the payment amount": {
+ "value": {
+ "amount": 7654
+ }
+ },
+ "Update the shipping address": {
+ "value": {
+ "shipping": {
+ "address": {
+ "city": "San Fransico",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "Doe",
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "state": "California",
+ "zip": "94122"
+ },
+ "phone": {
+ "country_code": "+91",
+ "number": "8056594427"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Business profiles Retrieved",
+ "description": "Payment updated",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/BusinessProfileResponse"
- }
+ "$ref": "#/components/schemas/PaymentsResponse"
}
}
}
+ },
+ "400": {
+ "description": "Missing mandatory fields"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "publishable_key": []
}
]
},
- "post": {
+ "get": {
"tags": [
- "Business Profile"
+ "Payments"
],
- "summary": "Business Profile - Create",
- "description": "Business Profile - Create\n\nCreates a new *business profile* for a merchant",
- "operationId": "Create A Business Profile",
+ "summary": "Payments - Retrieve",
+ "description": "Payments - Retrieve\n\nRetrieves a Payment. This API can also be used to get the status of a previously initiated payment or next action for an ongoing payment",
+ "operationId": "Retrieve a Payment",
"parameters": [
{
- "name": "account_id",
+ "name": "payment_id",
"in": "path",
- "description": "The unique identifier for the merchant account",
+ "description": "The identifier for payment",
"required": true,
"schema": {
"type": "string"
@@ -191,17 +310,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BusinessProfileCreate"
- },
- "examples": {
- "Create a business profile with minimal fields": {
- "value": {}
- },
- "Create a business profile with profile name": {
- "value": {
- "profile_name": "shoe_business"
- }
- }
+ "$ref": "#/components/schemas/PaymentRetrieveBody"
}
}
},
@@ -209,96 +318,121 @@
},
"responses": {
"200": {
- "description": "Business Account Created",
+ "description": "Gets the payment with final status",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BusinessProfileResponse"
+ "$ref": "#/components/schemas/PaymentsResponse"
}
}
}
},
- "400": {
- "description": "Invalid data"
+ "404": {
+ "description": "No payment found"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
+ },
+ {
+ "publishable_key": []
}
]
}
},
- "/account/{account_id}/business_profile/{profile_id}": {
- "get": {
+ "/payments/{payment_id}/confirm": {
+ "post": {
"tags": [
- "Business Profile"
+ "Payments"
],
- "summary": "Business Profile - Retrieve",
- "description": "Business Profile - Retrieve\n\nRetrieve existing *business profile*",
- "operationId": "Retrieve a Business Profile",
+ "summary": "Payments - Confirm",
+ "description": "Payments - Confirm\n\n**Use this API to confirm the payment and forward the payment to the payment processor.**\n\nAlternatively you can confirm the payment within the *Payments/Create* API by setting `confirm=true`. After confirmation, the payment could either:\n\n1. fail with `failed` status or\n\n2. transition to a `requires_customer_action` status with a `next_action` block or\n\n3. succeed with either `succeeded` in case of automatic capture or `requires_capture` in case of manual capture",
+ "operationId": "Confirm a Payment",
"parameters": [
{
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "profile_id",
+ "name": "payment_id",
"in": "path",
- "description": "The unique identifier for the business profile",
+ "description": "The identifier for payment",
"required": true,
"schema": {
"type": "string"
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentsConfirmRequest"
+ },
+ "examples": {
+ "Confirm a payment with payment method data": {
+ "value": {
+ "customer_acceptance": {
+ "acceptance_type": "offline",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ },
+ "payment_method": "card",
+ "payment_method_data": {
+ "card": {
+ "card_cvc": "123",
+ "card_exp_month": "10",
+ "card_exp_year": "25",
+ "card_holder_name": "joseph Doe",
+ "card_number": "4242424242424242"
+ }
+ },
+ "payment_method_type": "credit"
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Business Profile Updated",
+ "description": "Payment confirmed",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BusinessProfileResponse"
+ "$ref": "#/components/schemas/PaymentsResponse"
}
}
}
},
"400": {
- "description": "Invalid data"
+ "description": "Missing mandatory fields"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "publishable_key": []
}
]
- },
+ }
+ },
+ "/payments/{payment_id}/capture": {
"post": {
"tags": [
- "Business Profile"
+ "Payments"
],
- "summary": "Business Profile - Update",
- "description": "Business Profile - Update\n\nUpdate the *business profile*",
- "operationId": "Update a Business Profile",
+ "summary": "Payments - Capture",
+ "description": "Payments - Capture\n\nTo capture the funds for an uncaptured payment",
+ "operationId": "Capture a Payment",
"parameters": [
{
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "profile_id",
+ "name": "payment_id",
"in": "path",
- "description": "The unique identifier for the business profile",
+ "description": "The identifier for payment",
"required": true,
"schema": {
"type": "string"
@@ -309,13 +443,16 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BusinessProfileCreate"
+ "$ref": "#/components/schemas/PaymentsCaptureRequest"
},
"examples": {
- "Update business profile with profile name fields": {
+ "Capture partial amount": {
"value": {
- "profile_name": "shoe_business"
+ "amount_to_capture": 654
}
+ },
+ "Capture the full amount": {
+ "value": {}
}
}
}
@@ -324,17 +461,17 @@
},
"responses": {
"200": {
- "description": "Business Profile Updated",
+ "description": "Payment captured",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BusinessProfileResponse"
+ "$ref": "#/components/schemas/PaymentsResponse"
}
}
}
},
"400": {
- "description": "Invalid data"
+ "description": "Missing mandatory fields"
}
},
"security": [
@@ -342,89 +479,81 @@
"api_key": []
}
]
- },
- "delete": {
+ }
+ },
+ "/payments/session_tokens": {
+ "post": {
"tags": [
- "Business Profile"
+ "Payments"
],
- "summary": "Business Profile - Delete",
- "description": "Business Profile - Delete\n\nDelete the *business profile*",
- "operationId": "Delete the Business Profile",
- "parameters": [
- {
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "profile_id",
- "in": "path",
- "description": "The unique identifier for the business profile",
- "required": true,
- "schema": {
- "type": "string"
+ "summary": "Payments - Session token",
+ "description": "Payments - Session token\n\nCreates a session object or a session token for wallets like Apple Pay, Google Pay, etc. These tokens are used by Hyperswitch's SDK to initiate these wallets' SDK.",
+ "operationId": "Create Session tokens for a Payment",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentsSessionRequest"
+ }
}
- }
- ],
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Business profiles Deleted",
+ "description": "Payment session object created or session token was retrieved from wallets",
"content": {
- "text/plain": {
+ "application/json": {
"schema": {
- "type": "boolean"
+ "$ref": "#/components/schemas/PaymentsSessionResponse"
}
}
}
},
"400": {
- "description": "Invalid data"
+ "description": "Missing mandatory fields"
}
},
"security": [
{
- "api_key": []
+ "publishable_key": []
}
]
}
},
- "/accounts": {
+ "/payments/{payment_id}/cancel": {
"post": {
"tags": [
- "Merchant Account"
+ "Payments"
+ ],
+ "summary": "Payments - Cancel",
+ "description": "Payments - Cancel\n\nA Payment could can be cancelled when it is in one of these statuses: `requires_payment_method`, `requires_capture`, `requires_confirmation`, `requires_customer_action`.",
+ "operationId": "Cancel a Payment",
+ "parameters": [
+ {
+ "name": "payment_id",
+ "in": "path",
+ "description": "The identifier for payment",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Merchant Account - Create",
- "description": "Merchant Account - Create\n\nCreate a new account for a *merchant* and the *merchant* could be a seller or retailer or client who likes to receive and send payments.",
- "operationId": "Create a Merchant Account",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantAccountCreate"
+ "$ref": "#/components/schemas/PaymentsCancelRequest"
},
"examples": {
- "Create a merchant account with minimal fields": {
- "value": {
- "merchant_id": "merchant_abc"
- }
- },
- "Create a merchant account with return url": {
+ "Cancel the payment with cancellation reason": {
"value": {
- "merchant_id": "merchant_abc",
- "return_url": "https://example.com"
+ "cancellation_reason": "requested_by_customer"
}
},
- "Create a merchant account with webhook url": {
- "value": {
- "merchant_id": "merchant_abc",
- "webhook_details": {
- "webhook_url": "https://webhook.site/a5c54f75-1f7e-4545-b781-af525b7e37a0"
- }
- }
+ "Cancel the payment with minimal fields": {
+ "value": {}
}
}
}
@@ -433,78 +562,154 @@
},
"responses": {
"200": {
- "description": "Merchant Account Created",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/MerchantAccountResponse"
- }
- }
- }
+ "description": "Payment canceled"
},
"400": {
- "description": "Invalid data"
+ "description": "Missing mandatory fields"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
}
},
- "/accounts/{account_id}": {
+ "/payments/list": {
"get": {
"tags": [
- "Merchant Account"
+ "Payments"
],
- "summary": "Merchant Account - Retrieve",
- "description": "Merchant Account - Retrieve\n\nRetrieve a *merchant* account details.",
- "operationId": "Retrieve a Merchant Account",
+ "summary": "Payments - List",
+ "description": "Payments - List\n\nTo list the *payments*",
+ "operationId": "List all Payments",
"parameters": [
{
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
+ "name": "customer_id",
+ "in": "query",
+ "description": "The identifier for the customer",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "starting_after",
+ "in": "query",
+ "description": "A cursor for use in pagination, fetch the next list after some object",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "ending_before",
+ "in": "query",
+ "description": "A cursor for use in pagination, fetch the previous list before some object",
"required": true,
"schema": {
"type": "string"
}
+ },
+ {
+ "name": "limit",
+ "in": "query",
+ "description": "Limit on the number of objects to return",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ {
+ "name": "created",
+ "in": "query",
+ "description": "The time at which payment is created",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ {
+ "name": "created_lt",
+ "in": "query",
+ "description": "Time less than the payment created time",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ {
+ "name": "created_gt",
+ "in": "query",
+ "description": "Time greater than the payment created time",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ {
+ "name": "created_lte",
+ "in": "query",
+ "description": "Time less than or equals to the payment created time",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "date-time"
+ }
+ },
+ {
+ "name": "created_gte",
+ "in": "query",
+ "description": "Time greater than or equals to the payment created time",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "date-time"
+ }
}
],
"responses": {
"200": {
- "description": "Merchant Account Retrieved",
+ "description": "Successfully retrieved a payment list",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantAccountResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/PaymentListResponse"
+ }
}
}
}
},
"404": {
- "description": "Merchant account not found"
+ "description": "No payments found"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
- },
+ }
+ },
+ "/payments/{payment_id}/incremental_authorization": {
"post": {
"tags": [
- "Merchant Account"
+ "Payments"
],
- "summary": "Merchant Account - Update",
- "description": "Merchant Account - Update\n\nUpdates details of an existing merchant account. Helpful in updating merchant details such as email, contact details, or other configuration details like webhook, routing algorithm etc",
- "operationId": "Update a Merchant Account",
+ "summary": "Payments - Incremental Authorization",
+ "description": "Payments - Incremental Authorization\n\nAuthorized amount for a payment can be incremented if it is in status: requires_capture",
+ "operationId": "Increment authorized amount for a Payment",
"parameters": [
{
- "name": "account_id",
+ "name": "payment_id",
"in": "path",
- "description": "The unique identifier for the merchant account",
+ "description": "The identifier for payment",
"required": true,
"schema": {
"type": "string"
@@ -515,29 +720,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantAccountUpdate"
- },
- "examples": {
- "Update merchant name": {
- "value": {
- "merchant_id": "merchant_abc",
- "merchant_name": "merchant_name"
- }
- },
- "Update return url": {
- "value": {
- "merchant_id": "merchant_abc",
- "return_url": "https://example.com"
- }
- },
- "Update webhook url": {
- "value": {
- "merchant_id": "merchant_abc",
- "webhook_details": {
- "webhook_url": "https://webhook.site/a5c54f75-1f7e-4545-b781-af525b7e37a0"
- }
- }
- }
+ "$ref": "#/components/schemas/PaymentsIncrementalAuthorizationRequest"
}
}
},
@@ -545,158 +728,165 @@
},
"responses": {
"200": {
- "description": "Merchant Account Updated",
+ "description": "Payment authorized amount incremented",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantAccountResponse"
+ "$ref": "#/components/schemas/PaymentsResponse"
}
}
}
},
- "404": {
- "description": "Merchant account not found"
+ "400": {
+ "description": "Missing mandatory fields"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
- },
- "delete": {
+ }
+ },
+ "/payment_link/{payment_link_id}": {
+ "get": {
"tags": [
- "Merchant Account"
+ "Payments"
],
- "summary": "Merchant Account - Delete",
- "description": "Merchant Account - Delete\n\nDelete a *merchant* account",
- "operationId": "Delete a Merchant Account",
+ "summary": "Payments Link - Retrieve",
+ "description": "Payments Link - Retrieve\n\nTo retrieve the properties of a Payment Link. This may be used to get the status of a previously initiated payment or next action for an ongoing payment",
+ "operationId": "Retrieve a Payment Link",
"parameters": [
{
- "name": "account_id",
+ "name": "payment_link_id",
"in": "path",
- "description": "The unique identifier for the merchant account",
+ "description": "The identifier for payment link",
"required": true,
"schema": {
"type": "string"
}
- }
- ],
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/RetrievePaymentLinkRequest"
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Merchant Account Deleted",
+ "description": "Gets details regarding payment link",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantAccountDeleteResponse"
+ "$ref": "#/components/schemas/RetrievePaymentLinkResponse"
}
}
}
},
"404": {
- "description": "Merchant account not found"
+ "description": "No payment link found"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
+ },
+ {
+ "publishable_key": []
}
]
}
},
- "/accounts/{account_id}/connectors": {
- "get": {
+ "/payments/{payment_id}/3ds/authentication": {
+ "post": {
"tags": [
- "Merchant Connector Account"
+ "Payments"
],
- "summary": "Merchant Connector - List",
- "description": "Merchant Connector - List\n\nList Merchant Connector Details for the merchant",
- "operationId": "List all Merchant Connectors",
+ "summary": "Payments - External 3DS Authentication",
+ "description": "Payments - External 3DS Authentication\n\nExternal 3DS Authentication is performed and returns the AuthenticationResponse",
+ "operationId": "Initiate external authentication for a Payment",
"parameters": [
{
- "name": "account_id",
+ "name": "payment_id",
"in": "path",
- "description": "The unique identifier for the merchant account",
+ "description": "The identifier for payment",
"required": true,
"schema": {
"type": "string"
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentsExternalAuthenticationRequest"
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Merchant Connector list retrieved successfully",
+ "description": "Authentication created",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/MerchantConnectorResponse"
- }
+ "$ref": "#/components/schemas/PaymentsExternalAuthenticationResponse"
}
}
}
},
- "401": {
- "description": "Unauthorized request"
- },
- "404": {
- "description": "Merchant Connector does not exist in records"
+ "400": {
+ "description": "Missing mandatory fields"
}
},
"security": [
{
- "admin_api_key": []
+ "publishable_key": []
}
]
- },
+ }
+ },
+ "/refunds": {
"post": {
"tags": [
- "Merchant Connector Account"
+ "Refunds"
],
- "summary": "Merchant Connector - Create",
- "description": "Merchant Connector - Create\n\nCreates a new Merchant Connector for the merchant account. The connector could be a payment processor/facilitator/acquirer or a provider of specialized services like Fraud/Accounting etc.",
- "operationId": "Create a Merchant Connector",
+ "summary": "Refunds - Create",
+ "description": "Refunds - Create\n\nCreates a refund against an already processed payment. In case of some processors, you can even opt to refund only a partial amount multiple times until the original charge amount has been refunded",
+ "operationId": "Create a Refund",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantConnectorCreate"
+ "$ref": "#/components/schemas/RefundRequest"
},
"examples": {
- "Create a merchant account with custom connector label": {
+ "Create an instant refund to refund partial amount": {
"value": {
- "connector_account_details": {
- "api_key": "{{adyen-api-key}}",
- "auth_type": "BodyKey",
- "key1": "{{adyen_merchant_account}}"
- },
- "connector_label": "EU_adyen",
- "connector_name": "adyen",
- "connector_type": "fiz_operations"
+ "amount": 654,
+ "payment_id": "{{payment_id}}",
+ "refund_type": "instant"
}
},
- "Create a merchant connector account under a specific business profile": {
+ "Create an instant refund to refund the whole amount": {
"value": {
- "connector_account_details": {
- "api_key": "{{adyen-api-key}}",
- "auth_type": "BodyKey",
- "key1": "{{adyen_merchant_account}}"
- },
- "connector_name": "adyen",
- "connector_type": "fiz_operations",
- "profile_id": "{{profile_id}}"
+ "payment_id": "{{payment_id}}",
+ "refund_type": "instant"
}
},
- "Create a merchant connector account with minimal fields": {
+ "Create an instant refund with reason": {
"value": {
- "connector_account_details": {
- "api_key": "{{adyen-api-key}}",
- "auth_type": "BodyKey",
- "key1": "{{adyen_merchant_account}}"
- },
- "connector_name": "adyen",
- "connector_type": "fiz_operations"
+ "amount": 6540,
+ "payment_id": "{{payment_id}}",
+ "reason": "Customer returned product",
+ "refund_type": "instant"
}
}
}
@@ -706,11 +896,11 @@
},
"responses": {
"200": {
- "description": "Merchant Connector Created",
+ "description": "Refund created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantConnectorResponse"
+ "$ref": "#/components/schemas/RefundResponse"
}
}
}
@@ -721,114 +911,79 @@
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
}
},
- "/accounts/{account_id}/connectors/{connector_id}": {
+ "/refunds/{refund_id}": {
"get": {
"tags": [
- "Merchant Connector Account"
+ "Refunds"
],
- "summary": "Merchant Connector - Retrieve",
- "description": "Merchant Connector - Retrieve\n\nRetrieves details of a Connector account",
- "operationId": "Retrieve a Merchant Connector",
+ "summary": "Refunds - Retrieve",
+ "description": "Refunds - Retrieve\n\nRetrieves a Refund. This may be used to get the status of a previously initiated refund",
+ "operationId": "Retrieve a Refund",
"parameters": [
{
- "name": "account_id",
+ "name": "refund_id",
"in": "path",
- "description": "The unique identifier for the merchant account",
+ "description": "The identifier for refund",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "connector_id",
- "in": "path",
- "description": "The unique identifier for the Merchant Connector",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int32"
- }
}
],
"responses": {
"200": {
- "description": "Merchant Connector retrieved successfully",
+ "description": "Refund retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantConnectorResponse"
+ "$ref": "#/components/schemas/RefundResponse"
}
}
}
},
- "401": {
- "description": "Unauthorized request"
- },
"404": {
- "description": "Merchant Connector does not exist in records"
+ "description": "Refund does not exist in our records"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
},
"post": {
"tags": [
- "Merchant Connector Account"
+ "Refunds"
],
- "summary": "Merchant Connector - Update",
- "description": "Merchant Connector - Update\n\nTo update an existing Merchant Connector account. Helpful in enabling/disabling different payment methods and other settings for the connector",
- "operationId": "Update a Merchant Connector",
+ "summary": "Refunds - Update",
+ "description": "Refunds - Update\n\nUpdates the properties of a Refund object. This API can be used to attach a reason for the refund or metadata fields",
+ "operationId": "Update a Refund",
"parameters": [
{
- "name": "account_id",
+ "name": "refund_id",
"in": "path",
- "description": "The unique identifier for the merchant account",
+ "description": "The identifier for refund",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "connector_id",
- "in": "path",
- "description": "The unique identifier for the Merchant Connector",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int32"
- }
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantConnectorUpdate"
+ "$ref": "#/components/schemas/RefundUpdateRequest"
},
"examples": {
- "Enable card payment method": {
- "value": {
- "connector_type": "fiz_operations",
- "payment_methods_enabled": [
- {
- "payment_method": "card"
- }
- ]
- }
- },
- "Update webhook secret": {
+ "Update refund reason": {
"value": {
- "connector_webhook_details": {
- "merchant_secret": "{{webhook_secret}}"
- }
+ "reason": "Paid by mistake"
}
}
}
@@ -838,117 +993,39 @@
},
"responses": {
"200": {
- "description": "Merchant Connector Updated",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/MerchantConnectorResponse"
- }
- }
- }
- },
- "401": {
- "description": "Unauthorized request"
- },
- "404": {
- "description": "Merchant Connector does not exist in records"
- }
- },
- "security": [
- {
- "admin_api_key": []
- }
- ]
- },
- "delete": {
- "tags": [
- "Merchant Connector Account"
- ],
- "summary": "Merchant Connector - Delete",
- "description": "Merchant Connector - Delete\n\nDelete or Detach a Merchant Connector from Merchant Account",
- "operationId": "Delete a Merchant Connector",
- "parameters": [
- {
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "connector_id",
- "in": "path",
- "description": "The unique identifier for the Merchant Connector",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int32"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Merchant Connector Deleted",
+ "description": "Refund updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantConnectorDeleteResponse"
+ "$ref": "#/components/schemas/RefundResponse"
}
}
}
},
- "401": {
- "description": "Unauthorized request"
- },
- "404": {
- "description": "Merchant Connector does not exist in records"
+ "400": {
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
}
},
- "/accounts/{account_id}/kv": {
+ "/refunds/list": {
"post": {
"tags": [
- "Merchant Account"
- ],
- "summary": "Merchant Account - KV Status",
- "description": "Merchant Account - KV Status\n\nToggle KV mode for the Merchant Account",
- "operationId": "Enable/Disable KV for a Merchant Account",
- "parameters": [
- {
- "name": "account_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
+ "Refunds"
],
+ "summary": "Refunds - List",
+ "description": "Refunds - List\n\nLists all the refunds associated with the merchant or a payment_id if payment_id is not provided",
+ "operationId": "List all Refunds",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ToggleKVRequest"
- },
- "examples": {
- "Disable KV for Merchant": {
- "value": {
- "kv_enabled": "false"
- }
- },
- "Enable KV for Merchant": {
- "value": {
- "kv_enabled": "true"
- }
- }
+ "$ref": "#/components/schemas/RefundListRequest"
}
}
},
@@ -956,53 +1033,57 @@
},
"responses": {
"200": {
- "description": "KV mode is enabled/disabled for Merchant Account",
+ "description": "List of refunds",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ToggleKVResponse"
+ "$ref": "#/components/schemas/RefundListResponse"
}
}
}
- },
- "400": {
- "description": "Invalid data"
- },
- "404": {
- "description": "Merchant account not found"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
}
},
- "/api_keys/{merchant_id)": {
+ "/accounts": {
"post": {
"tags": [
- "API Key"
- ],
- "summary": "API Key - Create",
- "description": "API Key - Create\n\nCreate a new API Key for accessing our APIs from your servers. The plaintext API Key will be\ndisplayed only once on creation, so ensure you store it securely.",
- "operationId": "Create an API Key",
- "parameters": [
- {
- "name": "merchant_id",
- "in": "path",
- "description": "The unique identifier for the merchant account",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
+ "Merchant Account"
],
+ "summary": "Merchant Account - Create",
+ "description": "Merchant Account - Create\n\nCreate a new account for a *merchant* and the *merchant* could be a seller or retailer or client who likes to receive and send payments.",
+ "operationId": "Create a Merchant Account",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CreateApiKeyRequest"
+ "$ref": "#/components/schemas/MerchantAccountCreate"
+ },
+ "examples": {
+ "Create a merchant account with minimal fields": {
+ "value": {
+ "merchant_id": "merchant_abc"
+ }
+ },
+ "Create a merchant account with return url": {
+ "value": {
+ "merchant_id": "merchant_abc",
+ "return_url": "https://example.com"
+ }
+ },
+ "Create a merchant account with webhook url": {
+ "value": {
+ "merchant_id": "merchant_abc",
+ "webhook_details": {
+ "webhook_url": "https://webhook.site/a5c54f75-1f7e-4545-b781-af525b7e37a0"
+ }
+ }
+ }
}
}
},
@@ -1010,11 +1091,11 @@
},
"responses": {
"200": {
- "description": "API Key created",
+ "description": "Merchant Account Created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CreateApiKeyResponse"
+ "$ref": "#/components/schemas/MerchantAccountResponse"
}
}
}
@@ -1030,47 +1111,38 @@
]
}
},
- "/api_keys/{merchant_id)/{key_id}": {
- "delete": {
+ "/accounts/{account_id}": {
+ "get": {
"tags": [
- "API Key"
+ "Merchant Account"
],
- "summary": "API Key - Revoke",
- "description": "API Key - Revoke\n\nRevoke the specified API Key. Once revoked, the API Key can no longer be used for\nauthenticating with our APIs.",
- "operationId": "Revoke an API Key",
+ "summary": "Merchant Account - Retrieve",
+ "description": "Merchant Account - Retrieve\n\nRetrieve a *merchant* account details.",
+ "operationId": "Retrieve a Merchant Account",
"parameters": [
{
- "name": "merchant_id",
+ "name": "account_id",
"in": "path",
"description": "The unique identifier for the merchant account",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "key_id",
- "in": "path",
- "description": "The unique identifier for the API Key",
- "required": true,
- "schema": {
- "type": "string"
- }
}
],
"responses": {
"200": {
- "description": "API Key revoked",
+ "description": "Merchant Account Retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RevokeApiKeyResponse"
+ "$ref": "#/components/schemas/MerchantAccountResponse"
}
}
}
},
"404": {
- "description": "API Key not found"
+ "description": "Merchant account not found"
}
},
"security": [
@@ -1078,49 +1150,70 @@
"admin_api_key": []
}
]
- }
- },
- "/api_keys/{merchant_id}/{key_id}": {
- "get": {
+ },
+ "post": {
"tags": [
- "API Key"
+ "Merchant Account"
],
- "summary": "API Key - Retrieve",
- "description": "API Key - Retrieve\n\nRetrieve information about the specified API Key.",
- "operationId": "Retrieve an API Key",
+ "summary": "Merchant Account - Update",
+ "description": "Merchant Account - Update\n\nUpdates details of an existing merchant account. Helpful in updating merchant details such as email, contact details, or other configuration details like webhook, routing algorithm etc",
+ "operationId": "Update a Merchant Account",
"parameters": [
{
- "name": "merchant_id",
+ "name": "account_id",
"in": "path",
"description": "The unique identifier for the merchant account",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "key_id",
- "in": "path",
- "description": "The unique identifier for the API Key",
- "required": true,
- "schema": {
- "type": "string"
- }
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/MerchantAccountUpdate"
+ },
+ "examples": {
+ "Update merchant name": {
+ "value": {
+ "merchant_id": "merchant_abc",
+ "merchant_name": "merchant_name"
+ }
+ },
+ "Update return url": {
+ "value": {
+ "merchant_id": "merchant_abc",
+ "return_url": "https://example.com"
+ }
+ },
+ "Update webhook url": {
+ "value": {
+ "merchant_id": "merchant_abc",
+ "webhook_details": {
+ "webhook_url": "https://webhook.site/a5c54f75-1f7e-4545-b781-af525b7e37a0"
+ }
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "API Key retrieved",
+ "description": "Merchant Account Updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RetrieveApiKeyResponse"
+ "$ref": "#/components/schemas/MerchantAccountResponse"
}
}
}
},
"404": {
- "description": "API Key not found"
+ "description": "Merchant account not found"
}
},
"security": [
@@ -1129,56 +1222,37 @@
}
]
},
- "post": {
+ "delete": {
"tags": [
- "API Key"
+ "Merchant Account"
],
- "summary": "API Key - Update",
- "description": "API Key - Update\n\nUpdate information for the specified API Key.",
- "operationId": "Update an API Key",
+ "summary": "Merchant Account - Delete",
+ "description": "Merchant Account - Delete\n\nDelete a *merchant* account",
+ "operationId": "Delete a Merchant Account",
"parameters": [
{
- "name": "merchant_id",
+ "name": "account_id",
"in": "path",
"description": "The unique identifier for the merchant account",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "key_id",
- "in": "path",
- "description": "The unique identifier for the API Key",
- "required": true,
- "schema": {
- "type": "string"
- }
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/UpdateApiKeyRequest"
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "API Key updated",
+ "description": "Merchant Account Deleted",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RetrieveApiKeyResponse"
+ "$ref": "#/components/schemas/MerchantAccountDeleteResponse"
}
}
}
},
"404": {
- "description": "API Key not found"
+ "description": "Merchant account not found"
}
},
"security": [
@@ -1188,54 +1262,122 @@
]
}
},
- "/blocklist": {
- "get": {
+ "/accounts/{account_id}/kv": {
+ "post": {
"tags": [
- "Blocklist"
+ "Merchant Account"
],
- "operationId": "List Blocked fingerprints of a particular kind",
+ "summary": "Merchant Account - KV Status",
+ "description": "Merchant Account - KV Status\n\nToggle KV mode for the Merchant Account",
+ "operationId": "Enable/Disable KV for a Merchant Account",
"parameters": [
{
- "name": "data_kind",
- "in": "query",
- "description": "Kind of the fingerprint list requested",
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
"required": true,
"schema": {
- "$ref": "#/components/schemas/BlocklistDataKind"
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ToggleKVRequest"
+ },
+ "examples": {
+ "Disable KV for Merchant": {
+ "value": {
+ "kv_enabled": "false"
+ }
+ },
+ "Enable KV for Merchant": {
+ "value": {
+ "kv_enabled": "true"
+ }
+ }
+ }
}
- }
- ],
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Blocked Fingerprints",
+ "description": "KV mode is enabled/disabled for Merchant Account",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BlocklistResponse"
+ "$ref": "#/components/schemas/ToggleKVResponse"
}
}
}
},
"400": {
- "description": "Invalid Data"
+ "description": "Invalid data"
+ },
+ "404": {
+ "description": "Merchant account not found"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
- },
+ }
+ },
+ "/accounts/{account_id}/connectors": {
"post": {
"tags": [
- "Blocklist"
+ "Merchant Connector Account"
],
- "operationId": "Block a Fingerprint",
+ "summary": "Merchant Connector - Create",
+ "description": "Merchant Connector - Create\n\nCreates a new Merchant Connector for the merchant account. The connector could be a payment processor/facilitator/acquirer or a provider of specialized services like Fraud/Accounting etc.",
+ "operationId": "Create a Merchant Connector",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BlocklistRequest"
+ "$ref": "#/components/schemas/MerchantConnectorCreate"
+ },
+ "examples": {
+ "Create a merchant account with custom connector label": {
+ "value": {
+ "connector_account_details": {
+ "api_key": "{{adyen-api-key}}",
+ "auth_type": "BodyKey",
+ "key1": "{{adyen_merchant_account}}"
+ },
+ "connector_label": "EU_adyen",
+ "connector_name": "adyen",
+ "connector_type": "fiz_operations"
+ }
+ },
+ "Create a merchant connector account under a specific business profile": {
+ "value": {
+ "connector_account_details": {
+ "api_key": "{{adyen-api-key}}",
+ "auth_type": "BodyKey",
+ "key1": "{{adyen_merchant_account}}"
+ },
+ "connector_name": "adyen",
+ "connector_type": "fiz_operations",
+ "profile_id": "{{profile_id}}"
+ }
+ },
+ "Create a merchant connector account with minimal fields": {
+ "value": {
+ "connector_account_details": {
+ "api_key": "{{adyen-api-key}}",
+ "auth_type": "BodyKey",
+ "key1": "{{adyen_merchant_account}}"
+ },
+ "connector_name": "adyen",
+ "connector_type": "fiz_operations"
+ }
+ }
}
}
},
@@ -1243,120 +1385,174 @@
},
"responses": {
"200": {
- "description": "Fingerprint Blocked",
+ "description": "Merchant Connector Created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BlocklistResponse"
+ "$ref": "#/components/schemas/MerchantConnectorResponse"
}
}
}
},
"400": {
- "description": "Invalid Data"
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
},
- "delete": {
+ "get": {
"tags": [
- "Blocklist"
+ "Merchant Connector Account"
],
- "operationId": "Unblock a Fingerprint",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/BlocklistRequest"
- }
+ "summary": "Merchant Connector - List",
+ "description": "Merchant Connector - List\n\nList Merchant Connector Details for the merchant",
+ "operationId": "List all Merchant Connectors",
+ "parameters": [
+ {
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
}
- },
- "required": true
- },
+ }
+ ],
"responses": {
"200": {
- "description": "Fingerprint Unblocked",
+ "description": "Merchant Connector list retrieved successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/BlocklistResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/MerchantConnectorResponse"
+ }
}
}
}
},
- "400": {
- "description": "Invalid Data"
+ "401": {
+ "description": "Unauthorized request"
+ },
+ "404": {
+ "description": "Merchant Connector does not exist in records"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
}
},
- "/blocklist/toggle": {
- "post": {
+ "/accounts/{account_id}/connectors/{connector_id}": {
+ "get": {
"tags": [
- "Blocklist"
+ "Merchant Connector Account"
],
- "operationId": "Toggle blocklist guard for a particular merchant",
+ "summary": "Merchant Connector - Retrieve",
+ "description": "Merchant Connector - Retrieve\n\nRetrieves details of a Connector account",
+ "operationId": "Retrieve a Merchant Connector",
"parameters": [
{
- "name": "status",
- "in": "query",
- "description": "Boolean value to enable/disable blocklist",
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
"required": true,
"schema": {
- "type": "boolean"
+ "type": "string"
+ }
+ },
+ {
+ "name": "connector_id",
+ "in": "path",
+ "description": "The unique identifier for the Merchant Connector",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int32"
}
}
],
"responses": {
"200": {
- "description": "Blocklist guard enabled/disabled",
+ "description": "Merchant Connector retrieved successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ToggleBlocklistResponse"
+ "$ref": "#/components/schemas/MerchantConnectorResponse"
}
}
}
},
- "400": {
- "description": "Invalid Data"
+ "401": {
+ "description": "Unauthorized request"
+ },
+ "404": {
+ "description": "Merchant Connector does not exist in records"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
- }
- },
- "/customers": {
+ },
"post": {
"tags": [
- "Customers"
+ "Merchant Connector Account"
+ ],
+ "summary": "Merchant Connector - Update",
+ "description": "Merchant Connector - Update\n\nTo update an existing Merchant Connector account. Helpful in enabling/disabling different payment methods and other settings for the connector",
+ "operationId": "Update a Merchant Connector",
+ "parameters": [
+ {
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "connector_id",
+ "in": "path",
+ "description": "The unique identifier for the Merchant Connector",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int32"
+ }
+ }
],
- "summary": "Customers - Create",
- "description": "Customers - Create\n\nCreates a customer object and stores the customer details to be reused for future payments.\nIncase the customer already exists in the system, this API will respond with the customer details.",
- "operationId": "Create a Customer",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerRequest"
+ "$ref": "#/components/schemas/MerchantConnectorUpdate"
},
"examples": {
- "Update name and email of a customer": {
+ "Enable card payment method": {
"value": {
- "email": "[email protected]",
- "name": "John Doe"
+ "connector_type": "fiz_operations",
+ "payment_methods_enabled": [
+ {
+ "payment_method": "card"
+ }
+ ]
+ }
+ },
+ "Update webhook secret": {
+ "value": {
+ "connector_webhook_details": {
+ "merchant_secret": "{{webhook_secret}}"
+ }
}
}
}
@@ -1366,248 +1562,174 @@
},
"responses": {
"200": {
- "description": "Customer Created",
+ "description": "Merchant Connector Updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerResponse"
+ "$ref": "#/components/schemas/MerchantConnectorResponse"
}
}
}
},
- "400": {
- "description": "Invalid data"
- }
- },
- "security": [
- {
- "api_key": []
- }
- ]
- }
- },
- "/customers/list": {
- "post": {
- "tags": [
- "Customers List"
- ],
- "summary": "Customers - List",
- "description": "Customers - List\n\nLists all the customers for a particular merchant id.",
- "operationId": "List all Customers for a Merchant",
- "responses": {
- "200": {
- "description": "Customers retrieved",
- "content": {
- "application/json": {
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/CustomerResponse"
- }
- }
- }
- }
+ "401": {
+ "description": "Unauthorized request"
},
- "400": {
- "description": "Invalid Data"
+ "404": {
+ "description": "Merchant Connector does not exist in records"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
- }
- },
- "/customers/payment_methods": {
- "get": {
+ },
+ "delete": {
"tags": [
- "Payment Methods"
+ "Merchant Connector Account"
],
- "summary": "List customer saved payment methods for a Payment",
- "description": "List customer saved payment methods for a Payment\n\nLists all the applicable payment methods for a particular payment tied to the `client_secret`.",
- "operationId": "List all Payment Methods for a Customer",
+ "summary": "Merchant Connector - Delete",
+ "description": "Merchant Connector - Delete\n\nDelete or Detach a Merchant Connector from Merchant Account",
+ "operationId": "Delete a Merchant Connector",
"parameters": [
{
- "name": "client-secret",
- "in": "path",
- "description": "A secret known only to your client and the authorization server. Used for client side authentication",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "customer_id",
+ "name": "account_id",
"in": "path",
- "description": "The unique identifier for the customer account",
+ "description": "The unique identifier for the merchant account",
"required": true,
"schema": {
"type": "string"
}
},
{
- "name": "accepted_country",
- "in": "query",
- "description": "The two-letter ISO currency code",
- "required": true,
- "schema": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- {
- "name": "accepted_currency",
+ "name": "connector_id",
"in": "path",
- "description": "The three-letter ISO currency code",
- "required": true,
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Currency"
- }
- }
- },
- {
- "name": "minimum_amount",
- "in": "query",
- "description": "The minimum amount accepted for processing by the particular payment method.",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "maximum_amount",
- "in": "query",
- "description": "The maximum amount accepted for processing by the particular payment method.",
+ "description": "The unique identifier for the Merchant Connector",
"required": true,
"schema": {
"type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "recurring_payment_enabled",
- "in": "query",
- "description": "Indicates whether the payment method is eligible for recurring payments",
- "required": true,
- "schema": {
- "type": "boolean"
- }
- },
- {
- "name": "installment_payment_enabled",
- "in": "query",
- "description": "Indicates whether the payment method is eligible for installment payments",
- "required": true,
- "schema": {
- "type": "boolean"
+ "format": "int32"
}
}
],
"responses": {
"200": {
- "description": "Payment Methods retrieved for customer tied to its respective client-secret passed in the param",
+ "description": "Merchant Connector Deleted",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
+ "$ref": "#/components/schemas/MerchantConnectorDeleteResponse"
}
}
}
},
- "400": {
- "description": "Invalid Data"
+ "401": {
+ "description": "Unauthorized request"
},
"404": {
- "description": "Payment Methods does not exist in records"
+ "description": "Merchant Connector does not exist in records"
}
},
"security": [
{
- "publishable_key": []
+ "admin_api_key": []
}
]
}
},
- "/customers/{customer_id}": {
- "get": {
+ "/gsm": {
+ "post": {
"tags": [
- "Customers"
+ "Gsm"
],
- "summary": "Customers - Retrieve",
- "description": "Customers - Retrieve\n\nRetrieves a customer's details.",
- "operationId": "Retrieve a Customer",
- "parameters": [
- {
- "name": "customer_id",
- "in": "path",
- "description": "The unique identifier for the Customer",
- "required": true,
- "schema": {
- "type": "string"
+ "summary": "Gsm - Create",
+ "description": "Gsm - Create\n\nCreates a GSM (Global Status Mapping) Rule. A GSM rule is used to map a connector's error message/error code combination during a particular payments flow/sub-flow to Hyperswitch's unified status/error code/error message combination. It is also used to decide the next action in the flow - retry/requeue/do_default",
+ "operationId": "Create Gsm Rule",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/GsmCreateRequest"
+ }
}
- }
- ],
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Customer Retrieved",
+ "description": "Gsm created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerResponse"
+ "$ref": "#/components/schemas/GsmResponse"
}
}
}
},
- "404": {
- "description": "Customer was not found"
+ "400": {
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
- "api_key": []
- },
- {
- "ephemeral_key": []
+ "admin_api_key": []
}
]
- },
+ }
+ },
+ "/gsm/get": {
"post": {
"tags": [
- "Customers"
+ "Gsm"
],
- "summary": "Customers - Update",
- "description": "Customers - Update\n\nUpdates the customer's details in a customer object.",
- "operationId": "Update a Customer",
- "parameters": [
- {
- "name": "customer_id",
- "in": "path",
- "description": "The unique identifier for the Customer",
- "required": true,
- "schema": {
- "type": "string"
+ "summary": "Gsm - Get",
+ "description": "Gsm - Get\n\nRetrieves a Gsm Rule",
+ "operationId": "Retrieve Gsm Rule",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/GsmRetrieveRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "Gsm retrieved",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/GsmResponse"
+ }
+ }
}
+ },
+ "400": {
+ "description": "Missing Mandatory fields"
+ }
+ },
+ "security": [
+ {
+ "admin_api_key": []
}
+ ]
+ }
+ },
+ "/gsm/update": {
+ "post": {
+ "tags": [
+ "Gsm"
],
+ "summary": "Gsm - Update",
+ "description": "Gsm - Update\n\nUpdates a Gsm Rule",
+ "operationId": "Update Gsm Rule",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerRequest"
- },
- "examples": {
- "Update name and email of a customer": {
- "value": {
- "email": "[email protected]",
- "name": "John Doe"
- }
- }
+ "$ref": "#/components/schemas/GsmUpdateRequest"
}
}
},
@@ -1615,89 +1737,98 @@
},
"responses": {
"200": {
- "description": "Customer was Updated",
+ "description": "Gsm updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerResponse"
+ "$ref": "#/components/schemas/GsmResponse"
}
}
}
},
- "404": {
- "description": "Customer was not found"
+ "400": {
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
- },
- "delete": {
+ }
+ },
+ "/gsm/delete": {
+ "post": {
"tags": [
- "Customers"
+ "Gsm"
],
- "summary": "Customers - Delete",
- "description": "Customers - Delete\n\nDelete a customer record.",
- "operationId": "Delete a Customer",
- "parameters": [
- {
- "name": "customer_id",
- "in": "path",
- "description": "The unique identifier for the Customer",
- "required": true,
- "schema": {
- "type": "string"
+ "summary": "Gsm - Delete",
+ "description": "Gsm - Delete\n\nDeletes a Gsm Rule",
+ "operationId": "Delete Gsm Rule",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/GsmDeleteRequest"
+ }
}
- }
- ],
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Customer was Deleted",
+ "description": "Gsm deleted",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerDeleteResponse"
+ "$ref": "#/components/schemas/GsmDeleteResponse"
}
}
}
},
- "404": {
- "description": "Customer was not found"
+ "400": {
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
}
},
- "/customers/{customer_id}/mandates": {
- "post": {
+ "/mandates/{mandate_id}": {
+ "get": {
"tags": [
- "Customers Mandates List"
+ "Mandates"
+ ],
+ "summary": "Mandates - Retrieve Mandate",
+ "description": "Mandates - Retrieve Mandate\n\nRetrieves a mandate created using the Payments/Create API",
+ "operationId": "Retrieve a Mandate",
+ "parameters": [
+ {
+ "name": "mandate_id",
+ "in": "path",
+ "description": "The identifier for mandate",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Customers - Mandates List",
- "description": "Customers - Mandates List\n\nLists all the mandates for a particular customer id.",
- "operationId": "List all Mandates for a Customer",
"responses": {
"200": {
- "description": "List of retrieved mandates for a customer",
+ "description": "The mandate was retrieved successfully",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/MandateResponse"
- }
+ "$ref": "#/components/schemas/MandateResponse"
}
}
}
},
- "400": {
- "description": "Invalid Data"
+ "404": {
+ "description": "Mandate does not exist in our records"
}
},
"security": [
@@ -1707,103 +1838,38 @@
]
}
},
- "/customers/{customer_id}/payment_methods": {
- "get": {
+ "/mandates/revoke/{mandate_id}": {
+ "post": {
"tags": [
- "Payment Methods"
+ "Mandates"
],
- "summary": "List payment methods for a Customer",
- "description": "List payment methods for a Customer\n\nLists all the applicable payment methods for a particular Customer ID.",
- "operationId": "List all Payment Methods for a Customer",
+ "summary": "Mandates - Revoke Mandate",
+ "description": "Mandates - Revoke Mandate\n\nRevokes a mandate created using the Payments/Create API",
+ "operationId": "Revoke a Mandate",
"parameters": [
{
- "name": "customer_id",
+ "name": "mandate_id",
"in": "path",
- "description": "The unique identifier for the customer account",
+ "description": "The identifier for a mandate",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "accepted_country",
- "in": "query",
- "description": "The two-letter ISO currency code",
- "required": true,
- "schema": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- {
- "name": "accepted_currency",
- "in": "path",
- "description": "The three-letter ISO currency code",
- "required": true,
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Currency"
- }
- }
- },
- {
- "name": "minimum_amount",
- "in": "query",
- "description": "The minimum amount accepted for processing by the particular payment method.",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "maximum_amount",
- "in": "query",
- "description": "The maximum amount accepted for processing by the particular payment method.",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "recurring_payment_enabled",
- "in": "query",
- "description": "Indicates whether the payment method is eligible for recurring payments",
- "required": true,
- "schema": {
- "type": "boolean"
- }
- },
- {
- "name": "installment_payment_enabled",
- "in": "query",
- "description": "Indicates whether the payment method is eligible for installment payments",
- "required": true,
- "schema": {
- "type": "boolean"
- }
}
],
"responses": {
"200": {
- "description": "Payment Methods retrieved",
+ "description": "The mandate was revoked successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
+ "$ref": "#/components/schemas/MandateRevokedResponse"
}
}
}
},
"400": {
- "description": "Invalid Data"
- },
- "404": {
- "description": "Payment Methods does not exist in records"
+ "description": "Mandate does not exist in our records"
}
},
"security": [
@@ -1813,146 +1879,78 @@
]
}
},
- "/disputes/list": {
- "get": {
+ "/customers/{customer_id}/mandates": {
+ "post": {
"tags": [
- "Disputes"
+ "Mandates"
],
- "summary": "Disputes - List Disputes",
- "description": "Disputes - List Disputes\nLists all the Disputes for a merchant",
- "operationId": "List Disputes",
- "parameters": [
- {
- "name": "limit",
- "in": "query",
- "description": "The maximum number of Dispute Objects to include in the response",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int64",
- "nullable": true
- }
- },
- {
- "name": "dispute_status",
- "in": "query",
- "description": "The status of dispute",
- "required": false,
- "schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/DisputeStatus"
- }
- ],
- "nullable": true
- }
- },
- {
- "name": "dispute_stage",
- "in": "query",
- "description": "The stage of dispute",
- "required": false,
- "schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/DisputeStage"
- }
- ],
- "nullable": true
- }
- },
- {
- "name": "reason",
- "in": "query",
- "description": "The reason for dispute",
- "required": false,
- "schema": {
- "type": "string",
- "nullable": true
- }
- },
- {
- "name": "connector",
- "in": "query",
- "description": "The connector linked to dispute",
- "required": false,
- "schema": {
- "type": "string",
- "nullable": true
- }
- },
- {
- "name": "received_time",
- "in": "query",
- "description": "The time at which dispute is received",
- "required": false,
- "schema": {
- "type": "string",
- "format": "date-time",
- "nullable": true
- }
- },
- {
- "name": "received_time.lt",
- "in": "query",
- "description": "Time less than the dispute received time",
- "required": false,
- "schema": {
- "type": "string",
- "format": "date-time",
- "nullable": true
- }
- },
- {
- "name": "received_time.gt",
- "in": "query",
- "description": "Time greater than the dispute received time",
- "required": false,
- "schema": {
- "type": "string",
- "format": "date-time",
- "nullable": true
- }
- },
- {
- "name": "received_time.lte",
- "in": "query",
- "description": "Time less than or equals to the dispute received time",
- "required": false,
- "schema": {
- "type": "string",
- "format": "date-time",
- "nullable": true
- }
- },
- {
- "name": "received_time.gte",
- "in": "query",
- "description": "Time greater than or equals to the dispute received time",
- "required": false,
- "schema": {
- "type": "string",
- "format": "date-time",
- "nullable": true
+ "summary": "Mandates - Customer Mandates List",
+ "description": "Mandates - Customer Mandates List\n\nLists all the mandates for a particular customer id.",
+ "operationId": "List Mandates for a Customer",
+ "responses": {
+ "200": {
+ "description": "List of retrieved mandates for a customer",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/MandateResponse"
+ }
+ }
+ }
}
+ },
+ "400": {
+ "description": "Invalid Data"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
}
+ ]
+ }
+ },
+ "/customers": {
+ "post": {
+ "tags": [
+ "Customers"
],
+ "summary": "Customers - Create",
+ "description": "Customers - Create\n\nCreates a customer object and stores the customer details to be reused for future payments.\nIncase the customer already exists in the system, this API will respond with the customer details.",
+ "operationId": "Create a Customer",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CustomerRequest"
+ },
+ "examples": {
+ "Update name and email of a customer": {
+ "value": {
+ "email": "[email protected]",
+ "name": "John Doe"
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "The dispute list was retrieved successfully",
+ "description": "Customer Created",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/DisputeResponse"
- }
+ "$ref": "#/components/schemas/CustomerResponse"
}
}
}
},
- "401": {
- "description": "Unauthorized request"
+ "400": {
+ "description": "Invalid data"
}
},
"security": [
@@ -1962,19 +1960,19 @@
]
}
},
- "/disputes/{dispute_id}": {
+ "/customers/{customer_id}": {
"get": {
"tags": [
- "Disputes"
+ "Customers"
],
- "summary": "Disputes - Retrieve Dispute",
- "description": "Disputes - Retrieve Dispute\nRetrieves a dispute",
- "operationId": "Retrieve a Dispute",
+ "summary": "Customers - Retrieve",
+ "description": "Customers - Retrieve\n\nRetrieves a customer's details.",
+ "operationId": "Retrieve a Customer",
"parameters": [
{
- "name": "dispute_id",
+ "name": "customer_id",
"in": "path",
- "description": "The identifier for dispute",
+ "description": "The unique identifier for the Customer",
"required": true,
"schema": {
"type": "string"
@@ -1983,39 +1981,59 @@
],
"responses": {
"200": {
- "description": "The dispute was retrieved successfully",
+ "description": "Customer Retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/DisputeResponse"
+ "$ref": "#/components/schemas/CustomerResponse"
}
}
}
},
"404": {
- "description": "Dispute does not exist in our records"
+ "description": "Customer was not found"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "ephemeral_key": []
}
]
- }
- },
- "/gsm": {
+ },
"post": {
"tags": [
- "Gsm"
+ "Customers"
+ ],
+ "summary": "Customers - Update",
+ "description": "Customers - Update\n\nUpdates the customer's details in a customer object.",
+ "operationId": "Update a Customer",
+ "parameters": [
+ {
+ "name": "customer_id",
+ "in": "path",
+ "description": "The unique identifier for the Customer",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Gsm - Create",
- "description": "Gsm - Create\n\nCreates a GSM (Global Status Mapping) Rule. A GSM rule is used to map a connector's error message/error code combination during a particular payments flow/sub-flow to Hyperswitch's unified status/error code/error message combination. It is also used to decide the next action in the flow - retry/requeue/do_default",
- "operationId": "Create Gsm Rule",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/GsmCreateRequest"
+ "$ref": "#/components/schemas/CustomerRequest"
+ },
+ "examples": {
+ "Update name and email of a customer": {
+ "value": {
+ "email": "[email protected]",
+ "name": "John Doe"
+ }
+ }
}
}
},
@@ -2023,79 +2041,127 @@
},
"responses": {
"200": {
- "description": "Gsm created",
+ "description": "Customer was Updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/GsmResponse"
+ "$ref": "#/components/schemas/CustomerResponse"
}
}
}
},
- "400": {
- "description": "Missing Mandatory fields"
+ "404": {
+ "description": "Customer was not found"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
- }
- },
- "/gsm/delete": {
- "post": {
+ },
+ "delete": {
"tags": [
- "Gsm"
+ "Customers"
],
- "summary": "Gsm - Delete",
- "description": "Gsm - Delete\n\nDeletes a Gsm Rule",
- "operationId": "Delete Gsm Rule",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GsmDeleteRequest"
+ "summary": "Customers - Delete",
+ "description": "Customers - Delete\n\nDelete a customer record.",
+ "operationId": "Delete a Customer",
+ "parameters": [
+ {
+ "name": "customer_id",
+ "in": "path",
+ "description": "The unique identifier for the Customer",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Customer was Deleted",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CustomerDeleteResponse"
+ }
}
}
},
- "required": true
+ "404": {
+ "description": "Customer was not found"
+ }
},
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
+ "/customers/list": {
+ "post": {
+ "tags": [
+ "Customers"
+ ],
+ "summary": "Customers - List",
+ "description": "Customers - List\n\nLists all the customers for a particular merchant id.",
+ "operationId": "List all Customers for a Merchant",
"responses": {
"200": {
- "description": "Gsm deleted",
+ "description": "Customers retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/GsmDeleteResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CustomerResponse"
+ }
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Invalid Data"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
}
},
- "/gsm/get": {
+ "/payment_methods": {
"post": {
"tags": [
- "Gsm"
+ "Payment Methods"
],
- "summary": "Gsm - Get",
- "description": "Gsm - Get\n\nRetrieves a Gsm Rule",
- "operationId": "Retrieve Gsm Rule",
+ "summary": "PaymentMethods - Create",
+ "description": "PaymentMethods - Create\n\nCreates and stores a payment method against a customer.\nIn case of cards, this API should be used only by PCI compliant merchants.",
+ "operationId": "Create a Payment Method",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/GsmRetrieveRequest"
+ "$ref": "#/components/schemas/PaymentMethodCreate"
+ },
+ "examples": {
+ "Save a card": {
+ "value": {
+ "card": {
+ "card_exp_month": "11",
+ "card_exp_year": "25",
+ "card_holder_name": "John Doe",
+ "card_number": "4242424242424242"
+ },
+ "customer_id": "{{customer_id}}",
+ "payment_method": "card",
+ "payment_method_issuer": "Visa",
+ "payment_method_type": "credit"
+ }
+ }
}
}
},
@@ -2103,139 +2169,232 @@
},
"responses": {
"200": {
- "description": "Gsm retrieved",
+ "description": "Payment Method Created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/GsmResponse"
+ "$ref": "#/components/schemas/PaymentMethodResponse"
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Invalid Data"
}
},
"security": [
{
- "admin_api_key": []
+ "api_key": []
}
]
}
},
- "/gsm/update": {
- "post": {
+ "/account/payment_methods": {
+ "get": {
"tags": [
- "Gsm"
+ "Payment Methods"
],
- "summary": "Gsm - Update",
- "description": "Gsm - Update\n\nUpdates a Gsm Rule",
- "operationId": "Update Gsm Rule",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GsmUpdateRequest"
+ "summary": "List payment methods for a Merchant",
+ "description": "List payment methods for a Merchant\n\nLists the applicable payment methods for a particular Merchant ID.\nUse the client secret and publishable key authorization to list all relevant payment methods of the merchant for the payment corresponding to the client secret.",
+ "operationId": "List all Payment Methods for a Merchant",
+ "parameters": [
+ {
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "accepted_country",
+ "in": "query",
+ "description": "The two-letter ISO currency code",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "string"
}
}
},
- "required": true
- },
- "responses": {
- "200": {
- "description": "Gsm updated",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GsmResponse"
- }
+ {
+ "name": "accepted_currency",
+ "in": "path",
+ "description": "The three-letter ISO currency code",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Currency"
}
}
},
- "400": {
- "description": "Missing Mandatory fields"
- }
- },
- "security": [
{
- "admin_api_key": []
- }
- ]
- }
- },
- "/mandates/revoke/{mandate_id}": {
- "post": {
- "tags": [
- "Mandates"
- ],
- "summary": "Mandates - Revoke Mandate",
- "description": "Mandates - Revoke Mandate\n\nRevokes a mandate created using the Payments/Create API",
- "operationId": "Revoke a Mandate",
- "parameters": [
+ "name": "minimum_amount",
+ "in": "query",
+ "description": "The minimum amount accepted for processing by the particular payment method.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
{
- "name": "mandate_id",
- "in": "path",
- "description": "The identifier for a mandate",
+ "name": "maximum_amount",
+ "in": "query",
+ "description": "The maximum amount accepted for processing by the particular payment method.",
"required": true,
"schema": {
- "type": "string"
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ {
+ "name": "recurring_payment_enabled",
+ "in": "query",
+ "description": "Indicates whether the payment method is eligible for recurring payments",
+ "required": true,
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ {
+ "name": "installment_payment_enabled",
+ "in": "query",
+ "description": "Indicates whether the payment method is eligible for installment payments",
+ "required": true,
+ "schema": {
+ "type": "boolean"
}
}
],
"responses": {
"200": {
- "description": "The mandate was revoked successfully",
+ "description": "Payment Methods retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MandateRevokedResponse"
+ "$ref": "#/components/schemas/PaymentMethodListResponse"
}
}
}
},
"400": {
- "description": "Mandate does not exist in our records"
+ "description": "Invalid Data"
+ },
+ "404": {
+ "description": "Payment Methods does not exist in records"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "publishable_key": []
}
]
}
},
- "/mandates/{mandate_id}": {
+ "/customers/{customer_id}/payment_methods": {
"get": {
"tags": [
- "Mandates"
+ "Payment Methods"
],
- "summary": "Mandates - Retrieve Mandate",
- "description": "Mandates - Retrieve Mandate\n\nRetrieves a mandate created using the Payments/Create API",
- "operationId": "Retrieve a Mandate",
+ "summary": "List payment methods for a Customer",
+ "description": "List payment methods for a Customer\n\nLists all the applicable payment methods for a particular Customer ID.",
+ "operationId": "List all Payment Methods for a Customer",
"parameters": [
{
- "name": "mandate_id",
+ "name": "customer_id",
"in": "path",
- "description": "The identifier for mandate",
+ "description": "The unique identifier for the customer account",
"required": true,
"schema": {
"type": "string"
}
+ },
+ {
+ "name": "accepted_country",
+ "in": "query",
+ "description": "The two-letter ISO currency code",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "name": "accepted_currency",
+ "in": "path",
+ "description": "The three-letter ISO currency code",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Currency"
+ }
+ }
+ },
+ {
+ "name": "minimum_amount",
+ "in": "query",
+ "description": "The minimum amount accepted for processing by the particular payment method.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ {
+ "name": "maximum_amount",
+ "in": "query",
+ "description": "The maximum amount accepted for processing by the particular payment method.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ {
+ "name": "recurring_payment_enabled",
+ "in": "query",
+ "description": "Indicates whether the payment method is eligible for recurring payments",
+ "required": true,
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ {
+ "name": "installment_payment_enabled",
+ "in": "query",
+ "description": "Indicates whether the payment method is eligible for installment payments",
+ "required": true,
+ "schema": {
+ "type": "boolean"
+ }
}
],
"responses": {
"200": {
- "description": "The mandate was retrieved successfully",
+ "description": "Payment Methods retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MandateResponse"
+ "$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
}
}
}
},
+ "400": {
+ "description": "Invalid Data"
+ },
"404": {
- "description": "Mandate does not exist in our records"
+ "description": "Payment Methods does not exist in records"
}
},
"security": [
@@ -2245,112 +2404,170 @@
]
}
},
- "/payment_link/{payment_link_id}": {
+ "/customers/payment_methods": {
"get": {
"tags": [
- "Payments"
+ "Payment Methods"
],
- "summary": "Payments Link - Retrieve",
- "description": "Payments Link - Retrieve\n\nTo retrieve the properties of a Payment Link. This may be used to get the status of a previously initiated payment or next action for an ongoing payment",
- "operationId": "Retrieve a Payment Link",
+ "summary": "List customer saved payment methods for a Payment",
+ "description": "List customer saved payment methods for a Payment\n\nLists all the applicable payment methods for a particular payment tied to the `client_secret`.",
+ "operationId": "List all Payment Methods for a Customer",
"parameters": [
{
- "name": "payment_link_id",
+ "name": "client-secret",
"in": "path",
- "description": "The identifier for payment link",
+ "description": "A secret known only to your client and the authorization server. Used for client side authentication",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "customer_id",
+ "in": "path",
+ "description": "The unique identifier for the customer account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "accepted_country",
+ "in": "query",
+ "description": "The two-letter ISO currency code",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ {
+ "name": "accepted_currency",
+ "in": "path",
+ "description": "The three-letter ISO currency code",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Currency"
+ }
+ }
+ },
+ {
+ "name": "minimum_amount",
+ "in": "query",
+ "description": "The minimum amount accepted for processing by the particular payment method.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ {
+ "name": "maximum_amount",
+ "in": "query",
+ "description": "The maximum amount accepted for processing by the particular payment method.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ },
+ {
+ "name": "recurring_payment_enabled",
+ "in": "query",
+ "description": "Indicates whether the payment method is eligible for recurring payments",
+ "required": true,
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ {
+ "name": "installment_payment_enabled",
+ "in": "query",
+ "description": "Indicates whether the payment method is eligible for installment payments",
"required": true,
"schema": {
- "type": "string"
+ "type": "boolean"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/RetrievePaymentLinkRequest"
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "Gets details regarding payment link",
+ "description": "Payment Methods retrieved for customer tied to its respective client-secret passed in the param",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RetrievePaymentLinkResponse"
+ "$ref": "#/components/schemas/CustomerPaymentMethodsListResponse"
}
}
}
},
+ "400": {
+ "description": "Invalid Data"
+ },
"404": {
- "description": "No payment link found"
+ "description": "Payment Methods does not exist in records"
}
},
"security": [
- {
- "api_key": []
- },
{
"publishable_key": []
}
]
}
},
- "/payment_methods": {
- "post": {
+ "/{customer_id}/payment_methods/{payment_method_id}/default": {
+ "get": {
"tags": [
"Payment Methods"
],
- "summary": "PaymentMethods - Create",
- "description": "PaymentMethods - Create\n\nCreates and stores a payment method against a customer.\nIn case of cards, this API should be used only by PCI compliant merchants.",
- "operationId": "Create a Payment Method",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentMethodCreate"
- },
- "examples": {
- "Save a card": {
- "value": {
- "card": {
- "card_exp_month": "11",
- "card_exp_year": "25",
- "card_holder_name": "John Doe",
- "card_number": "4242424242424242"
- },
- "customer_id": "{{customer_id}}",
- "payment_method": "card",
- "payment_method_issuer": "Visa",
- "payment_method_type": "credit"
- }
- }
- }
+ "summary": "Payment Method - Set Default Payment Method for Customer",
+ "description": "Payment Method - Set Default Payment Method for Customer\n\nSet the Payment Method as Default for the Customer.",
+ "operationId": "Set the Payment Method as Default",
+ "parameters": [
+ {
+ "name": "customer_id",
+ "in": "path",
+ "description": "The unique identifier for the Customer",
+ "required": true,
+ "schema": {
+ "type": "string"
}
},
- "required": true
- },
+ {
+ "name": "payment_method_id",
+ "in": "path",
+ "description": "The unique identifier for the Payment Method",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
"responses": {
"200": {
- "description": "Payment Method Created",
+ "description": "Payment Method has been set as default",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentMethodResponse"
+ "$ref": "#/components/schemas/CustomerDefaultPaymentMethodResponse"
}
}
}
},
"400": {
- "description": "Invalid Data"
+ "description": "Payment Method has already been set as default for that customer"
+ },
+ "404": {
+ "description": "Payment Method not found for the customer"
}
},
"security": [
{
- "api_key": []
+ "ephemeral_key": []
}
]
}
@@ -2484,164 +2701,38 @@
]
}
},
- "/payments": {
+ "/account/{account_id}/business_profile": {
"post": {
"tags": [
- "Payments"
+ "Business Profile"
+ ],
+ "summary": "Business Profile - Create",
+ "description": "Business Profile - Create\n\nCreates a new *business profile* for a merchant",
+ "operationId": "Create A Business Profile",
+ "parameters": [
+ {
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Payments - Create",
- "description": "Payments - Create\n\n**Creates a payment object when amount and currency are passed.** This API is also used to create a mandate by passing the `mandate_object`.\n\nTo completely process a payment you will have to create a payment, attach a payment method, confirm and capture funds.\n\nDepending on the user journey you wish to achieve, you may opt to complete all the steps in a single request by attaching a payment method, setting `confirm=true` and `capture_method = automatic` in the *Payments/Create API* request or you could use the following sequence of API requests to achieve the same:\n\n1. Payments - Create\n\n2. Payments - Update\n\n3. Payments - Confirm\n\n4. Payments - Capture.\n\nUse the client secret returned in this API along with your publishable key to make subsequent API calls from your client",
- "operationId": "Create a Payment",
"requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentsCreateRequest"
- },
- "examples": {
- "Create a 3DS payment": {
- "value": {
- "amount": 6540,
- "authentication_type": "three_ds",
- "currency": "USD"
- }
- },
- "Create a manual capture payment": {
- "value": {
- "amount": 6540,
- "billing": {
- "address": {
- "city": "San Fransico",
- "country": "US",
- "first_name": "joseph",
- "last_name": "Doe",
- "line1": "1467",
- "line2": "Harrison Street",
- "line3": "Harrison Street",
- "state": "California",
- "zip": "94122"
- },
- "phone": {
- "country_code": "+91",
- "number": "8056594427"
- }
- },
- "currency": "USD",
- "customer": {
- "id": "cus_abcdefgh"
- }
- }
- },
- "Create a payment and save the card": {
- "value": {
- "amount": 6540,
- "authentication_type": "no_three_ds",
- "confirm": true,
- "currency": "USD",
- "customer_id": "StripeCustomer123",
- "payment_method": "card",
- "payment_method_data": {
- "card": {
- "card_cvc": "123",
- "card_exp_month": "10",
- "card_exp_year": "25",
- "card_holder_name": "joseph Doe",
- "card_number": "4242424242424242"
- }
- },
- "setup_future_usage": "off_session"
- }
- },
- "Create a payment using an already saved card's token": {
- "value": {
- "amount": 6540,
- "card_cvc": "123",
- "client_secret": "{{client_secret}}",
- "confirm": true,
- "currency": "USD",
- "payment_method": "card",
- "payment_token": "{{payment_token}}"
- }
- },
- "Create a payment with customer details and metadata": {
- "value": {
- "amount": 6540,
- "currency": "USD",
- "customer": {
- "email": "[email protected]",
- "id": "cus_abcdefgh",
- "name": "John Dough",
- "phone": "9999999999"
- },
- "description": "Its my first payment request",
- "metadata": {
- "udf1": "some-value",
- "udf2": "some-value"
- },
- "payment_id": "abcdefghijklmnopqrstuvwxyz",
- "statement_descriptor_name": "joseph",
- "statement_descriptor_suffix": "JS"
- }
- },
- "Create a payment with minimal fields": {
- "value": {
- "amount": 6540,
- "currency": "USD"
- }
- },
- "Create a recurring payment with mandate_id": {
- "value": {
- "amount": 6540,
- "authentication_type": "no_three_ds",
- "confirm": true,
- "currency": "USD",
- "customer_id": "StripeCustomer",
- "mandate_id": "{{mandate_id}}",
- "off_session": true
- }
- },
- "Create a setup mandate payment": {
- "value": {
- "amount": 6540,
- "authentication_type": "no_three_ds",
- "confirm": true,
- "currency": "USD",
- "customer_acceptance": {
- "acceptance_type": "offline",
- "accepted_at": "1963-05-03T04:07:52.723Z",
- "online": {
- "ip_address": "127.0.0.1",
- "user_agent": "amet irure esse"
- }
- },
- "customer_id": "StripeCustomer123",
- "mandate_data": {
- "customer_acceptance": {
- "acceptance_type": "offline",
- "accepted_at": "1963-05-03T04:07:52.723Z",
- "online": {
- "ip_address": "127.0.0.1",
- "user_agent": "amet irure esse"
- }
- },
- "mandate_type": {
- "single_use": {
- "amount": 6540,
- "currency": "USD"
- }
- }
- },
- "payment_method": "card",
- "payment_method_data": {
- "card": {
- "card_cvc": "123",
- "card_exp_month": "10",
- "card_exp_year": "25",
- "card_holder_name": "joseph Doe",
- "card_number": "4242424242424242"
- }
- },
- "setup_future_usage": "off_session"
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/BusinessProfileCreate"
+ },
+ "examples": {
+ "Create a business profile with minimal fields": {
+ "value": {}
+ },
+ "Create a business profile with profile name": {
+ "value": {
+ "profile_name": "shoe_business"
}
}
}
@@ -2651,139 +2742,106 @@
},
"responses": {
"200": {
- "description": "Payment created",
+ "description": "Business Account Created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsResponse"
+ "$ref": "#/components/schemas/BusinessProfileResponse"
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Invalid data"
}
},
"security": [
{
- "api_key": []
+ "admin_api_key": []
}
]
- }
- },
- "/payments/list": {
+ },
"get": {
"tags": [
- "Payments"
+ "Business Profile"
],
- "summary": "Payments - List",
- "description": "Payments - List\n\nTo list the *payments*",
- "operationId": "List all Payments",
+ "summary": "Business Profile - List",
+ "description": "Business Profile - List\n\nLists all the *business profiles* under a merchant",
+ "operationId": "List Business Profiles",
"parameters": [
{
- "name": "customer_id",
- "in": "query",
- "description": "The identifier for the customer",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "starting_after",
- "in": "query",
- "description": "A cursor for use in pagination, fetch the next list after some object",
- "required": true,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "ending_before",
- "in": "query",
- "description": "A cursor for use in pagination, fetch the previous list before some object",
+ "name": "account_id",
+ "in": "path",
+ "description": "Merchant Identifier",
"required": true,
"schema": {
"type": "string"
}
- },
- {
- "name": "limit",
- "in": "query",
- "description": "Limit on the number of objects to return",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- },
- {
- "name": "created",
- "in": "query",
- "description": "The time at which payment is created",
- "required": true,
- "schema": {
- "type": "string",
- "format": "date-time"
- }
- },
- {
- "name": "created_lt",
- "in": "query",
- "description": "Time less than the payment created time",
- "required": true,
- "schema": {
- "type": "string",
- "format": "date-time"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Business profiles Retrieved",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/BusinessProfileResponse"
+ }
+ }
+ }
}
- },
+ }
+ },
+ "security": [
{
- "name": "created_gt",
- "in": "query",
- "description": "Time greater than the payment created time",
- "required": true,
- "schema": {
- "type": "string",
- "format": "date-time"
- }
- },
+ "api_key": []
+ }
+ ]
+ }
+ },
+ "/account/{account_id}/business_profile/{profile_id}": {
+ "get": {
+ "tags": [
+ "Business Profile"
+ ],
+ "summary": "Business Profile - Retrieve",
+ "description": "Business Profile - Retrieve\n\nRetrieve existing *business profile*",
+ "operationId": "Retrieve a Business Profile",
+ "parameters": [
{
- "name": "created_lte",
- "in": "query",
- "description": "Time less than or equals to the payment created time",
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
"required": true,
"schema": {
- "type": "string",
- "format": "date-time"
+ "type": "string"
}
},
{
- "name": "created_gte",
- "in": "query",
- "description": "Time greater than or equals to the payment created time",
+ "name": "profile_id",
+ "in": "path",
+ "description": "The unique identifier for the business profile",
"required": true,
"schema": {
- "type": "string",
- "format": "date-time"
+ "type": "string"
}
}
],
"responses": {
"200": {
- "description": "Successfully retrieved a payment list",
+ "description": "Business Profile Updated",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/PaymentListResponse"
- }
+ "$ref": "#/components/schemas/BusinessProfileResponse"
}
}
}
},
- "404": {
- "description": "No payments found"
+ "400": {
+ "description": "Invalid data"
}
},
"security": [
@@ -2791,21 +2849,46 @@
"api_key": []
}
]
- }
- },
- "/payments/session_tokens": {
+ },
"post": {
"tags": [
- "Payments"
+ "Business Profile"
+ ],
+ "summary": "Business Profile - Update",
+ "description": "Business Profile - Update\n\nUpdate the *business profile*",
+ "operationId": "Update a Business Profile",
+ "parameters": [
+ {
+ "name": "account_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "profile_id",
+ "in": "path",
+ "description": "The unique identifier for the business profile",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Payments - Session token",
- "description": "Payments - Session token\n\nCreates a session object or a session token for wallets like Apple Pay, Google Pay, etc. These tokens are used by Hyperswitch's SDK to initiate these wallets' SDK.",
- "operationId": "Create Session tokens for a Payment",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsSessionRequest"
+ "$ref": "#/components/schemas/BusinessProfileCreate"
+ },
+ "examples": {
+ "Update business profile with profile name fields": {
+ "value": {
+ "profile_name": "shoe_business"
+ }
+ }
}
}
},
@@ -2813,245 +2896,277 @@
},
"responses": {
"200": {
- "description": "Payment session object created or session token was retrieved from wallets",
+ "description": "Business Profile Updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsSessionResponse"
+ "$ref": "#/components/schemas/BusinessProfileResponse"
}
}
}
},
"400": {
- "description": "Missing mandatory fields"
+ "description": "Invalid data"
}
},
"security": [
{
- "publishable_key": []
+ "api_key": []
}
]
- }
- },
- "/payments/{payment_id}": {
- "get": {
+ },
+ "delete": {
"tags": [
- "Payments"
+ "Business Profile"
],
- "summary": "Payments - Retrieve",
- "description": "Payments - Retrieve\n\nRetrieves a Payment. This API can also be used to get the status of a previously initiated payment or next action for an ongoing payment",
- "operationId": "Retrieve a Payment",
+ "summary": "Business Profile - Delete",
+ "description": "Business Profile - Delete\n\nDelete the *business profile*",
+ "operationId": "Delete the Business Profile",
"parameters": [
{
- "name": "payment_id",
+ "name": "account_id",
"in": "path",
- "description": "The identifier for payment",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "profile_id",
+ "in": "path",
+ "description": "The unique identifier for the business profile",
"required": true,
"schema": {
"type": "string"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentRetrieveBody"
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "Gets the payment with final status",
+ "description": "Business profiles Deleted",
"content": {
- "application/json": {
+ "text/plain": {
"schema": {
- "$ref": "#/components/schemas/PaymentsResponse"
+ "type": "boolean"
}
}
}
},
- "404": {
- "description": "No payment found"
+ "400": {
+ "description": "Invalid data"
}
},
"security": [
{
"api_key": []
- },
- {
- "publishable_key": []
}
]
- },
- "post": {
+ }
+ },
+ "/disputes/{dispute_id}": {
+ "get": {
"tags": [
- "Payments"
+ "Disputes"
],
- "summary": "Payments - Update",
- "description": "Payments - Update\n\nTo update the properties of a *PaymentIntent* object. This may include attaching a payment method, or attaching customer object or metadata fields after the Payment is created",
- "operationId": "Update a Payment",
+ "summary": "Disputes - Retrieve Dispute",
+ "description": "Disputes - Retrieve Dispute\nRetrieves a dispute",
+ "operationId": "Retrieve a Dispute",
"parameters": [
{
- "name": "payment_id",
+ "name": "dispute_id",
"in": "path",
- "description": "The identifier for payment",
+ "description": "The identifier for dispute",
"required": true,
"schema": {
"type": "string"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentsUpdateRequest"
- },
- "examples": {
- "Update the payment amount": {
- "value": {
- "amount": 7654
- }
- },
- "Update the shipping address": {
- "value": {
- "shipping": {
- "address": {
- "city": "San Fransico",
- "country": "US",
- "first_name": "joseph",
- "last_name": "Doe",
- "line1": "1467",
- "line2": "Harrison Street",
- "line3": "Harrison Street",
- "state": "California",
- "zip": "94122"
- },
- "phone": {
- "country_code": "+91",
- "number": "8056594427"
- }
- }
- }
- }
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "Payment updated",
+ "description": "The dispute was retrieved successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsResponse"
+ "$ref": "#/components/schemas/DisputeResponse"
}
}
}
},
- "400": {
- "description": "Missing mandatory fields"
+ "404": {
+ "description": "Dispute does not exist in our records"
}
},
"security": [
{
"api_key": []
- },
- {
- "publishable_key": []
}
]
}
},
- "/payments/{payment_id}/3ds/authentication": {
- "post": {
+ "/disputes/list": {
+ "get": {
"tags": [
- "Payments"
+ "Disputes"
],
- "summary": "Payments - External 3DS Authentication",
- "description": "Payments - External 3DS Authentication\n\nExternal 3DS Authentication is performed and returns the AuthenticationResponse",
- "operationId": "Initiate external authentication for a Payment",
+ "summary": "Disputes - List Disputes",
+ "description": "Disputes - List Disputes\nLists all the Disputes for a merchant",
+ "operationId": "List Disputes",
"parameters": [
{
- "name": "payment_id",
- "in": "path",
- "description": "The identifier for payment",
- "required": true,
+ "name": "limit",
+ "in": "query",
+ "description": "The maximum number of Dispute Objects to include in the response",
+ "required": false,
"schema": {
- "type": "string"
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
}
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentsExternalAuthenticationRequest"
- }
+ },
+ {
+ "name": "dispute_status",
+ "in": "query",
+ "description": "The status of dispute",
+ "required": false,
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/DisputeStatus"
+ }
+ ],
+ "nullable": true
}
},
- "required": true
- },
+ {
+ "name": "dispute_stage",
+ "in": "query",
+ "description": "The stage of dispute",
+ "required": false,
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/DisputeStage"
+ }
+ ],
+ "nullable": true
+ }
+ },
+ {
+ "name": "reason",
+ "in": "query",
+ "description": "The reason for dispute",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "nullable": true
+ }
+ },
+ {
+ "name": "connector",
+ "in": "query",
+ "description": "The connector linked to dispute",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "nullable": true
+ }
+ },
+ {
+ "name": "received_time",
+ "in": "query",
+ "description": "The time at which dispute is received",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ },
+ {
+ "name": "received_time.lt",
+ "in": "query",
+ "description": "Time less than the dispute received time",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ },
+ {
+ "name": "received_time.gt",
+ "in": "query",
+ "description": "Time greater than the dispute received time",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ },
+ {
+ "name": "received_time.lte",
+ "in": "query",
+ "description": "Time less than or equals to the dispute received time",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ },
+ {
+ "name": "received_time.gte",
+ "in": "query",
+ "description": "Time greater than or equals to the dispute received time",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ }
+ ],
"responses": {
"200": {
- "description": "Authentication created",
+ "description": "The dispute list was retrieved successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsExternalAuthenticationResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DisputeResponse"
+ }
}
}
}
},
- "400": {
- "description": "Missing mandatory fields"
+ "401": {
+ "description": "Unauthorized request"
}
},
"security": [
{
- "publishable_key": []
+ "api_key": []
}
]
}
},
- "/payments/{payment_id}/cancel": {
+ "/routing": {
"post": {
"tags": [
- "Payments"
- ],
- "summary": "Payments - Cancel",
- "description": "Payments - Cancel\n\nA Payment could can be cancelled when it is in one of these statuses: `requires_payment_method`, `requires_capture`, `requires_confirmation`, `requires_customer_action`.",
- "operationId": "Cancel a Payment",
- "parameters": [
- {
- "name": "payment_id",
- "in": "path",
- "description": "The identifier for payment",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
+ "Routing"
],
+ "summary": "Routing - Create",
+ "description": "Routing - Create\n\nCreate a routing config",
+ "operationId": "Create a routing config",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsCancelRequest"
- },
- "examples": {
- "Cancel the payment with cancellation reason": {
- "value": {
- "cancellation_reason": "requested_by_customer"
- }
- },
- "Cancel the payment with minimal fields": {
- "value": {}
- }
+ "$ref": "#/components/schemas/RoutingConfigRequest"
}
}
},
@@ -3059,147 +3174,149 @@
},
"responses": {
"200": {
- "description": "Payment canceled"
+ "description": "Routing config created",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/RoutingDictionaryRecord"
+ }
+ }
+ }
},
"400": {
- "description": "Missing mandatory fields"
+ "description": "Request body is malformed"
+ },
+ "403": {
+ "description": "Forbidden"
+ },
+ "404": {
+ "description": "Resource missing"
+ },
+ "422": {
+ "description": "Unprocessable request"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
- }
- },
- "/payments/{payment_id}/capture": {
- "post": {
+ },
+ "get": {
"tags": [
- "Payments"
+ "Routing"
],
- "summary": "Payments - Capture",
- "description": "Payments - Capture\n\nTo capture the funds for an uncaptured payment",
- "operationId": "Capture a Payment",
+ "summary": "Routing - List",
+ "description": "Routing - List\n\nList all routing configs",
+ "operationId": "List routing configs",
"parameters": [
{
- "name": "payment_id",
- "in": "path",
- "description": "The identifier for payment",
- "required": true,
+ "name": "limit",
+ "in": "query",
+ "description": "The number of records to be returned",
+ "required": false,
"schema": {
- "type": "string"
+ "type": "integer",
+ "format": "int32",
+ "nullable": true,
+ "minimum": 0
}
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentsCaptureRequest"
- },
- "examples": {
- "Capture partial amount": {
- "value": {
- "amount_to_capture": 654
- }
- },
- "Capture the full amount": {
- "value": {}
- }
- }
+ },
+ {
+ "name": "offset",
+ "in": "query",
+ "description": "The record offset from which to start gathering of results",
+ "required": false,
+ "schema": {
+ "type": "integer",
+ "format": "int32",
+ "nullable": true,
+ "minimum": 0
}
},
- "required": true
- },
+ {
+ "name": "profile_id",
+ "in": "query",
+ "description": "The unique identifier for a merchant profile",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "nullable": true
+ }
+ }
+ ],
"responses": {
"200": {
- "description": "Payment captured",
+ "description": "Successfully fetched routing configs",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsResponse"
+ "$ref": "#/components/schemas/RoutingKind"
}
}
}
},
- "400": {
- "description": "Missing mandatory fields"
+ "404": {
+ "description": "Resource missing"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
}
},
- "/payments/{payment_id}/confirm": {
+ "/routing/{algorithm_id}/activate": {
"post": {
"tags": [
- "Payments"
+ "Routing"
],
- "summary": "Payments - Confirm",
- "description": "Payments - Confirm\n\n**Use this API to confirm the payment and forward the payment to the payment processor.**\n\nAlternatively you can confirm the payment within the *Payments/Create* API by setting `confirm=true`. After confirmation, the payment could either:\n\n1. fail with `failed` status or\n\n2. transition to a `requires_customer_action` status with a `next_action` block or\n\n3. succeed with either `succeeded` in case of automatic capture or `requires_capture` in case of manual capture",
- "operationId": "Confirm a Payment",
+ "summary": "Routing - Activate config",
+ "description": "Routing - Activate config\n\nActivate a routing config",
+ "operationId": "Activate a routing config",
"parameters": [
{
- "name": "payment_id",
+ "name": "algorithm_id",
"in": "path",
- "description": "The identifier for payment",
+ "description": "The unique identifier for a config",
"required": true,
"schema": {
"type": "string"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentsConfirmRequest"
- },
- "examples": {
- "Confirm a payment with payment method data": {
- "value": {
- "customer_acceptance": {
- "acceptance_type": "offline",
- "accepted_at": "1963-05-03T04:07:52.723Z",
- "online": {
- "ip_address": "127.0.0.1",
- "user_agent": "amet irure esse"
- }
- },
- "payment_method": "card",
- "payment_method_data": {
- "card": {
- "card_cvc": "123",
- "card_exp_month": "10",
- "card_exp_year": "25",
- "card_holder_name": "joseph Doe",
- "card_number": "4242424242424242"
- }
- },
- "payment_method_type": "credit"
- }
- }
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "Payment confirmed",
+ "description": "Routing config activated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsResponse"
+ "$ref": "#/components/schemas/RoutingDictionaryRecord"
}
}
}
},
"400": {
- "description": "Missing mandatory fields"
+ "description": "Bad request"
+ },
+ "404": {
+ "description": "Resource missing"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
@@ -3207,75 +3324,74 @@
"api_key": []
},
{
- "publishable_key": []
+ "jwt_key": []
}
]
}
},
- "/payments/{payment_id}/incremental_authorization": {
- "post": {
+ "/routing/{algorithm_id}": {
+ "get": {
"tags": [
- "Payments"
+ "Routing"
],
- "summary": "Payments - Incremental Authorization",
- "description": "Payments - Incremental Authorization\n\nAuthorized amount for a payment can be incremented if it is in status: requires_capture",
- "operationId": "Increment authorized amount for a Payment",
+ "summary": "Routing - Retrieve",
+ "description": "Routing - Retrieve\n\nRetrieve a routing algorithm",
+ "operationId": "Retrieve a routing config",
"parameters": [
{
- "name": "payment_id",
+ "name": "algorithm_id",
"in": "path",
- "description": "The identifier for payment",
+ "description": "The unique identifier for a config",
"required": true,
"schema": {
"type": "string"
}
}
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PaymentsIncrementalAuthorizationRequest"
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "Payment authorized amount incremented",
+ "description": "Successfully fetched routing config",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentsResponse"
+ "$ref": "#/components/schemas/MerchantRoutingAlgorithm"
}
}
}
},
- "400": {
- "description": "Missing mandatory fields"
+ "403": {
+ "description": "Forbidden"
+ },
+ "404": {
+ "description": "Resource missing"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
}
},
- "/payouts/create": {
+ "/routing/deactivate": {
"post": {
"tags": [
- "Payouts"
+ "Routing"
],
- "summary": "Payouts - Create",
- "description": "Payouts - Create",
- "operationId": "Create a Payout",
+ "summary": "Routing - Deactivate",
+ "description": "Routing - Deactivate\n\nDeactivates a routing config",
+ "operationId": "Deactivate a routing config",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutCreateRequest"
+ "$ref": "#/components/schemas/RoutingConfigRequest"
}
}
},
@@ -3283,187 +3399,227 @@
},
"responses": {
"200": {
- "description": "Payout created",
+ "description": "Successfully deactivated routing config",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutCreateResponse"
+ "$ref": "#/components/schemas/RoutingDictionaryRecord"
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Malformed request"
+ },
+ "403": {
+ "description": "Malformed request"
+ },
+ "422": {
+ "description": "Unprocessable request"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
}
},
- "/payouts/list": {
- "get": {
+ "/routing/default": {
+ "post": {
"tags": [
- "Payouts"
+ "Routing"
],
- "summary": "Payouts - List",
- "description": "Payouts - List",
- "operationId": "List payouts",
+ "summary": "Routing - Update Default Config",
+ "description": "Routing - Update Default Config\n\nUpdate default fallback config",
+ "operationId": "Update default fallback config",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/RoutableConnectorChoice"
+ }
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Payouts listed",
+ "description": "Successfully updated default config",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutListResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/RoutableConnectorChoice"
+ }
}
}
}
},
- "404": {
- "description": "Payout not found"
+ "400": {
+ "description": "Malformed request"
+ },
+ "422": {
+ "description": "Unprocessable request"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
},
- "post": {
+ "get": {
"tags": [
- "Payouts"
+ "Routing"
],
- "summary": "Payouts - Filter",
- "description": "Payouts - Filter",
- "operationId": "Filter payouts",
+ "summary": "Routing - Retrieve Default Config",
+ "description": "Routing - Retrieve Default Config\n\nRetrieve default fallback config",
+ "operationId": "Retrieve default fallback config",
"responses": {
"200": {
- "description": "Payouts filtered",
+ "description": "Successfully retrieved default config",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutListResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/RoutableConnectorChoice"
+ }
}
}
}
},
- "404": {
- "description": "Payout not found"
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
}
},
- "/payouts/{payout_id}": {
+ "/routing/active": {
"get": {
"tags": [
- "Payouts"
+ "Routing"
],
- "summary": "Payouts - Retrieve",
- "description": "Payouts - Retrieve",
- "operationId": "Retrieve a Payout",
+ "summary": "Routing - Retrieve Config",
+ "description": "Routing - Retrieve Config\n\nRetrieve active config",
+ "operationId": "Retrieve active config",
"parameters": [
{
- "name": "payout_id",
- "in": "path",
- "description": "The identifier for payout]",
- "required": true,
+ "name": "profile_id",
+ "in": "query",
+ "description": "The unique identifier for a merchant profile",
+ "required": false,
"schema": {
- "type": "string"
+ "type": "string",
+ "nullable": true
}
}
],
"responses": {
"200": {
- "description": "Payout retrieved",
+ "description": "Successfully retrieved active config",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutCreateResponse"
+ "$ref": "#/components/schemas/LinkedRoutingConfigRetrieveResponse"
}
}
}
},
+ "403": {
+ "description": "Forbidden"
+ },
"404": {
- "description": "Payout does not exist in our records"
+ "description": "Resource missing"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
- },
- "post": {
+ }
+ },
+ "/routing/default/profile": {
+ "get": {
"tags": [
- "Payouts"
- ],
- "summary": "Payouts - Update",
- "description": "Payouts - Update",
- "operationId": "Update a Payout",
- "parameters": [
- {
- "name": "payout_id",
- "in": "path",
- "description": "The identifier for payout]",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
+ "Routing"
],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PayoutCreateRequest"
- }
- }
- },
- "required": true
- },
+ "summary": "Routing - Retrieve Default For Profile",
+ "description": "Routing - Retrieve Default For Profile\n\nRetrieve default config for profiles",
+ "operationId": "Retrieve default configs for all profiles",
"responses": {
"200": {
- "description": "Payout updated",
+ "description": "Successfully retrieved default config",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutCreateResponse"
+ "$ref": "#/components/schemas/ProfileDefaultRoutingConfig"
}
}
}
},
- "400": {
- "description": "Missing Mandatory fields"
+ "404": {
+ "description": "Resource missing"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
}
},
- "/payouts/{payout_id}/cancel": {
+ "/routing/default/profile/{profile_id}": {
"post": {
"tags": [
- "Payouts"
+ "Routing"
],
- "summary": "Payouts - Cancel",
- "description": "Payouts - Cancel",
- "operationId": "Cancel a Payout",
+ "summary": "Routing - Update Default For Profile",
+ "description": "Routing - Update Default For Profile\n\nUpdate default config for profiles",
+ "operationId": "Update default configs for all profiles",
"parameters": [
{
- "name": "payout_id",
+ "name": "profile_id",
"in": "path",
- "description": "The identifier for payout",
+ "description": "The unique identifier for a profile",
"required": true,
"schema": {
"type": "string"
@@ -3474,7 +3630,10 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutActionRequest"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/RoutableConnectorChoice"
+ }
}
}
},
@@ -3482,50 +3641,52 @@
},
"responses": {
"200": {
- "description": "Payout cancelled",
+ "description": "Successfully updated default config for profile",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutCreateResponse"
+ "$ref": "#/components/schemas/ProfileDefaultRoutingConfig"
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Malformed request"
+ },
+ "403": {
+ "description": "Forbidden"
+ },
+ "404": {
+ "description": "Resource missing"
+ },
+ "422": {
+ "description": "Unprocessable request"
+ },
+ "500": {
+ "description": "Internal server error"
}
},
"security": [
{
"api_key": []
+ },
+ {
+ "jwt_key": []
}
]
}
},
- "/payouts/{payout_id}/fulfill": {
- "post": {
+ "/blocklist": {
+ "delete": {
"tags": [
- "Payouts"
- ],
- "summary": "Payouts - Fulfill",
- "description": "Payouts - Fulfill",
- "operationId": "Fulfill a Payout",
- "parameters": [
- {
- "name": "payout_id",
- "in": "path",
- "description": "The identifier for payout",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
+ "Blocklist"
],
+ "operationId": "Unblock a Fingerprint",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutActionRequest"
+ "$ref": "#/components/schemas/BlocklistRequest"
}
}
},
@@ -3533,17 +3694,17 @@
},
"responses": {
"200": {
- "description": "Payout fulfilled",
+ "description": "Fingerprint Unblocked",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PayoutCreateResponse"
+ "$ref": "#/components/schemas/BlocklistResponse"
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Invalid Data"
}
},
"security": [
@@ -3551,62 +3712,36 @@
"api_key": []
}
]
- }
- },
- "/refunds": {
- "post": {
+ },
+ "get": {
"tags": [
- "Refunds"
+ "Blocklist"
+ ],
+ "operationId": "List Blocked fingerprints of a particular kind",
+ "parameters": [
+ {
+ "name": "data_kind",
+ "in": "query",
+ "description": "Kind of the fingerprint list requested",
+ "required": true,
+ "schema": {
+ "$ref": "#/components/schemas/BlocklistDataKind"
+ }
+ }
],
- "summary": "Refunds - Create",
- "description": "Refunds - Create\n\nCreates a refund against an already processed payment. In case of some processors, you can even opt to refund only a partial amount multiple times until the original charge amount has been refunded",
- "operationId": "Create a Refund",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/RefundRequest"
- },
- "examples": {
- "Create an instant refund to refund partial amount": {
- "value": {
- "amount": 654,
- "payment_id": "{{payment_id}}",
- "refund_type": "instant"
- }
- },
- "Create an instant refund to refund the whole amount": {
- "value": {
- "payment_id": "{{payment_id}}",
- "refund_type": "instant"
- }
- },
- "Create an instant refund with reason": {
- "value": {
- "amount": 6540,
- "payment_id": "{{payment_id}}",
- "reason": "Customer returned product",
- "refund_type": "instant"
- }
- }
- }
- }
- },
- "required": true
- },
"responses": {
"200": {
- "description": "Refund created",
+ "description": "Blocked Fingerprints",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RefundResponse"
+ "$ref": "#/components/schemas/BlocklistResponse"
}
}
}
},
"400": {
- "description": "Missing Mandatory fields"
+ "description": "Invalid Data"
}
},
"security": [
@@ -3614,21 +3749,17 @@
"api_key": []
}
]
- }
- },
- "/refunds/list": {
+ },
"post": {
"tags": [
- "Refunds"
+ "Blocklist"
],
- "summary": "Refunds - List",
- "description": "Refunds - List\n\nLists all the refunds associated with the merchant or a payment_id if payment_id is not provided",
- "operationId": "List all Refunds",
+ "operationId": "Block a Fingerprint",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RefundListRequest"
+ "$ref": "#/components/schemas/BlocklistRequest"
}
}
},
@@ -3636,14 +3767,17 @@
},
"responses": {
"200": {
- "description": "List of refunds",
+ "description": "Fingerprint Blocked",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RefundListResponse"
+ "$ref": "#/components/schemas/BlocklistResponse"
}
}
}
+ },
+ "400": {
+ "description": "Invalid Data"
}
},
"security": [
@@ -3653,38 +3787,36 @@
]
}
},
- "/refunds/{refund_id}": {
- "get": {
+ "/blocklist/toggle": {
+ "post": {
"tags": [
- "Refunds"
+ "Blocklist"
],
- "summary": "Refunds - Retrieve",
- "description": "Refunds - Retrieve\n\nRetrieves a Refund. This may be used to get the status of a previously initiated refund",
- "operationId": "Retrieve a Refund",
+ "operationId": "Toggle blocklist guard for a particular merchant",
"parameters": [
{
- "name": "refund_id",
- "in": "path",
- "description": "The identifier for refund",
+ "name": "status",
+ "in": "query",
+ "description": "Boolean value to enable/disable blocklist",
"required": true,
"schema": {
- "type": "string"
+ "type": "boolean"
}
}
],
"responses": {
"200": {
- "description": "Refund retrieved",
+ "description": "Blocklist guard enabled/disabled",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RefundResponse"
+ "$ref": "#/components/schemas/ToggleBlocklistResponse"
}
}
}
},
- "404": {
- "description": "Refund does not exist in our records"
+ "400": {
+ "description": "Invalid Data"
}
},
"security": [
@@ -3692,37 +3824,21 @@
"api_key": []
}
]
- },
+ }
+ },
+ "/payouts/create": {
"post": {
"tags": [
- "Refunds"
- ],
- "summary": "Refunds - Update",
- "description": "Refunds - Update\n\nUpdates the properties of a Refund object. This API can be used to attach a reason for the refund or metadata fields",
- "operationId": "Update a Refund",
- "parameters": [
- {
- "name": "refund_id",
- "in": "path",
- "description": "The identifier for refund",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
+ "Payouts"
],
+ "summary": "Payouts - Create",
+ "description": "Payouts - Create",
+ "operationId": "Create a Payout",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RefundUpdateRequest"
- },
- "examples": {
- "Update refund reason": {
- "value": {
- "reason": "Paid by mistake"
- }
- }
+ "$ref": "#/components/schemas/PayoutCreateRequest"
}
}
},
@@ -3730,11 +3846,11 @@
},
"responses": {
"200": {
- "description": "Refund updated",
+ "description": "Payout created",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RefundResponse"
+ "$ref": "#/components/schemas/PayoutCreateResponse"
}
}
}
@@ -3750,195 +3866,178 @@
]
}
},
- "/routing": {
+ "/payouts/list": {
"get": {
"tags": [
- "Routing"
- ],
- "summary": "Routing - List",
- "description": "Routing - List\n\nList all routing configs",
- "operationId": "List routing configs",
- "parameters": [
- {
- "name": "limit",
- "in": "query",
- "description": "The number of records to be returned",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int32",
- "nullable": true,
- "minimum": 0
- }
- },
- {
- "name": "offset",
- "in": "query",
- "description": "The record offset from which to start gathering of results",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int32",
- "nullable": true,
- "minimum": 0
- }
- },
- {
- "name": "profile_id",
- "in": "query",
- "description": "The unique identifier for a merchant profile",
- "required": false,
- "schema": {
- "type": "string",
- "nullable": true
- }
- }
+ "Payouts"
],
+ "summary": "Payouts - List",
+ "description": "Payouts - List",
+ "operationId": "List payouts",
"responses": {
"200": {
- "description": "Successfully fetched routing configs",
+ "description": "Payouts listed",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RoutingKind"
+ "$ref": "#/components/schemas/PayoutListResponse"
}
}
}
},
"404": {
- "description": "Resource missing"
- },
- "500": {
- "description": "Internal server error"
+ "description": "Payout not found"
}
},
"security": [
{
"api_key": []
- },
- {
- "jwt_key": []
}
]
},
"post": {
"tags": [
- "Routing"
+ "Payouts"
],
- "summary": "Routing - Create",
- "description": "Routing - Create\n\nCreate a routing config",
- "operationId": "Create a routing config",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/RoutingConfigRequest"
+ "summary": "Payouts - Filter",
+ "description": "Payouts - Filter",
+ "operationId": "Filter payouts",
+ "responses": {
+ "200": {
+ "description": "Payouts filtered",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PayoutListResponse"
+ }
}
}
},
- "required": true
+ "404": {
+ "description": "Payout not found"
+ }
},
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
+ "/payouts/{payout_id}": {
+ "get": {
+ "tags": [
+ "Payouts"
+ ],
+ "summary": "Payouts - Retrieve",
+ "description": "Payouts - Retrieve",
+ "operationId": "Retrieve a Payout",
+ "parameters": [
+ {
+ "name": "payout_id",
+ "in": "path",
+ "description": "The identifier for payout]",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
"responses": {
"200": {
- "description": "Routing config created",
+ "description": "Payout retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RoutingDictionaryRecord"
+ "$ref": "#/components/schemas/PayoutCreateResponse"
}
}
}
},
- "400": {
- "description": "Request body is malformed"
- },
- "403": {
- "description": "Forbidden"
- },
"404": {
- "description": "Resource missing"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
+ "description": "Payout does not exist in our records"
}
},
"security": [
{
"api_key": []
- },
- {
- "jwt_key": []
}
]
- }
- },
- "/routing/active": {
- "get": {
+ },
+ "post": {
"tags": [
- "Routing"
+ "Payouts"
],
- "summary": "Routing - Retrieve Config",
- "description": "Routing - Retrieve Config\n\nRetrieve active config",
- "operationId": "Retrieve active config",
+ "summary": "Payouts - Update",
+ "description": "Payouts - Update",
+ "operationId": "Update a Payout",
"parameters": [
{
- "name": "profile_id",
- "in": "query",
- "description": "The unique identifier for a merchant profile",
- "required": false,
+ "name": "payout_id",
+ "in": "path",
+ "description": "The identifier for payout]",
+ "required": true,
"schema": {
- "type": "string",
- "nullable": true
+ "type": "string"
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PayoutCreateRequest"
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Successfully retrieved active config",
+ "description": "Payout updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/LinkedRoutingConfigRetrieveResponse"
+ "$ref": "#/components/schemas/PayoutCreateResponse"
}
}
}
},
- "403": {
- "description": "Forbidden"
- },
- "404": {
- "description": "Resource missing"
- },
- "500": {
- "description": "Internal server error"
+ "400": {
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
"api_key": []
- },
- {
- "jwt_key": []
}
]
}
},
- "/routing/deactivate": {
+ "/payouts/{payout_id}/cancel": {
"post": {
"tags": [
- "Routing"
+ "Payouts"
+ ],
+ "summary": "Payouts - Cancel",
+ "description": "Payouts - Cancel",
+ "operationId": "Cancel a Payout",
+ "parameters": [
+ {
+ "name": "payout_id",
+ "in": "path",
+ "description": "The identifier for payout",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Routing - Deactivate",
- "description": "Routing - Deactivate\n\nDeactivates a routing config",
- "operationId": "Deactivate a routing config",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RoutingConfigRequest"
+ "$ref": "#/components/schemas/PayoutActionRequest"
}
}
},
@@ -3946,88 +4045,101 @@
},
"responses": {
"200": {
- "description": "Successfully deactivated routing config",
+ "description": "Payout cancelled",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RoutingDictionaryRecord"
+ "$ref": "#/components/schemas/PayoutCreateResponse"
}
}
}
},
"400": {
- "description": "Malformed request"
- },
- "403": {
- "description": "Malformed request"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
"api_key": []
- },
- {
- "jwt_key": []
}
]
}
},
- "/routing/default": {
- "get": {
+ "/payouts/{payout_id}/fulfill": {
+ "post": {
"tags": [
- "Routing"
+ "Payouts"
],
- "summary": "Routing - Retrieve Default Config",
- "description": "Routing - Retrieve Default Config\n\nRetrieve default fallback config",
- "operationId": "Retrieve default fallback config",
+ "summary": "Payouts - Fulfill",
+ "description": "Payouts - Fulfill",
+ "operationId": "Fulfill a Payout",
+ "parameters": [
+ {
+ "name": "payout_id",
+ "in": "path",
+ "description": "The identifier for payout",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PayoutActionRequest"
+ }
+ }
+ },
+ "required": true
+ },
"responses": {
"200": {
- "description": "Successfully retrieved default config",
+ "description": "Payout fulfilled",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/RoutableConnectorChoice"
- }
+ "$ref": "#/components/schemas/PayoutCreateResponse"
}
}
}
},
- "500": {
- "description": "Internal server error"
+ "400": {
+ "description": "Missing Mandatory fields"
}
},
"security": [
{
"api_key": []
- },
- {
- "jwt_key": []
}
]
- },
+ }
+ },
+ "/api_keys/{merchant_id)": {
"post": {
"tags": [
- "Routing"
+ "API Key"
+ ],
+ "summary": "API Key - Create",
+ "description": "API Key - Create\n\nCreate a new API Key for accessing our APIs from your servers. The plaintext API Key will be\ndisplayed only once on creation, so ensure you store it securely.",
+ "operationId": "Create an API Key",
+ "parameters": [
+ {
+ "name": "merchant_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Routing - Update Default Config",
- "description": "Routing - Update Default Config\n\nUpdate default fallback config",
- "operationId": "Update default fallback config",
"requestBody": {
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/RoutableConnectorChoice"
- }
+ "$ref": "#/components/schemas/CreateApiKeyRequest"
}
}
},
@@ -4035,87 +4147,96 @@
},
"responses": {
"200": {
- "description": "Successfully updated default config",
+ "description": "API Key created",
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/RoutableConnectorChoice"
- }
+ "$ref": "#/components/schemas/CreateApiKeyResponse"
}
}
}
},
"400": {
- "description": "Malformed request"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
+ "description": "Invalid data"
}
},
"security": [
{
- "api_key": []
- },
- {
- "jwt_key": []
+ "admin_api_key": []
}
]
}
},
- "/routing/default/profile": {
+ "/api_keys/{merchant_id}/{key_id}": {
"get": {
"tags": [
- "Routing"
+ "API Key"
+ ],
+ "summary": "API Key - Retrieve",
+ "description": "API Key - Retrieve\n\nRetrieve information about the specified API Key.",
+ "operationId": "Retrieve an API Key",
+ "parameters": [
+ {
+ "name": "merchant_id",
+ "in": "path",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "key_id",
+ "in": "path",
+ "description": "The unique identifier for the API Key",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
],
- "summary": "Routing - Retrieve Default For Profile",
- "description": "Routing - Retrieve Default For Profile\n\nRetrieve default config for profiles",
- "operationId": "Retrieve default configs for all profiles",
"responses": {
"200": {
- "description": "Successfully retrieved default config",
+ "description": "API Key retrieved",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ProfileDefaultRoutingConfig"
+ "$ref": "#/components/schemas/RetrieveApiKeyResponse"
}
}
}
},
"404": {
- "description": "Resource missing"
- },
- "500": {
- "description": "Internal server error"
+ "description": "API Key not found"
}
},
"security": [
{
- "api_key": []
- },
- {
- "jwt_key": []
+ "admin_api_key": []
}
]
- }
- },
- "/routing/default/profile/{profile_id}": {
+ },
"post": {
"tags": [
- "Routing"
+ "API Key"
],
- "summary": "Routing - Update Default For Profile",
- "description": "Routing - Update Default For Profile\n\nUpdate default config for profiles",
- "operationId": "Update default configs for all profiles",
+ "summary": "API Key - Update",
+ "description": "API Key - Update\n\nUpdate information for the specified API Key.",
+ "operationId": "Update an API Key",
"parameters": [
{
- "name": "profile_id",
+ "name": "merchant_id",
"in": "path",
- "description": "The unique identifier for a profile",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "key_id",
+ "in": "path",
+ "description": "The unique identifier for the API Key",
"required": true,
"schema": {
"type": "string"
@@ -4126,10 +4247,7 @@
"content": {
"application/json": {
"schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/RoutableConnectorChoice"
- }
+ "$ref": "#/components/schemas/UpdateApiKeyRequest"
}
}
},
@@ -4137,54 +4255,48 @@
},
"responses": {
"200": {
- "description": "Successfully updated default config for profile",
+ "description": "API Key updated",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ProfileDefaultRoutingConfig"
+ "$ref": "#/components/schemas/RetrieveApiKeyResponse"
}
}
}
},
- "400": {
- "description": "Malformed request"
- },
- "403": {
- "description": "Forbidden"
- },
"404": {
- "description": "Resource missing"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
+ "description": "API Key not found"
}
},
"security": [
{
- "api_key": []
- },
- {
- "jwt_key": []
+ "admin_api_key": []
}
]
}
},
- "/routing/{algorithm_id}": {
- "get": {
+ "/api_keys/{merchant_id)/{key_id}": {
+ "delete": {
"tags": [
- "Routing"
+ "API Key"
],
- "summary": "Routing - Retrieve",
- "description": "Routing - Retrieve\n\nRetrieve a routing algorithm",
- "operationId": "Retrieve a routing config",
+ "summary": "API Key - Revoke",
+ "description": "API Key - Revoke\n\nRevoke the specified API Key. Once revoked, the API Key can no longer be used for\nauthenticating with our APIs.",
+ "operationId": "Revoke an API Key",
"parameters": [
{
- "name": "algorithm_id",
+ "name": "merchant_id",
"in": "path",
- "description": "The unique identifier for a config",
+ "description": "The unique identifier for the merchant account",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "key_id",
+ "in": "path",
+ "description": "The unique identifier for the API Key",
"required": true,
"schema": {
"type": "string"
@@ -4193,107 +4305,143 @@
],
"responses": {
"200": {
- "description": "Successfully fetched routing config",
+ "description": "API Key revoked",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/MerchantRoutingAlgorithm"
+ "$ref": "#/components/schemas/RevokeApiKeyResponse"
}
}
}
},
- "403": {
- "description": "Forbidden"
- },
"404": {
- "description": "Resource missing"
- },
- "500": {
- "description": "Internal server error"
+ "description": "API Key not found"
}
},
"security": [
{
- "api_key": []
- },
- {
- "jwt_key": []
+ "admin_api_key": []
}
]
}
},
- "/routing/{algorithm_id}/activate": {
- "post": {
+ "/events/{merchant_id}": {
+ "get": {
"tags": [
- "Routing"
+ "Event"
],
- "summary": "Routing - Activate config",
- "description": "Routing - Activate config\n\nActivate a routing config",
- "operationId": "Activate a routing config",
+ "summary": "Events - List",
+ "description": "Events - List\n\nList all Events associated with a Merchant Account.",
+ "operationId": "List all Events associated with a Merchant Account",
"parameters": [
{
- "name": "algorithm_id",
+ "name": "merchant_id",
"in": "path",
- "description": "The unique identifier for a config",
+ "description": "The unique identifier for the Merchant Account",
"required": true,
"schema": {
"type": "string"
}
+ },
+ {
+ "name": "created_after",
+ "in": "query",
+ "description": "Only include Events created after the specified time. Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ },
+ {
+ "name": "created_before",
+ "in": "query",
+ "description": "Only include Events created before the specified time. Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "date-time",
+ "nullable": true
+ }
+ },
+ {
+ "name": "limit",
+ "in": "query",
+ "description": "The maximum number of Events to include in the response. Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified.",
+ "required": false,
+ "schema": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ }
+ },
+ {
+ "name": "offset",
+ "in": "query",
+ "description": "The number of Events to skip when retrieving the list of Events.\n Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified.",
+ "required": false,
+ "schema": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ }
+ },
+ {
+ "name": "object_id",
+ "in": "query",
+ "description": "Only include Events associated with the specified object (Payment Intent ID, Refund ID, etc.). Either only `object_id` must be specified, or one or more of `created_after`, `created_before`, `limit` and `offset` must be specified.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "nullable": true
+ }
}
],
"responses": {
"200": {
- "description": "Routing config activated",
+ "description": "List of Events retrieved successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/RoutingDictionaryRecord"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/EventListItemResponse"
+ }
}
}
}
- },
- "400": {
- "description": "Bad request"
- },
- "404": {
- "description": "Resource missing"
- },
- "500": {
- "description": "Internal server error"
}
},
"security": [
{
- "api_key": []
- },
- {
- "jwt_key": []
+ "admin_api_key": []
}
]
}
},
- "/{customer_id}/payment_methods/{payment_method_id}/default": {
+ "/events/{merchant_id}/{event_id}/attempts": {
"get": {
"tags": [
- "Customer Set Default Payment Method"
+ "Event"
],
- "summary": "Customers - Set Default Payment Method",
- "description": "Customers - Set Default Payment Method\n\nSet the Payment Method as Default for the Customer.",
- "operationId": "Set the Payment Method as Default",
+ "summary": "Events - Delivery Attempt List",
+ "description": "Events - Delivery Attempt List\n\nList all delivery attempts for the specified Event.",
+ "operationId": "List all delivery attempts for an Event",
"parameters": [
{
- "name": "customer_id",
+ "name": "merchant_id",
"in": "path",
- "description": "The unique identifier for the Customer",
+ "description": "The unique identifier for the Merchant Account",
"required": true,
"schema": {
"type": "string"
}
},
{
- "name": "payment_method_id",
+ "name": "event_id",
"in": "path",
- "description": "The unique identifier for the Payment Method",
+ "description": "The unique identifier for the Event",
"required": true,
"schema": {
"type": "string"
@@ -4302,25 +4450,22 @@
],
"responses": {
"200": {
- "description": "Payment Method has been set as default",
+ "description": "List of delivery attempts retrieved successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/CustomerDefaultPaymentMethodResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/EventRetrieveResponse"
+ }
}
}
}
- },
- "400": {
- "description": "Payment Method has already been set as default for that customer"
- },
- "404": {
- "description": "Payment Method not found for the customer"
}
},
"security": [
{
- "ephemeral_key": []
+ "admin_api_key": []
}
]
}
@@ -8291,6 +8436,109 @@
}
}
},
+ "EventClass": {
+ "type": "string",
+ "enum": [
+ "payments",
+ "refunds",
+ "disputes",
+ "mandates"
+ ]
+ },
+ "EventListItemResponse": {
+ "type": "object",
+ "description": "The response body for each item when listing events.",
+ "required": [
+ "event_id",
+ "merchant_id",
+ "profile_id",
+ "object_id",
+ "event_type",
+ "event_class",
+ "is_delivery_successful",
+ "initial_attempt_id",
+ "created"
+ ],
+ "properties": {
+ "event_id": {
+ "type": "string",
+ "description": "The identifier for the Event.",
+ "example": "evt_018e31720d1b7a2b82677d3032cab959",
+ "maxLength": 64
+ },
+ "merchant_id": {
+ "type": "string",
+ "description": "The identifier for the Merchant Account.",
+ "example": "y3oqhf46pyzuxjbcn2giaqnb44",
+ "maxLength": 64
+ },
+ "profile_id": {
+ "type": "string",
+ "description": "The identifier for the Business Profile.",
+ "example": "SqB0zwDGR5wHppWf0bx7GKr1f2",
+ "maxLength": 64
+ },
+ "object_id": {
+ "type": "string",
+ "description": "The identifier for the object (Payment Intent ID, Refund ID, etc.)",
+ "example": "QHrfd5LUDdZaKtAjdJmMu0dMa1",
+ "maxLength": 64
+ },
+ "event_type": {
+ "$ref": "#/components/schemas/EventType"
+ },
+ "event_class": {
+ "$ref": "#/components/schemas/EventClass"
+ },
+ "is_delivery_successful": {
+ "type": "boolean",
+ "description": "Indicates whether the webhook delivery attempt was successful."
+ },
+ "initial_attempt_id": {
+ "type": "string",
+ "description": "The identifier for the initial delivery attempt. This will be the same as `event_id` for\nthe initial delivery attempt.",
+ "example": "evt_018e31720d1b7a2b82677d3032cab959",
+ "maxLength": 64
+ },
+ "created": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Time at which the event was created.",
+ "example": "2022-09-10T10:11:12Z"
+ }
+ }
+ },
+ "EventRetrieveResponse": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/EventListItemResponse"
+ },
+ {
+ "type": "object",
+ "required": [
+ "request",
+ "response"
+ ],
+ "properties": {
+ "request": {
+ "$ref": "#/components/schemas/OutgoingWebhookRequestContent"
+ },
+ "response": {
+ "$ref": "#/components/schemas/OutgoingWebhookResponseContent"
+ },
+ "delivery_attempt": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/WebhookDeliveryAttempt"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ }
+ ],
+ "description": "The response body for retrieving an event."
+ },
"EventType": {
"type": "string",
"enum": [
@@ -11350,6 +11598,96 @@
"propertyName": "type"
}
},
+ "OutgoingWebhookRequestContent": {
+ "type": "object",
+ "description": "The request information (headers and body) sent in the webhook.",
+ "required": [
+ "body",
+ "headers"
+ ],
+ "properties": {
+ "body": {
+ "type": "string",
+ "description": "The request body sent in the webhook."
+ },
+ "headers": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "allOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "description": "The request headers sent in the webhook.",
+ "example": [
+ [
+ "content-type",
+ "application/json"
+ ],
+ [
+ "content-length",
+ "1024"
+ ]
+ ]
+ }
+ }
+ },
+ "OutgoingWebhookResponseContent": {
+ "type": "object",
+ "description": "The response information (headers, body and status code) received for the webhook sent.",
+ "required": [
+ "body",
+ "headers",
+ "status_code"
+ ],
+ "properties": {
+ "body": {
+ "type": "string",
+ "description": "The response body received for the webhook sent."
+ },
+ "headers": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "allOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "description": "The response headers received for the webhook sent.",
+ "example": [
+ [
+ "content-type",
+ "application/json"
+ ],
+ [
+ "content-length",
+ "1024"
+ ]
+ ]
+ },
+ "status_code": {
+ "type": "integer",
+ "format": "int32",
+ "description": "The HTTP status code for the webhook sent.",
+ "example": 200,
+ "minimum": 0
+ }
+ }
+ },
"PayLaterData": {
"oneOf": [
{
@@ -17950,6 +18288,14 @@
"WeChatPayRedirection": {
"type": "object"
},
+ "WebhookDeliveryAttempt": {
+ "type": "string",
+ "enum": [
+ "initial_attempt",
+ "automatic_retry",
+ "manual_retry"
+ ]
+ },
"WebhookDetails": {
"type": "object",
"properties": {
@@ -18033,6 +18379,10 @@
"name": "Merchant Account",
"description": "Create and manage merchant accounts"
},
+ {
+ "name": "Business Profile",
+ "description": "Create and manage business profiles"
+ },
{
"name": "Merchant Connector Account",
"description": "Create and manage merchant connector accounts"
@@ -18076,6 +18426,10 @@
{
"name": "Routing",
"description": "Create and manage routing configurations"
+ },
+ {
+ "name": "Event",
+ "description": "Manage events"
}
]
}
\ No newline at end of file