mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix(connector): [BITPAY] Fixed Currency Conversion (#7378)
Co-authored-by: Sayak Bhattacharya <sayak.b@Sayak-Bhattacharya-G092THXJ34.local>
This commit is contained in:
committed by
GitHub
parent
cdfbb82ffa
commit
5d24286101
@ -5,7 +5,7 @@ use common_utils::{
|
|||||||
errors::{CustomResult, ReportSwitchExt},
|
errors::{CustomResult, ReportSwitchExt},
|
||||||
ext_traits::ByteSliceExt,
|
ext_traits::ByteSliceExt,
|
||||||
request::{Method, Request, RequestBuilder, RequestContent},
|
request::{Method, Request, RequestBuilder, RequestContent},
|
||||||
types::{AmountConvertor, MinorUnit, MinorUnitForConnector},
|
types::{AmountConvertor, FloatMajorUnit, FloatMajorUnitForConnector},
|
||||||
};
|
};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
use hyperswitch_domain_models::{
|
use hyperswitch_domain_models::{
|
||||||
@ -49,13 +49,13 @@ use crate::{constants::headers, types::ResponseRouterData, utils};
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Bitpay {
|
pub struct Bitpay {
|
||||||
amount_converter: &'static (dyn AmountConvertor<Output = MinorUnit> + Sync),
|
amount_converter: &'static (dyn AmountConvertor<Output = FloatMajorUnit> + Sync),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bitpay {
|
impl Bitpay {
|
||||||
pub fn new() -> &'static Self {
|
pub fn new() -> &'static Self {
|
||||||
&Self {
|
&Self {
|
||||||
amount_converter: &MinorUnitForConnector,
|
amount_converter: &FloatMajorUnitForConnector,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use common_enums::enums;
|
use common_enums::enums;
|
||||||
use common_utils::{request::Method, types::MinorUnit};
|
use common_utils::{request::Method, types::FloatMajorUnit};
|
||||||
use hyperswitch_domain_models::{
|
use hyperswitch_domain_models::{
|
||||||
router_data::{ConnectorAuthType, RouterData},
|
router_data::{ConnectorAuthType, RouterData},
|
||||||
router_flow_types::refunds::{Execute, RSync},
|
router_flow_types::refunds::{Execute, RSync},
|
||||||
@ -18,12 +18,12 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct BitpayRouterData<T> {
|
pub struct BitpayRouterData<T> {
|
||||||
pub amount: MinorUnit,
|
pub amount: FloatMajorUnit,
|
||||||
pub router_data: T,
|
pub router_data: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<(MinorUnit, T)> for BitpayRouterData<T> {
|
impl<T> From<(FloatMajorUnit, T)> for BitpayRouterData<T> {
|
||||||
fn from((amount, router_data): (MinorUnit, T)) -> Self {
|
fn from((amount, router_data): (FloatMajorUnit, T)) -> Self {
|
||||||
Self {
|
Self {
|
||||||
amount,
|
amount,
|
||||||
router_data,
|
router_data,
|
||||||
@ -40,10 +40,10 @@ pub enum TransactionSpeed {
|
|||||||
High,
|
High,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Serialize, Eq, PartialEq)]
|
#[derive(Default, Debug, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct BitpayPaymentsRequest {
|
pub struct BitpayPaymentsRequest {
|
||||||
price: MinorUnit,
|
price: FloatMajorUnit,
|
||||||
currency: String,
|
currency: String,
|
||||||
#[serde(rename = "redirectURL")]
|
#[serde(rename = "redirectURL")]
|
||||||
redirect_url: String,
|
redirect_url: String,
|
||||||
@ -117,10 +117,10 @@ pub enum ExceptionStatus {
|
|||||||
pub struct BitpayPaymentResponseData {
|
pub struct BitpayPaymentResponseData {
|
||||||
pub url: Option<url::Url>,
|
pub url: Option<url::Url>,
|
||||||
pub status: BitpayPaymentStatus,
|
pub status: BitpayPaymentStatus,
|
||||||
pub price: MinorUnit,
|
pub price: FloatMajorUnit,
|
||||||
pub currency: String,
|
pub currency: String,
|
||||||
pub amount_paid: MinorUnit,
|
pub amount_paid: FloatMajorUnit,
|
||||||
pub invoice_time: Option<MinorUnit>,
|
pub invoice_time: Option<FloatMajorUnit>,
|
||||||
pub rate_refresh_time: Option<i64>,
|
pub rate_refresh_time: Option<i64>,
|
||||||
pub expiration_time: Option<i64>,
|
pub expiration_time: Option<i64>,
|
||||||
pub current_time: Option<i64>,
|
pub current_time: Option<i64>,
|
||||||
@ -180,7 +180,7 @@ impl<F, T> TryFrom<ResponseRouterData<F, BitpayPaymentsResponse, T, PaymentsResp
|
|||||||
// Type definition for RefundRequest
|
// Type definition for RefundRequest
|
||||||
#[derive(Default, Debug, Serialize)]
|
#[derive(Default, Debug, Serialize)]
|
||||||
pub struct BitpayRefundRequest {
|
pub struct BitpayRefundRequest {
|
||||||
pub amount: MinorUnit,
|
pub amount: FloatMajorUnit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> TryFrom<&BitpayRouterData<&types::RefundsRouterData<F>>> for BitpayRefundRequest {
|
impl<F> TryFrom<&BitpayRouterData<&types::RefundsRouterData<F>>> for BitpayRefundRequest {
|
||||||
|
|||||||
Reference in New Issue
Block a user