mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
fix(connector): [Paypal] fix PSync for redirection flow for PayPal (#2068)
This commit is contained in:
@ -569,9 +569,9 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
|
||||
match data.payment_method {
|
||||
diesel_models::enums::PaymentMethod::Wallet
|
||||
| diesel_models::enums::PaymentMethod::BankRedirect => {
|
||||
let response: paypal::PaypalOrdersResponse = res
|
||||
let response: paypal::PaypalSyncResponse = res
|
||||
.response
|
||||
.parse_struct("paypal PaymentsOrderResponse")
|
||||
.parse_struct("paypal SyncResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
types::RouterData::try_from(types::ResponseRouterData {
|
||||
response,
|
||||
@ -659,6 +659,7 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
|
||||
.headers(types::PaymentsCaptureType::get_headers(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.body(types::PaymentsCaptureType::get_request_body(self, req)?)
|
||||
.build(),
|
||||
))
|
||||
}
|
||||
|
||||
@ -410,6 +410,13 @@ pub struct PaypalRedirectResponse {
|
||||
links: Vec<PaypalLinks>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PaypalSyncResponse {
|
||||
PaypalOrdersSyncResponse(PaypalOrdersResponse),
|
||||
PaypalRedirectSyncResponse(PaypalRedirectResponse),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PaypalPaymentsSyncResponse {
|
||||
id: String,
|
||||
@ -535,6 +542,32 @@ fn get_redirect_url(
|
||||
Ok(link)
|
||||
}
|
||||
|
||||
impl<F, T> TryFrom<types::ResponseRouterData<F, PaypalSyncResponse, T, types::PaymentsResponseData>>
|
||||
for types::RouterData<F, T, types::PaymentsResponseData>
|
||||
{
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(
|
||||
item: types::ResponseRouterData<F, PaypalSyncResponse, T, types::PaymentsResponseData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
match item.response {
|
||||
PaypalSyncResponse::PaypalOrdersSyncResponse(response) => {
|
||||
Self::try_from(types::ResponseRouterData {
|
||||
response,
|
||||
data: item.data,
|
||||
http_code: item.http_code,
|
||||
})
|
||||
}
|
||||
PaypalSyncResponse::PaypalRedirectSyncResponse(response) => {
|
||||
Self::try_from(types::ResponseRouterData {
|
||||
response,
|
||||
data: item.data,
|
||||
http_code: item.http_code,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, T>
|
||||
TryFrom<types::ResponseRouterData<F, PaypalRedirectResponse, T, types::PaymentsResponseData>>
|
||||
for types::RouterData<F, T, types::PaymentsResponseData>
|
||||
|
||||
Reference in New Issue
Block a user