feat(connector): [Paypal] Add manual capture for paypal wallet (#2072)

This commit is contained in:
Prasunna Soppa
2023-09-01 20:07:05 +05:30
committed by GitHub
parent e44c32dd80
commit 99ff82ef6d
2 changed files with 10 additions and 6 deletions

View File

@ -437,8 +437,13 @@ impl
req: &types::PaymentsCompleteAuthorizeRouterData,
connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let paypal_meta: PaypalMeta = to_connector_meta(req.request.connector_meta.clone())?;
let complete_authorize_url = match paypal_meta.psync_flow {
transformers::PaypalPaymentIntent::Authorize => "authorize".to_string(),
transformers::PaypalPaymentIntent::Capture => "capture".to_string(),
};
Ok(format!(
"{}v2/checkout/orders/{}/capture",
"{}v2/checkout/orders/{}/{complete_authorize_url}",
self.base_url(connectors),
req.request
.connector_transaction_id

View File

@ -207,9 +207,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
let intent = if item.request.is_auto_capture()? {
PaypalPaymentIntent::Capture
} else {
Err(errors::ConnectorError::NotImplemented(
"Manual capture method for Paypal wallet".to_string(),
))?
PaypalPaymentIntent::Authorize
};
let amount = OrderAmount {
currency_code: item.request.currency,
@ -476,7 +474,7 @@ impl<F, T>
.ok_or(errors::ConnectorError::MissingConnectorTransactionID)?;
let id = get_id_based_on_intent(&item.response.intent, purchase_units)?;
let (connector_meta, capture_id) = match item.response.intent.clone() {
let (connector_meta, order_id) = match item.response.intent.clone() {
PaypalPaymentIntent::Capture => (
serde_json::json!(PaypalMeta {
authorize_id: None,
@ -509,6 +507,7 @@ impl<F, T>
) {
(Some(authorizations), None) => authorizations.first(),
(None, Some(captures)) => captures.first(),
(Some(_), Some(captures)) => captures.first(),
_ => None,
}
.ok_or(errors::ConnectorError::ResponseDeserializationFailed)?;
@ -517,7 +516,7 @@ impl<F, T>
Ok(Self {
status,
response: Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: capture_id,
resource_id: order_id,
redirection_data: None,
mandate_reference: None,
connector_metadata: Some(connector_meta),