mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
Feat(connector): [Fiuu] Add DuitNow/FPX PaymentMethod (#5841)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -70,7 +70,6 @@ futures = "0.3.30"
|
||||
hex = "0.4.3"
|
||||
http = "0.2.12"
|
||||
hyper = "0.14.28"
|
||||
image = { version = "0.25.1", default-features = false, features = ["png"] }
|
||||
infer = "0.15.0"
|
||||
iso_currency = "0.4.4"
|
||||
isocountry = "0.3.2"
|
||||
@ -85,7 +84,6 @@ num-traits = "0.2.19"
|
||||
once_cell = "1.19.0"
|
||||
openidconnect = "3.5.0" # TODO: remove reqwest
|
||||
openssl = "0.10.64"
|
||||
qrcode = "0.14.0"
|
||||
quick-xml = { version = "0.31.0", features = ["serialize"] }
|
||||
rand = "0.8.5"
|
||||
rand_chacha = "0.3.1"
|
||||
|
||||
@ -942,6 +942,7 @@ impl TryFrom<&common_enums::BankNames> for OpenBankingUKIssuer {
|
||||
| common_enums::BankNames::AllianceBank
|
||||
| common_enums::BankNames::AmBank
|
||||
| common_enums::BankNames::BankOfAmerica
|
||||
| common_enums::BankNames::BankOfChina
|
||||
| common_enums::BankNames::BankIslam
|
||||
| common_enums::BankNames::BankMuamalat
|
||||
| common_enums::BankNames::BankRakyat
|
||||
|
||||
@ -243,6 +243,7 @@ impl TryFrom<&BankNames> for MultisafepayBankNames {
|
||||
| BankNames::AllianceBank
|
||||
| BankNames::AmBank
|
||||
| BankNames::BankOfAmerica
|
||||
| BankNames::BankOfChina
|
||||
| BankNames::BankIslam
|
||||
| BankNames::BankMuamalat
|
||||
| BankNames::BankRakyat
|
||||
|
||||
@ -618,6 +618,7 @@ impl TryFrom<common_enums::enums::BankNames> for NuveiBIC {
|
||||
| common_enums::enums::BankNames::AllianceBank
|
||||
| common_enums::enums::BankNames::AmBank
|
||||
| common_enums::enums::BankNames::BankOfAmerica
|
||||
| common_enums::enums::BankNames::BankOfChina
|
||||
| common_enums::enums::BankNames::BankIslam
|
||||
| common_enums::enums::BankNames::BankMuamalat
|
||||
| common_enums::enums::BankNames::BankRakyat
|
||||
|
||||
@ -58,10 +58,6 @@ pub(crate) const API_KEY_LENGTH: usize = 64;
|
||||
pub(crate) const APPLEPAY_VALIDATION_URL: &str =
|
||||
"https://apple-pay-gateway-cert.apple.com/paymentservices/startSession";
|
||||
|
||||
// Qr Image data source starts with this string
|
||||
// The base64 image data will be appended to it to image data source
|
||||
pub(crate) const QR_IMAGE_DATA_SOURCE_STRING: &str = "data:image/png;base64";
|
||||
|
||||
// OID (Object Identifier) for the merchant ID field extension.
|
||||
pub(crate) const MERCHANT_ID_FIELD_EXTENSION_ID: &str = "1.2.840.113635.100.6.32";
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ use api_models::{
|
||||
payments::{self},
|
||||
webhooks,
|
||||
};
|
||||
use base64::Engine;
|
||||
use common_utils::types::keymanager::KeyManagerState;
|
||||
pub use common_utils::{
|
||||
crypto,
|
||||
@ -35,12 +34,11 @@ use common_utils::{
|
||||
types::keymanager::{Identifier, ToEncryptable},
|
||||
};
|
||||
use error_stack::ResultExt;
|
||||
pub use hyperswitch_connectors::utils::QrImage;
|
||||
use hyperswitch_domain_models::payments::PaymentIntent;
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
|
||||
use hyperswitch_domain_models::type_encryption::{crypto_operation, CryptoOperation};
|
||||
use image::Luma;
|
||||
use nanoid::nanoid;
|
||||
use qrcode;
|
||||
use router_env::metrics::add_attributes;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde_json::Value;
|
||||
@ -166,37 +164,6 @@ impl<E> ConnectorResponseExt
|
||||
pub fn get_payout_attempt_id(payout_id: impl std::fmt::Display, attempt_count: i16) -> String {
|
||||
format!("{payout_id}_{attempt_count}")
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct QrImage {
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
impl QrImage {
|
||||
pub fn new_from_data(
|
||||
data: String,
|
||||
) -> Result<Self, error_stack::Report<common_utils::errors::QrCodeError>> {
|
||||
let qr_code = qrcode::QrCode::new(data.as_bytes())
|
||||
.change_context(common_utils::errors::QrCodeError::FailedToCreateQrCode)?;
|
||||
|
||||
// Renders the QR code into an image.
|
||||
let qrcode_image_buffer = qr_code.render::<Luma<u8>>().build();
|
||||
let qrcode_dynamic_image = image::DynamicImage::ImageLuma8(qrcode_image_buffer);
|
||||
|
||||
let mut image_bytes = std::io::BufWriter::new(std::io::Cursor::new(Vec::new()));
|
||||
|
||||
// Encodes qrcode_dynamic_image and write it to image_bytes
|
||||
let _ = qrcode_dynamic_image.write_to(&mut image_bytes, image::ImageFormat::Png);
|
||||
|
||||
let image_data_source = format!(
|
||||
"{},{}",
|
||||
consts::QR_IMAGE_DATA_SOURCE_STRING,
|
||||
consts::BASE64_ENGINE.encode(image_bytes.buffer())
|
||||
);
|
||||
Ok(Self {
|
||||
data: image_data_source,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn find_payment_intent_from_payment_id_type(
|
||||
state: &SessionState,
|
||||
@ -1186,13 +1153,3 @@ pub async fn flatten_join_error<T>(handle: Handle<T>) -> RouterResult<T> {
|
||||
.attach_printable("Join Error"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::utils;
|
||||
#[test]
|
||||
fn test_image_data_source_url() {
|
||||
let qr_image_data_source_url = utils::QrImage::new_from_data("Hyperswitch".to_string());
|
||||
assert!(qr_image_data_source_url.is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user