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] fix webhook deserialization error (#8116)
AkshayaFoiger0fb7eb0b9201
diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay.rs b/crates/hyperswitch_connectors/src/connectors/trustpay.rsindex 185d86d066..730100eddb 100644--- a/crates/hyperswitch_connectors/src/connectors/trustpay.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustpay.rs@@ -887,26 +887,26 @@ impl webhooks::IncomingWebhook for Trustpay {.body.parse_struct("TrustpayWebhookResponse").switch()?;+ let payment_attempt_id = details+ .payment_information+ .references+ .merchant_reference+ .ok_or(errors::ConnectorError::WebhookReferenceIdNotFound)?;+match details.payment_information.credit_debit_indicator {trustpay::CreditDebitIndicator::Crdt => {Ok(api_models::webhooks::ObjectReferenceId::PaymentId(- api_models::payments::PaymentIdType::PaymentAttemptId(- details.payment_information.references.merchant_reference,- ),+ api_models::payments::PaymentIdType::PaymentAttemptId(payment_attempt_id),))}trustpay::CreditDebitIndicator::Dbit => {if details.payment_information.status == trustpay::WebhookStatus::Chargebacked {Ok(api_models::webhooks::ObjectReferenceId::PaymentId(- api_models::payments::PaymentIdType::PaymentAttemptId(- details.payment_information.references.merchant_reference,- ),+ api_models::payments::PaymentIdType::PaymentAttemptId(payment_attempt_id),))} else {Ok(api_models::webhooks::ObjectReferenceId::RefundId(- api_models::webhooks::RefundIdType::RefundId(- details.payment_information.references.merchant_reference,- ),+ api_models::webhooks::RefundIdType::RefundId(payment_attempt_id),))}}diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rsindex d3cfe77c4b..92ad6e39ca 100644--- a/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs@@ -1896,7 +1896,7 @@ impl TryFrom<WebhookStatus> for enums::RefundStatus {#[derive(Default, Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]#[serde(rename_all = "PascalCase")]pub struct WebhookReferences {- pub merchant_reference: String,+ pub merchant_reference: Option<String>,pub payment_id: Option<String>,pub payment_request_id: Option<String>,}