use serde::{Deserialize, Serialize};
use serde_json::Value;
const REDACTED: &str = "[redacted]";
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorResponse {
pub merchant_connector_id: String,
#[serde(default)]
pub connector_type: Option<String>,
#[serde(default)]
pub connector_name: Option<String>,
#[serde(default)]
pub profile_id: Option<String>,
#[serde(default)]
pub merchant_id: Option<String>,
#[serde(default)]
pub status: Option<String>,
#[serde(default)]
pub connector_label: Option<String>,
#[serde(default)]
pub connector_account_details: Option<Value>,
#[serde(default)]
pub payment_methods_enabled: Option<Vec<Value>>,
#[serde(default)]
pub metadata: Option<Value>,
#[serde(default)]
pub test_mode: Option<bool>,
#[serde(default)]
pub disabled: Option<bool>,
#[serde(default)]
pub connector_webhook_details: Option<Value>,
#[serde(default)]
pub has_live_webhook_secret: Option<bool>,
#[serde(default)]
pub has_sandbox_webhook_secret: Option<bool>,
#[serde(default)]
pub created_at: Option<String>,
#[serde(default)]
pub deleted: Option<bool>,
#[serde(default)]
pub assigned_profile_ids: Vec<String>,
#[serde(default)]
pub shared_profile_ids: Vec<String>,
#[serde(default)]
pub disabled_profile_ids: Vec<String>,
#[serde(default)]
pub payment_methods_enabled_sandbox: Option<Vec<Value>>,
#[serde(default)]
pub unsupported_payment_method_types_live: Option<Vec<String>>,
#[serde(default)]
pub unsupported_payment_method_types_sandbox: Option<Vec<String>>,
#[serde(default)]
pub sandbox_mechanism: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for ConnectorResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ConnectorResponse")
.field("merchant_connector_id", &self.merchant_connector_id)
.field("connector_type", &self.connector_type)
.field("connector_name", &self.connector_name)
.field("profile_id", &self.profile_id)
.field("merchant_id", &self.merchant_id)
.field("status", &self.status)
.field("connector_label", &self.connector_label)
.field(
"connector_account_details",
&self.connector_account_details.as_ref().map(|_| REDACTED),
)
.field("payment_methods_enabled", &self.payment_methods_enabled)
.field("metadata", &self.metadata)
.field("test_mode", &self.test_mode)
.field("disabled", &self.disabled)
.field(
"connector_webhook_details",
&self.connector_webhook_details.as_ref().map(|_| REDACTED),
)
.field("has_live_webhook_secret", &self.has_live_webhook_secret)
.field(
"has_sandbox_webhook_secret",
&self.has_sandbox_webhook_secret,
)
.field("created_at", &self.created_at)
.field("deleted", &self.deleted)
.field("assigned_profile_ids", &self.assigned_profile_ids)
.field("shared_profile_ids", &self.shared_profile_ids)
.field("disabled_profile_ids", &self.disabled_profile_ids)
.field(
"payment_methods_enabled_sandbox",
&self.payment_methods_enabled_sandbox,
)
.field(
"unsupported_payment_method_types_live",
&self.unsupported_payment_method_types_live,
)
.field(
"unsupported_payment_method_types_sandbox",
&self.unsupported_payment_method_types_sandbox,
)
.field("sandbox_mechanism", &self.sandbox_mechanism)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorWebhookRegisterResponse {
pub webhook_registration_status: String,
#[serde(default)]
pub event_type: Option<Value>,
#[serde(default)]
pub environment: Option<String>,
#[serde(default)]
pub connector_webhook_id: Option<String>,
#[serde(default)]
pub webhook_secret: Option<String>,
#[serde(default)]
pub error_code: Option<String>,
#[serde(default)]
pub error_message: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for ConnectorWebhookRegisterResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ConnectorWebhookRegisterResponse")
.field(
"webhook_registration_status",
&self.webhook_registration_status,
)
.field("event_type", &self.event_type)
.field("environment", &self.environment)
.field("connector_webhook_id", &self.connector_webhook_id)
.field(
"webhook_secret",
&self.webhook_secret.as_ref().map(|_| REDACTED),
)
.field("error_code", &self.error_code)
.field("error_message", &self.error_message)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorWebhookEntry {
pub connector_webhook_id: String,
#[serde(default)]
pub event_type: Option<Value>,
#[serde(default)]
pub environment: Option<String>,
#[serde(default)]
pub webhook_url: Option<String>,
#[serde(default)]
pub status: Option<String>,
#[serde(default)]
pub enabled_events: Option<Vec<String>>,
#[serde(default)]
pub missing_events: Option<Vec<String>>,
#[serde(default)]
pub created_at: Option<i64>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorWebhookListResponse {
pub connector: String,
#[serde(default = "Vec::new")]
pub webhooks: Vec<ConnectorWebhookEntry>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorWebhookSyncResult {
pub connector_webhook_id: String,
#[serde(default)]
pub environment: Option<String>,
#[serde(default)]
pub webhook_url: Option<String>,
#[serde(default)]
pub status: Option<String>,
#[serde(default)]
pub updated: bool,
#[serde(default = "Vec::new")]
pub added_events: Vec<String>,
#[serde(default)]
pub error_message: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorWebhookSyncResponse {
pub connector: String,
#[serde(default = "Vec::new")]
pub expected_events: Vec<String>,
#[serde(default = "Vec::new")]
pub endpoints: Vec<ConnectorWebhookSyncResult>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct StripePaymentMethodDomainResult {
pub url: String,
#[serde(default)]
pub domain: Option<String>,
#[serde(default)]
pub status: Option<String>,
#[serde(default)]
pub apple_pay_status: Option<String>,
#[serde(default)]
pub message: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct StripePaymentMethodDomainsRegisterResponse {
#[serde(default)]
pub environment: Option<String>,
#[serde(default = "Vec::new")]
pub results: Vec<StripePaymentMethodDomainResult>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorHealthResponse {
pub merchant_connector_id: String,
pub connector: String,
pub test_mode: bool,
pub state: ConnectorHealthState,
#[serde(default)]
pub can_accept_charges: Option<bool>,
#[serde(default = "Vec::new")]
pub capabilities: Vec<ConnectorCapability>,
#[serde(default)]
pub requirements: Option<ConnectorHealthRequirements>,
#[serde(default = "Vec::new")]
pub checks: Vec<ConnectorHealthCheck>,
#[serde(default)]
pub stale: Option<bool>,
#[serde(default)]
pub credential_source: Option<String>,
#[serde(default)]
pub processor_account_id: Option<String>,
#[serde(default)]
pub processor_account_name: Option<String>,
#[serde(default)]
pub processor_account_country: Option<String>,
#[serde(default)]
pub processor_default_currency: Option<String>,
#[serde(default)]
pub processor_account_email: Option<String>,
#[serde(default)]
pub processor_account_type: Option<String>,
#[serde(default)]
pub payouts_enabled: Option<bool>,
#[serde(default)]
pub unknown_reason: Option<ConnectorHealthUnknownReason>,
#[serde(default)]
pub probed_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
pub type ConnectorHealthState = String;
pub type ConnectorHealthUnknownReason = String;
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorCapability {
pub id: String,
pub state: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorHealthCheck {
pub id: String,
pub status: String,
#[serde(default)]
pub reason: Option<String>,
#[serde(default)]
pub params: Option<Value>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorHealthRequirements {
#[serde(default)]
pub disabled_reason: Option<String>,
#[serde(default = "Vec::new")]
pub currently_due: Vec<String>,
#[serde(default = "Vec::new")]
pub past_due: Vec<String>,
#[serde(default = "Vec::new")]
pub errors: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct AirwallexApplePayDomainResult {
pub url: String,
#[serde(default)]
pub domain: Option<String>,
#[serde(default)]
pub status: Option<String>,
#[serde(default)]
pub message: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct AirwallexApplePayDomainsRegisterResponse {
#[serde(default)]
pub environment: Option<String>,
#[serde(default = "Vec::new")]
pub results: Vec<AirwallexApplePayDomainResult>,
#[serde(default = "Vec::new")]
pub registered_domains: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorBuyerMailResponse {
pub merchant_connector_id: String,
pub connector: String,
pub provider_account_id: String,
pub test_mode: bool,
pub scope: String,
#[serde(default)]
pub send_customer_emails: Option<bool>,
pub outcome: String,
#[serde(default)]
pub reason: Option<String>,
pub observed_at: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorConsolidationResponse {
pub merchant_connector_id: String,
pub connector_name: String,
pub dry_run: bool,
pub consolidated: bool,
pub preview_token: String,
#[serde(default = "Vec::new")]
pub accounts: Vec<ConsolidationAccount>,
#[serde(default = "Vec::new")]
pub shops: Vec<ConsolidationShop>,
#[serde(default = "Vec::new")]
pub conflicts: Vec<ConsolidationConflict>,
#[serde(default = "Vec::new")]
pub blockers: Vec<String>,
#[serde(default)]
pub changes: Option<ConsolidationChanges>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConsolidationAccount {
pub merchant_connector_id: String,
#[serde(default)]
pub connector_label: Option<String>,
pub kept: bool,
pub eligibility: String,
#[serde(default = "Vec::new")]
pub profile_ids: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConsolidationShop {
pub profile_id: String,
#[serde(default = "Vec::new")]
pub served_by: Vec<String>,
pub enabled_before: bool,
pub enabled_after: bool,
#[serde(default)]
pub currencies_after: Option<Vec<String>>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConsolidationConflict {
pub setting: String,
#[serde(default = "Vec::new")]
pub values: Vec<ConsolidationConflictValue>,
#[serde(default = "Vec::new")]
pub choosable: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConsolidationConflictValue {
#[serde(default = "Vec::new")]
pub merchant_connector_ids: Vec<String>,
#[serde(default)]
pub summary: Value,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConsolidationChanges {
pub routing_configs: i32,
pub fallback_lists: i32,
pub checkout_layouts: i32,
pub surcharge_rules: i32,
pub hidden_accounts: i32,
pub subscription_shop_configs: i32,
pub product_references: i32,
pub shop_billing_settings: i32,
pub role_grants: i32,
pub saved_payment_methods: i32,
pub customers: i32,
pub mandates: i32,
pub subscriptions: i32,
pub subscription_terms: i32,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorCurrencyPolicyResponse {
pub merchant_connector_id: String,
pub connector_name: String,
pub profile_id: String,
#[serde(default)]
pub allowed_currencies: Option<Vec<String>>,
pub unreadable: bool,
pub conversion: ConnectorCurrencyConversion,
pub provider_capability: ConnectorCurrencyCapability,
#[serde(default = "Vec::new")]
pub shops: Vec<ConnectorShopCurrencies>,
#[serde(default)]
pub impact: Option<Vec<ConnectorCurrencyShopImpact>>,
pub applied: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorCurrencyConversion {
#[serde(default)]
pub convert_to: Option<String>,
#[serde(default)]
pub unreadable: bool,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ConnectorCurrencyConversionSetting {
#[serde(default)]
pub convert_to: Option<String>,
#[serde(flatten, default, skip_serializing_if = "serde_json::Map::is_empty")]
pub extra: serde_json::Map<String, Value>,
}
impl ConnectorCurrencyConversionSetting {
#[must_use]
pub fn convert_to(currency: impl Into<String>) -> Self {
Self {
convert_to: Some(currency.into()),
extra: serde_json::Map::new(),
}
}
#[must_use]
pub fn refuse() -> Self {
Self::default()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorCurrencyCapability {
#[serde(default)]
pub currencies: Option<Vec<String>>,
#[serde(default = "Vec::new")]
pub payment_method_types: Vec<Value>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorShopCurrencies {
pub profile_id: String,
pub disabled: bool,
#[serde(default)]
pub allowed_currencies: Option<Vec<String>>,
#[serde(default)]
pub effective_currencies: Option<Vec<String>>,
#[serde(default = "Vec::new")]
pub ignored_currencies: Vec<String>,
#[serde(default)]
pub conversion: Option<ConnectorCurrencyConversionSetting>,
#[serde(default)]
pub effective_convert_to: Option<String>,
#[serde(default)]
pub creation_policy: Option<Value>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorCurrencyShopImpact {
pub profile_id: String,
#[serde(default)]
pub before: Option<Vec<String>>,
#[serde(default)]
pub after: Option<Vec<String>>,
#[serde(default = "Vec::new")]
pub removed: Vec<String>,
pub removed_unbounded: bool,
#[serde(default = "Vec::new")]
pub uncovered: Vec<Value>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorShopsResponse {
pub merchant_connector_id: String,
pub profile_id: String,
#[serde(default = "Vec::new")]
pub shared_profile_ids: Vec<String>,
#[serde(default = "Vec::new")]
pub disabled_profile_ids: Vec<String>,
#[serde(default = "Vec::new")]
pub assigned_profile_ids: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultRoutesPreviewResponse {
pub vault_id: String,
pub environment: String,
pub desired_fingerprint: String,
#[serde(default = "Vec::new")]
pub desired_upstream_hosts: Vec<String>,
#[serde(default)]
pub current_fingerprint: Option<String>,
#[serde(default = "Vec::new")]
pub changes: Vec<VaultRouteChange>,
#[serde(default = "Vec::new")]
pub warnings: Vec<VaultRouteWarning>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultRouteChange {
pub route_id: String,
pub purpose: String,
pub change: String,
#[serde(default = "Vec::new")]
pub field_changes: Vec<Value>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultRouteWarning {
pub code: String,
#[serde(default)]
pub connector: Option<String>,
#[serde(default)]
pub detail: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultRoutesApplyResponse {
pub applied: bool,
pub route_ids: VaultRouteIds,
pub collect_route_id_stored: bool,
#[serde(default = "Vec::new")]
pub warnings: Vec<VaultRouteWarning>,
#[serde(default)]
pub verification: Option<VaultRouteApplyVerification>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultRouteIds {
pub collect: String,
pub reveal: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultRouteApplyVerification {
#[serde(default = "Vec::new")]
pub established: Vec<String>,
#[serde(default = "Vec::new")]
pub not_established: Vec<String>,
#[serde(default = "Vec::new")]
pub routes_appeared: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultOutagesResponse {
#[serde(default = "Vec::new")]
pub outages: Vec<VaultOutage>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultOutage {
pub profile_id: String,
pub profile_name: String,
pub vault_connector_id: String,
pub vault_connector_name: String,
pub cause: String,
pub since: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultVerificationResponse {
pub passed: bool,
#[serde(default = "Vec::new")]
pub checks: Vec<VaultCheck>,
#[serde(default = "Vec::new")]
pub processors: Vec<VaultProcessorHiding>,
#[serde(default = "Vec::new")]
pub egress_ips_to_allowlist: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultCheck {
pub id: String,
pub status: String,
#[serde(default)]
pub detail: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct VaultProcessorHiding {
pub merchant_connector_id: String,
pub connector_name: String,
pub status: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressResponse {
pub connector: String,
pub merchant_connector_id: String,
pub management: String,
pub constraints: WebhookAddressConstraints,
#[serde(default = "Vec::new")]
pub environments: Vec<WebhookAddressEnvironment>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressConstraints {
pub alias_min_length: i32,
pub alias_max_length: i32,
pub prefix_max_length: i32,
pub body_min_length: i32,
pub numeric_body_min_length: i32,
pub body_max_length: i32,
pub max_changes: i32,
pub change_window_days: i32,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressEnvironment {
#[serde(default)]
pub environment: Option<String>,
pub shared_across_environments: bool,
pub mode: String,
#[serde(default)]
pub identifier: Option<String>,
#[serde(default)]
pub format: Option<WebhookAddressFormat>,
#[serde(default)]
pub updated_at: Option<String>,
pub rate_limit: WebhookAddressRateLimit,
pub editable: bool,
#[serde(default = "Vec::new")]
pub groups: Vec<Value>,
pub hidden_group_count: i64,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressFormat {
pub prefix: String,
pub style: String,
pub length: i32,
#[serde(flatten, default, skip_serializing_if = "serde_json::Map::is_empty")]
pub extra: serde_json::Map<String, Value>,
}
impl WebhookAddressFormat {
#[must_use]
pub fn new(prefix: impl Into<String>, style: impl Into<String>, length: i32) -> Self {
Self {
prefix: prefix.into(),
style: style.into(),
length,
extra: serde_json::Map::new(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressRateLimit {
pub remaining_changes: i32,
#[serde(default)]
pub next_change_allowed_at: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressPreviewResponse {
pub valid: bool,
#[serde(default = "Vec::new")]
pub errors: Vec<WebhookAddressValidationError>,
#[serde(default)]
pub example_identifier: Option<String>,
pub identifier_final: bool,
pub changes_address: bool,
pub rate_limit: WebhookAddressRateLimit,
pub editable: bool,
pub requires_shared_confirmation: bool,
#[serde(default = "Vec::new")]
pub groups: Vec<WebhookAddressPreviewGroup>,
pub hidden_group_count: i64,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressValidationError {
pub field: String,
pub code: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WebhookAddressPreviewGroup {
pub credentials_sha256: String,
pub contains_this_connector: bool,
pub current_url: String,
#[serde(default)]
pub resulting_url: Option<String>,
#[serde(default = "Vec::new")]
pub accounts: Vec<Value>,
pub hidden_account_count: i64,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookListResponse {
pub connector: String,
pub environment: String,
pub coverage: String,
#[serde(default)]
pub provider_account: Option<String>,
pub capabilities: ProviderWebhookCapabilities,
#[serde(default)]
pub endpoint_limit: Option<i32>,
#[serde(default = "Vec::new")]
pub required_events: Vec<String>,
pub managed: ManagedWebhookState,
#[serde(default = "Vec::new")]
pub endpoints: Vec<ProviderWebhookEndpoint>,
pub editable: bool,
#[serde(default)]
pub edit_blocked: Option<String>,
pub read_at: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookCapabilities {
pub create: bool,
pub update_url: bool,
pub update_events: bool,
pub update_enabled: bool,
pub delete: bool,
pub replace_all: bool,
#[serde(default)]
pub replace_all_unavailable: Option<Value>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ManagedWebhookState {
pub status: String,
#[serde(default)]
pub url: Option<String>,
#[serde(default)]
pub endpoint_id: Option<String>,
#[serde(default = "Vec::new")]
pub missing_events: Vec<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookEndpoint {
pub id: String,
pub url: String,
pub host: String,
pub owner: String,
#[serde(default)]
pub connector_label: Option<String>,
#[serde(default)]
pub events: Option<Vec<String>>,
#[serde(default)]
pub enabled: Option<bool>,
#[serde(default)]
pub missing_events: Option<Vec<String>>,
#[serde(default)]
pub created_at: Option<i64>,
pub fingerprint: String,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookCreateResponse {
pub endpoint: ProviderWebhookEndpoint,
#[serde(default)]
pub signing_secret: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl std::fmt::Debug for ProviderWebhookCreateResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ProviderWebhookCreateResponse")
.field("endpoint", &self.endpoint)
.field(
"signing_secret",
&self.signing_secret.as_ref().map(|_| REDACTED),
)
.field("extra", &self.extra)
.finish()
}
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookDeleteResult {
pub id: String,
pub url: String,
pub outcome: String,
#[serde(default)]
pub error_message: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookReplacePreviewResponse {
pub connector: String,
pub environment: String,
pub coverage: String,
#[serde(default)]
pub provider_account: Option<String>,
pub sequence: String,
pub managed: ManagedWebhookState,
#[serde(default = "Vec::new")]
pub delete: Vec<ProviderWebhookEndpoint>,
#[serde(default = "Vec::new")]
pub keep: Vec<ProviderWebhookEndpoint>,
#[serde(default = "Vec::new")]
pub accounts: Vec<Value>,
pub hidden_account_count: i64,
pub editable: bool,
#[serde(default)]
pub edit_blocked: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProviderWebhookReplaceResponse {
pub status: String,
pub sequence: String,
pub managed: ManagedWebhookState,
#[serde(default = "Vec::new")]
pub results: Vec<ProviderWebhookDeleteResult>,
#[serde(default = "Vec::new")]
pub remaining: Vec<ProviderWebhookEndpoint>,
#[serde(default = "Vec::new")]
pub unconfirmed: Vec<ProviderWebhookEndpoint>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopApplePayDomainsRegisterResponse {
pub environment: String,
#[serde(default = "Vec::new")]
pub results: Vec<WhopApplePayDomainResult>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopApplePayDomainResult {
pub url: String,
#[serde(default)]
pub domain: Option<String>,
pub status: String,
#[serde(default)]
pub whop_domain_id: Option<String>,
#[serde(default)]
pub message: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn connector_response_decodes_shop_assignment_and_sandbox_fields() {
let parsed: ConnectorResponse = serde_json::from_str(
r#"{
"merchant_connector_id": "mca_1",
"assigned_profile_ids": ["pro_1", "pro_2"],
"shared_profile_ids": ["pro_2"],
"disabled_profile_ids": ["pro_2"],
"payment_methods_enabled_sandbox": null,
"unsupported_payment_method_types_live": ["klarna"],
"sandbox_mechanism": "request_flag"
}"#,
)
.unwrap();
assert_eq!(parsed.assigned_profile_ids, ["pro_1", "pro_2"]);
assert_eq!(parsed.shared_profile_ids, ["pro_2"]);
assert!(parsed.payment_methods_enabled_sandbox.is_none());
assert_eq!(parsed.sandbox_mechanism.as_deref(), Some("request_flag"));
let older: ConnectorResponse =
serde_json::from_str(r#"{"merchant_connector_id":"mca_1"}"#).unwrap();
assert!(older.assigned_profile_ids.is_empty());
assert!(older.disabled_profile_ids.is_empty());
let check: ConnectorHealthCheck = serde_json::from_str(
r#"{"id":"min_amount","status":"unhealthy","params":{"amount_minor":50,"currency":"EUR"}}"#,
)
.unwrap();
assert_eq!(check.params.unwrap()["amount_minor"], 50);
}
#[test]
fn connector_response_debug_redacts_credentials() {
let parsed: ConnectorResponse = serde_json::from_str(
r#"{
"merchant_connector_id": "mca_1",
"connector_name": "stripe",
"connector_account_details": {"api_key": "sk_live_supersecret"},
"connector_webhook_details": {"merchant_secret": "whsec_topsecret"}
}"#,
)
.unwrap();
let rendered = format!("{parsed:?}");
assert!(!rendered.contains("sk_live_supersecret"), "{rendered}");
assert!(!rendered.contains("whsec_topsecret"), "{rendered}");
assert!(
rendered.contains("connector_account_details: Some(\"[redacted]\")"),
"{rendered}"
);
assert!(
rendered.contains("connector_webhook_details: Some(\"[redacted]\")"),
"{rendered}"
);
assert!(rendered.contains("stripe"), "{rendered}");
assert!(rendered.contains("mca_1"), "{rendered}");
}
#[test]
fn connector_response_debug_shows_none_for_absent_credentials() {
let parsed: ConnectorResponse =
serde_json::from_str(r#"{"merchant_connector_id":"mca_1"}"#).unwrap();
let rendered = format!("{parsed:?}");
assert!(
rendered.contains("connector_account_details: None"),
"{rendered}"
);
}
#[test]
fn connector_response_keeps_unknown_fields() {
let parsed: ConnectorResponse = serde_json::from_str(
r#"{"merchant_connector_id":"mca_1","status":"active","brand_new_field":42}"#,
)
.unwrap();
assert_eq!(parsed.status.as_deref(), Some("active"));
assert_eq!(parsed.extra.get("brand_new_field"), Some(&Value::from(42)));
assert!(!parsed.extra.contains_key("status"));
}
#[test]
fn register_response_debug_redacts_the_webhook_secret() {
let parsed: ConnectorWebhookRegisterResponse = serde_json::from_str(
r#"{
"webhook_registration_status": "success",
"event_type": "all_events",
"environment": "sandbox",
"connector_webhook_id": "we_1",
"webhook_secret": "whsec_minted",
"error_code": null,
"error_message": null
}"#,
)
.unwrap();
let rendered = format!("{parsed:?}");
assert!(!rendered.contains("whsec_minted"), "{rendered}");
assert!(
rendered.contains("webhook_secret: Some(\"[redacted]\")"),
"{rendered}"
);
assert!(rendered.contains("we_1"), "{rendered}");
assert_eq!(parsed.webhook_registration_status, "success");
assert_eq!(parsed.environment.as_deref(), Some("sandbox"));
assert_eq!(parsed.error_code, None);
}
#[test]
fn webhook_list_parses_entries_and_structured_event_types() {
let parsed: ConnectorWebhookListResponse = serde_json::from_str(
r#"{
"connector": "stripe",
"webhooks": [
{
"connector_webhook_id": "we_1",
"event_type": {"specific_event": "payment_intent.succeeded"},
"enabled_events": ["payment_intent.succeeded"],
"created_at": 1700000000
}
]
}"#,
)
.unwrap();
assert_eq!(parsed.connector, "stripe");
assert_eq!(parsed.webhooks.len(), 1);
let entry = &parsed.webhooks[0];
assert_eq!(entry.connector_webhook_id, "we_1");
assert_eq!(
entry.event_type.as_ref().unwrap()["specific_event"],
"payment_intent.succeeded"
);
assert_eq!(entry.created_at, Some(1_700_000_000));
assert_eq!(entry.environment, None);
}
#[test]
fn webhook_list_defaults_to_no_webhooks() {
let parsed: ConnectorWebhookListResponse =
serde_json::from_str(r#"{"connector":"adyen"}"#).unwrap();
assert!(parsed.webhooks.is_empty());
}
#[test]
fn webhook_entry_distinguishes_empty_from_absent_missing_events() {
let parsed: ConnectorWebhookListResponse = serde_json::from_str(
r#"{
"connector": "stripe",
"webhooks": [
{"connector_webhook_id": "we_current", "missing_events": []},
{"connector_webhook_id": "we_stale", "missing_events": ["refund.succeeded"]},
{"connector_webhook_id": "we_unknown"}
]
}"#,
)
.unwrap();
assert_eq!(parsed.webhooks[0].missing_events.as_deref(), Some(&[][..]));
assert_eq!(
parsed.webhooks[1].missing_events.as_deref(),
Some(&["refund.succeeded".to_string()][..])
);
assert_eq!(parsed.webhooks[2].missing_events, None);
}
#[test]
fn webhook_sync_parses_mixed_endpoint_outcomes() {
let parsed: ConnectorWebhookSyncResponse = serde_json::from_str(
r#"{
"connector": "stripe",
"expected_events": ["payment_intent.succeeded", "refund.succeeded"],
"endpoints": [
{
"connector_webhook_id": "we_1",
"environment": "live",
"webhook_url": "https://api.delopay.net/webhooks/mer_1/mca_1",
"status": "enabled",
"updated": true,
"added_events": ["refund.succeeded"]
},
{
"connector_webhook_id": "we_2",
"updated": false,
"added_events": [],
"error_message": "endpoint is disabled at Stripe"
}
]
}"#,
)
.unwrap();
assert_eq!(parsed.expected_events.len(), 2);
assert!(parsed.endpoints[0].updated);
assert_eq!(parsed.endpoints[0].added_events, ["refund.succeeded"]);
assert_eq!(parsed.endpoints[0].error_message, None);
assert!(!parsed.endpoints[1].updated);
assert!(parsed.endpoints[1].added_events.is_empty());
assert_eq!(
parsed.endpoints[1].error_message.as_deref(),
Some("endpoint is disabled at Stripe")
);
}
#[test]
fn stripe_domain_registration_parses_per_url_outcomes() {
let parsed: StripePaymentMethodDomainsRegisterResponse = serde_json::from_str(
r#"{
"environment": "live",
"results": [
{
"url": "https://checkout.delopay.net",
"domain": "checkout.delopay.net",
"status": "registered",
"apple_pay_status": "active"
},
{"url": "not a url", "status": "invalid_url", "message": "could not parse host"}
]
}"#,
)
.unwrap();
assert_eq!(parsed.environment.as_deref(), Some("live"));
assert_eq!(
parsed.results[0].domain.as_deref(),
Some("checkout.delopay.net")
);
assert_eq!(
parsed.results[0].apple_pay_status.as_deref(),
Some("active")
);
assert_eq!(parsed.results[1].domain, None);
assert_eq!(parsed.results[1].status.as_deref(), Some("invalid_url"));
}
}