@@ -191,28 +191,30 @@ pub struct ArchipelCardHolder {
191
191
billing_address : Option < ArchipelBillingAddress > ,
192
192
}
193
193
194
- impl TryFrom < Option < ArchipelBillingAddress > > for ArchipelCardHolder {
195
- type Error = ( ) ;
196
- fn try_from ( value : Option < ArchipelBillingAddress > ) -> Result < Self , Self :: Error > {
197
- Ok ( Self {
194
+ impl From < Option < ArchipelBillingAddress > > for ArchipelCardHolder {
195
+ fn from ( value : Option < ArchipelBillingAddress > ) -> Self {
196
+ Self {
198
197
billing_address : value,
199
- } )
198
+ }
200
199
}
201
200
}
202
201
203
202
#[ derive( Debug , Serialize , Eq , PartialEq ) ]
204
203
#[ serde( rename_all = "camelCase" ) ]
205
204
pub struct ArchipelBillingAddress {
206
- address : Secret < String > ,
207
- postal_code : Secret < String > ,
205
+ address : Option < Secret < String > > ,
206
+ postal_code : Option < Secret < String > > ,
208
207
}
209
208
210
- impl TryFrom < & AddressDetails > for ArchipelBillingAddress {
211
- type Error = error_stack:: Report < errors:: ConnectorError > ;
212
- fn try_from ( address_details : & AddressDetails ) -> Result < Self , Self :: Error > {
213
- Ok ( Self {
214
- address : address_details. get_combined_address_line ( ) ?,
215
- postal_code : address_details. get_zip ( ) ?. clone ( ) ,
209
+ pub trait ToArchipelBillingAddress {
210
+ fn to_archipel_billing_address ( & self ) -> Option < ArchipelBillingAddress > ;
211
+ }
212
+
213
+ impl ToArchipelBillingAddress for AddressDetails {
214
+ fn to_archipel_billing_address ( & self ) -> Option < ArchipelBillingAddress > {
215
+ Some ( ArchipelBillingAddress {
216
+ address : self . get_combined_address_line ( ) . ok ( ) ,
217
+ postal_code : self . get_optional_zip ( ) ,
216
218
} )
217
219
}
218
220
}
@@ -658,13 +660,15 @@ impl TryFrom<(MinorUnit, &PaymentsAuthorizeRouterData)> for ArchipelPaymentInfor
658
660
initiator : transaction_initiator. clone ( ) ,
659
661
} ;
660
662
661
- let card_holder_name = router_data. get_billing ( ) ?. get_optional_full_name ( ) ;
663
+ let card_holder_name: Option < Secret < String > > = router_data
664
+ . get_billing ( )
665
+ . ok ( )
666
+ . and_then ( |billing| billing. get_optional_full_name ( ) ) ;
662
667
let cardholder = Some ( ArchipelCardHolder {
663
- billing_address : Some (
664
- router_data
665
- . get_billing_address ( )
666
- . and_then ( ArchipelBillingAddress :: try_from) ?,
667
- ) ,
668
+ billing_address : router_data
669
+ . get_billing_address ( )
670
+ . ok ( )
671
+ . and_then ( |address| address. to_archipel_billing_address ( ) ) ,
668
672
} ) ;
669
673
670
674
let indicator_status = if is_subsequent_trx {
@@ -1027,14 +1031,18 @@ impl TryFrom<ArchipelRouterData<&SetupMandateRouterData>> for ArchipelCardAuthor
1027
1031
initiator : ArchipelPaymentInitiator :: Customer ,
1028
1032
} ;
1029
1033
1030
- let card_holder_name = item. router_data . get_billing ( ) ?. get_optional_full_name ( ) ;
1034
+ let card_holder_name = item
1035
+ . router_data
1036
+ . get_billing ( )
1037
+ . ok ( )
1038
+ . and_then ( |billing| billing. get_optional_full_name ( ) ) ;
1031
1039
1032
1040
let cardholder = Some ( ArchipelCardHolder {
1033
- billing_address : Some (
1034
- item . router_data
1035
- . get_billing_address ( )
1036
- . and_then ( ArchipelBillingAddress :: try_from ) ? ,
1037
- ) ,
1041
+ billing_address : item
1042
+ . router_data
1043
+ . get_billing_address ( )
1044
+ . ok ( )
1045
+ . and_then ( |address| address . to_archipel_billing_address ( ) ) ,
1038
1046
} ) ;
1039
1047
1040
1048
let stored_on_file = true ;
0 commit comments