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

feat(mandate_kv): add kv support for mandate #4275

Merged
merged 4 commits into from
Apr 16, 2024
Merged

Conversation

akshay-97
Copy link
Contributor

@akshay-97 akshay-97 commented Apr 2, 2024

Type of Change

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

Description

Mandate table is being written to db in payment flow, this change moves all db writes and updates to kv

Additional Changes

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

Motivation and Context

Mandate table is being written to db in payment flow, this change moves all db writes and updates to kv

How did you test it?

sanity check on payment flow

test list:

  1. create payment with mandate for merchant with kv enabled
  2. check drainer for errors and verify in db if mandate entry is written

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
  • I added a CHANGELOG entry if applicable

@akshay-97 akshay-97 requested review from a team as code owners April 2, 2024 13:48
@akshay-97 akshay-97 force-pushed the mandate_kv_support branch from fa4d3ae to 76c381c Compare April 4, 2024 18:48
Comment on lines 185 to 216
impl MandateNew {
pub fn from_new(&self) -> Mandate {
Mandate {
id: 0i32,
mandate_id: self.mandate_id.clone(),
customer_id: self.customer_id.clone(),
merchant_id: self.merchant_id.clone(),
payment_method_id: self.payment_method_id.clone(),
mandate_status: self.mandate_status.clone(),
mandate_type: self.mandate_type.clone(),
customer_accepted_at: self.customer_accepted_at.clone(),
customer_ip_address: self.customer_ip_address.clone(),
customer_user_agent: self.customer_user_agent.clone(),
network_transaction_id: self.network_transaction_id.clone(),
previous_attempt_id: self.previous_attempt_id.clone(),
created_at: self
.created_at
.clone()
.unwrap_or_else(common_utils::date_time::now),
mandate_amount: self.mandate_amount.clone(),
mandate_currency: self.mandate_currency.clone(),
amount_captured: self.amount_captured.clone(),
connector: self.connector.clone(),
connector_mandate_id: self.connector_mandate_id.clone(),
start_date: self.start_date.clone(),
end_date: self.end_date.clone(),
metadata: self.metadata.clone(),
connector_mandate_ids: self.connector_mandate_ids.clone(),
original_payment_id: self.original_payment_id.clone(),
merchant_connector_id: self.merchant_connector_id.clone(),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

You can use impl From<> here

Comment on lines 85 to 84

pub async fn update_by_merchant_id_mandate_id_drainer(
conn: &PgPooledConn,
merchant_id: &str,
mandate_id: &str,
mandate: MandateUpdateInternal,
) -> StorageResult<Self> {
generics::generic_update_with_results::<<Self as HasTable>::Table, _, _, _>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::mandate_id.eq(mandate_id.to_owned())),
mandate,
)
.await?
.first()
.cloned()
.ok_or_else(|| {
report!(errors::DatabaseError::NotFound)
.attach_printable("Error while updating mandate")
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems redundant you can change the above function to accomodate this

@akshay-97 akshay-97 force-pushed the mandate_kv_support branch from 7774146 to 0a76b82 Compare April 5, 2024 10:24
@akshay-97 akshay-97 force-pushed the mandate_kv_support branch from 26682d7 to dffa098 Compare April 10, 2024 15:15
@akshay-97 akshay-97 changed the title feat(mandate_kv) add kv support for mandate enhancement(mandate_kv): add kv support for mandate Apr 10, 2024
@akshay-97 akshay-97 self-assigned this Apr 10, 2024
@akshay-97 akshay-97 changed the title enhancement(mandate_kv): add kv support for mandate feat(mandate_kv): add kv support for mandate Apr 10, 2024
jarnura
jarnura previously approved these changes Apr 10, 2024
dracarys18
dracarys18 previously approved these changes Apr 10, 2024
@akshay-97 akshay-97 dismissed stale reviews from dracarys18 and jarnura via 2c2d2ab April 12, 2024 07:39
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Apr 16, 2024
Merged via the queue into main with commit 00340a3 Apr 16, 2024
10 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the mandate_kv_support branch April 16, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants