Skip to content
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

refactor(core): add recurring customer support for nomupay payouts. #6687

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sumanmaji4
Copy link
Contributor

@sumanmaji4 sumanmaji4 commented Nov 27, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

recurring customer support for nomupay

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@sumanmaji4 sumanmaji4 self-assigned this Nov 27, 2024
@sumanmaji4 sumanmaji4 requested review from a team as code owners November 27, 2024 20:08
Copy link

semanticdiff-com bot commented Nov 27, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payouts/helpers.rs  61% smaller
  crates/router/src/core/payouts/validator.rs  39% smaller
  crates/router/src/core/payouts.rs  12% smaller
  crates/router/src/core/utils.rs  2% smaller
  crates/router/src/core/webhooks/incoming.rs  2% smaller
  crates/router/src/core/payment_methods/cards.rs  1% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  api-reference/openapi_spec.json  0% smaller
  crates/api_models/src/payouts.rs  0% smaller
  crates/diesel_models/src/enums.rs  0% smaller
  crates/diesel_models/src/payment_method.rs  0% smaller
  crates/diesel_models/src/schema.rs  0% smaller
  crates/diesel_models/src/schema_v2.rs  0% smaller
  crates/hyperswitch_connectors/src/utils.rs  0% smaller
  crates/hyperswitch_domain_models/src/payment_methods.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  0% smaller
  crates/router/src/core/payment_methods.rs  0% smaller
  crates/router/src/core/payments/operations/payment_response.rs  0% smaller
  crates/router/src/core/payments/routing.rs  0% smaller
  crates/router/src/core/payments/tokenization.rs  0% smaller
  crates/router/src/core/payouts/transformers.rs  0% smaller
  crates/router/src/core/pm_auth.rs  0% smaller
  crates/router/src/types/transformers.rs  0% smaller
  crates/router/tests/connectors/utils.rs  0% smaller
  migrations/2024-11-27-143958_add_transaction_flow_in_payment_method/down.sql Unsupported file format
  migrations/2024-11-27-143958_add_transaction_flow_in_payment_method/up.sql Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Nov 27, 2024
@sumanmaji4 sumanmaji4 changed the title refactor(payout core): add recurring customer support for nomupay refactor(core): add recurring customer support for nomupay payouts. Nov 27, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 27, 2024
@sumanmaji4 sumanmaji4 force-pushed the core_changes_to_support_nomupay branch from b098698 to 13f9582 Compare November 29, 2024 08:17
@hyperswitch-bot hyperswitch-bot bot added M-api-contract-changes Metadata: This PR involves API contract changes and removed M-api-contract-changes Metadata: This PR involves API contract changes labels Nov 29, 2024
@sumanmaji4 sumanmaji4 force-pushed the core_changes_to_support_nomupay branch from a6d2247 to dba2017 Compare December 1, 2024 13:24
@hyperswitch-bot hyperswitch-bot bot added M-api-contract-changes Metadata: This PR involves API contract changes and removed M-api-contract-changes Metadata: This PR involves API contract changes labels Dec 1, 2024
@@ -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 payment_method_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub payment_method_id: Option<String>,
pub payout_method_id: Option<String>,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -568,6 +570,8 @@ pub struct PayoutCreateResponse {
#[remove_in(PayoutCreateResponse)]
#[schema(value_type = Option<String>, max_length = 1024, example = "Invalid card details")]
pub unified_message: Option<UnifiedMessage>,

pub payment_method_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub payment_method_id: Option<String>,
pub payout_method_id: Option<String>,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 342 to 346
pub enum TransactionFlow {
#[default]
Payment,
Payouts,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub enum TransactionFlow {
#[default]
Payment,
Payouts,
}
pub enum PaymentDirection {
#[default]
Payin,
Payout,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
) -> RouterResult<()> {
todo!()
Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

use crate::{
core::{
errors::{self, RouterResult},
// payment_methods::cards::get_pm_list_context,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

connector_data.merchant_connector_id.clone(),
) {
let connector_mandate_details = HashMap::from([(
merchant_connector_id, // which connector was called [MCA]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove these comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


let payment_method_id: Option<String> = payout_data
.payment_method
.as_ref() // Safely access the `payment_method` as a reference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 2138 to 2141
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this feature flag needed here? 🤔

Comment on lines 2143 to 2156
let payment_method = db
.find_payment_method(
&(state.into()),
key_store,
&payout_method_id, // need to get from api request
merchant_account.storage_scheme,
)
.await
.change_context(errors::ApiErrorResponse::PaymentMethodNotFound)
.attach_printable("Unable to find payment method")?;

payout_data.payment_method = Some(payment_method.clone());
payout_data.payouts.payout_method_id =
Some(payment_method.payment_method_id.clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

db.find_payment_method(
&(state.into()),
key_store,
&pm_id, // need to get from api request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sumanmaji4 sumanmaji4 force-pushed the core_changes_to_support_nomupay branch from 403de74 to 9247d06 Compare December 2, 2024 18:32
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 2, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants