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

fix: few fields were not getting updated in apply_changeset function #3002

Merged
merged 2 commits into from
Nov 29, 2023
Merged
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
46 changes: 30 additions & 16 deletions crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,39 @@ impl From<BusinessProfileNew> for BusinessProfile {

impl BusinessProfileUpdateInternal {
pub fn apply_changeset(self, source: BusinessProfile) -> BusinessProfile {
let Self {
profile_name,
modified_at: _,
return_url,
enable_payment_response_hash,
payment_response_hash_key,
redirect_to_merchant_with_http_post,
webhook_details,
metadata,
routing_algorithm,
intent_fulfillment_time,
frm_routing_algorithm,
payout_routing_algorithm,
is_recon_enabled,
applepay_verified_domains,
} = self;
BusinessProfile {
profile_name: self.profile_name.unwrap_or(source.profile_name),
modified_at: self.modified_at.unwrap_or(source.modified_at),
return_url: self.return_url,
enable_payment_response_hash: self
.enable_payment_response_hash
profile_name: profile_name.unwrap_or(source.profile_name),
modified_at: common_utils::date_time::now(),
return_url,
enable_payment_response_hash: enable_payment_response_hash
.unwrap_or(source.enable_payment_response_hash),
payment_response_hash_key: self.payment_response_hash_key,
redirect_to_merchant_with_http_post: self
.redirect_to_merchant_with_http_post
payment_response_hash_key,
redirect_to_merchant_with_http_post: redirect_to_merchant_with_http_post
.unwrap_or(source.redirect_to_merchant_with_http_post),
webhook_details: self.webhook_details,
metadata: self.metadata,
routing_algorithm: self.routing_algorithm,
intent_fulfillment_time: self.intent_fulfillment_time,
frm_routing_algorithm: self.frm_routing_algorithm,
payout_routing_algorithm: self.payout_routing_algorithm,
is_recon_enabled: self.is_recon_enabled.unwrap_or(source.is_recon_enabled),
applepay_verified_domains: self.applepay_verified_domains,
webhook_details,
metadata,
routing_algorithm,
intent_fulfillment_time,
frm_routing_algorithm,
payout_routing_algorithm,
is_recon_enabled: is_recon_enabled.unwrap_or(source.is_recon_enabled),
applepay_verified_domains,
..source
}
}
Expand Down
21 changes: 16 additions & 5 deletions crates/diesel_models/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,24 @@ pub struct CaptureUpdateInternal {

impl CaptureUpdate {
pub fn apply_changeset(self, source: Capture) -> Capture {
let capture_update: CaptureUpdateInternal = self.into();
let CaptureUpdateInternal {
status,
error_message,
error_code,
error_reason,
modified_at: _,
connector_capture_id,
connector_response_reference_id,
} = self.into();
Capture {
status: capture_update.status.unwrap_or(source.status),
error_message: capture_update.error_message.or(source.error_message),
error_code: capture_update.error_code.or(source.error_code),
error_reason: capture_update.error_reason.or(source.error_reason),
status: status.unwrap_or(source.status),
error_message: error_message.or(source.error_message),
error_code: error_code.or(source.error_code),
error_reason: error_reason.or(source.error_reason),
modified_at: common_utils::date_time::now(),
connector_capture_id: connector_capture_id.or(source.connector_capture_id),
connector_response_reference_id: connector_response_reference_id
.or(source.connector_response_reference_id),
..source
}
}
Expand Down
123 changes: 73 additions & 50 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,60 +314,83 @@ pub struct PaymentAttemptUpdateInternal {

impl PaymentAttemptUpdate {
pub fn apply_changeset(self, source: PaymentAttempt) -> PaymentAttempt {
let pa_update: PaymentAttemptUpdateInternal = self.into();
let PaymentAttemptUpdateInternal {
amount,
currency,
status,
connector_transaction_id,
amount_to_capture,
connector,
authentication_type,
payment_method,
error_message,
payment_method_id,
cancellation_reason,
modified_at: _,
mandate_id,
browser_info,
payment_token,
error_code,
connector_metadata,
payment_method_data,
payment_method_type,
payment_experience,
business_sub_label,
straight_through_algorithm,
preprocessing_step_id,
error_reason,
capture_method,
connector_response_reference_id,
multiple_capture_count,
surcharge_amount,
tax_amount,
amount_capturable,
updated_by,
merchant_connector_id,
authentication_data,
encoded_data,
unified_code,
unified_message,
} = self.into();
PaymentAttempt {
amount: pa_update.amount.unwrap_or(source.amount),
currency: pa_update.currency.or(source.currency),
status: pa_update.status.unwrap_or(source.status),
connector_transaction_id: pa_update
.connector_transaction_id
.or(source.connector_transaction_id),
amount_to_capture: pa_update.amount_to_capture.or(source.amount_to_capture),
connector: pa_update.connector.or(source.connector),
authentication_type: pa_update.authentication_type.or(source.authentication_type),
payment_method: pa_update.payment_method.or(source.payment_method),
error_message: pa_update.error_message.unwrap_or(source.error_message),
payment_method_id: pa_update
.payment_method_id
.unwrap_or(source.payment_method_id),
cancellation_reason: pa_update.cancellation_reason.or(source.cancellation_reason),
amount: amount.unwrap_or(source.amount),
currency: currency.or(source.currency),
status: status.unwrap_or(source.status),
connector_transaction_id: connector_transaction_id.or(source.connector_transaction_id),
amount_to_capture: amount_to_capture.or(source.amount_to_capture),
connector: connector.or(source.connector),
authentication_type: authentication_type.or(source.authentication_type),
payment_method: payment_method.or(source.payment_method),
error_message: error_message.unwrap_or(source.error_message),
payment_method_id: payment_method_id.unwrap_or(source.payment_method_id),
cancellation_reason: cancellation_reason.or(source.cancellation_reason),
modified_at: common_utils::date_time::now(),
mandate_id: pa_update.mandate_id.or(source.mandate_id),
browser_info: pa_update.browser_info.or(source.browser_info),
payment_token: pa_update.payment_token.or(source.payment_token),
error_code: pa_update.error_code.unwrap_or(source.error_code),
connector_metadata: pa_update.connector_metadata.or(source.connector_metadata),
payment_method_data: pa_update.payment_method_data.or(source.payment_method_data),
payment_method_type: pa_update.payment_method_type.or(source.payment_method_type),
payment_experience: pa_update.payment_experience.or(source.payment_experience),
business_sub_label: pa_update.business_sub_label.or(source.business_sub_label),
straight_through_algorithm: pa_update
.straight_through_algorithm
mandate_id: mandate_id.or(source.mandate_id),
browser_info: browser_info.or(source.browser_info),
payment_token: payment_token.or(source.payment_token),
error_code: error_code.unwrap_or(source.error_code),
connector_metadata: connector_metadata.or(source.connector_metadata),
payment_method_data: payment_method_data.or(source.payment_method_data),
payment_method_type: payment_method_type.or(source.payment_method_type),
payment_experience: payment_experience.or(source.payment_experience),
business_sub_label: business_sub_label.or(source.business_sub_label),
straight_through_algorithm: straight_through_algorithm
.or(source.straight_through_algorithm),
preprocessing_step_id: pa_update
.preprocessing_step_id
.or(source.preprocessing_step_id),
error_reason: pa_update.error_reason.unwrap_or(source.error_reason),
capture_method: pa_update.capture_method.or(source.capture_method),
connector_response_reference_id: pa_update
.connector_response_reference_id
preprocessing_step_id: preprocessing_step_id.or(source.preprocessing_step_id),
error_reason: error_reason.unwrap_or(source.error_reason),
capture_method: capture_method.or(source.capture_method),
connector_response_reference_id: connector_response_reference_id
.or(source.connector_response_reference_id),
multiple_capture_count: pa_update
.multiple_capture_count
.or(source.multiple_capture_count),
surcharge_amount: pa_update.surcharge_amount.or(source.surcharge_amount),
tax_amount: pa_update.tax_amount.or(source.tax_amount),
amount_capturable: pa_update
.amount_capturable
.unwrap_or(source.amount_capturable),
updated_by: pa_update.updated_by,
merchant_connector_id: pa_update
.merchant_connector_id
.or(source.merchant_connector_id),
authentication_data: pa_update.authentication_data.or(source.authentication_data),
encoded_data: pa_update.encoded_data.or(source.encoded_data),
unified_code: pa_update.unified_code.unwrap_or(source.unified_code),
unified_message: pa_update.unified_message.unwrap_or(source.unified_message),
multiple_capture_count: multiple_capture_count.or(source.multiple_capture_count),
surcharge_amount: surcharge_amount.or(source.surcharge_amount),
tax_amount: tax_amount.or(source.tax_amount),
amount_capturable: amount_capturable.unwrap_or(source.amount_capturable),
updated_by,
merchant_connector_id: merchant_connector_id.or(source.merchant_connector_id),
authentication_data: authentication_data.or(source.authentication_data),
encoded_data: encoded_data.or(source.encoded_data),
unified_code: unified_code.unwrap_or(source.unified_code),
unified_message: unified_message.unwrap_or(source.unified_message),
..source
}
}
Expand Down
91 changes: 51 additions & 40 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,50 +217,61 @@ pub struct PaymentIntentUpdateInternal {

impl PaymentIntentUpdate {
pub fn apply_changeset(self, source: PaymentIntent) -> PaymentIntent {
let internal_update: PaymentIntentUpdateInternal = self.into();
let PaymentIntentUpdateInternal {
amount,
currency,
status,
amount_captured,
customer_id,
return_url,
setup_future_usage,
off_session,
metadata,
billing_address_id,
shipping_address_id,
modified_at: _,
active_attempt_id,
business_country,
business_label,
description,
statement_descriptor_name,
statement_descriptor_suffix,
order_details,
attempt_count,
profile_id,
merchant_decision,
payment_confirm_source,
updated_by,
surcharge_applicable,
} = self.into();
PaymentIntent {
amount: internal_update.amount.unwrap_or(source.amount),
currency: internal_update.currency.or(source.currency),
status: internal_update.status.unwrap_or(source.status),
amount_captured: internal_update.amount_captured.or(source.amount_captured),
customer_id: internal_update.customer_id.or(source.customer_id),
return_url: internal_update.return_url.or(source.return_url),
setup_future_usage: internal_update
.setup_future_usage
.or(source.setup_future_usage),
off_session: internal_update.off_session.or(source.off_session),
metadata: internal_update.metadata.or(source.metadata),
billing_address_id: internal_update
.billing_address_id
.or(source.billing_address_id),
shipping_address_id: internal_update
.shipping_address_id
.or(source.shipping_address_id),
amount: amount.unwrap_or(source.amount),
currency: currency.or(source.currency),
status: status.unwrap_or(source.status),
amount_captured: amount_captured.or(source.amount_captured),
customer_id: customer_id.or(source.customer_id),
return_url: return_url.or(source.return_url),
setup_future_usage: setup_future_usage.or(source.setup_future_usage),
off_session: off_session.or(source.off_session),
metadata: metadata.or(source.metadata),
billing_address_id: billing_address_id.or(source.billing_address_id),
shipping_address_id: shipping_address_id.or(source.shipping_address_id),
modified_at: common_utils::date_time::now(),
active_attempt_id: internal_update
.active_attempt_id
.unwrap_or(source.active_attempt_id),
business_country: internal_update.business_country.or(source.business_country),
business_label: internal_update.business_label.or(source.business_label),
description: internal_update.description.or(source.description),
statement_descriptor_name: internal_update
.statement_descriptor_name
active_attempt_id: active_attempt_id.unwrap_or(source.active_attempt_id),
business_country: business_country.or(source.business_country),
business_label: business_label.or(source.business_label),
description: description.or(source.description),
statement_descriptor_name: statement_descriptor_name
.or(source.statement_descriptor_name),
statement_descriptor_suffix: internal_update
.statement_descriptor_suffix
statement_descriptor_suffix: statement_descriptor_suffix
.or(source.statement_descriptor_suffix),
order_details: internal_update.order_details.or(source.order_details),
attempt_count: internal_update
.attempt_count
.unwrap_or(source.attempt_count),
profile_id: internal_update.profile_id.or(source.profile_id),
merchant_decision: internal_update
.merchant_decision
.or(source.merchant_decision),
payment_confirm_source: internal_update
.payment_confirm_source
.or(source.payment_confirm_source),
updated_by: internal_update.updated_by,
order_details: order_details.or(source.order_details),
attempt_count: attempt_count.unwrap_or(source.attempt_count),
profile_id: profile_id.or(source.profile_id),
merchant_decision: merchant_decision.or(source.merchant_decision),
payment_confirm_source: payment_confirm_source.or(source.payment_confirm_source),
updated_by,
surcharge_applicable: surcharge_applicable.or(source.surcharge_applicable),
..source
}
}
Expand Down
32 changes: 20 additions & 12 deletions crates/diesel_models/src/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,27 @@ impl From<RefundUpdate> for RefundUpdateInternal {

impl RefundUpdate {
pub fn apply_changeset(self, source: Refund) -> Refund {
let pa_update: RefundUpdateInternal = self.into();
let RefundUpdateInternal {
connector_refund_id,
refund_status,
sent_to_gateway,
refund_error_message,
refund_arn,
metadata,
refund_reason,
refund_error_code,
updated_by,
} = self.into();
Refund {
connector_refund_id: pa_update.connector_refund_id.or(source.connector_refund_id),
refund_status: pa_update.refund_status.unwrap_or(source.refund_status),
sent_to_gateway: pa_update.sent_to_gateway.unwrap_or(source.sent_to_gateway),
refund_error_message: pa_update
.refund_error_message
.or(source.refund_error_message),
refund_error_code: pa_update.refund_error_code.or(source.refund_error_code),
refund_arn: pa_update.refund_arn.or(source.refund_arn),
metadata: pa_update.metadata.or(source.metadata),
refund_reason: pa_update.refund_reason.or(source.refund_reason),
updated_by: pa_update.updated_by,
connector_refund_id: connector_refund_id.or(source.connector_refund_id),
refund_status: refund_status.unwrap_or(source.refund_status),
sent_to_gateway: sent_to_gateway.unwrap_or(source.sent_to_gateway),
refund_error_message: refund_error_message.or(source.refund_error_message),
refund_error_code: refund_error_code.or(source.refund_error_code),
refund_arn: refund_arn.or(source.refund_arn),
metadata: metadata.or(source.metadata),
refund_reason: refund_reason.or(source.refund_reason),
updated_by,
..source
}
}
Expand Down
Loading