feat(router): added incoming refund webhooks flow (#683)

Co-authored-by: sai harsha <sai.harsha@sai.harsha-MacBookPro>
This commit is contained in:
saiharsha-juspay
2023-02-28 19:15:25 +05:30
committed by GitHub
parent 2e99152d35
commit f12abbcef4
12 changed files with 302 additions and 11 deletions

View File

@ -264,6 +264,8 @@ pub enum Currency {
#[strum(serialize_all = "snake_case")]
pub enum EventType {
PaymentSucceeded,
RefundSucceeded,
RefundFailed,
}
#[derive(

View File

@ -2,13 +2,15 @@ use common_utils::custom_serde;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use crate::{enums as api_enums, payments};
use crate::{enums as api_enums, payments, refunds};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum IncomingWebhookEvent {
PaymentIntentFailure,
PaymentIntentSuccess,
RefundFailure,
RefundSuccess,
EndpointVerification,
}
@ -24,6 +26,8 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
match evt {
IncomingWebhookEvent::PaymentIntentFailure => Self::Payment,
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
IncomingWebhookEvent::RefundSuccess => Self::Refund,
IncomingWebhookEvent::RefundFailure => Self::Refund,
IncomingWebhookEvent::EndpointVerification => Self::ReturnResponse,
}
}
@ -56,4 +60,5 @@ pub struct OutgoingWebhook {
#[serde(tag = "type", content = "object", rename_all = "snake_case")]
pub enum OutgoingWebhookContent {
PaymentDetails(payments::PaymentsResponse),
RefundDetails(refunds::RefundResponse),
}