mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(payment_method_session): implement payment methods session confirm (#7248)
Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Anurag Thakur <anurag.thakur@juspay.in> Co-authored-by: Pa1NarK <69745008+pixincreate@users.noreply.github.com> Co-authored-by: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com> Co-authored-by: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com> Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in> Co-authored-by: Debarati Ghatak <88573135+cookieg13@users.noreply.github.com> Co-authored-by: awasthi21 <107559116+awasthi21@users.noreply.github.com> Co-authored-by: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Arindam Sahoo <88739246+arindam-sahoo@users.noreply.github.com> Co-authored-by: Arindam Sahoo <arindam.sahoo@Arindam-Sahoo-F565040VFJ.local> Co-authored-by: Sakil Mostak <73734619+Sakilmostak@users.noreply.github.com> Co-authored-by: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Co-authored-by: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Co-authored-by: Suman Maji <77887221+sumanmaji4@users.noreply.github.com> Co-authored-by: Sandeep Kumar <83278309+tsdk02@users.noreply.github.com> Co-authored-by: Debarshi Gupta <debarshigupta47@gmail.com> Co-authored-by: Debarshi Gupta <debarshi.gupta@Debarshi-Gupta-CM92YWDXFD.local> Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com> Co-authored-by: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com> Co-authored-by: pranav-arjunan <pranav.arjunan@juspay.in> Co-authored-by: Kashif <kashif.dev@protonmail.com> Co-authored-by: Sagnik Mitra <83326850+ImSagnik007@users.noreply.github.com> Co-authored-by: sweta-kumari-sharma <77436883+Sweta-Kumari-Sharma@users.noreply.github.com> Co-authored-by: shivansh.mathur <shivansh.mathur@juspay.in>
This commit is contained in:
@ -208,7 +208,10 @@ impl ApiEventMetric for DisputeListFilters {
|
||||
impl ApiEventMetric for PaymentMethodSessionRequest {}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for PaymentMethodsSessionResponse {
|
||||
impl ApiEventMetric for PaymentMethodsSessionUpdateRequest {}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for PaymentMethodSessionResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::PaymentMethodSession {
|
||||
payment_method_session_id: self.id.clone(),
|
||||
|
||||
@ -2,8 +2,8 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
use super::{
|
||||
PaymentStartRedirectionRequest, PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest,
|
||||
PaymentsGetIntentRequest, PaymentsIntentResponse, PaymentsRequest,
|
||||
PaymentStartRedirectionRequest, PaymentsCreateIntentRequest, PaymentsGetIntentRequest,
|
||||
PaymentsIntentResponse, PaymentsRequest,
|
||||
};
|
||||
#[cfg(all(
|
||||
any(feature = "v2", feature = "v1"),
|
||||
@ -31,7 +31,7 @@ use crate::{
|
||||
PaymentsExternalAuthenticationResponse, PaymentsIncrementalAuthorizationRequest,
|
||||
PaymentsManualUpdateRequest, PaymentsManualUpdateResponse,
|
||||
PaymentsPostSessionTokensRequest, PaymentsPostSessionTokensResponse, PaymentsRejectRequest,
|
||||
PaymentsResponse, PaymentsRetrieveRequest, PaymentsSessionResponse, PaymentsStartRequest,
|
||||
PaymentsRetrieveRequest, PaymentsSessionResponse, PaymentsStartRequest,
|
||||
RedirectionResponse,
|
||||
},
|
||||
};
|
||||
@ -158,15 +158,6 @@ impl ApiEventMetric for PaymentsRequest {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for payments::PaymentsResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.id.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for PaymentsGetIntentRequest {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
@ -186,16 +177,7 @@ impl ApiEventMetric for PaymentsIntentResponse {
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for PaymentsConfirmIntentResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.id.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for super::PaymentsRetrieveResponse {
|
||||
impl ApiEventMetric for payments::PaymentsResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.id.clone(),
|
||||
@ -204,7 +186,7 @@ impl ApiEventMetric for super::PaymentsRetrieveResponse {
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
impl ApiEventMetric for PaymentsResponse {
|
||||
impl ApiEventMetric for payments::PaymentsResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.payment_id.clone(),
|
||||
|
||||
@ -136,6 +136,10 @@ pub struct PaymentMethodCreate {
|
||||
#[schema(value_type = Option<Address>)]
|
||||
pub billing: Option<payments::Address>,
|
||||
|
||||
/// The tokenization type to be applied
|
||||
#[schema(value_type = Option<PspTokenization>)]
|
||||
pub psp_tokenization: Option<common_types::payment_methods::PspTokenization>,
|
||||
|
||||
/// The network tokenization configuration if applicable
|
||||
#[schema(value_type = Option<NetworkTokenization>)]
|
||||
pub network_tokenization: Option<common_types::payment_methods::NetworkTokenization>,
|
||||
@ -268,7 +272,7 @@ pub struct PaymentMethodMigrate {
|
||||
pub network_transaction_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodMigrateResponse {
|
||||
//payment method response when payment method entry is created
|
||||
pub payment_method_response: PaymentMethodResponse,
|
||||
@ -474,8 +478,11 @@ pub struct PaymentMethodUpdate {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct PaymentMethodUpdate {
|
||||
/// payment method data to be passed
|
||||
pub payment_method_data: PaymentMethodUpdateData,
|
||||
/// Payment method details to be updated for the payment_method
|
||||
pub payment_method_data: Option<PaymentMethodUpdateData>,
|
||||
|
||||
/// The connector token details to be updated for the payment_method
|
||||
pub connector_token_details: Option<ConnectorTokenDetails>,
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
@ -567,6 +574,11 @@ pub enum CardType {
|
||||
Debit,
|
||||
}
|
||||
|
||||
// We cannot use the card struct that we have for payments for the following reason
|
||||
// The card struct used for payments has card_cvc as mandatory
|
||||
// but when vaulting the card, we do not need cvc to be collected from the user
|
||||
// This is because, the vaulted payment method can be used for future transactions in the presence of the customer
|
||||
// when the customer is on_session again, the cvc can be collected from the customer
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@ -604,6 +616,11 @@ pub struct CardDetail {
|
||||
|
||||
/// Card Type
|
||||
pub card_type: Option<CardType>,
|
||||
|
||||
/// The CVC number for the card
|
||||
/// This is optional in case the card needs to be vaulted
|
||||
#[schema(value_type = String, example = "242")]
|
||||
pub card_cvc: Option<masking::Secret<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
@ -778,6 +795,7 @@ impl CardDetailUpdate {
|
||||
card_network: None,
|
||||
card_issuer: None,
|
||||
card_type: None,
|
||||
card_cvc: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -858,6 +876,37 @@ pub struct PaymentMethodResponse {
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema, Clone)]
|
||||
pub struct ConnectorTokenDetails {
|
||||
/// The unique identifier of the connector account through which the token was generated
|
||||
#[schema(value_type = String, example = "mca_")]
|
||||
pub connector_id: id_type::MerchantConnectorAccountId,
|
||||
|
||||
#[schema(value_type = TokenizationType)]
|
||||
pub token_type: common_enums::TokenizationType,
|
||||
|
||||
/// The status of connector token if it is active or inactive
|
||||
#[schema(value_type = ConnectorTokenStatus)]
|
||||
pub status: common_enums::ConnectorTokenStatus,
|
||||
|
||||
/// The reference id of the connector token
|
||||
/// This is the reference that was passed to connector when creating the token
|
||||
pub connector_token_request_reference_id: Option<String>,
|
||||
|
||||
pub original_payment_authorized_amount: Option<MinorUnit>,
|
||||
|
||||
/// The currency of the original payment authorized amount
|
||||
#[schema(value_type = Currency)]
|
||||
pub original_payment_authorized_currency: Option<common_enums::Currency>,
|
||||
|
||||
/// Metadata associated with the connector token
|
||||
pub metadata: Option<pii::SecretSerdeValue>,
|
||||
|
||||
/// The value of the connector token. This token can be used to make merchant initiated payments ( MIT ), directly with the connector.
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[derive(Debug, serde::Serialize, ToSchema, Clone)]
|
||||
pub struct PaymentMethodResponse {
|
||||
/// The unique identifier of the Payment method
|
||||
#[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
|
||||
@ -893,11 +942,16 @@ pub struct PaymentMethodResponse {
|
||||
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub created: Option<time::PrimitiveDateTime>,
|
||||
|
||||
/// A timestamp (ISO 8601 code) that determines when the payment method was last used
|
||||
#[schema(value_type = Option<PrimitiveDateTime>, example = "2024-02-24T11:04:09.922Z")]
|
||||
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
|
||||
pub last_used_at: Option<time::PrimitiveDateTime>,
|
||||
|
||||
/// The payment method details related to the payment method
|
||||
pub payment_method_data: Option<PaymentMethodResponseData>,
|
||||
|
||||
/// The connector token details if available
|
||||
pub connector_tokens: Option<Vec<ConnectorTokenDetails>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
|
||||
@ -2501,6 +2555,10 @@ pub struct PaymentMethodSessionRequest {
|
||||
#[schema(value_type = Option<Address>)]
|
||||
pub billing: Option<payments::Address>,
|
||||
|
||||
/// The return url to which the customer should be redirected to after adding the payment method
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
|
||||
/// The tokenization type to be applied
|
||||
#[schema(value_type = Option<PspTokenization>)]
|
||||
pub psp_tokenization: Option<common_types::payment_methods::PspTokenization>,
|
||||
@ -2515,6 +2573,22 @@ pub struct PaymentMethodSessionRequest {
|
||||
pub expires_in: Option<u32>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodsSessionUpdateRequest {
|
||||
/// The billing address details of the customer. This will also be used for any new payment methods added during the session
|
||||
#[schema(value_type = Option<Address>)]
|
||||
pub billing: Option<payments::Address>,
|
||||
|
||||
/// The tokenization type to be applied
|
||||
#[schema(value_type = Option<PspTokenization>)]
|
||||
pub psp_tokenization: Option<common_types::payment_methods::PspTokenization>,
|
||||
|
||||
/// The network tokenization configuration if applicable
|
||||
#[schema(value_type = Option<NetworkTokenization>)]
|
||||
pub network_tokenization: Option<common_types::payment_methods::NetworkTokenization>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodSessionUpdateSavedPaymentMethod {
|
||||
@ -2529,7 +2603,27 @@ pub struct PaymentMethodSessionUpdateSavedPaymentMethod {
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodsSessionResponse {
|
||||
pub struct PaymentMethodSessionConfirmRequest {
|
||||
/// The payment method type
|
||||
#[schema(value_type = PaymentMethod, example = "card")]
|
||||
pub payment_method_type: common_enums::PaymentMethod,
|
||||
|
||||
/// The payment method subtype
|
||||
#[schema(value_type = PaymentMethodType, example = "credit")]
|
||||
pub payment_method_subtype: common_enums::PaymentMethodType,
|
||||
|
||||
/// The payment instrument data to be used for the payment
|
||||
#[schema(value_type = PaymentMethodDataRequest)]
|
||||
pub payment_method_data: payments::PaymentMethodDataRequest,
|
||||
|
||||
/// The return url to which the customer should be redirected to after adding the payment method
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodSessionResponse {
|
||||
#[schema(value_type = String, example = "12345_pms_01926c58bc6e77c09e809964e72af8c8")]
|
||||
pub id: id_type::GlobalPaymentMethodSessionId,
|
||||
|
||||
@ -2558,4 +2652,26 @@ pub struct PaymentMethodsSessionResponse {
|
||||
/// Client Secret
|
||||
#[schema(value_type = String)]
|
||||
pub client_secret: masking::Secret<String>,
|
||||
|
||||
/// The return url to which the user should be redirected to
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
|
||||
/// The next action details for the payment method session
|
||||
#[schema(value_type = Option<NextActionData>)]
|
||||
pub next_action: Option<payments::NextActionData>,
|
||||
|
||||
/// The customer authenticaion details for the payment method
|
||||
/// This refers to either the payment / external authentication details
|
||||
pub authentication_details: Option<AuthenticationDetails>,
|
||||
|
||||
/// The payment method that was created using this payment method session
|
||||
pub associated_payment_methods: Option<Vec<id_type::GlobalPaymentMethodId>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, ToSchema, Clone)]
|
||||
pub struct AuthenticationDetails {
|
||||
pub status: common_enums::IntentStatus,
|
||||
pub error: Option<payments::ErrorDetails>,
|
||||
}
|
||||
|
||||
@ -586,6 +586,22 @@ pub struct AmountDetails {
|
||||
tax_on_surcharge: Option<MinorUnit>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl AmountDetails {
|
||||
pub fn new_for_zero_auth_payment(currency: common_enums::Currency) -> Self {
|
||||
Self {
|
||||
order_amount: Amount::Zero,
|
||||
currency,
|
||||
shipping_cost: None,
|
||||
order_tax_amount: None,
|
||||
skip_external_tax_calculation: common_enums::TaxCalculationOverride::Skip,
|
||||
skip_surcharge_calculation: common_enums::SurchargeCalculationOverride::Skip,
|
||||
surcharge_amount: None,
|
||||
tax_on_surcharge: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct AmountDetailsUpdate {
|
||||
@ -1871,6 +1887,43 @@ pub struct Card {
|
||||
pub nick_name: Option<Secret<String>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl TryFrom<payment_methods::CardDetail> for Card {
|
||||
type Error = error_stack::Report<ValidationError>;
|
||||
|
||||
fn try_from(value: payment_methods::CardDetail) -> Result<Self, Self::Error> {
|
||||
use common_utils::ext_traits::OptionExt;
|
||||
|
||||
let payment_methods::CardDetail {
|
||||
card_number,
|
||||
card_exp_month,
|
||||
card_exp_year,
|
||||
card_holder_name,
|
||||
nick_name,
|
||||
card_network,
|
||||
card_issuer,
|
||||
card_cvc,
|
||||
..
|
||||
} = value;
|
||||
|
||||
let card_cvc = card_cvc.get_required_value("card_cvc")?;
|
||||
|
||||
Ok(Self {
|
||||
card_number,
|
||||
card_exp_month,
|
||||
card_exp_year,
|
||||
card_holder_name,
|
||||
card_cvc,
|
||||
card_issuer,
|
||||
card_network,
|
||||
card_type: None,
|
||||
card_issuing_country: None,
|
||||
bank_code: None,
|
||||
nick_name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct ExtendedCardInfo {
|
||||
/// The card number
|
||||
@ -5097,6 +5150,10 @@ pub struct PaymentsConfirmIntentRequest {
|
||||
/// Additional details required by 3DS 2.0
|
||||
#[schema(value_type = Option<BrowserInformation>)]
|
||||
pub browser_info: Option<common_utils::types::BrowserInformation>,
|
||||
|
||||
/// The payment_method_id to be associated with the payment
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub payment_method_id: Option<id_type::GlobalPaymentMethodId>,
|
||||
}
|
||||
|
||||
// This struct contains the union of fields in `PaymentsCreateIntentRequest` and
|
||||
@ -5233,6 +5290,10 @@ pub struct PaymentsRequest {
|
||||
/// Additional details required by 3DS 2.0
|
||||
#[schema(value_type = Option<BrowserInformation>)]
|
||||
pub browser_info: Option<common_utils::types::BrowserInformation>,
|
||||
|
||||
/// The payment_method_id to be associated with the payment
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub payment_method_id: Option<id_type::GlobalPaymentMethodId>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -5281,89 +5342,11 @@ impl From<&PaymentsRequest> for PaymentsConfirmIntentRequest {
|
||||
shipping: request.shipping.clone(),
|
||||
customer_acceptance: request.customer_acceptance.clone(),
|
||||
browser_info: request.browser_info.clone(),
|
||||
payment_method_id: request.payment_method_id.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentsResponse {
|
||||
/// Unique identifier for the payment. This ensures idempotency for multiple payments
|
||||
/// that have been done by a single merchant.
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_pay_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String,
|
||||
)]
|
||||
pub id: id_type::GlobalPaymentId,
|
||||
|
||||
#[schema(value_type = IntentStatus, example = "success")]
|
||||
pub status: api_enums::IntentStatus,
|
||||
|
||||
/// Amount related information for this payment and attempt
|
||||
pub amount: PaymentAmountDetailsResponse,
|
||||
|
||||
/// The identifier for the customer
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String
|
||||
)]
|
||||
pub customer_id: Option<id_type::GlobalCustomerId>,
|
||||
|
||||
/// The connector used for the payment
|
||||
#[schema(example = "stripe")]
|
||||
pub connector: String,
|
||||
|
||||
/// It's a token used for client side verification.
|
||||
#[schema(value_type = String)]
|
||||
pub client_secret: common_utils::types::ClientSecret,
|
||||
|
||||
/// Time when the payment was created
|
||||
#[schema(example = "2022-09-10T10:11:12Z")]
|
||||
#[serde(with = "common_utils::custom_serde::iso8601")]
|
||||
pub created: PrimitiveDateTime,
|
||||
|
||||
/// The payment method information provided for making a payment
|
||||
#[schema(value_type = Option<PaymentMethodDataResponseWithBilling>)]
|
||||
#[serde(serialize_with = "serialize_payment_method_data_response")]
|
||||
pub payment_method_data: Option<PaymentMethodDataResponseWithBilling>,
|
||||
|
||||
/// The payment method type for this payment attempt
|
||||
#[schema(value_type = PaymentMethod, example = "wallet")]
|
||||
pub payment_method_type: api_enums::PaymentMethod,
|
||||
|
||||
#[schema(value_type = PaymentMethodType, example = "apple_pay")]
|
||||
pub payment_method_subtype: api_enums::PaymentMethodType,
|
||||
|
||||
/// Additional information required for redirection
|
||||
pub next_action: Option<NextActionData>,
|
||||
|
||||
/// A unique identifier for a payment provided by the connector
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub connector_transaction_id: Option<String>,
|
||||
|
||||
/// reference(Identifier) to the payment at connector side
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub connector_reference_id: Option<String>,
|
||||
|
||||
/// Connector token information that can be used to make payments directly by the merchant.
|
||||
pub connector_token_details: Option<ConnectorTokenDetails>,
|
||||
|
||||
/// Identifier of the connector ( merchant connector account ) which was chosen to make the payment
|
||||
#[schema(value_type = String)]
|
||||
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
|
||||
|
||||
/// The browser information used for this payment
|
||||
#[schema(value_type = Option<BrowserInformation>)]
|
||||
pub browser_info: Option<common_utils::types::BrowserInformation>,
|
||||
|
||||
/// Error details for the payment if any
|
||||
pub error: Option<ErrorDetails>,
|
||||
}
|
||||
|
||||
// Serialize is implemented because, this will be serialized in the api events.
|
||||
// Usually request types should not have serialize implemented.
|
||||
//
|
||||
@ -5400,94 +5383,6 @@ pub struct ErrorDetails {
|
||||
pub unified_message: Option<String>,
|
||||
}
|
||||
|
||||
/// Response for Payment Intent Confirm
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentsConfirmIntentResponse {
|
||||
/// Unique identifier for the payment. This ensures idempotency for multiple payments
|
||||
/// that have been done by a single merchant.
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_pay_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String,
|
||||
)]
|
||||
pub id: id_type::GlobalPaymentId,
|
||||
|
||||
#[schema(value_type = IntentStatus, example = "success")]
|
||||
pub status: api_enums::IntentStatus,
|
||||
|
||||
/// Amount related information for this payment and attempt
|
||||
pub amount: PaymentAmountDetailsResponse,
|
||||
|
||||
/// The identifier for the customer
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String
|
||||
)]
|
||||
pub customer_id: Option<id_type::GlobalCustomerId>,
|
||||
|
||||
/// The connector used for the payment
|
||||
#[schema(example = "stripe")]
|
||||
pub connector: String,
|
||||
|
||||
/// It's a token used for client side verification.
|
||||
#[schema(value_type = String)]
|
||||
pub client_secret: common_utils::types::ClientSecret,
|
||||
|
||||
/// Time when the payment was created
|
||||
#[schema(example = "2022-09-10T10:11:12Z")]
|
||||
#[serde(with = "common_utils::custom_serde::iso8601")]
|
||||
pub created: PrimitiveDateTime,
|
||||
|
||||
/// The payment method information provided for making a payment
|
||||
#[schema(value_type = Option<PaymentMethodDataResponseWithBilling>)]
|
||||
#[serde(serialize_with = "serialize_payment_method_data_response")]
|
||||
pub payment_method_data: Option<PaymentMethodDataResponseWithBilling>,
|
||||
|
||||
/// The payment method type for this payment attempt
|
||||
#[schema(value_type = PaymentMethod, example = "wallet")]
|
||||
pub payment_method_type: api_enums::PaymentMethod,
|
||||
|
||||
#[schema(value_type = PaymentMethodType, example = "apple_pay")]
|
||||
pub payment_method_subtype: api_enums::PaymentMethodType,
|
||||
|
||||
/// Additional information required for redirection
|
||||
pub next_action: Option<NextActionData>,
|
||||
|
||||
/// A unique identifier for a payment provided by the connector
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub connector_transaction_id: Option<String>,
|
||||
|
||||
/// reference(Identifier) to the payment at connector side
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub connector_reference_id: Option<String>,
|
||||
|
||||
/// Connector token information that can be used to make payments directly by the merchant.
|
||||
pub connector_token_details: Option<ConnectorTokenDetails>,
|
||||
|
||||
/// Identifier of the connector ( merchant connector account ) which was chosen to make the payment
|
||||
#[schema(value_type = String)]
|
||||
pub merchant_connector_id: id_type::MerchantConnectorAccountId,
|
||||
|
||||
/// The browser information used for this payment
|
||||
#[schema(value_type = Option<BrowserInformation>)]
|
||||
pub browser_info: Option<common_utils::types::BrowserInformation>,
|
||||
|
||||
/// Error details for the payment if any
|
||||
pub error: Option<ErrorDetails>,
|
||||
|
||||
/// The transaction authentication can be set to undergo payer authentication. By default, the authentication will be marked as NO_THREE_DS
|
||||
#[schema(value_type = Option<AuthenticationType>, example = "no_three_ds")]
|
||||
pub authentication_type: Option<api_enums::AuthenticationType>,
|
||||
|
||||
/// The authentication type applied for the payment
|
||||
#[schema(value_type = AuthenticationType, example = "no_three_ds")]
|
||||
pub applied_authentication_type: api_enums::AuthenticationType,
|
||||
}
|
||||
|
||||
/// Token information that can be used to initiate transactions by the merchant.
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
@ -5495,13 +5390,19 @@ pub struct ConnectorTokenDetails {
|
||||
/// A token that can be used to make payments directly with the connector.
|
||||
#[schema(example = "pm_9UhMqBMEOooRIvJFFdeW")]
|
||||
pub token: String,
|
||||
|
||||
/// The reference id sent to the connector when creating the token
|
||||
pub connector_token_request_reference_id: Option<String>,
|
||||
}
|
||||
|
||||
// TODO: have a separate response for detailed, summarized
|
||||
/// Response for Payment Intent Confirm
|
||||
/// Few fields should be expandable, we need not return these in the normal response
|
||||
/// But when explictly requested for expanded objects, these can be returned
|
||||
/// For example
|
||||
/// shipping, billing, customer, payment_method
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
|
||||
pub struct PaymentsRetrieveResponse {
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentsResponse {
|
||||
/// Unique identifier for the payment. This ensures idempotency for multiple payments
|
||||
/// that have been done by a single merchant.
|
||||
#[schema(
|
||||
@ -5579,10 +5480,33 @@ pub struct PaymentsRetrieveResponse {
|
||||
|
||||
/// List of payment attempts associated with payment intent
|
||||
pub attempts: Option<Vec<PaymentAttemptResponse>>,
|
||||
|
||||
/// Connector token information that can be used to make payments directly by the merchant.
|
||||
pub connector_token_details: Option<ConnectorTokenDetails>,
|
||||
|
||||
/// The payment_method_id associated with the payment
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub payment_method_id: Option<id_type::GlobalPaymentMethodId>,
|
||||
|
||||
/// Additional information required for redirection
|
||||
pub next_action: Option<NextActionData>,
|
||||
|
||||
/// The url to which user must be redirected to after completion of the purchase
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
|
||||
/// The authentication type that was requested for this order
|
||||
#[schema(value_type = Option<AuthenticationType>, example = "no_three_ds", default = "no_three_ds")]
|
||||
pub authentication_type: Option<api_enums::AuthenticationType>,
|
||||
|
||||
/// The authentication type that was appliced for this order
|
||||
/// This depeneds on the 3DS rules configured, If not a default authentication type will be applied
|
||||
#[schema(value_type = Option<AuthenticationType>, example = "no_three_ds", default = "no_three_ds")]
|
||||
pub authentication_type_applied: Option<api_enums::AuthenticationType>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl PaymentsRetrieveResponse {
|
||||
impl PaymentsResponse {
|
||||
pub fn find_attempt_in_attempts_list_using_connector_transaction_id(
|
||||
self,
|
||||
connector_transaction_id: &common_utils::types::ConnectorTransactionId,
|
||||
|
||||
@ -266,7 +266,7 @@ pub struct IncomingWebhookDetails {
|
||||
pub resource_object: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct OutgoingWebhook {
|
||||
/// The merchant id of the merchant
|
||||
#[schema(value_type = String)]
|
||||
@ -304,12 +304,12 @@ pub enum OutgoingWebhookContent {
|
||||
PayoutDetails(Box<payouts::PayoutCreateResponse>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
#[serde(tag = "type", content = "object", rename_all = "snake_case")]
|
||||
#[cfg(feature = "v2")]
|
||||
pub enum OutgoingWebhookContent {
|
||||
#[schema(value_type = PaymentsRetrieveResponse, title = "PaymentsResponse")]
|
||||
PaymentDetails(Box<payments::PaymentsRetrieveResponse>),
|
||||
#[schema(value_type = PaymentsResponse, title = "PaymentsResponse")]
|
||||
PaymentDetails(Box<payments::PaymentsResponse>),
|
||||
#[schema(value_type = RefundResponse, title = "RefundResponse")]
|
||||
RefundDetails(Box<refunds::RefundResponse>),
|
||||
#[schema(value_type = DisputeResponse, title = "DisputeResponse")]
|
||||
|
||||
Reference in New Issue
Block a user