@@ -15,7 +15,7 @@ use common_utils::{
15
15
id_type, pii,
16
16
types:: {
17
17
keymanager:: { self , KeyManagerState } ,
18
- ConnectorTransactionId , ConnectorTransactionIdTrait , MinorUnit ,
18
+ ConnectorTransactionId , ConnectorTransactionIdTrait , CreatedBy , MinorUnit ,
19
19
} ,
20
20
} ;
21
21
use diesel_models:: {
@@ -463,6 +463,10 @@ pub struct PaymentAttempt {
463
463
pub charges : Option < common_types:: payments:: ConnectorChargeResponseData > ,
464
464
/// Additional data that might be required by hyperswitch, to enable some specific features.
465
465
pub feature_metadata : Option < PaymentAttemptFeatureMetadata > ,
466
+ /// merchant who owns the credentials of the processor, i.e. processor owner
467
+ pub processor_merchant_id : id_type:: MerchantId ,
468
+ /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))
469
+ pub created_by : Option < CreatedBy > ,
466
470
}
467
471
468
472
impl PaymentAttempt {
@@ -592,6 +596,8 @@ impl PaymentAttempt {
592
596
id,
593
597
card_discovery : None ,
594
598
feature_metadata : None ,
599
+ processor_merchant_id : payment_intent. merchant_id . clone ( ) ,
600
+ created_by : None ,
595
601
} )
596
602
}
597
603
@@ -679,6 +685,8 @@ impl PaymentAttempt {
679
685
feature_metadata : None ,
680
686
id,
681
687
card_discovery : None ,
688
+ processor_merchant_id : payment_intent. merchant_id . clone ( ) ,
689
+ created_by : None ,
682
690
} )
683
691
}
684
692
@@ -776,6 +784,8 @@ impl PaymentAttempt {
776
784
} ) ,
777
785
card_discovery : None ,
778
786
charges : None ,
787
+ processor_merchant_id : payment_intent. merchant_id . clone ( ) ,
788
+ created_by : None ,
779
789
} )
780
790
}
781
791
@@ -868,6 +878,10 @@ pub struct PaymentAttempt {
868
878
pub charges : Option < common_types:: payments:: ConnectorChargeResponseData > ,
869
879
pub issuer_error_code : Option < String > ,
870
880
pub issuer_error_message : Option < String > ,
881
+ /// merchant who owns the credentials of the processor, i.e. processor owner
882
+ pub processor_merchant_id : id_type:: MerchantId ,
883
+ /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))
884
+ pub created_by : Option < CreatedBy > ,
871
885
pub setup_future_usage_applied : Option < storage_enums:: FutureUsage > ,
872
886
}
873
887
@@ -1118,6 +1132,10 @@ pub struct PaymentAttemptNew {
1118
1132
pub extended_authorization_applied : Option < ExtendedAuthorizationAppliedBool > ,
1119
1133
pub capture_before : Option < PrimitiveDateTime > ,
1120
1134
pub card_discovery : Option < common_enums:: CardDiscovery > ,
1135
+ /// merchant who owns the credentials of the processor, i.e. processor owner
1136
+ pub processor_merchant_id : id_type:: MerchantId ,
1137
+ /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))
1138
+ pub created_by : Option < CreatedBy > ,
1121
1139
pub setup_future_usage_applied : Option < storage_enums:: FutureUsage > ,
1122
1140
}
1123
1141
@@ -1868,6 +1886,8 @@ impl behaviour::Conversion for PaymentAttempt {
1868
1886
setup_future_usage_applied : self . setup_future_usage_applied ,
1869
1887
// Below fields are deprecated. Please add any new fields above this line.
1870
1888
connector_transaction_data : None ,
1889
+ processor_merchant_id : Some ( self . processor_merchant_id ) ,
1890
+ created_by : self . created_by . map ( |cb| cb. to_string ( ) ) ,
1871
1891
} )
1872
1892
}
1873
1893
@@ -1886,7 +1906,7 @@ impl behaviour::Conversion for PaymentAttempt {
1886
1906
. cloned ( ) ;
1887
1907
Ok :: < Self , error_stack:: Report < common_utils:: errors:: CryptoError > > ( Self {
1888
1908
payment_id : storage_model. payment_id ,
1889
- merchant_id : storage_model. merchant_id ,
1909
+ merchant_id : storage_model. merchant_id . clone ( ) ,
1890
1910
attempt_id : storage_model. attempt_id ,
1891
1911
status : storage_model. status ,
1892
1912
net_amount : NetAmount :: new (
@@ -1956,6 +1976,12 @@ impl behaviour::Conversion for PaymentAttempt {
1956
1976
charges : storage_model. charges ,
1957
1977
issuer_error_code : storage_model. issuer_error_code ,
1958
1978
issuer_error_message : storage_model. issuer_error_message ,
1979
+ processor_merchant_id : storage_model
1980
+ . processor_merchant_id
1981
+ . unwrap_or ( storage_model. merchant_id ) ,
1982
+ created_by : storage_model
1983
+ . created_by
1984
+ . and_then ( |created_by| created_by. parse :: < CreatedBy > ( ) . ok ( ) ) ,
1959
1985
setup_future_usage_applied : storage_model. setup_future_usage_applied ,
1960
1986
} )
1961
1987
}
@@ -2042,6 +2068,8 @@ impl behaviour::Conversion for PaymentAttempt {
2042
2068
extended_authorization_applied : self . extended_authorization_applied ,
2043
2069
capture_before : self . capture_before ,
2044
2070
card_discovery : self . card_discovery ,
2071
+ processor_merchant_id : Some ( self . processor_merchant_id ) ,
2072
+ created_by : self . created_by . map ( |cb| cb. to_string ( ) ) ,
2045
2073
setup_future_usage_applied : self . setup_future_usage_applied ,
2046
2074
} )
2047
2075
}
@@ -2112,6 +2140,8 @@ impl behaviour::Conversion for PaymentAttempt {
2112
2140
card_discovery,
2113
2141
charges,
2114
2142
feature_metadata,
2143
+ processor_merchant_id,
2144
+ created_by,
2115
2145
} = self ;
2116
2146
2117
2147
let AttemptAmountDetails {
@@ -2204,6 +2234,8 @@ impl behaviour::Conversion for PaymentAttempt {
2204
2234
network_error_message : error
2205
2235
. as_ref ( )
2206
2236
. and_then ( |details| details. network_error_message . clone ( ) ) ,
2237
+ processor_merchant_id : Some ( processor_merchant_id) ,
2238
+ created_by : created_by. map ( |cb| cb. to_string ( ) ) ,
2207
2239
} )
2208
2240
}
2209
2241
@@ -2275,7 +2307,7 @@ impl behaviour::Conversion for PaymentAttempt {
2275
2307
2276
2308
Ok :: < Self , error_stack:: Report < common_utils:: errors:: CryptoError > > ( Self {
2277
2309
payment_id : storage_model. payment_id ,
2278
- merchant_id : storage_model. merchant_id ,
2310
+ merchant_id : storage_model. merchant_id . clone ( ) ,
2279
2311
id : storage_model. id ,
2280
2312
status : storage_model. status ,
2281
2313
amount_details,
@@ -2320,6 +2352,12 @@ impl behaviour::Conversion for PaymentAttempt {
2320
2352
connector_token_details : storage_model. connector_token_details ,
2321
2353
card_discovery : storage_model. card_discovery ,
2322
2354
feature_metadata : storage_model. feature_metadata . map ( From :: from) ,
2355
+ processor_merchant_id : storage_model
2356
+ . processor_merchant_id
2357
+ . unwrap_or ( storage_model. merchant_id ) ,
2358
+ created_by : storage_model
2359
+ . created_by
2360
+ . and_then ( |created_by| created_by. parse :: < CreatedBy > ( ) . ok ( ) ) ,
2323
2361
} )
2324
2362
}
2325
2363
. await
@@ -2376,6 +2414,8 @@ impl behaviour::Conversion for PaymentAttempt {
2376
2414
card_discovery,
2377
2415
charges,
2378
2416
feature_metadata,
2417
+ processor_merchant_id,
2418
+ created_by,
2379
2419
} = self ;
2380
2420
2381
2421
let card_network = payment_method_data
@@ -2465,6 +2505,8 @@ impl behaviour::Conversion for PaymentAttempt {
2465
2505
network_error_message : error_details
2466
2506
. as_ref ( )
2467
2507
. and_then ( |details| details. network_error_message . clone ( ) ) ,
2508
+ processor_merchant_id : Some ( processor_merchant_id) ,
2509
+ created_by : created_by. map ( |cb| cb. to_string ( ) ) ,
2468
2510
} )
2469
2511
}
2470
2512
}
0 commit comments