@@ -8,7 +8,10 @@ use common_utils::{
8
8
errors:: CustomResult ,
9
9
ext_traits:: { ByteSliceExt , OptionExt } ,
10
10
request:: { Method , Request , RequestBuilder , RequestContent } ,
11
- types:: { AmountConvertor , MinorUnit , MinorUnitForConnector } ,
11
+ types:: {
12
+ AmountConvertor , MinorUnit , MinorUnitForConnector , StringMinorUnit ,
13
+ StringMinorUnitForConnector ,
14
+ } ,
12
15
} ;
13
16
use error_stack:: { report, ResultExt } ;
14
17
use hyperswitch_domain_models:: {
@@ -86,7 +89,7 @@ use crate::{
86
89
SubmitEvidenceRouterData ,
87
90
} ,
88
91
utils:: {
89
- self as connector_utils , convert_payment_authorize_router_response,
92
+ convert_amount , convert_payment_authorize_router_response,
90
93
convert_setup_mandate_router_data_to_authorize_router_data, is_mandate_supported,
91
94
ForeignTryFrom , PaymentMethodDataType ,
92
95
} ,
@@ -96,12 +99,14 @@ const ADYEN_API_VERSION: &str = "v68";
96
99
#[ derive( Clone ) ]
97
100
pub struct Adyen {
98
101
amount_converter : & ' static ( dyn AmountConvertor < Output = MinorUnit > + Sync ) ,
102
+ amount_converter_webhooks : & ' static ( dyn AmountConvertor < Output = StringMinorUnit > + Sync ) ,
99
103
}
100
104
101
105
impl Adyen {
102
106
pub const fn new ( ) -> & ' static Self {
103
107
& Self {
104
108
amount_converter : & MinorUnitForConnector ,
109
+ amount_converter_webhooks : & StringMinorUnitForConnector ,
105
110
}
106
111
}
107
112
}
@@ -467,7 +472,7 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
467
472
convert_setup_mandate_router_data_to_authorize_router_data ( req) ,
468
473
) ) ;
469
474
470
- let amount = connector_utils :: convert_amount (
475
+ let amount = convert_amount (
471
476
self . amount_converter ,
472
477
authorize_req. request . minor_amount ,
473
478
authorize_req. request . currency ,
@@ -584,7 +589,7 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
584
589
req : & PaymentsCaptureRouterData ,
585
590
_connectors : & Connectors ,
586
591
) -> CustomResult < RequestContent , errors:: ConnectorError > {
587
- let amount_to_capture = connector_utils :: convert_amount (
592
+ let amount_to_capture = convert_amount (
588
593
self . amount_converter ,
589
594
req. request . minor_amount_to_capture ,
590
595
req. request . currency ,
@@ -850,7 +855,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
850
855
req : & PaymentsAuthorizeRouterData ,
851
856
_connectors : & Connectors ,
852
857
) -> CustomResult < RequestContent , errors:: ConnectorError > {
853
- let amount = connector_utils :: convert_amount (
858
+ let amount = convert_amount (
854
859
self . amount_converter ,
855
860
req. request . minor_amount ,
856
861
req. request . currency ,
@@ -1013,7 +1018,7 @@ impl ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResp
1013
1018
} ) ?,
1014
1019
} ;
1015
1020
1016
- let amount = connector_utils :: convert_amount ( self . amount_converter , amount, currency) ?;
1021
+ let amount = convert_amount ( self . amount_converter , amount, currency) ?;
1017
1022
1018
1023
if response. balance . currency != currency || response. balance . value < amount {
1019
1024
Ok ( RouterData {
@@ -1298,7 +1303,7 @@ impl ConnectorIntegration<PoCreate, PayoutsData, PayoutsResponseData> for Adyen
1298
1303
req : & PayoutsRouterData < PoCreate > ,
1299
1304
_connectors : & Connectors ,
1300
1305
) -> CustomResult < RequestContent , errors:: ConnectorError > {
1301
- let amount = connector_utils :: convert_amount (
1306
+ let amount = convert_amount (
1302
1307
self . amount_converter ,
1303
1308
req. request . minor_amount ,
1304
1309
req. request . destination_currency ,
@@ -1396,7 +1401,7 @@ impl ConnectorIntegration<PoEligibility, PayoutsData, PayoutsResponseData> for A
1396
1401
req : & PayoutsRouterData < PoEligibility > ,
1397
1402
_connectors : & Connectors ,
1398
1403
) -> CustomResult < RequestContent , errors:: ConnectorError > {
1399
- let amount = connector_utils :: convert_amount (
1404
+ let amount = convert_amount (
1400
1405
self . amount_converter ,
1401
1406
req. request . minor_amount ,
1402
1407
req. request . destination_currency ,
@@ -1523,7 +1528,7 @@ impl ConnectorIntegration<PoFulfill, PayoutsData, PayoutsResponseData> for Adyen
1523
1528
req : & PayoutsRouterData < PoFulfill > ,
1524
1529
_connectors : & Connectors ,
1525
1530
) -> CustomResult < RequestContent , errors:: ConnectorError > {
1526
- let amount = connector_utils :: convert_amount (
1531
+ let amount = convert_amount (
1527
1532
self . amount_converter ,
1528
1533
req. request . minor_amount ,
1529
1534
req. request . destination_currency ,
@@ -1628,7 +1633,7 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Adyen {
1628
1633
req : & RefundsRouterData < Execute > ,
1629
1634
_connectors : & Connectors ,
1630
1635
) -> CustomResult < RequestContent , errors:: ConnectorError > {
1631
- let refund_amount = connector_utils :: convert_amount (
1636
+ let refund_amount = convert_amount (
1632
1637
self . amount_converter ,
1633
1638
req. request . minor_refund_amount ,
1634
1639
req. request . currency ,
@@ -1876,8 +1881,14 @@ impl IncomingWebhook for Adyen {
1876
1881
) -> CustomResult < disputes:: DisputePayload , errors:: ConnectorError > {
1877
1882
let notif = get_webhook_object_from_body ( request. body )
1878
1883
. change_context ( errors:: ConnectorError :: WebhookBodyDecodingFailed ) ?;
1884
+
1885
+ let amount = convert_amount (
1886
+ self . amount_converter_webhooks ,
1887
+ notif. amount . value ,
1888
+ notif. amount . currency ,
1889
+ ) ?;
1879
1890
Ok ( disputes:: DisputePayload {
1880
- amount : notif . amount . value . to_string ( ) ,
1891
+ amount,
1881
1892
currency : notif. amount . currency ,
1882
1893
dispute_stage : api_models:: enums:: DisputeStage :: from ( notif. event_code . clone ( ) ) ,
1883
1894
connector_dispute_id : notif. psp_reference ,
0 commit comments