-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(router): added incoming refund webhooks flow #683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SanchithHegde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that, looks good to me!
crates/router/src/connector/adyen.rs
Outdated
| "AUTHORISATION" => api::IncomingWebhookEvent::PaymentIntentSuccess, | ||
| "REFUND" => api::IncomingWebhookEvent::RefundSuccess, | ||
| "CANCEL_OR_REFUND" => api::IncomingWebhookEvent::RefundSuccess, | ||
| "REFUND_FAILED" => api::IncomingWebhookEvent::RefundFailure, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these event codes have been documented on their docs, please convert this to an enum instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
| CREATE TYPE "EventClass" AS ENUM ('payments', 'refunds'); | ||
|
|
||
| CREATE TYPE "EventObjectType" AS ENUM ('payment_details'); | ||
| CREATE TYPE "EventObjectType" AS ENUM ('payment_details', 'refund_details'); | ||
|
|
||
| CREATE TYPE "EventType" AS ENUM ('payment_succeeded'); | ||
| CREATE TYPE "EventType" AS ENUM ('payment_succeeded', 'refund_succeeded', 'refund_failed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add new migrations for these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, adding the migrations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert changes made to this old migrations file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
| #[derive(Debug, Deserialize)] | ||
| pub enum WebhookEventCode { | ||
| #[serde(rename = "AUTHORISATION")] | ||
| Authorisation, | ||
| #[serde(rename = "REFUND")] | ||
| Refund, | ||
| #[serde(rename = "CANCEL_OR_REFUND")] | ||
| CancelOrRefund, | ||
| #[serde(rename = "REFUND_FAILED")] | ||
| RefundFailed, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #[derive(Debug, Deserialize)] | |
| pub enum WebhookEventCode { | |
| #[serde(rename = "AUTHORISATION")] | |
| Authorisation, | |
| #[serde(rename = "REFUND")] | |
| Refund, | |
| #[serde(rename = "CANCEL_OR_REFUND")] | |
| CancelOrRefund, | |
| #[serde(rename = "REFUND_FAILED")] | |
| RefundFailed, | |
| } | |
| #[derive(Debug, Deserialize)] | |
| #[serde(rename_all = "SCREAMING_SNAKE_CASE") | |
| pub enum WebhookEventCode { | |
| Authorisation, | |
| Refund, | |
| CancelOrRefund, | |
| RefundFailed, | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
SanchithHegde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the pg_enum table being modified in the down.sql file, looks good to me!
| #[derive(Debug, Deserialize)] | ||
| #[serde(rename_all = "SCREAMING_SNAKE_CASE")] | ||
| pub enum WebhookEventCode { | ||
| Authorisation, | ||
| Refund, | ||
| CancelOrRefund, | ||
| RefundFailed, | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derive strum::Display and annotate with #[strum(serialize_all = "SCREAMING_SNAKE_CASE")] to get a display implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/router/src/connector/adyen.rs
Outdated
|
|
||
| let message = format!( | ||
| "{}:{}:{}:{}:{}:{}:{}:{}", | ||
| "{}:{}:{}:{}:{}:{}:{:?}:{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a display implementation for event_code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
vspecky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
crates/router/src/connector/adyen.rs
Outdated
| Ok(match notif.event_code { | ||
| adyen::WebhookEventCode::Authorisation => { | ||
| api::IncomingWebhookEvent::PaymentIntentSuccess | ||
| } | ||
| adyen::WebhookEventCode::Refund => api::IncomingWebhookEvent::RefundSuccess, | ||
| adyen::WebhookEventCode::CancelOrRefund => api::IncomingWebhookEvent::RefundSuccess, | ||
| adyen::WebhookEventCode::RefundFailed => api::IncomingWebhookEvent::RefundFailure, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be converted to From implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
vspecky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Type of Change
Description
Added support for incoming refund webhooks.
Additional Changes
Motivation and Context
How did you test it?
Manually tested

Webhook Request
Outgoing webhook to merchant

Checklist
cargo +nightly fmt --allcargo clippy