mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 12:15:40 +08:00
feat(router): add payment failed webhook event (#305)
This commit is contained in:
@ -7,6 +7,7 @@ use crate::{enums as api_enums, payments};
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum IncomingWebhookEvent {
|
pub enum IncomingWebhookEvent {
|
||||||
|
PaymentIntentFailure,
|
||||||
PaymentIntentSuccess,
|
PaymentIntentSuccess,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ pub enum WebhookFlow {
|
|||||||
impl From<IncomingWebhookEvent> for WebhookFlow {
|
impl From<IncomingWebhookEvent> for WebhookFlow {
|
||||||
fn from(evt: IncomingWebhookEvent) -> Self {
|
fn from(evt: IncomingWebhookEvent) -> Self {
|
||||||
match evt {
|
match evt {
|
||||||
|
IncomingWebhookEvent::PaymentIntentFailure => Self::Payment,
|
||||||
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
|
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ where
|
|||||||
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let val_str: &str = val.as_ref();
|
let val_str: &str = val.as_ref();
|
||||||
|
|
||||||
if val_str.len() < 15 && val_str.len() > 19 {
|
if val_str.len() < 15 || val_str.len() > 19 {
|
||||||
return WithType::fmt(val, f);
|
return WithType::fmt(val, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -935,6 +935,7 @@ impl api::IncomingWebhook for Stripe {
|
|||||||
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
|
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
|
||||||
|
|
||||||
Ok(match details.event_type.as_str() {
|
Ok(match details.event_type.as_str() {
|
||||||
|
"payment_intent.payment_failed" => api::IncomingWebhookEvent::PaymentIntentFailure,
|
||||||
"payment_intent.succeeded" => api::IncomingWebhookEvent::PaymentIntentSuccess,
|
"payment_intent.succeeded" => api::IncomingWebhookEvent::PaymentIntentSuccess,
|
||||||
_ => Err(errors::ConnectorError::WebhookEventTypeNotFound).into_report()?,
|
_ => Err(errors::ConnectorError::WebhookEventTypeNotFound).into_report()?,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -31,7 +31,7 @@ use crate::{
|
|||||||
utils::{
|
utils::{
|
||||||
self,
|
self,
|
||||||
crypto::{self, SignMessage},
|
crypto::{self, SignMessage},
|
||||||
OptionExt, ValueExt,
|
OptionExt,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -658,8 +658,9 @@ pub async fn get_connector_default(
|
|||||||
.parse_value("CustomRoutingRulesVec")
|
.parse_value("CustomRoutingRulesVec")
|
||||||
.change_context(errors::ConnectorError::RoutingRulesParsingError)
|
.change_context(errors::ConnectorError::RoutingRulesParsingError)
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
||||||
let custom_routing_rules: api::CustomRoutingRules = vec_val[0]
|
let custom_routing_rules: api::CustomRoutingRules = vec_val
|
||||||
.clone()
|
.first()
|
||||||
|
.cloned()
|
||||||
.parse_value("CustomRoutingRules")
|
.parse_value("CustomRoutingRules")
|
||||||
.change_context(errors::ConnectorError::RoutingRulesParsingError)
|
.change_context(errors::ConnectorError::RoutingRulesParsingError)
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user