Skip to content

Commit

Permalink
made some requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayak Bhattacharya authored and Sayak Bhattacharya committed Dec 10, 2024
1 parent fa28b59 commit 17d3b31
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
4 changes: 4 additions & 0 deletions config/deployments/integration_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ debit.currency = "USD"
ali_pay.currency = "GBP,CNY"
we_chat_pay.currency = "GBP,CNY"

[pm.filters.jpmorgan]
debit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }
credit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }

[pm_filters.klarna]
klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NL,NZ,NO,PL,PT,ES,SE,CH,GB,US", currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" }

Expand Down
4 changes: 2 additions & 2 deletions config/deployments/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ ali_pay.currency = "GBP,CNY"
we_chat_pay.currency = "GBP,CNY"

[pm.filters.jpmorgan]
debit = { country = "CA, EU, UK, US", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, ISK, JMD, JPY, KES, KHR, KMF, KRW, KYD, KZT, LAK, LBP, LKR, LRD, LSL, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RWF, SAR, SBD, SCR, SEK, SGD, SHP, SLL, SOS, SRD, STN, SZL, THB, TJS, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW" }
credit = { country = "CA, EU, UK, US", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, ISK, JMD, JPY, KES, KHR, KMF, KRW, KYD, KZT, LAK, LBP, LKR, LRD, LSL, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RWF, SAR, SBD, SCR, SEK, SGD, SHP, SLL, SOS, SRD, STN, SZL, THB, TJS, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW" }
debit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }
credit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }

[pm_filters.klarna]
klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NL,NZ,NO,PL,PT,ES,SE,CH,GB,US", currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" }
Expand Down
4 changes: 4 additions & 0 deletions config/deployments/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ debit.currency = "USD"
ali_pay.currency = "GBP,CNY"
we_chat_pay.currency = "GBP,CNY"

[pm.filters.jpmorgan]
debit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }
credit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }

[pm_filters.klarna]
klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NL,NZ,NO,PL,PT,ES,SE,CH,GB,US", currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" }

Expand Down
4 changes: 4 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ paypal = { currency = "AUD,BRL,CAD,CNY,CZK,DKK,EUR,HKD,HUF,ILS,JPY,MYR,MXN,TWD,N
credit = { currency = "USD" }
debit = { currency = "USD" }

[pm.filters.jpmorgan]
debit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }
credit = { country = "CA, EU, UK, US", currency = "CAD, EUR, GBP, USD" }

[pm_filters.klarna]
klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NL,NZ,NO,PL,PT,ES,SE,CH,GB,US", currency = "AUD,EUR,EUR,CAD,CZK,DKK,EUR,EUR,EUR,EUR,EUR,EUR,EUR,NZD,NOK,PLN,EUR,EUR,SEK,CHF,GBP,USD" }

Expand Down
4 changes: 1 addition & 3 deletions crates/hyperswitch_connectors/src/connectors/jpmorgan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use hyperswitch_interfaces::{
types::{self, RefreshTokenType, Response},
webhooks,
};
use masking::{Mask, PeekInterface};
use masking::{Mask, Maskable, PeekInterface};
use transformers::{self as jpmorgan, JpmorganErrorResponse};

use crate::{
Expand Down Expand Up @@ -75,8 +75,6 @@ impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, Pay
// Not Implemented (R)
}

use masking::Maskable;

impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Jpmorgan
where
Self: ConnectorIntegration<Flow, Request, Response>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<F, T> TryFrom<ResponseRouterData<F, JpmorganAuthUpdateResponse, T, AccessTo
pub struct JpmorganPaymentsRequest {
capture_method: CapMethod,
amount: MinorUnit,
currency: String,
currency: common_enums::Currency,
merchant: JpmorganMerchant,
payment_method_type: JpmorganPaymentMethodType,
}
Expand Down Expand Up @@ -148,7 +148,7 @@ impl TryFrom<&JpmorganRouterData<&PaymentsAuthorizeRouterData>> for JpmorganPaym
let capture_method =
map_capture_method(item.router_data.request.capture_method.unwrap_or_default());

