mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(mandates): allow off-session payments using payment_method_id (#4132)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -19,10 +19,8 @@ use url::Url;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::{
|
||||
admin, disputes,
|
||||
enums::{self as api_enums},
|
||||
ephemeral_key::EphemeralKeyCreateResponse,
|
||||
refunds,
|
||||
admin, disputes, enums as api_enums, ephemeral_key::EphemeralKeyCreateResponse,
|
||||
mandates::RecurringDetails, refunds,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@ -459,6 +457,9 @@ pub struct PaymentsRequest {
|
||||
/// Whether to perform external authentication (if applicable)
|
||||
#[schema(example = true)]
|
||||
pub request_external_three_ds_authentication: Option<bool>,
|
||||
|
||||
/// Details required for recurring payment
|
||||
pub recurring_details: Option<RecurringDetails>,
|
||||
}
|
||||
|
||||
impl PaymentsRequest {
|
||||
@ -3360,7 +3361,7 @@ pub struct PaymentsRedirectionResponse {
|
||||
}
|
||||
|
||||
pub struct MandateValidationFields {
|
||||
pub mandate_id: Option<String>,
|
||||
pub recurring_details: Option<RecurringDetails>,
|
||||
pub confirm: Option<bool>,
|
||||
pub customer_id: Option<String>,
|
||||
pub mandate_data: Option<MandateData>,
|
||||
@ -3370,8 +3371,14 @@ pub struct MandateValidationFields {
|
||||
|
||||
impl From<&PaymentsRequest> for MandateValidationFields {
|
||||
fn from(req: &PaymentsRequest) -> Self {
|
||||
let recurring_details = req
|
||||
.mandate_id
|
||||
.clone()
|
||||
.map(RecurringDetails::MandateId)
|
||||
.or(req.recurring_details.clone());
|
||||
|
||||
Self {
|
||||
mandate_id: req.mandate_id.clone(),
|
||||
recurring_details,
|
||||
confirm: req.confirm,
|
||||
customer_id: req
|
||||
.customer
|
||||
@ -3389,7 +3396,7 @@ impl From<&PaymentsRequest> for MandateValidationFields {
|
||||
impl From<&VerifyRequest> for MandateValidationFields {
|
||||
fn from(req: &VerifyRequest) -> Self {
|
||||
Self {
|
||||
mandate_id: None,
|
||||
recurring_details: None,
|
||||
confirm: Some(true),
|
||||
customer_id: req.customer_id.clone(),
|
||||
mandate_data: req.mandate_data.clone(),
|
||||
|
||||
Reference in New Issue
Block a user