Skip to content

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

feat(connector): senders instrument id - paypal id for paypal (#12381)

Nithin N28a23efd2a62
diff --git a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
index 7fde54f00e..cb2e354489 100644
--- a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
@@ -2222,6 +2222,7 @@ pub struct PaypalOrdersResponse {
status: PaypalOrderStatus,
purchase_units: Vec<PurchaseUnitItem>,
payment_source: Option<PaymentSourceItemResponse>,
+ payer: Option<Payer>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -2243,6 +2244,7 @@ pub struct PaypalRedirectResponse {
purchase_units: Vec<RedirectPurchaseUnitItem>,
links: Vec<PaypalLinks>,
payment_source: Option<PaymentSourceItemResponse>,
+ payer: Option<Payer>,
}
// Note: Don't change order of deserialization of variant, priority is in descending order
@@ -2271,6 +2273,7 @@ pub struct PaypalPaymentsSyncResponse {
amount: OrderAmount,
invoice_id: Option<String>,
supplementary_data: PaypalSupplementaryData,
+ payer: Option<Payer>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -2494,6 +2497,10 @@ where
authentication_data: None,
charges: None,
}),
+ sender_payment_instrument_id: item
+ .response
+ .payer
+ .and_then(|payer| payer.payer_id.map(|payer_id| payer_id.expose())),
..item.data
})
}
@@ -2609,6 +2616,10 @@ impl<F, T>
authentication_data: None,
charges: None,
}),
+ sender_payment_instrument_id: item
+ .response
+ .payer
+ .and_then(|payer| payer.payer_id.map(|payer_id| payer_id.expose())),
..item.data
})
}
@@ -2849,6 +2860,10 @@ impl<F, T> TryFrom<ResponseRouterData<F, PaypalPaymentsSyncResponse, T, Payments
authentication_data: None,
charges: None,
}),
+ sender_payment_instrument_id: item
+ .response
+ .payer
+ .and_then(|payer| payer.payer_id.map(|payer_id| payer_id.expose())),
..item.data
})
}
@@ -3179,6 +3194,12 @@ pub struct PaypalCaptureResponse {
invoice_id: Option<String>,
final_capture: bool,
payment_source: Option<PaymentSourceItemResponse>,
+ payer: Option<Payer>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Payer {
+ payer_id: Option<Secret<String>>,
}
impl From<PaypalPaymentStatus> for storage_enums::AttemptStatus {
@@ -3610,6 +3631,7 @@ pub struct PaypalCardWebhooks {
pub supplementary_data: PaypalSupplementaryData,
pub amount: OrderAmount,
pub invoice_id: Option<String>,
+ pub payer: Option<Payer>,
}
#[derive(Deserialize, Debug, Serialize)]
@@ -3618,6 +3640,7 @@ pub struct PaypalRedirectsWebhooks {
pub links: Vec<PaypalLinks>,
pub id: String,
pub intent: PaypalPaymentIntent,
+ pub payer: Option<Payer>,
}
#[derive(Deserialize, Debug, Serialize)]
@@ -3787,6 +3810,7 @@ impl TryFrom<(PaypalCardWebhooks, PaypalWebhookEventType)> for PaypalPaymentsSyn
amount: webhook_body.amount,
supplementary_data: webhook_body.supplementary_data,
invoice_id: webhook_body.invoice_id,
+ payer: webhook_body.payer,
})
}
}
@@ -3802,6 +3826,7 @@ impl TryFrom<(PaypalRedirectsWebhooks, PaypalWebhookEventType)> for PaypalOrders
status: PaypalOrderStatus::try_from(webhook_event)?,
purchase_units: webhook_body.purchase_units,
payment_source: None,
+ payer: webhook_body.payer,
})
}
}