Skip to content

Commit

Permalink
feat(connector): expand webhook event coverage stripe nmi (#3298)
Browse files Browse the repository at this point in the history
Co-authored-by: hrithikeshvm <[email protected]>
  • Loading branch information
hrithikesh026 and hrithikeshvm authored Jan 9, 2024
1 parent 5d5933d commit 7457f74
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
15 changes: 15 additions & 0 deletions crates/router/src/connector/nmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,21 @@ impl api::IncomingWebhook for Nmi {
reference_body.event_body.order_id,
),
),
nmi::NmiActionType::Auth => api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::PaymentAttemptId(
reference_body.event_body.order_id,
),
),
nmi::NmiActionType::Capture => api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::PaymentAttemptId(
reference_body.event_body.order_id,
),
),
nmi::NmiActionType::Void => api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::PaymentAttemptId(
reference_body.event_body.order_id,
),
),
nmi::NmiActionType::Refund => api_models::webhooks::ObjectReferenceId::RefundId(
api_models::webhooks::RefundIdType::RefundId(reference_body.event_body.order_id),
),
Expand Down
10 changes: 5 additions & 5 deletions crates/router/src/connector/nmi/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,15 +1167,15 @@ impl ForeignFrom<NmiWebhookEventType> for webhooks::IncomingWebhookEvent {
NmiWebhookEventType::RefundSuccess => Self::RefundSuccess,
NmiWebhookEventType::RefundFailure => Self::RefundFailure,
NmiWebhookEventType::VoidSuccess => Self::PaymentIntentCancelled,
NmiWebhookEventType::AuthSuccess => Self::PaymentIntentAuthorizationSuccess,
NmiWebhookEventType::CaptureSuccess => Self::PaymentIntentCaptureSuccess,
NmiWebhookEventType::AuthFailure => Self::PaymentIntentAuthorizationFailure,
NmiWebhookEventType::CaptureFailure => Self::PaymentIntentCaptureFailure,
NmiWebhookEventType::VoidFailure => Self::PaymentIntentCancelFailure,
NmiWebhookEventType::SaleUnknown
| NmiWebhookEventType::RefundUnknown
| NmiWebhookEventType::AuthSuccess
| NmiWebhookEventType::AuthFailure
| NmiWebhookEventType::AuthUnknown
| NmiWebhookEventType::VoidFailure
| NmiWebhookEventType::VoidUnknown
| NmiWebhookEventType::CaptureSuccess
| NmiWebhookEventType::CaptureFailure
| NmiWebhookEventType::CaptureUnknown => Self::EventNotSupported,
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/router/src/connector/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,9 @@ impl api::IncomingWebhook for Stripe {
stripe::WebhookEventType::PaymentIntentCanceled => {
api::IncomingWebhookEvent::PaymentIntentCancelled
}
stripe::WebhookEventType::PaymentIntentAmountCapturableUpdated => {
api::IncomingWebhookEvent::PaymentIntentAuthorizationSuccess
}
stripe::WebhookEventType::ChargeSucceeded => {
if let Some(stripe::WebhookPaymentMethodDetails {
payment_method:
Expand Down Expand Up @@ -2012,7 +2015,6 @@ impl api::IncomingWebhook for Stripe {
| stripe::WebhookEventType::ChargeRefunded
| stripe::WebhookEventType::PaymentIntentCreated
| stripe::WebhookEventType::PaymentIntentProcessing
| stripe::WebhookEventType::PaymentIntentAmountCapturableUpdated
| stripe::WebhookEventType::SourceTransactionCreated => {
api::IncomingWebhookEvent::EventNotSupported
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3268,7 +3268,7 @@ pub enum WebhookEventType {
PaymentIntentProcessing,
#[serde(rename = "payment_intent.requires_action")]
PaymentIntentRequiresAction,
#[serde(rename = "amount_capturable_updated")]
#[serde(rename = "payment_intent.amount_capturable_updated")]
PaymentIntentAmountCapturableUpdated,
#[serde(rename = "source.chargeable")]
SourceChargeable,
Expand Down
11 changes: 1 addition & 10 deletions crates/router/src/core/payments/operations/payment_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
services::RedirectForm,
types::{
self, api,
storage::{self, enums, payment_attempt::AttemptStatusExt},
storage::{self, enums},
transformers::{ForeignFrom, ForeignTryFrom},
CaptureSyncResponse,
},
Expand Down Expand Up @@ -632,15 +632,6 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
unified_code: error_status.clone(),
unified_message: error_status,
connector_response_reference_id,
amount_capturable: if router_data.status.is_terminal_status()
|| router_data
.status
.maps_to_intent_status(enums::IntentStatus::Processing)
{
Some(0)
} else {
None
},
updated_by: storage_scheme.to_string(),
authentication_data,
encoded_data,
Expand Down

0 comments on commit 7457f74

Please sign in to comment.