fix: requires payment method data for paypal (#248)

This commit is contained in:
Sangamesh Kulkarni
2022-12-28 13:50:19 +05:30
committed by GitHub
parent 781b6dded2
commit ed27b0c61d
2 changed files with 10 additions and 6 deletions

View File

@ -211,7 +211,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentConfirm {
Option<api::PaymentMethod>,
Option<String>,
)> {
let (op, payment_method, payment_token) = helpers::make_pm_data(
let (op, payment_method_data, payment_token) = helpers::make_pm_data(
Box::new(self),
state,
payment_method,
@ -223,11 +223,13 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentConfirm {
)
.await?;
utils::when(payment_method.is_none(), || {
Err(errors::ApiErrorResponse::PaymentMethodNotFound)
})?;
if payment_method != Some(enums::PaymentMethodType::Paypal) {
utils::when(payment_method_data.is_none(), || {
Err(errors::ApiErrorResponse::PaymentMethodNotFound)
})?;
}
Ok((op, payment_method, payment_token))
Ok((op, payment_method_data, payment_token))
}
#[instrument(skip_all)]

View File

@ -407,7 +407,9 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentCreate
None => None,
};
if let Some(true) = request.confirm {
if request.confirm == Some(true)
&& request.payment_method != Some(api_models::enums::PaymentMethodType::Paypal)
{
helpers::validate_pm_or_token_given(
&request.payment_token,
&request.payment_method_data,