File tree 1 file changed +15
-10
lines changed
crates/router/src/types/api
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -68,18 +68,23 @@ impl PaymentMethodCreateExt for PaymentMethodCreate {
68
68
#[ cfg( all( feature = "v2" , feature = "payment_methods_v2" ) ) ]
69
69
impl PaymentMethodCreateExt for PaymentMethodCreate {
70
70
fn validate ( & self ) -> RouterResult < ( ) > {
71
- self . payment_method_subtype . map ( |pm_subtype| {
72
- if !validate_payment_method_type_against_payment_method (
73
- self . payment_method_type ,
74
- pm_subtype,
75
- ) {
76
- return Err ( report ! ( errors:: ApiErrorResponse :: InvalidRequestData {
71
+ utils:: when (
72
+ !self
73
+ . payment_method_subtype
74
+ . map ( |sub| {
75
+ validate_payment_method_type_against_payment_method (
76
+ self . payment_method_type ,
77
+ sub,
78
+ )
79
+ } )
80
+ . unwrap_or ( true ) , // If payment_method_subtype is None, we assume it to be valid
81
+ || {
82
+ Err ( report ! ( errors:: ApiErrorResponse :: InvalidRequestData {
77
83
message: "Invalid 'payment_method_type' provided" . to_string( )
78
84
} )
79
- . attach_printable ( "Invalid payment method type" ) ) ;
80
- }
81
- Ok ( ( ) )
82
- } ) ;
85
+ . attach_printable ( "Invalid payment method type" ) )
86
+ } ,
87
+ ) ?;
83
88
84
89
utils:: when (
85
90
!Self :: validate_payment_method_data_against_payment_method (
You can’t perform that action at this time.
0 commit comments