mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
feat(payment_method_validate): add new operation to payments_operation_core for payment method validation (#53)
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
@ -20,7 +20,7 @@ use crate::{
|
||||
routes::AppState,
|
||||
services,
|
||||
types::{
|
||||
api::{self, PgRedirectResponse},
|
||||
api,
|
||||
storage::{self, enums},
|
||||
},
|
||||
utils::{
|
||||
@ -226,7 +226,10 @@ pub fn validate_request_amount_and_amount_to_capture(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn validate_mandate(req: &api::PaymentsRequest) -> RouterResult<Option<api::MandateTxnType>> {
|
||||
pub fn validate_mandate(
|
||||
req: impl Into<api::MandateValidationFields>,
|
||||
) -> RouterResult<Option<api::MandateTxnType>> {
|
||||
let req: api::MandateValidationFields = req.into();
|
||||
match req.is_mandate() {
|
||||
Some(api::MandateTxnType::NewMandateTxn) => {
|
||||
validate_new_mandate_request(req)?;
|
||||
@ -240,7 +243,7 @@ pub fn validate_mandate(req: &api::PaymentsRequest) -> RouterResult<Option<api::
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_new_mandate_request(req: &api::PaymentsRequest) -> RouterResult<()> {
|
||||
fn validate_new_mandate_request(req: api::MandateValidationFields) -> RouterResult<()> {
|
||||
let confirm = req.confirm.get_required_value("confirm")?;
|
||||
|
||||
if !confirm {
|
||||
@ -302,8 +305,7 @@ pub fn create_redirect_url(server: &Server, payment_attempt: &storage::PaymentAt
|
||||
payment_attempt.connector
|
||||
)
|
||||
}
|
||||
|
||||
fn validate_recurring_mandate(req: &api::PaymentsRequest) -> RouterResult<()> {
|
||||
fn validate_recurring_mandate(req: api::MandateValidationFields) -> RouterResult<()> {
|
||||
req.mandate_id.check_value_present("mandate_id")?;
|
||||
|
||||
req.customer_id.check_value_present("customer_id")?;
|
||||
@ -844,7 +846,7 @@ pub fn get_handle_response_url(
|
||||
|
||||
pub fn make_merchant_url_with_response(
|
||||
merchant_account: &storage::MerchantAccount,
|
||||
redirection_response: PgRedirectResponse,
|
||||
redirection_response: api::PgRedirectResponse,
|
||||
request_return_url: Option<&String>,
|
||||
) -> RouterResult<String> {
|
||||
// take return url if provided in the request else use merchant return url
|
||||
@ -889,8 +891,8 @@ pub fn make_pg_redirect_response(
|
||||
payment_id: String,
|
||||
response: &api::PaymentsResponse,
|
||||
connector: String,
|
||||
) -> PgRedirectResponse {
|
||||
PgRedirectResponse {
|
||||
) -> api::PgRedirectResponse {
|
||||
api::PgRedirectResponse {
|
||||
payment_id,
|
||||
status: response.status,
|
||||
gateway_id: connector,
|
||||
|
||||
Reference in New Issue
Block a user