@@ -4,8 +4,7 @@ use api_models::payments::{MandateIds, MandateReferenceId};
44use base64:: Engine ;
55use common_enums:: { enums, Currency , PaymentChannel } ;
66use common_utils:: {
7- consts:: BASE64_ENGINE , errors:: CustomResult , ext_traits:: OptionExt , pii:: SecretSerdeValue ,
8- types:: MinorUnit ,
7+ consts:: BASE64_ENGINE , errors:: CustomResult , pii:: SecretSerdeValue , types:: MinorUnit ,
98} ;
109use error_stack:: ResultExt ;
1110use hyperswitch_domain_models:: {
@@ -64,28 +63,24 @@ fn fetch_payment_instrument(
6463 billing_address : Option < & Address > ,
6564 connector_mandate_id : Option < MandateIds > ,
6665) -> CustomResult < PaymentInstrument , ConnectorError > {
67- let billing_address =
68- if let Some ( address) = billing_address. and_then ( |addr| addr. address . clone ( ) ) {
69- Some ( BillingAddress {
70- address1 : address. line1 ,
71- address2 : address. line2 ,
72- address3 : address. line3 ,
73- city : address. city ,
74- state : address. state ,
75- postal_code : address
76- . zip
77- . get_required_value ( "zip" )
78- . change_context ( ConnectorError :: MissingRequiredField { field_name : "zip" } ) ?,
79- country_code : address
80- . country
81- . get_required_value ( "country_code" )
82- . change_context ( ConnectorError :: MissingRequiredField {
83- field_name : "country_code" ,
84- } ) ?,
85- } )
86- } else {
87- None
88- } ;
66+ let billing_address = billing_address
67+ . and_then ( |addr| addr. address . clone ( ) )
68+ . and_then (
69+ |address| match ( address. line1 , address. city , address. zip , address. country ) {
70+ ( Some ( address1) , Some ( city) , Some ( postal_code) , Some ( country_code) ) => {
71+ Some ( BillingAddress {
72+ address1,
73+ address2 : address. line2 ,
74+ address3 : address. line3 ,
75+ city,
76+ state : address. state ,
77+ postal_code,
78+ country_code,
79+ } )
80+ }
81+ _ => None ,
82+ } ,
83+ ) ;
8984 match payment_method {
9085 PaymentMethodData :: MandatePayment => {
9186 let mandate_id = connector_mandate_id
@@ -186,8 +181,13 @@ impl
186181 Ok ( Self {
187182 instruction : Instruction {
188183 request_auto_settlement : RequestAutoSettlement {
189- enabled : item. router_data . request . capture_method
190- == Some ( enums:: CaptureMethod :: Automatic ) ,
184+ enabled : match item. router_data . request . capture_method . unwrap_or_default ( ) {
185+ enums:: CaptureMethod :: Automatic
186+ | enums:: CaptureMethod :: SequentialAutomatic => true ,
187+ enums:: CaptureMethod :: Manual
188+ | enums:: CaptureMethod :: ManualMultiple
189+ | enums:: CaptureMethod :: Scheduled => false ,
190+ } ,
191191 } ,
192192 value : PaymentValue {
193193 amount : item. amount ,
0 commit comments