mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(router): Add Cancel Event in Webhooks and Mapping it in Stripe (#2573)
This commit is contained in:
@ -12,6 +12,7 @@ pub enum IncomingWebhookEvent {
|
||||
PaymentIntentSuccess,
|
||||
PaymentIntentProcessing,
|
||||
PaymentIntentPartiallyFunded,
|
||||
PaymentIntentCancelled,
|
||||
PaymentActionRequired,
|
||||
EventNotSupported,
|
||||
SourceChargeable,
|
||||
@ -84,7 +85,8 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
|
||||
| IncomingWebhookEvent::PaymentIntentSuccess
|
||||
| IncomingWebhookEvent::PaymentIntentProcessing
|
||||
| IncomingWebhookEvent::PaymentActionRequired
|
||||
| IncomingWebhookEvent::PaymentIntentPartiallyFunded => Self::Payment,
|
||||
| IncomingWebhookEvent::PaymentIntentPartiallyFunded
|
||||
| IncomingWebhookEvent::PaymentIntentCancelled => Self::Payment,
|
||||
IncomingWebhookEvent::EventNotSupported => Self::ReturnResponse,
|
||||
IncomingWebhookEvent::RefundSuccess | IncomingWebhookEvent::RefundFailure => {
|
||||
Self::Refund
|
||||
|
||||
@ -794,6 +794,7 @@ pub enum EventType {
|
||||
PaymentSucceeded,
|
||||
PaymentFailed,
|
||||
PaymentProcessing,
|
||||
PaymentCancelled,
|
||||
ActionRequired,
|
||||
RefundSucceeded,
|
||||
RefundFailed,
|
||||
|
||||
@ -168,6 +168,7 @@ fn get_stripe_event_type(event_type: api_models::enums::EventType) -> &'static s
|
||||
api_models::enums::EventType::PaymentSucceeded => "payment_intent.succeeded",
|
||||
api_models::enums::EventType::PaymentFailed => "payment_intent.payment_failed",
|
||||
api_models::enums::EventType::PaymentProcessing => "payment_intent.processing",
|
||||
api_models::enums::EventType::PaymentCancelled => "payment_intent.canceled",
|
||||
|
||||
// the below are not really stripe compatible because stripe doesn't provide this
|
||||
api_models::enums::EventType::ActionRequired => "action.required",
|
||||
|
||||
@ -1844,6 +1844,9 @@ impl api::IncomingWebhook for Stripe {
|
||||
stripe::WebhookEventType::PaymentIntentSucceed => {
|
||||
api::IncomingWebhookEvent::PaymentIntentSuccess
|
||||
}
|
||||
stripe::WebhookEventType::PaymentIntentCanceled => {
|
||||
api::IncomingWebhookEvent::PaymentIntentCancelled
|
||||
}
|
||||
stripe::WebhookEventType::ChargeSucceeded => {
|
||||
if let Some(stripe::WebhookPaymentMethodDetails {
|
||||
payment_method:
|
||||
@ -1898,7 +1901,6 @@ impl api::IncomingWebhook for Stripe {
|
||||
| stripe::WebhookEventType::ChargePending
|
||||
| stripe::WebhookEventType::ChargeUpdated
|
||||
| stripe::WebhookEventType::ChargeRefunded
|
||||
| stripe::WebhookEventType::PaymentIntentCanceled
|
||||
| stripe::WebhookEventType::PaymentIntentCreated
|
||||
| stripe::WebhookEventType::PaymentIntentProcessing
|
||||
| stripe::WebhookEventType::PaymentIntentAmountCapturableUpdated
|
||||
|
||||
@ -17,6 +17,7 @@ fn default_webhook_config() -> api::MerchantWebhookConfig {
|
||||
api::IncomingWebhookEvent::PaymentIntentSuccess,
|
||||
api::IncomingWebhookEvent::PaymentIntentFailure,
|
||||
api::IncomingWebhookEvent::PaymentIntentProcessing,
|
||||
api::IncomingWebhookEvent::PaymentIntentCancelled,
|
||||
api::IncomingWebhookEvent::PaymentActionRequired,
|
||||
api::IncomingWebhookEvent::RefundSuccess,
|
||||
])
|
||||
|
||||
@ -257,8 +257,8 @@ impl ForeignFrom<api_enums::IntentStatus> for Option<storage_enums::EventType> {
|
||||
| api_enums::IntentStatus::RequiresCustomerAction => {
|
||||
Some(storage_enums::EventType::ActionRequired)
|
||||
}
|
||||
api_enums::IntentStatus::Cancelled
|
||||
| api_enums::IntentStatus::RequiresPaymentMethod
|
||||
api_enums::IntentStatus::Cancelled => Some(storage_enums::EventType::PaymentCancelled),
|
||||
api_enums::IntentStatus::RequiresPaymentMethod
|
||||
| api_enums::IntentStatus::RequiresConfirmation
|
||||
| api_enums::IntentStatus::RequiresCapture
|
||||
| api_enums::IntentStatus::PartiallyCaptured => None,
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
Select 1;
|
||||
@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TYPE "EventType" ADD VALUE 'payment_cancelled';
|
||||
@ -5076,6 +5076,7 @@
|
||||
"payment_succeeded",
|
||||
"payment_failed",
|
||||
"payment_processing",
|
||||
"payment_cancelled",
|
||||
"action_required",
|
||||
"refund_succeeded",
|
||||
"refund_failed",
|
||||
|
||||
Reference in New Issue
Block a user