@@ -6,7 +6,8 @@ use common_utils::{
6
6
use serde:: { Deserialize , Serialize } ;
7
7
use time:: PrimitiveDateTime ;
8
8
9
- use crate :: { errors, MerchantStorageScheme } ;
9
+ use super :: { payment_attempt:: PaymentAttempt , PaymentIntent } ;
10
+ use crate :: { errors, MerchantStorageScheme , RemoteStorageObject } ;
10
11
#[ async_trait:: async_trait]
11
12
pub trait PaymentIntentInterface {
12
13
async fn update_payment_intent (
@@ -29,6 +30,12 @@ pub trait PaymentIntentInterface {
29
30
storage_scheme : MerchantStorageScheme ,
30
31
) -> error_stack:: Result < PaymentIntent , errors:: StorageError > ;
31
32
33
+ async fn get_active_payment_attempt (
34
+ & self ,
35
+ payment : & mut PaymentIntent ,
36
+ storage_scheme : MerchantStorageScheme ,
37
+ ) -> error_stack:: Result < PaymentAttempt , errors:: StorageError > ;
38
+
32
39
#[ cfg( feature = "olap" ) ]
33
40
async fn filter_payment_intent_by_constraints (
34
41
& self ,
@@ -51,10 +58,7 @@ pub trait PaymentIntentInterface {
51
58
merchant_id : & str ,
52
59
constraints : & PaymentIntentFetchConstraints ,
53
60
storage_scheme : MerchantStorageScheme ,
54
- ) -> error_stack:: Result <
55
- Vec < ( PaymentIntent , super :: payment_attempt:: PaymentAttempt ) > ,
56
- errors:: StorageError ,
57
- > ;
61
+ ) -> error_stack:: Result < Vec < ( PaymentIntent , PaymentAttempt ) > , errors:: StorageError > ;
58
62
59
63
#[ cfg( feature = "olap" ) ]
60
64
async fn get_filtered_active_attempt_ids_for_total_count (
@@ -65,50 +69,7 @@ pub trait PaymentIntentInterface {
65
69
) -> error_stack:: Result < Vec < String > , errors:: StorageError > ;
66
70
}
67
71
68
- #[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize ) ]
69
- pub struct PaymentIntent {
70
- pub id : i32 ,
71
- pub payment_id : String ,
72
- pub merchant_id : String ,
73
- pub status : storage_enums:: IntentStatus ,
74
- pub amount : i64 ,
75
- pub currency : Option < storage_enums:: Currency > ,
76
- pub amount_captured : Option < i64 > ,
77
- pub customer_id : Option < String > ,
78
- pub description : Option < String > ,
79
- pub return_url : Option < String > ,
80
- pub metadata : Option < pii:: SecretSerdeValue > ,
81
- pub connector_id : Option < String > ,
82
- pub shipping_address_id : Option < String > ,
83
- pub billing_address_id : Option < String > ,
84
- pub statement_descriptor_name : Option < String > ,
85
- pub statement_descriptor_suffix : Option < String > ,
86
- #[ serde( with = "common_utils::custom_serde::iso8601" ) ]
87
- pub created_at : PrimitiveDateTime ,
88
- #[ serde( with = "common_utils::custom_serde::iso8601" ) ]
89
- pub modified_at : PrimitiveDateTime ,
90
- #[ serde( default , with = "common_utils::custom_serde::iso8601::option" ) ]
91
- pub last_synced : Option < PrimitiveDateTime > ,
92
- pub setup_future_usage : Option < storage_enums:: FutureUsage > ,
93
- pub off_session : Option < bool > ,
94
- pub client_secret : Option < String > ,
95
- pub active_attempt_id : String ,
96
- pub business_country : Option < storage_enums:: CountryAlpha2 > ,
97
- pub business_label : Option < String > ,
98
- pub order_details : Option < Vec < pii:: SecretSerdeValue > > ,
99
- pub allowed_payment_method_types : Option < serde_json:: Value > ,
100
- pub connector_metadata : Option < serde_json:: Value > ,
101
- pub feature_metadata : Option < serde_json:: Value > ,
102
- pub attempt_count : i16 ,
103
- pub profile_id : Option < String > ,
104
- // Denotes the action(approve or reject) taken by merchant in case of manual review.
105
- // Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto payment
106
- pub merchant_decision : Option < String > ,
107
- pub payment_link_id : Option < String > ,
108
- pub payment_confirm_source : Option < storage_enums:: PaymentSource > ,
109
- }
110
-
111
- #[ derive( Clone , Debug , Default , Eq , PartialEq , Serialize , Deserialize ) ]
72
+ #[ derive( Clone , Debug , Eq , PartialEq ) ]
112
73
pub struct PaymentIntentNew {
113
74
pub payment_id : String ,
114
75
pub merchant_id : String ,
@@ -125,16 +86,13 @@ pub struct PaymentIntentNew {
125
86
pub billing_address_id : Option < String > ,
126
87
pub statement_descriptor_name : Option < String > ,
127
88
pub statement_descriptor_suffix : Option < String > ,
128
- #[ serde( default , with = "common_utils::custom_serde::iso8601::option" ) ]
129
89
pub created_at : Option < PrimitiveDateTime > ,
130
- #[ serde( default , with = "common_utils::custom_serde::iso8601::option" ) ]
131
90
pub modified_at : Option < PrimitiveDateTime > ,
132
- #[ serde( default , with = "common_utils::custom_serde::iso8601::option" ) ]
133
91
pub last_synced : Option < PrimitiveDateTime > ,
134
92
pub setup_future_usage : Option < storage_enums:: FutureUsage > ,
135
93
pub off_session : Option < bool > ,
136
94
pub client_secret : Option < String > ,
137
- pub active_attempt_id : String ,
95
+ pub active_attempt : RemoteStorageObject < PaymentAttempt > ,
138
96
pub business_country : Option < storage_enums:: CountryAlpha2 > ,
139
97
pub business_label : Option < String > ,
140
98
pub order_details : Option < Vec < pii:: SecretSerdeValue > > ,
0 commit comments