let currency = item.router_data.request.currency.to_string();
let currency = item.router_data.request.currency;

let merchant_software = JpmorganMerchantSoftware {
company_name: String::from("JPMC"),
Expand Down Expand Up @@ -206,19 +206,17 @@ impl TryFrom<&JpmorganRouterData<&PaymentsAuthorizeRouterData>> for JpmorganPaym
}
#[derive(Debug)]
pub struct JpmorganAuthType {
#[allow(dead_code)]
pub(super) api_key: Secret<String>,
#[allow(dead_code)]
pub(super) key1: Secret<String>,
pub(super) _api_key: Secret<String>,
pub(super) _key1: Secret<String>,
}

impl TryFrom<&ConnectorAuthType> for JpmorganAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {
api_key: api_key.to_owned(),
key1: key1.to_owned(),
_api_key: api_key.to_owned(),
_key1: key1.to_owned(),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
}
Expand Down Expand Up @@ -263,7 +261,7 @@ pub struct JpmorganPaymentsResponse {
approval_code: Option<String>,
host_message: Option<String>,
amount: Option<i64>,
currency: Option<String>,
currency: Option<common_enums::Currency>,
remaining_refundable_amount: Option<i64>,
remaining_auth_amount: Option<i64>,
host_reference_id: Option<String>,
Expand Down Expand Up @@ -422,7 +420,7 @@ pub struct JpmorganCaptureRequest {
original_transaction_id: Option<String>,
is_amount_final: Option<bool>,
amount: MinorUnit,
currency: Option<String>,
currency: Option<common_enums::Currency>,
merchant_order_number: Option<String>,
risk: Option<RiskCapReq>,
retail_addenda: Option<RetailAddendaCapReq>,
Expand Down Expand Up @@ -483,7 +481,7 @@ pub struct BusinessInformation {
#[serde(rename_all = "camelCase")]
pub struct PartnerService {
pub external_vendor_product_name: Option<String>,
pub currency: Option<String>,
pub currency: Option<common_enums::Currency>,
pub external_monthly_service_fee_amount: Option<i64>,
}

Expand All @@ -510,7 +508,7 @@ pub struct MerchantReportedRevenue {
pub amount: Option<i64>,
pub start_date: Option<String>,
pub end_date: Option<String>,
pub currency: Option<String>,
pub currency: Option<common_enums::Currency>,
pub amount_type: Option<String>,
}

Expand Down Expand Up @@ -846,7 +844,7 @@ impl TryFrom<&JpmorganRouterData<&PaymentsCaptureRouterData>> for JpmorganCaptur
.as_ref()
.map(|cm| cm.to_string());

let currency = Some(item.router_data.request.currency.to_string());
let currency = Some(item.router_data.request.currency);
let amount = item.amount;
Ok(Self {
capture_method,
Expand Down Expand Up @@ -874,7 +872,6 @@ impl TryFrom<&JpmorganRouterData<&PaymentsCaptureRouterData>> for JpmorganCaptur
}
}

//made changes here in JpmorganTransactionState
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JpmorganCaptureResponse {
Expand Down Expand Up @@ -1053,7 +1050,7 @@ pub struct JpmorganRefundResponse {
pub request_id: String,
pub transaction_state: JpmorganTransactionState,
pub amount: MinorUnit,
pub currency: String,
pub currency: common_enums::Currency,
pub response_status: JpmorganResponseStatus,
pub response_code: String,
pub response_message: String,
Expand Down Expand Up @@ -1134,7 +1131,7 @@ pub struct JpmorganRefundSyncResponse {
request_id: String,
transaction_state: JpmorganTransactionState,
amount: MinorUnit,
currency: String,
currency: common_enums::Currency,
response_status: JpmorganResponseStatus,
response_code: String,
}
Expand Down

0 comments on commit 17d3b31

Please sign in to comment.