Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): [TRUSTPAY] Consuming Amount in PSync Response (#8455)
Sayak Bhattacharya537d1755329c
diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay.rs b/crates/hyperswitch_connectors/src/connectors/trustpay.rsindex 730100eddb..c1c713a731 100644--- a/crates/hyperswitch_connectors/src/connectors/trustpay.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustpay.rs@@ -423,40 +423,69 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Tru.parse_struct("trustpay PaymentsResponse").change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- if let trustpay::TrustpayPaymentsResponse::WebhookResponse(ref webhook_response) = response- {- let response_integrity_object = connector_utils::get_sync_integrity_object(- self.amount_converter_to_float_major_unit,- webhook_response.amount.amount,- webhook_response.amount.currency.to_string(),- )?;-- event_builder.map(|i| i.set_response_body(&response));- router_env::logger::info!(connector_response=?response);-- let new_router_data = RouterData::try_from(ResponseRouterData {- response,- data: data.clone(),- http_code: res.status_code,- });-- return new_router_data+ match &response {+ trustpay::TrustpayPaymentsResponse::WebhookResponse(webhook_response) => {+ let response_integrity_object = connector_utils::get_sync_integrity_object(+ self.amount_converter_to_float_major_unit,+ webhook_response.amount.amount,+ webhook_response.amount.currency.to_string(),+ )?;++ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ }).map(|mut router_data| {router_data.request.integrity_object = Some(response_integrity_object);router_data})- .change_context(errors::ConnectorError::ResponseHandlingFailed);- }+ .change_context(errors::ConnectorError::ResponseHandlingFailed)+ }- event_builder.map(|i| i.set_response_body(&response));- router_env::logger::info!(connector_response=?response);+ trustpay::TrustpayPaymentsResponse::BankRedirectSync(bank_redirect_sync_response) => {+ let response_integrity_object = connector_utils::get_sync_integrity_object(+ self.amount_converter_to_float_major_unit,+ bank_redirect_sync_response+ .payment_information+ .amount+ .amount,+ bank_redirect_sync_response+ .payment_information+ .amount+ .currency+ .to_string(),+ )?;++ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ .map(|mut router_data| {+ router_data.request.integrity_object = Some(response_integrity_object);+ router_data+ })+ .change_context(errors::ConnectorError::ResponseHandlingFailed)+ }- RouterData::try_from(ResponseRouterData {- response,- data: data.clone(),- http_code: res.status_code,- })- .change_context(errors::ConnectorError::ResponseHandlingFailed)+ _ => {+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ .change_context(errors::ConnectorError::ResponseHandlingFailed)+ }+ }}}diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rsindex de40805ad4..4b48a229a7 100644--- a/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs@@ -147,12 +147,13 @@ pub struct BankPaymentInformation {pub debtor: Option<DebtorInformation>,}-#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]+#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]#[serde(rename_all = "PascalCase")]pub struct BankPaymentInformationResponse {pub status: TrustpayBankRedirectPaymentStatus,pub status_reason_information: Option<StatusReasonInformation>,pub references: ReferencesResponse,+ pub amount: WebhookAmount,}#[derive(Debug, Serialize, Eq, PartialEq)]