1
1
use api_models:: {
2
- enums:: DisputeStatus ,
2
+ enums:: { DisputeStatus , MandateStatus } ,
3
3
webhooks:: { self as api} ,
4
4
} ;
5
5
use common_utils:: { crypto:: SignMessage , date_time, ext_traits} ;
@@ -73,6 +73,7 @@ pub enum StripeWebhookObject {
73
73
PaymentIntent ( StripePaymentIntentResponse ) ,
74
74
Refund ( StripeRefundResponse ) ,
75
75
Dispute ( StripeDisputeResponse ) ,
76
+ Mandate ( StripeMandateResponse ) ,
76
77
}
77
78
78
79
#[ derive( Serialize , Debug ) ]
@@ -85,6 +86,22 @@ pub struct StripeDisputeResponse {
85
86
pub status : StripeDisputeStatus ,
86
87
}
87
88
89
+ #[ derive( Serialize , Debug ) ]
90
+ pub struct StripeMandateResponse {
91
+ pub mandate_id : String ,
92
+ pub status : StripeMandateStatus ,
93
+ pub payment_method_id : String ,
94
+ pub payment_method : String ,
95
+ }
96
+
97
+ #[ derive( Serialize , Debug ) ]
98
+ #[ serde( rename_all = "snake_case" ) ]
99
+ pub enum StripeMandateStatus {
100
+ Active ,
101
+ Inactive ,
102
+ Pending ,
103
+ }
104
+
88
105
#[ derive( Serialize , Debug ) ]
89
106
#[ serde( rename_all = "snake_case" ) ]
90
107
pub enum StripeDisputeStatus {
@@ -111,6 +128,27 @@ impl From<api_models::disputes::DisputeResponse> for StripeDisputeResponse {
111
128
}
112
129
}
113
130
131
+ impl From < api_models:: mandates:: MandateResponse > for StripeMandateResponse {
132
+ fn from ( res : api_models:: mandates:: MandateResponse ) -> Self {
133
+ Self {
134
+ mandate_id : res. mandate_id ,
135
+ payment_method : res. payment_method ,
136
+ payment_method_id : res. payment_method_id ,
137
+ status : StripeMandateStatus :: from ( res. status ) ,
138
+ }
139
+ }
140
+ }
141
+
142
+ impl From < MandateStatus > for StripeMandateStatus {
143
+ fn from ( status : MandateStatus ) -> Self {
144
+ match status {
145
+ MandateStatus :: Active => Self :: Active ,
146
+ MandateStatus :: Inactive | MandateStatus :: Revoked => Self :: Inactive ,
147
+ MandateStatus :: Pending => Self :: Pending ,
148
+ }
149
+ }
150
+ }
151
+
114
152
impl From < DisputeStatus > for StripeDisputeStatus {
115
153
fn from ( status : DisputeStatus ) -> Self {
116
154
match status {
@@ -142,6 +180,8 @@ fn get_stripe_event_type(event_type: api_models::enums::EventType) -> &'static s
142
180
api_models:: enums:: EventType :: DisputeChallenged => "dispute.challenged" ,
143
181
api_models:: enums:: EventType :: DisputeWon => "dispute.won" ,
144
182
api_models:: enums:: EventType :: DisputeLost => "dispute.lost" ,
183
+ api_models:: enums:: EventType :: MandateActive => "mandate.active" ,
184
+ api_models:: enums:: EventType :: MandateRevoked => "mandate.revoked" ,
145
185
}
146
186
}
147
187
@@ -179,6 +219,9 @@ impl From<api::OutgoingWebhookContent> for StripeWebhookObject {
179
219
api:: OutgoingWebhookContent :: DisputeDetails ( dispute) => {
180
220
Self :: Dispute ( ( * dispute) . into ( ) )
181
221
}
222
+ api:: OutgoingWebhookContent :: MandateDetails ( mandate) => {
223
+ Self :: Mandate ( ( * mandate) . into ( ) )
224
+ }
182
225
}
183
226
}
184
227
}
0 commit comments