Skip to content
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

feat(router): add outgoing payment webhooks for v2 #6613

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
110a041
feat: implement payments retrieve for v2
Narayanbhat166 Oct 29, 2024
579cec1
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Oct 29, 2024
d098629
refactor: remove direct attempt access in call_connector_service
Narayanbhat166 Oct 29, 2024
186136c
chore: run formatter
hyperswitch-bot[bot] Oct 29, 2024
a5d0526
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Oct 29, 2024
d040fbc
chore: rename PaymentStatusRequest to PaymentRetrieveRequest
Narayanbhat166 Oct 30, 2024
c5e4df2
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Oct 30, 2024
ef71de3
chore: cargo clippy
Narayanbhat166 Oct 30, 2024
e50a071
refactor: use separate update enums for sync update
Narayanbhat166 Oct 30, 2024
0643a08
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Oct 31, 2024
575ef18
chore: run formatter
hyperswitch-bot[bot] Oct 31, 2024
0e93355
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Oct 31, 2024
ebe079f
chore: cargo clippy
Narayanbhat166 Oct 31, 2024
ba7daba
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Nov 4, 2024
1c5212c
refactor: address PR comments
Narayanbhat166 Nov 4, 2024
5709519
chore: run formatter
hyperswitch-bot[bot] Nov 4, 2024
56dab7e
refactor: move updatable trackers objects to a trait on router_data
Narayanbhat166 Nov 4, 2024
95b51f4
chore: cargo clippy
Narayanbhat166 Nov 4, 2024
940fbe0
refactor: change payments retrieve to get api and added jwt auth
Narayanbhat166 Nov 4, 2024
e832d29
refactor: allow force sync for PartiallyCapturedAndCapturable status
Narayanbhat166 Nov 4, 2024
f8ed350
chore: add a todo comment
Narayanbhat166 Nov 4, 2024
f26679e
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Nov 5, 2024
252bd8e
chore: cargo cilipy
Narayanbhat166 Nov 5, 2024
002b060
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Nov 5, 2024
b85b6f6
refactor: remove client secret auth and add header auth
Narayanbhat166 Nov 5, 2024
62c4479
chore: remove unused struct
Narayanbhat166 Nov 5, 2024
3248d77
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Nov 6, 2024
76d872a
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Nov 8, 2024
cc54284
chore: cargo clippy_v2
Narayanbhat166 Nov 8, 2024
d050efb
Merge branch 'main' into payment_sync_v2
Narayanbhat166 Nov 9, 2024
301bd59
refactor: rename authentication data to redirect form
Narayanbhat166 Nov 9, 2024
ee63776
chore: run formatter
hyperswitch-bot[bot] Nov 9, 2024
4475dab
wip: add payment sync PR and fix errors
Narayanbhat166 Nov 11, 2024
f5cd386
wip: add payment sync PR and fix errors
Narayanbhat166 Nov 11, 2024
c7feceb
chore: fix cargo run failure
hrithikesh026 Nov 11, 2024
400b356
refactor: fix errors in authentication
Narayanbhat166 Nov 11, 2024
5a6eb53
chore: cargo clippy
Narayanbhat166 Nov 11, 2024
9887b71
chore: update mintlify
Narayanbhat166 Nov 12, 2024
9a1b053
Merge branch 'main' into add_payment_sync_openapi
Narayanbhat166 Nov 12, 2024
223babf
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Nov 12, 2024
9163455
chore: cargo clippy
Narayanbhat166 Nov 12, 2024
a1bff1a
resolve conflicts
hrithikesh026 Nov 11, 2024
84e1300
chore: remove unwanted feature flagging
Narayanbhat166 Nov 12, 2024
fcd73a0
refactor: fix errors in authentication
Narayanbhat166 Nov 11, 2024
1a26d2f
wip: add payments finish redirection
Narayanbhat166 Nov 12, 2024
7671603
wip: add payments finish redirection checkpoint 2
Narayanbhat166 Nov 12, 2024
0177677
feat: add payments redirection endpoint
Narayanbhat166 Nov 12, 2024
6a9518a
refactor: test and fix minor bugs in creating finish redirection url
Narayanbhat166 Nov 12, 2024
ad1df13
chore: add status to finish redirection
Narayanbhat166 Nov 12, 2024
ddece54
refactor: move get trackers to payments_operation from payments_opera…
Narayanbhat166 Nov 13, 2024
58d24e5
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Nov 13, 2024
70f3a26
refactor: get call connector action from connector
Narayanbhat166 Nov 13, 2024
d0fcf8d
chore: run formatter
hyperswitch-bot[bot] Nov 13, 2024
76ca26f
chore: cargo clippy
Narayanbhat166 Nov 13, 2024
401515f
add payment incoming webhooks support for v2
sai-harsha-vardhan Nov 13, 2024
5311abc
resolve conflicts
sai-harsha-vardhan Nov 13, 2024
907fbc2
resolve comments
sai-harsha-vardhan Nov 13, 2024
5dbfaba
resolve conflicts
sai-harsha-vardhan Nov 13, 2024
776def6
chore: change printables and strings
Narayanbhat166 Nov 13, 2024
70915d1
chore: remove dependency graph
Narayanbhat166 Nov 13, 2024
df4d0d9
chore: remove unwanted files
Narayanbhat166 Nov 13, 2024
94aa0da
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Nov 13, 2024
c2747c4
resolve conflicts
sai-harsha-vardhan Nov 13, 2024
597da4d
resolve comments
sai-harsha-vardhan Nov 14, 2024
d887550
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Nov 14, 2024
d82e2a1
add outgoing webhooks for payments v2
sai-harsha-vardhan Nov 19, 2024
6d3b880
resolve conflicts
sai-harsha-vardhan Nov 19, 2024
bbb6b2d
Merge branch 'main' into add-outgoing-webhooks-v2
sai-harsha-vardhan Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/diesel_models/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,39 @@ pub struct Event {
#[derive(Clone, Debug, Deserialize, Serialize, AsExpression, diesel::FromSqlRow)]
#[diesel(sql_type = diesel::sql_types::Jsonb)]
pub enum EventMetadata {
#[cfg(feature = "v1")]
Payment {
payment_id: common_utils::id_type::PaymentId,
},
#[cfg(feature = "v2")]
Payment {
payment_id: common_utils::id_type::GlobalPaymentId,
},
Payout {
payout_id: String,
},
#[cfg(feature = "v1")]
Refund {
payment_id: common_utils::id_type::PaymentId,
refund_id: String,
},
#[cfg(feature = "v2")]
Refund {
payment_id: common_utils::id_type::GlobalPaymentId,
refund_id: common_utils::id_type::GlobalRefundId,
},
#[cfg(feature = "v1")]
Dispute {
payment_id: common_utils::id_type::PaymentId,
attempt_id: String,
dispute_id: String,
},
#[cfg(feature = "v2")]
Dispute {
payment_id: common_utils::id_type::GlobalPaymentId,
attempt_id: String,
dispute_id: String,
},
Mandate {
payment_method_id: String,
mandate_id: String,
Expand Down
8 changes: 6 additions & 2 deletions crates/router/src/core/webhooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ mod incoming;
mod incoming_v2;
#[cfg(feature = "v1")]
mod outgoing;
#[cfg(feature = "v2")]
mod outgoing_v2;
pub mod types;
pub mod utils;
#[cfg(feature = "olap")]
pub mod webhook_events;

#[cfg(feature = "v2")]
pub(crate) use self::incoming_v2::incoming_webhooks_wrapper;
#[cfg(feature = "v1")]
pub(crate) use self::{
incoming::incoming_webhooks_wrapper,
Expand All @@ -19,5 +19,9 @@ pub(crate) use self::{
trigger_webhook_and_raise_event,
},
};
#[cfg(feature = "v2")]
pub(crate) use self::{
incoming_v2::incoming_webhooks_wrapper, outgoing_v2::create_event_and_trigger_outgoing_webhook,
};

const MERCHANT_ID: &str = "merchant_id";
32 changes: 16 additions & 16 deletions crates/router/src/core/webhooks/incoming_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ async fn payments_incoming_webhook_flow(
req_state,
merchant_account.clone(),
key_store.clone(),
profile,
profile.clone(),
payments::operations::PaymentGet,
api::PaymentsRetrieveRequest {
force_sync: true,
Expand Down Expand Up @@ -499,22 +499,22 @@ async fn payments_incoming_webhook_flow(
let event_type: Option<enums::EventType> = payments_response.status.foreign_into();

// If event is NOT an UnsupportedEvent, trigger Outgoing Webhook
if let Some(_outgoing_event_type) = event_type {
let _primary_object_created_at = payments_response.created;
if let Some(outgoing_event_type) = event_type {
let primary_object_created_at = payments_response.created;
// TODO: trigger an outgoing webhook to merchant
// Box::pin(super::create_event_and_trigger_outgoing_webhook(
// state,
// merchant_account,
// profile,
// &key_store,
// outgoing_event_type,
// enums::EventClass::Payments,
// payment_id.get_string_repr().to_owned(),
// enums::EventObjectType::PaymentDetails,
// api::OutgoingWebhookContent::PaymentDetails(Box::new(payments_response)),
// Some(primary_object_created_at),
// ))
// .await?;
Box::pin(super::create_event_and_trigger_outgoing_webhook(
state,
merchant_account,
profile,
&key_store,
outgoing_event_type,
enums::EventClass::Payments,
payment_id.get_string_repr().to_owned(),
enums::EventObjectType::PaymentDetails,
api::OutgoingWebhookContent::PaymentDetails(Box::new(payments_response)),
Some(primary_object_created_at),
))
.await?;
};

let response = WebhookResponseTracker::Payment { payment_id, status };
Expand Down
Loading
Loading