Skip to content

Core changes for nomupay #6581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ nexixpay = { payment_method = "card" }
connector_list = "gocardless,stax,stripe"
payout_connector_list = "stripe,wise"

[some_name]
payout_connector_list = "nomupay"

[dummy_connector]
enabled = true
payment_ttl = 172800
Expand Down
2 changes: 2 additions & 0 deletions crates/api_models/src/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ pub struct PayoutCreateRequest {
/// Customer's phone country code. _Deprecated: Use customer object instead._
#[schema(deprecated, max_length = 255, example = "+1")]
pub phone_country_code: Option<String>,

pub payout_method_id: Option<common_enums::PaymentMethod>, // here
}

impl PayoutCreateRequest {
Expand Down
16 changes: 16 additions & 0 deletions crates/diesel_models/src/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct PaymentMethod {
pub locker_id: Option<String>,
pub last_used_at: PrimitiveDateTime,
pub connector_mandate_details: Option<serde_json::Value>,
pub transaction_flow: Option<String>, //here
pub customer_acceptance: Option<pii::SecretSerdeValue>,
pub status: storage_enums::PaymentMethodStatus,
pub network_transaction_id: Option<String>,
Expand Down Expand Up @@ -142,6 +143,7 @@ pub struct PaymentMethodNew {
pub locker_id: Option<String>,
pub last_used_at: PrimitiveDateTime,
pub connector_mandate_details: Option<serde_json::Value>,
pub transaction_flow: Option<String>,
pub customer_acceptance: Option<pii::SecretSerdeValue>,
pub status: storage_enums::PaymentMethodStatus,
pub network_transaction_id: Option<String>,
Expand Down Expand Up @@ -247,6 +249,7 @@ pub enum PaymentMethodUpdate {
},
ConnectorMandateDetailsUpdate {
connector_mandate_details: Option<serde_json::Value>,
transaction_flow: Option<String>,
},
}

Expand Down Expand Up @@ -380,6 +383,7 @@ pub struct PaymentMethodUpdateInternal {
network_token_requestor_reference_id: Option<String>,
payment_method: Option<storage_enums::PaymentMethod>,
connector_mandate_details: Option<serde_json::Value>,
transaction_flow: Option<String>,
updated_by: Option<String>,
payment_method_type: Option<storage_enums::PaymentMethodType>,
payment_method_issuer: Option<String>,
Expand All @@ -404,6 +408,7 @@ impl PaymentMethodUpdateInternal {
network_token_requestor_reference_id,
payment_method,
connector_mandate_details,
transaction_flow,
updated_by,
payment_method_type,
payment_method_issuer,
Expand Down Expand Up @@ -438,6 +443,7 @@ impl PaymentMethodUpdateInternal {
last_used_at: last_used_at.unwrap_or(source.last_used_at),
connector_mandate_details: connector_mandate_details
.or(source.connector_mandate_details),
transaction_flow: transaction_flow.or(source.transaction_flow), //here
customer_acceptance: source.customer_acceptance,
status: status.unwrap_or(source.status),
network_transaction_id: network_transaction_id.or(source.network_transaction_id),
Expand Down Expand Up @@ -474,6 +480,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
Expand All @@ -493,6 +500,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
Expand All @@ -510,6 +518,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
Expand All @@ -530,6 +539,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
Expand All @@ -550,6 +560,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
Expand All @@ -567,6 +578,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer: None,
payment_method_type: None,
Expand Down Expand Up @@ -594,6 +606,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id,
payment_method,
connector_mandate_details: None,
transaction_flow: None,
updated_by: None,
payment_method_issuer,
payment_method_type,
Expand All @@ -603,6 +616,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
},
PaymentMethodUpdate::ConnectorMandateDetailsUpdate {
connector_mandate_details,
transaction_flow,
} => Self {
metadata: None,
payment_method_data: None,
Expand All @@ -612,6 +626,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
payment_method: None,
connector_mandate_details,
transaction_flow, //here
network_transaction_id: None,
updated_by: None,
payment_method_issuer: None,
Expand Down Expand Up @@ -790,6 +805,7 @@ impl From<&PaymentMethodNew> for PaymentMethod {
payment_method_data: payment_method_new.payment_method_data.clone(),
last_used_at: payment_method_new.last_used_at,
connector_mandate_details: payment_method_new.connector_mandate_details.clone(),
transaction_flow: payment_method_new.transaction_flow.clone(), //here
customer_acceptance: payment_method_new.customer_acceptance.clone(),
status: payment_method_new.status,
network_transaction_id: payment_method_new.network_transaction_id.clone(),
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,8 @@ diesel::table! {
#[max_length = 64]
network_token_locker_id -> Nullable<Varchar>,
network_token_payment_method_data -> Nullable<Bytea>,
#[max_length = 255]
transaction_flow -> Nullable<Varchar>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ pub struct UploadFileRequestData {
pub struct PayoutsData {
pub payout_id: String,
pub amount: i64,
pub connector_payout_id: Option<String>,
pub connector_payout_id: Option<String>, //not this
pub destination_currency: storage_enums::Currency,
pub source_currency: storage_enums::Currency,
pub payout_type: Option<storage_enums::PayoutType>,
Expand All @@ -793,6 +793,7 @@ pub struct PayoutsData {
// New minor amount for amount framework
pub minor_amount: MinorUnit,
pub priority: Option<storage_enums::PayoutSendPriority>,
pub transfer_method_id: Option<String>, // will be using as destination_id: item.request.clone().connector_payout_id,
}

#[derive(Debug, Default, Clone)]
Expand Down
8 changes: 8 additions & 0 deletions crates/router/src/configs/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub struct Settings<S: SecretState> {
pub secrets_management: SecretsManagementConfig,
pub tokenization: TokenizationConfig,
pub connector_customer: ConnectorCustomer,
pub some_name: SomeName,
#[cfg(feature = "dummy_connector")]
pub dummy_connector: DummyConnector,
#[cfg(feature = "email")]
Expand Down Expand Up @@ -359,6 +360,13 @@ pub struct ConnectorCustomer {
pub payout_connector_list: HashSet<enums::PayoutConnectors>,
}

#[derive(Debug, Deserialize, Clone, Default)]
pub struct SomeName {
#[cfg(feature = "payouts")]
#[serde(deserialize_with = "deserialize_hashset")]
pub payout_connector_list: HashSet<enums::PayoutConnectors>,
}

#[cfg(feature = "dummy_connector")]
#[derive(Debug, Deserialize, Clone, Default)]
pub struct DummyConnector {
Expand Down
27 changes: 25 additions & 2 deletions crates/router/src/core/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use std::{collections::HashSet, vec::IntoIter};

#[cfg(feature = "olap")]
use api_models::payments as payment_enums;
use api_models::{self, enums as api_enums, payouts::PayoutLinkResponse};
use api_models::{
self, enums as api_enums, payments::ConnectorMandateReferenceId, payouts::PayoutLinkResponse,
};
#[cfg(feature = "payout_retry")]
use common_enums::PayoutRetryType;
use common_utils::{
Expand Down Expand Up @@ -72,6 +74,7 @@ pub struct PayoutData {
pub should_terminate: bool,
pub payout_link: Option<PayoutLink>,
pub current_locale: String,
pub payment_method: Option<storage::PaymentMethod>,
}

// ********************************************** CORE FLOWS **********************************************
Expand Down Expand Up @@ -1988,7 +1991,7 @@ pub async fn create_recipient_disburse_account(
.status
.unwrap_or(payout_attempt.status.to_owned());
let updated_payout_attempt = storage::PayoutAttemptUpdate::StatusUpdate {
connector_payout_id: payout_response_data.connector_payout_id,
connector_payout_id: payout_response_data.connector_payout_id, // need to store this
status,
error_code: None,
error_message: None,
Expand All @@ -2006,6 +2009,24 @@ pub async fn create_recipient_disburse_account(
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error updating payout_attempt in db")?;

/*
if recurring need to store



*/

// fetch the id
// payout_data.payment_method.map(|pm|) {
// let pmd = HashMap::new();

// }
// let payment_method_update = ConnectorMandateDetailsUpdate {
// connector_mandate_details: Some()
// }

//
}
Err(err) => {
let (error_code, error_message) = (Some(err.code), Some(err.message));
Expand Down Expand Up @@ -2628,6 +2649,7 @@ pub async fn payout_create_db_entries(
profile_id: profile_id.to_owned(),
payout_link,
current_locale: locale.to_string(),
payment_method,
})
}

Expand Down Expand Up @@ -2829,6 +2851,7 @@ pub async fn make_payout_data(
profile_id,
payout_link,
current_locale: locale.to_string(),
payment_method,
})
}

Expand Down
13 changes: 13 additions & 0 deletions crates/router/src/core/payouts/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub async fn validate_create_request(
Option<payouts::PayoutMethodData>,
common_utils::id_type::ProfileId,
Option<domain::Customer>,
Option<domain::PaymentMethod>,
)> {
let merchant_id = merchant_account.get_id();

Expand Down Expand Up @@ -182,6 +183,18 @@ pub async fn validate_create_request(
})
.attach_printable("Profile id is a mandatory parameter")?;

// //Validate payout_method_id //here
// let payment_method = match req.payout_method_id {
// Some(payout_method_id) => {
// db.find_payment_method(

// )
// }
// =>{

// }
// }

Ok((payout_id, payout_method_data, profile_id, customer))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE payment_methods
DROP COLUMN transaction_flow;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Your SQL goes here
ALTER TABLE payment_methods
ADD COLUMN transaction_flow VARCHAR(255);
Loading