mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
fix(connector): [Cryptopay]fix redirection for cryptopay (#4272)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -4,7 +4,7 @@ use reqwest::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
connector::utils::{self, is_payment_failure, CryptoData},
|
||||
connector::utils::{self, is_payment_failure, CryptoData, PaymentsAuthorizeRequestData},
|
||||
consts,
|
||||
core::errors,
|
||||
services,
|
||||
@ -70,7 +70,8 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>>
|
||||
pay_currency,
|
||||
success_redirect_url: item.router_data.request.router_return_url.clone(),
|
||||
unsuccess_redirect_url: item.router_data.request.router_return_url.clone(),
|
||||
metadata: item.router_data.request.metadata.clone(),
|
||||
//Cryptopay only accepts metadata as Object. If any other type, payment will fail with error.
|
||||
metadata: item.router_data.request.get_metadata_as_object(),
|
||||
custom_id: item.router_data.connector_request_reference_id.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -498,6 +498,7 @@ pub trait PaymentsAuthorizeRequestData {
|
||||
fn get_surcharge_amount(&self) -> Option<i64>;
|
||||
fn get_tax_on_surcharge_amount(&self) -> Option<i64>;
|
||||
fn get_total_surcharge_amount(&self) -> Option<i64>;
|
||||
fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue>;
|
||||
}
|
||||
|
||||
pub trait PaymentMethodTokenizationRequestData {
|
||||
@ -632,6 +633,19 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
|
||||
fn is_customer_initiated_mandate_payment(&self) -> bool {
|
||||
self.setup_mandate_details.is_some()
|
||||
}
|
||||
|
||||
fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue> {
|
||||
self.metadata
|
||||
.clone()
|
||||
.and_then(|meta_data| match meta_data.peek() {
|
||||
serde_json::Value::Null
|
||||
| serde_json::Value::Bool(_)
|
||||
| serde_json::Value::Number(_)
|
||||
| serde_json::Value::String(_)
|
||||
| serde_json::Value::Array(_) => None,
|
||||
serde_json::Value::Object(_) => Some(meta_data),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ConnectorCustomerData {
|
||||
|
||||
Reference in New Issue
Block a user