mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(connector): [INESPAY] add Connector Template Code (#6614)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
26c61969eb
commit
710186f035
@ -220,6 +220,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
|
||||
jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
|
||||
|
||||
@ -62,6 +62,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
|
||||
jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
|
||||
|
||||
@ -66,6 +66,7 @@ gocardless.base_url = "https://api.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://secure.api.itau/"
|
||||
jpmorgan.base_url = "https://api-ms.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.klarna.com/"
|
||||
|
||||
@ -66,6 +66,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
|
||||
jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
|
||||
|
||||
@ -130,6 +130,7 @@ cards = [
|
||||
"gpayments",
|
||||
"helcim",
|
||||
"iatapay",
|
||||
"inespay",
|
||||
"itaubank",
|
||||
"jpmorgan",
|
||||
"mollie",
|
||||
@ -235,6 +236,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
|
||||
jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
|
||||
|
||||
@ -150,6 +150,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
|
||||
jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
|
||||
@ -249,6 +250,7 @@ cards = [
|
||||
"gpayments",
|
||||
"helcim",
|
||||
"iatapay",
|
||||
"inespay",
|
||||
"itaubank",
|
||||
"jpmorgan",
|
||||
"mollie",
|
||||
|
||||
@ -84,6 +84,7 @@ pub enum Connector {
|
||||
Gocardless,
|
||||
Gpayments,
|
||||
Helcim,
|
||||
// Inespay,
|
||||
Iatapay,
|
||||
Itaubank,
|
||||
//Jpmorgan,
|
||||
@ -228,6 +229,7 @@ impl Connector {
|
||||
| Self::Gpayments
|
||||
| Self::Helcim
|
||||
| Self::Iatapay
|
||||
// | Self::Inespay
|
||||
| Self::Itaubank
|
||||
//| Self::Jpmorgan
|
||||
| Self::Klarna
|
||||
|
||||
@ -81,6 +81,7 @@ pub enum RoutableConnectors {
|
||||
Gocardless,
|
||||
Helcim,
|
||||
Iatapay,
|
||||
// Inespay,
|
||||
Itaubank,
|
||||
//Jpmorgan,
|
||||
Klarna,
|
||||
|
||||
@ -192,6 +192,7 @@ pub struct ConnectorConfig {
|
||||
pub gocardless: Option<ConnectorTomlConfig>,
|
||||
pub gpayments: Option<ConnectorTomlConfig>,
|
||||
pub helcim: Option<ConnectorTomlConfig>,
|
||||
// pub inespay: Option<ConnectorTomlConfig>,
|
||||
pub klarna: Option<ConnectorTomlConfig>,
|
||||
pub mifinity: Option<ConnectorTomlConfig>,
|
||||
pub mollie: Option<ConnectorTomlConfig>,
|
||||
@ -357,6 +358,7 @@ impl ConnectorConfig {
|
||||
Connector::Gocardless => Ok(connector_data.gocardless),
|
||||
Connector::Gpayments => Ok(connector_data.gpayments),
|
||||
Connector::Helcim => Ok(connector_data.helcim),
|
||||
// Connector::Inespay => Ok(connector_data.inespay),
|
||||
Connector::Klarna => Ok(connector_data.klarna),
|
||||
Connector::Mifinity => Ok(connector_data.mifinity),
|
||||
Connector::Mollie => Ok(connector_data.mollie),
|
||||
|
||||
@ -16,6 +16,7 @@ pub mod fiuu;
|
||||
pub mod forte;
|
||||
pub mod globepay;
|
||||
pub mod helcim;
|
||||
pub mod inespay;
|
||||
pub mod jpmorgan;
|
||||
pub mod mollie;
|
||||
pub mod multisafepay;
|
||||
@ -45,9 +46,9 @@ pub use self::{
|
||||
bitpay::Bitpay, cashtocode::Cashtocode, coinbase::Coinbase, cryptopay::Cryptopay,
|
||||
deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon,
|
||||
fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay,
|
||||
helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay,
|
||||
nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, payeezy::Payeezy,
|
||||
payu::Payu, powertranz::Powertranz, razorpay::Razorpay, shift4::Shift4, square::Square,
|
||||
stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline,
|
||||
worldpay::Worldpay, xendit::Xendit, zen::Zen, zsl::Zsl,
|
||||
helcim::Helcim, inespay::Inespay, jpmorgan::Jpmorgan, mollie::Mollie,
|
||||
multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay,
|
||||
novalnet::Novalnet, payeezy::Payeezy, payu::Payu, powertranz::Powertranz, razorpay::Razorpay,
|
||||
shift4::Shift4, square::Square, stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys,
|
||||
volt::Volt, worldline::Worldline, worldpay::Worldpay, xendit::Xendit, zen::Zen, zsl::Zsl,
|
||||
};
|
||||
|
||||
563
crates/hyperswitch_connectors/src/connectors/inespay.rs
Normal file
563
crates/hyperswitch_connectors/src/connectors/inespay.rs
Normal file
@ -0,0 +1,563 @@
|
||||
pub mod transformers;
|
||||
|
||||
use common_utils::{
|
||||
errors::CustomResult,
|
||||
ext_traits::BytesExt,
|
||||
request::{Method, Request, RequestBuilder, RequestContent},
|
||||
types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
|
||||
};
|
||||
use error_stack::{report, ResultExt};
|
||||
use hyperswitch_domain_models::{
|
||||
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
|
||||
router_flow_types::{
|
||||
access_token_auth::AccessTokenAuth,
|
||||
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
|
||||
refunds::{Execute, RSync},
|
||||
},
|
||||
router_request_types::{
|
||||
AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
|
||||
PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
|
||||
RefundsData, SetupMandateRequestData,
|
||||
},
|
||||
router_response_types::{PaymentsResponseData, RefundsResponseData},
|
||||
types::{
|
||||
PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
|
||||
RefundSyncRouterData, RefundsRouterData,
|
||||
},
|
||||
};
|
||||
use hyperswitch_interfaces::{
|
||||
api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation},
|
||||
configs::Connectors,
|
||||
errors,
|
||||
events::connector_api_logs::ConnectorEvent,
|
||||
types::{self, Response},
|
||||
webhooks,
|
||||
};
|
||||
use masking::{ExposeInterface, Mask};
|
||||
use transformers as inespay;
|
||||
|
||||
use crate::{constants::headers, types::ResponseRouterData, utils};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Inespay {
|
||||
amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
|
||||
}
|
||||
|
||||
impl Inespay {
|
||||
pub fn new() -> &'static Self {
|
||||
&Self {
|
||||
amount_converter: &StringMinorUnitForConnector,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl api::Payment for Inespay {}
|
||||
impl api::PaymentSession for Inespay {}
|
||||
impl api::ConnectorAccessToken for Inespay {}
|
||||
impl api::MandateSetup for Inespay {}
|
||||
impl api::PaymentAuthorize for Inespay {}
|
||||
impl api::PaymentSync for Inespay {}
|
||||
impl api::PaymentCapture for Inespay {}
|
||||
impl api::PaymentVoid for Inespay {}
|
||||
impl api::Refund for Inespay {}
|
||||
impl api::RefundExecute for Inespay {}
|
||||
impl api::RefundSync for Inespay {}
|
||||
impl api::PaymentToken for Inespay {}
|
||||
|
||||
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
|
||||
for Inespay
|
||||
{
|
||||
// Not Implemented (R)
|
||||
}
|
||||
|
||||
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Inespay
|
||||
where
|
||||
Self: ConnectorIntegration<Flow, Request, Response>,
|
||||
{
|
||||
fn build_headers(
|
||||
&self,
|
||||
req: &RouterData<Flow, Request, Response>,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
let mut header = vec![(
|
||||
headers::CONTENT_TYPE.to_string(),
|
||||
self.get_content_type().to_string().into(),
|
||||
)];
|
||||
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
|
||||
header.append(&mut api_key);
|
||||
Ok(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectorCommon for Inespay {
|
||||
fn id(&self) -> &'static str {
|
||||
"inespay"
|
||||
}
|
||||
|
||||
fn get_currency_unit(&self) -> api::CurrencyUnit {
|
||||
api::CurrencyUnit::Base
|
||||
// TODO! Check connector documentation, on which unit they are processing the currency.
|
||||
// If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,
|
||||
// if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base
|
||||
}
|
||||
|
||||
fn common_get_content_type(&self) -> &'static str {
|
||||
"application/json"
|
||||
}
|
||||
|
||||
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
|
||||
connectors.inespay.base_url.as_ref()
|
||||
}
|
||||
|
||||
fn get_auth_header(
|
||||
&self,
|
||||
auth_type: &ConnectorAuthType,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
let auth = inespay::InespayAuthType::try_from(auth_type)
|
||||
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||
Ok(vec![(
|
||||
headers::AUTHORIZATION.to_string(),
|
||||
auth.api_key.expose().into_masked(),
|
||||
)])
|
||||
}
|
||||
|
||||
fn build_error_response(
|
||||
&self,
|
||||
res: Response,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
|
||||
let response: inespay::InespayErrorResponse = res
|
||||
.response
|
||||
.parse_struct("InespayErrorResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
|
||||
event_builder.map(|i| i.set_response_body(&response));
|
||||
router_env::logger::info!(connector_response=?response);
|
||||
|
||||
Ok(ErrorResponse {
|
||||
status_code: res.status_code,
|
||||
code: response.code,
|
||||
message: response.message,
|
||||
reason: response.reason,
|
||||
attempt_status: None,
|
||||
connector_transaction_id: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectorValidation for Inespay {
|
||||
//TODO: implement functions when support enabled
|
||||
}
|
||||
|
||||
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Inespay {
|
||||
//TODO: implement sessions flow
|
||||
}
|
||||
|
||||
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Inespay {}
|
||||
|
||||
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Inespay {}
|
||||
|
||||
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Inespay {
|
||||
fn get_headers(
|
||||
&self,
|
||||
req: &PaymentsAuthorizeRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
self.build_headers(req, connectors)
|
||||
}
|
||||
|
||||
fn get_content_type(&self) -> &'static str {
|
||||
self.common_get_content_type()
|
||||
}
|
||||
|
||||
fn get_url(
|
||||
&self,
|
||||
_req: &PaymentsAuthorizeRouterData,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
|
||||
}
|
||||
|
||||
fn get_request_body(
|
||||
&self,
|
||||
req: &PaymentsAuthorizeRouterData,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<RequestContent, errors::ConnectorError> {
|
||||
let amount = utils::convert_amount(
|
||||
self.amount_converter,
|
||||
req.request.minor_amount,
|
||||
req.request.currency,
|
||||
)?;
|
||||
|
||||
let connector_router_data = inespay::InespayRouterData::from((amount, req));
|
||||
let connector_req = inespay::InespayPaymentsRequest::try_from(&connector_router_data)?;
|
||||
Ok(RequestContent::Json(Box::new(connector_req)))
|
||||
}
|
||||
|
||||
fn build_request(
|
||||
&self,
|
||||
req: &PaymentsAuthorizeRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||
Ok(Some(
|
||||
RequestBuilder::new()
|
||||
.method(Method::Post)
|
||||
.url(&types::PaymentsAuthorizeType::get_url(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.attach_default_headers()
|
||||
.headers(types::PaymentsAuthorizeType::get_headers(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.set_body(types::PaymentsAuthorizeType::get_request_body(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.build(),
|
||||
))
|
||||
}
|
||||
|
||||
fn handle_response(
|
||||
&self,
|
||||
data: &PaymentsAuthorizeRouterData,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
res: Response,
|
||||
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
|
||||
let response: inespay::InespayPaymentsResponse = res
|
||||
.response
|
||||
.parse_struct("Inespay PaymentsAuthorizeResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
event_builder.map(|i| i.set_response_body(&response));
|
||||
router_env::logger::info!(connector_response=?response);
|
||||
RouterData::try_from(ResponseRouterData {
|
||||
response,
|
||||
data: data.clone(),
|
||||
http_code: res.status_code,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_error_response(
|
||||
&self,
|
||||
res: Response,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
|
||||
self.build_error_response(res, event_builder)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Inespay {
|
||||
fn get_headers(
|
||||
&self,
|
||||
req: &PaymentsSyncRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
self.build_headers(req, connectors)
|
||||
}
|
||||
|
||||
fn get_content_type(&self) -> &'static str {
|
||||
self.common_get_content_type()
|
||||
}
|
||||
|
||||
fn get_url(
|
||||
&self,
|
||||
_req: &PaymentsSyncRouterData,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
|
||||
}
|
||||
|
||||
fn build_request(
|
||||
&self,
|
||||
req: &PaymentsSyncRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||
Ok(Some(
|
||||
RequestBuilder::new()
|
||||
.method(Method::Get)
|
||||
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
|
||||
.attach_default_headers()
|
||||
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
|
||||
.build(),
|
||||
))
|
||||
}
|
||||
|
||||
fn handle_response(
|
||||
&self,
|
||||
data: &PaymentsSyncRouterData,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
res: Response,
|
||||
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
|
||||
let response: inespay::InespayPaymentsResponse = res
|
||||
.response
|
||||
.parse_struct("inespay PaymentsSyncResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
event_builder.map(|i| i.set_response_body(&response));
|
||||
router_env::logger::info!(connector_response=?response);
|
||||
RouterData::try_from(ResponseRouterData {
|
||||
response,
|
||||
data: data.clone(),
|
||||
http_code: res.status_code,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_error_response(
|
||||
&self,
|
||||
res: Response,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
|
||||
self.build_error_response(res, event_builder)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Inespay {
|
||||
fn get_headers(
|
||||
&self,
|
||||
req: &PaymentsCaptureRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
self.build_headers(req, connectors)
|
||||
}
|
||||
|
||||
fn get_content_type(&self) -> &'static str {
|
||||
self.common_get_content_type()
|
||||
}
|
||||
|
||||
fn get_url(
|
||||
&self,
|
||||
_req: &PaymentsCaptureRouterData,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
|
||||
}
|
||||
|
||||
fn get_request_body(
|
||||
&self,
|
||||
_req: &PaymentsCaptureRouterData,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<RequestContent, errors::ConnectorError> {
|
||||
Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
|
||||
}
|
||||
|
||||
fn build_request(
|
||||
&self,
|
||||
req: &PaymentsCaptureRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||
Ok(Some(
|
||||
RequestBuilder::new()
|
||||
.method(Method::Post)
|
||||
.url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
|
||||
.attach_default_headers()
|
||||
.headers(types::PaymentsCaptureType::get_headers(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.set_body(types::PaymentsCaptureType::get_request_body(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.build(),
|
||||
))
|
||||
}
|
||||
|
||||
fn handle_response(
|
||||
&self,
|
||||
data: &PaymentsCaptureRouterData,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
res: Response,
|
||||
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
|
||||
let response: inespay::InespayPaymentsResponse = res
|
||||
.response
|
||||
.parse_struct("Inespay PaymentsCaptureResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
event_builder.map(|i| i.set_response_body(&response));
|
||||
router_env::logger::info!(connector_response=?response);
|
||||
RouterData::try_from(ResponseRouterData {
|
||||
response,
|
||||
data: data.clone(),
|
||||
http_code: res.status_code,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_error_response(
|
||||
&self,
|
||||
res: Response,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
|
||||
self.build_error_response(res, event_builder)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Inespay {}
|
||||
|
||||
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Inespay {
|
||||
fn get_headers(
|
||||
&self,
|
||||
req: &RefundsRouterData<Execute>,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
self.build_headers(req, connectors)
|
||||
}
|
||||
|
||||
fn get_content_type(&self) -> &'static str {
|
||||
self.common_get_content_type()
|
||||
}
|
||||
|
||||
fn get_url(
|
||||
&self,
|
||||
_req: &RefundsRouterData<Execute>,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
|
||||
}
|
||||
|
||||
fn get_request_body(
|
||||
&self,
|
||||
req: &RefundsRouterData<Execute>,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<RequestContent, errors::ConnectorError> {
|
||||
let refund_amount = utils::convert_amount(
|
||||
self.amount_converter,
|
||||
req.request.minor_refund_amount,
|
||||
req.request.currency,
|
||||
)?;
|
||||
|
||||
let connector_router_data = inespay::InespayRouterData::from((refund_amount, req));
|
||||
let connector_req = inespay::InespayRefundRequest::try_from(&connector_router_data)?;
|
||||
Ok(RequestContent::Json(Box::new(connector_req)))
|
||||
}
|
||||
|
||||
fn build_request(
|
||||
&self,
|
||||
req: &RefundsRouterData<Execute>,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||
let request = RequestBuilder::new()
|
||||
.method(Method::Post)
|
||||
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
|
||||
.attach_default_headers()
|
||||
.headers(types::RefundExecuteType::get_headers(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.set_body(types::RefundExecuteType::get_request_body(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.build();
|
||||
Ok(Some(request))
|
||||
}
|
||||
|
||||
fn handle_response(
|
||||
&self,
|
||||
data: &RefundsRouterData<Execute>,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
res: Response,
|
||||
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
|
||||
let response: inespay::RefundResponse = res
|
||||
.response
|
||||
.parse_struct("inespay RefundResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
event_builder.map(|i| i.set_response_body(&response));
|
||||
router_env::logger::info!(connector_response=?response);
|
||||
RouterData::try_from(ResponseRouterData {
|
||||
response,
|
||||
data: data.clone(),
|
||||
http_code: res.status_code,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_error_response(
|
||||
&self,
|
||||
res: Response,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
|
||||
self.build_error_response(res, event_builder)
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Inespay {
|
||||
fn get_headers(
|
||||
&self,
|
||||
req: &RefundSyncRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||
self.build_headers(req, connectors)
|
||||
}
|
||||
|
||||
fn get_content_type(&self) -> &'static str {
|
||||
self.common_get_content_type()
|
||||
}
|
||||
|
||||
fn get_url(
|
||||
&self,
|
||||
_req: &RefundSyncRouterData,
|
||||
_connectors: &Connectors,
|
||||
) -> CustomResult<String, errors::ConnectorError> {
|
||||
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
|
||||
}
|
||||
|
||||
fn build_request(
|
||||
&self,
|
||||
req: &RefundSyncRouterData,
|
||||
connectors: &Connectors,
|
||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||
Ok(Some(
|
||||
RequestBuilder::new()
|
||||
.method(Method::Get)
|
||||
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
|
||||
.attach_default_headers()
|
||||
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
|
||||
.set_body(types::RefundSyncType::get_request_body(
|
||||
self, req, connectors,
|
||||
)?)
|
||||
.build(),
|
||||
))
|
||||
}
|
||||
|
||||
fn handle_response(
|
||||
&self,
|
||||
data: &RefundSyncRouterData,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
res: Response,
|
||||
) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
|
||||
let response: inespay::RefundResponse = res
|
||||
.response
|
||||
.parse_struct("inespay RefundSyncResponse")
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
event_builder.map(|i| i.set_response_body(&response));
|
||||
router_env::logger::info!(connector_response=?response);
|
||||
RouterData::try_from(ResponseRouterData {
|
||||
response,
|
||||
data: data.clone(),
|
||||
http_code: res.status_code,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_error_response(
|
||||
&self,
|
||||
res: Response,
|
||||
event_builder: Option<&mut ConnectorEvent>,
|
||||
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
|
||||
self.build_error_response(res, event_builder)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl webhooks::IncomingWebhook for Inespay {
|
||||
fn get_webhook_object_reference_id(
|
||||
&self,
|
||||
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
|
||||
) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
|
||||
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
|
||||
}
|
||||
|
||||
fn get_webhook_event_type(
|
||||
&self,
|
||||
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
|
||||
) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
|
||||
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
|
||||
}
|
||||
|
||||
fn get_webhook_resource_object(
|
||||
&self,
|
||||
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
|
||||
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
|
||||
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,228 @@
|
||||
use common_enums::enums;
|
||||
use common_utils::types::StringMinorUnit;
|
||||
use hyperswitch_domain_models::{
|
||||
payment_method_data::PaymentMethodData,
|
||||
router_data::{ConnectorAuthType, RouterData},
|
||||
router_flow_types::refunds::{Execute, RSync},
|
||||
router_request_types::ResponseId,
|
||||
router_response_types::{PaymentsResponseData, RefundsResponseData},
|
||||
types::{PaymentsAuthorizeRouterData, RefundsRouterData},
|
||||
};
|
||||
use hyperswitch_interfaces::errors;
|
||||
use masking::Secret;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
types::{RefundsResponseRouterData, ResponseRouterData},
|
||||
utils::PaymentsAuthorizeRequestData,
|
||||
};
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
pub struct InespayRouterData<T> {
|
||||
pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
|
||||
pub router_data: T,
|
||||
}
|
||||
|
||||
impl<T> From<(StringMinorUnit, T)> for InespayRouterData<T> {
|
||||
fn from((amount, item): (StringMinorUnit, T)) -> Self {
|
||||
//Todo : use utils to convert the amount to the type of amount that a connector accepts
|
||||
Self {
|
||||
amount,
|
||||
router_data: item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
#[derive(Default, Debug, Serialize, PartialEq)]
|
||||
pub struct InespayPaymentsRequest {
|
||||
amount: StringMinorUnit,
|
||||
card: InespayCard,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Eq, PartialEq)]
|
||||
pub struct InespayCard {
|
||||
number: cards::CardNumber,
|
||||
expiry_month: Secret<String>,
|
||||
expiry_year: Secret<String>,
|
||||
cvc: Secret<String>,
|
||||
complete: bool,
|
||||
}
|
||||
|
||||
impl TryFrom<&InespayRouterData<&PaymentsAuthorizeRouterData>> for InespayPaymentsRequest {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(
|
||||
item: &InespayRouterData<&PaymentsAuthorizeRouterData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
match item.router_data.request.payment_method_data.clone() {
|
||||
PaymentMethodData::Card(req_card) => {
|
||||
let card = InespayCard {
|
||||
number: req_card.card_number,
|
||||
expiry_month: req_card.card_exp_month,
|
||||
expiry_year: req_card.card_exp_year,
|
||||
cvc: req_card.card_cvc,
|
||||
complete: item.router_data.request.is_auto_capture()?,
|
||||
};
|
||||
Ok(Self {
|
||||
amount: item.amount.clone(),
|
||||
card,
|
||||
})
|
||||
}
|
||||
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
// Auth Struct
|
||||
pub struct InespayAuthType {
|
||||
pub(super) api_key: Secret<String>,
|
||||
}
|
||||
|
||||
impl TryFrom<&ConnectorAuthType> for InespayAuthType {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
|
||||
match auth_type {
|
||||
ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
|
||||
api_key: api_key.to_owned(),
|
||||
}),
|
||||
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
// PaymentsResponse
|
||||
//TODO: Append the remaining status flags
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum InespayPaymentStatus {
|
||||
Succeeded,
|
||||
Failed,
|
||||
#[default]
|
||||
Processing,
|
||||
}
|
||||
|
||||
impl From<InespayPaymentStatus> for common_enums::AttemptStatus {
|
||||
fn from(item: InespayPaymentStatus) -> Self {
|
||||
match item {
|
||||
InespayPaymentStatus::Succeeded => Self::Charged,
|
||||
InespayPaymentStatus::Failed => Self::Failure,
|
||||
InespayPaymentStatus::Processing => Self::Authorizing,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct InespayPaymentsResponse {
|
||||
status: InespayPaymentStatus,
|
||||
id: String,
|
||||
}
|
||||
|
||||
impl<F, T> TryFrom<ResponseRouterData<F, InespayPaymentsResponse, T, PaymentsResponseData>>
|
||||
for RouterData<F, T, PaymentsResponseData>
|
||||
{
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(
|
||||
item: ResponseRouterData<F, InespayPaymentsResponse, T, PaymentsResponseData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
status: common_enums::AttemptStatus::from(item.response.status),
|
||||
response: Ok(PaymentsResponseData::TransactionResponse {
|
||||
resource_id: ResponseId::ConnectorTransactionId(item.response.id),
|
||||
redirection_data: Box::new(None),
|
||||
mandate_reference: Box::new(None),
|
||||
connector_metadata: None,
|
||||
network_txn_id: None,
|
||||
connector_response_reference_id: None,
|
||||
incremental_authorization_allowed: None,
|
||||
charge_id: None,
|
||||
}),
|
||||
..item.data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
// REFUND :
|
||||
// Type definition for RefundRequest
|
||||
#[derive(Default, Debug, Serialize)]
|
||||
pub struct InespayRefundRequest {
|
||||
pub amount: StringMinorUnit,
|
||||
}
|
||||
|
||||
impl<F> TryFrom<&InespayRouterData<&RefundsRouterData<F>>> for InespayRefundRequest {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(item: &InespayRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
amount: item.amount.to_owned(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Type definition for Refund Response
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Serialize, Default, Deserialize, Clone)]
|
||||
pub enum RefundStatus {
|
||||
Succeeded,
|
||||
Failed,
|
||||
#[default]
|
||||
Processing,
|
||||
}
|
||||
|
||||
impl From<RefundStatus> for enums::RefundStatus {
|
||||
fn from(item: RefundStatus) -> Self {
|
||||
match item {
|
||||
RefundStatus::Succeeded => Self::Success,
|
||||
RefundStatus::Failed => Self::Failure,
|
||||
RefundStatus::Processing => Self::Pending,
|
||||
//TODO: Review mapping
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct RefundResponse {
|
||||
id: String,
|
||||
status: RefundStatus,
|
||||
}
|
||||
|
||||
impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(
|
||||
item: RefundsResponseRouterData<Execute, RefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
response: Ok(RefundsResponseData {
|
||||
connector_refund_id: item.response.id.to_string(),
|
||||
refund_status: enums::RefundStatus::from(item.response.status),
|
||||
}),
|
||||
..item.data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
|
||||
type Error = error_stack::Report<errors::ConnectorError>;
|
||||
fn try_from(
|
||||
item: RefundsResponseRouterData<RSync, RefundResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
response: Ok(RefundsResponseData {
|
||||
connector_refund_id: item.response.id.to_string(),
|
||||
refund_status: enums::RefundStatus::from(item.response.status),
|
||||
}),
|
||||
..item.data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Fill the struct with respective fields
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct InespayErrorResponse {
|
||||
pub status_code: u16,
|
||||
pub code: String,
|
||||
pub message: String,
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
@ -107,6 +107,7 @@ default_imp_for_authorize_session_token!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -164,6 +165,7 @@ default_imp_for_calculate_tax!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Mollie,
|
||||
connectors::Multisafepay,
|
||||
@ -218,6 +220,7 @@ default_imp_for_session_update!(
|
||||
connectors::Fiservemea,
|
||||
connectors::Forte,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Razorpay,
|
||||
connectors::Shift4,
|
||||
@ -277,6 +280,7 @@ default_imp_for_post_session_tokens!(
|
||||
connectors::Fiservemea,
|
||||
connectors::Forte,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Razorpay,
|
||||
connectors::Shift4,
|
||||
@ -335,6 +339,7 @@ default_imp_for_complete_authorize!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Multisafepay,
|
||||
connectors::Nomupay,
|
||||
@ -389,6 +394,7 @@ default_imp_for_incremental_authorization!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -448,6 +454,7 @@ default_imp_for_create_customer!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Mollie,
|
||||
connectors::Multisafepay,
|
||||
@ -505,6 +512,7 @@ default_imp_for_connector_redirect_response!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Multisafepay,
|
||||
connectors::Nexinets,
|
||||
@ -559,6 +567,7 @@ default_imp_for_pre_processing_steps!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -616,6 +625,7 @@ default_imp_for_post_processing_steps!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -675,6 +685,7 @@ default_imp_for_approve!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -734,6 +745,7 @@ default_imp_for_reject!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -793,6 +805,7 @@ default_imp_for_webhook_source_verification!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -853,6 +866,7 @@ default_imp_for_accept_dispute!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -912,6 +926,7 @@ default_imp_for_submit_evidence!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -970,6 +985,7 @@ default_imp_for_defend_dispute!(
|
||||
connectors::Fiuu,
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Helcim,
|
||||
connectors::Nomupay,
|
||||
@ -1039,6 +1055,7 @@ default_imp_for_file_upload!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1091,6 +1108,7 @@ default_imp_for_payouts!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Mollie,
|
||||
connectors::Multisafepay,
|
||||
@ -1151,6 +1169,7 @@ default_imp_for_payouts_create!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1212,6 +1231,7 @@ default_imp_for_payouts_retrieve!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1273,6 +1293,7 @@ default_imp_for_payouts_eligibility!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1334,6 +1355,7 @@ default_imp_for_payouts_fulfill!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1395,6 +1417,7 @@ default_imp_for_payouts_cancel!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1456,6 +1479,7 @@ default_imp_for_payouts_quote!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1517,6 +1541,7 @@ default_imp_for_payouts_recipient!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1578,6 +1603,7 @@ default_imp_for_payouts_recipient_account!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1639,6 +1665,7 @@ default_imp_for_frm_sale!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1700,6 +1727,7 @@ default_imp_for_frm_checkout!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1761,6 +1789,7 @@ default_imp_for_frm_transaction!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1822,6 +1851,7 @@ default_imp_for_frm_fulfillment!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1883,6 +1913,7 @@ default_imp_for_frm_record_return!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1941,6 +1972,7 @@ default_imp_for_revoking_mandates!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
|
||||
@ -223,6 +223,7 @@ default_imp_for_new_connector_integration_payment!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -283,6 +284,7 @@ default_imp_for_new_connector_integration_refund!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -338,6 +340,7 @@ default_imp_for_new_connector_integration_connector_access_token!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -399,6 +402,7 @@ default_imp_for_new_connector_integration_accept_dispute!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -459,6 +463,7 @@ default_imp_for_new_connector_integration_submit_evidence!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -519,6 +524,7 @@ default_imp_for_new_connector_integration_defend_dispute!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -589,6 +595,7 @@ default_imp_for_new_connector_integration_file_upload!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -651,6 +658,7 @@ default_imp_for_new_connector_integration_payouts_create!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -713,6 +721,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -775,6 +784,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -837,6 +847,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -899,6 +910,7 @@ default_imp_for_new_connector_integration_payouts_quote!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -961,6 +973,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1023,6 +1036,7 @@ default_imp_for_new_connector_integration_payouts_sync!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1085,6 +1099,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1145,6 +1160,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1207,6 +1223,7 @@ default_imp_for_new_connector_integration_frm_sale!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1269,6 +1286,7 @@ default_imp_for_new_connector_integration_frm_checkout!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1331,6 +1349,7 @@ default_imp_for_new_connector_integration_frm_transaction!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1393,6 +1412,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1455,6 +1475,7 @@ default_imp_for_new_connector_integration_frm_record_return!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
@ -1514,6 +1535,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(
|
||||
connectors::Forte,
|
||||
connectors::Globepay,
|
||||
connectors::Helcim,
|
||||
connectors::Inespay,
|
||||
connectors::Jpmorgan,
|
||||
connectors::Nomupay,
|
||||
connectors::Novalnet,
|
||||
|
||||
@ -47,6 +47,7 @@ pub struct Connectors {
|
||||
pub gpayments: ConnectorParams,
|
||||
pub helcim: ConnectorParams,
|
||||
pub iatapay: ConnectorParams,
|
||||
pub inespay: ConnectorParams,
|
||||
pub itaubank: ConnectorParams,
|
||||
pub jpmorgan: ConnectorParams,
|
||||
pub klarna: ConnectorParams,
|
||||
|
||||
@ -50,14 +50,14 @@ pub use hyperswitch_connectors::connectors::{
|
||||
coinbase, coinbase::Coinbase, cryptopay, cryptopay::Cryptopay, deutschebank,
|
||||
deutschebank::Deutschebank, digitalvirgo, digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal,
|
||||
elavon, elavon::Elavon, fiserv, fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu,
|
||||
fiuu::Fiuu, forte, forte::Forte, globepay, globepay::Globepay, helcim, helcim::Helcim,
|
||||
jpmorgan, jpmorgan::Jpmorgan, mollie, mollie::Mollie, multisafepay, multisafepay::Multisafepay,
|
||||
nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay,
|
||||
novalnet, novalnet::Novalnet, payeezy, payeezy::Payeezy, payu, payu::Payu, powertranz,
|
||||
powertranz::Powertranz, razorpay, razorpay::Razorpay, shift4, shift4::Shift4, square,
|
||||
square::Square, stax, stax::Stax, taxjar, taxjar::Taxjar, thunes, thunes::Thunes, tsys,
|
||||
tsys::Tsys, volt, volt::Volt, worldline, worldline::Worldline, worldpay, worldpay::Worldpay,
|
||||
xendit, xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,
|
||||
fiuu::Fiuu, forte, forte::Forte, globepay, globepay::Globepay, helcim, helcim::Helcim, inespay,
|
||||
inespay::Inespay, jpmorgan, jpmorgan::Jpmorgan, mollie, mollie::Mollie, multisafepay,
|
||||
multisafepay::Multisafepay, nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay,
|
||||
nomupay, nomupay::Nomupay, novalnet, novalnet::Novalnet, payeezy, payeezy::Payeezy, payu,
|
||||
payu::Payu, powertranz, powertranz::Powertranz, razorpay, razorpay::Razorpay, shift4,
|
||||
shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar, taxjar::Taxjar, thunes,
|
||||
thunes::Thunes, tsys, tsys::Tsys, volt, volt::Volt, worldline, worldline::Worldline, worldpay,
|
||||
worldpay::Worldpay, xendit, xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,
|
||||
};
|
||||
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
|
||||
@ -1393,6 +1393,10 @@ impl<'a> ConnectorAuthTypeAndMetadataValidation<'a> {
|
||||
iatapay::transformers::IatapayAuthType::try_from(self.auth_type)?;
|
||||
Ok(())
|
||||
}
|
||||
// api_enums::Connector::Inespay => {
|
||||
// inespay::transformers::InespayAuthType::try_from(self.auth_type)?;
|
||||
// Ok(())
|
||||
// }
|
||||
api_enums::Connector::Itaubank => {
|
||||
itaubank::transformers::ItaubankAuthType::try_from(self.auth_type)?;
|
||||
Ok(())
|
||||
|
||||
@ -1142,6 +1142,7 @@ default_imp_for_new_connector_integration_payouts!(
|
||||
connector::Gpayments,
|
||||
connector::Helcim,
|
||||
connector::Iatapay,
|
||||
connector::Inespay,
|
||||
connector::Itaubank,
|
||||
connector::Jpmorgan,
|
||||
connector::Klarna,
|
||||
@ -1789,6 +1790,7 @@ default_imp_for_new_connector_integration_frm!(
|
||||
connector::Gpayments,
|
||||
connector::Helcim,
|
||||
connector::Iatapay,
|
||||
connector::Inespay,
|
||||
connector::Itaubank,
|
||||
connector::Jpmorgan,
|
||||
connector::Klarna,
|
||||
@ -2284,6 +2286,7 @@ default_imp_for_new_connector_integration_connector_authentication!(
|
||||
connector::Gpayments,
|
||||
connector::Helcim,
|
||||
connector::Iatapay,
|
||||
connector::Inespay,
|
||||
connector::Itaubank,
|
||||
connector::Jpmorgan,
|
||||
connector::Klarna,
|
||||
|
||||
@ -483,6 +483,7 @@ default_imp_for_connector_request_id!(
|
||||
connector::Gocardless,
|
||||
connector::Gpayments,
|
||||
connector::Iatapay,
|
||||
connector::Inespay,
|
||||
connector::Itaubank,
|
||||
connector::Jpmorgan,
|
||||
connector::Klarna,
|
||||
@ -1769,6 +1770,7 @@ default_imp_for_fraud_check!(
|
||||
connector::Gpayments,
|
||||
connector::Helcim,
|
||||
connector::Iatapay,
|
||||
connector::Inespay,
|
||||
connector::Itaubank,
|
||||
connector::Jpmorgan,
|
||||
connector::Klarna,
|
||||
@ -2432,6 +2434,7 @@ default_imp_for_connector_authentication!(
|
||||
connector::Gocardless,
|
||||
connector::Helcim,
|
||||
connector::Iatapay,
|
||||
connector::Inespay,
|
||||
connector::Itaubank,
|
||||
connector::Jpmorgan,
|
||||
connector::Klarna,
|
||||
|
||||
@ -434,6 +434,9 @@ impl ConnectorData {
|
||||
enums::Connector::Iatapay => {
|
||||
Ok(ConnectorEnum::Old(Box::new(connector::Iatapay::new())))
|
||||
}
|
||||
// enums::Connector::Inespay => {
|
||||
// Ok(ConnectorEnum::Old(Box::new(connector::Inespay::new())))
|
||||
// }
|
||||
enums::Connector::Itaubank => {
|
||||
//enums::Connector::Jpmorgan => Ok(ConnectorEnum::Old(Box::new(connector::Jpmorgan))),
|
||||
Ok(ConnectorEnum::Old(Box::new(connector::Itaubank::new())))
|
||||
|
||||
@ -249,6 +249,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
|
||||
}
|
||||
api_enums::Connector::Helcim => Self::Helcim,
|
||||
api_enums::Connector::Iatapay => Self::Iatapay,
|
||||
// api_enums::Connector::Inespay => Self::Inespay,
|
||||
api_enums::Connector::Itaubank => Self::Itaubank,
|
||||
//api_enums::Connector::Jpmorgan => Self::Jpmorgan,
|
||||
api_enums::Connector::Klarna => Self::Klarna,
|
||||
|
||||
421
crates/router/tests/connectors/inespay.rs
Normal file
421
crates/router/tests/connectors/inespay.rs
Normal file
@ -0,0 +1,421 @@
|
||||
use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData};
|
||||
use masking::Secret;
|
||||
use router::types::{self, api, storage::enums};
|
||||
use test_utils::connector_auth;
|
||||
|
||||
use crate::utils::{self, ConnectorActions};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct InespayTest;
|
||||
impl ConnectorActions for InespayTest {}
|
||||
impl utils::Connector for InespayTest {
|
||||
fn get_data(&self) -> api::ConnectorData {
|
||||
use router::connector::Inespay;
|
||||
utils::construct_connector_data_old(
|
||||
Box::new(Inespay::new()),
|
||||
types::Connector::Plaid,
|
||||
api::GetToken::Connector,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
fn get_auth_token(&self) -> types::ConnectorAuthType {
|
||||
utils::to_connector_auth_type(
|
||||
connector_auth::ConnectorAuthentication::new()
|
||||
.inespay
|
||||
.expect("Missing connector authentication configuration")
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
fn get_name(&self) -> String {
|
||||
"inespay".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
static CONNECTOR: InespayTest = InespayTest {};
|
||||
|
||||
fn get_default_payment_info() -> Option<utils::PaymentInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
|
||||
None
|
||||
}
|
||||
|
||||
// Cards Positive Tests
|
||||
// Creates a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_only_authorize_payment() {
|
||||
let response = CONNECTOR
|
||||
.authorize_payment(payment_method_details(), get_default_payment_info())
|
||||
.await
|
||||
.expect("Authorize payment response");
|
||||
assert_eq!(response.status, enums::AttemptStatus::Authorized);
|
||||
}
|
||||
|
||||
// Captures a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_capture_authorized_payment() {
|
||||
let response = CONNECTOR
|
||||
.authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info())
|
||||
.await
|
||||
.expect("Capture payment response");
|
||||
assert_eq!(response.status, enums::AttemptStatus::Charged);
|
||||
}
|
||||
|
||||
// Partially captures a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_partially_capture_authorized_payment() {
|
||||
let response = CONNECTOR
|
||||
.authorize_and_capture_payment(
|
||||
payment_method_details(),
|
||||
Some(types::PaymentsCaptureData {
|
||||
amount_to_capture: 50,
|
||||
..utils::PaymentCaptureType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.expect("Capture payment response");
|
||||
assert_eq!(response.status, enums::AttemptStatus::Charged);
|
||||
}
|
||||
|
||||
// Synchronizes a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_sync_authorized_payment() {
|
||||
let authorize_response = CONNECTOR
|
||||
.authorize_payment(payment_method_details(), get_default_payment_info())
|
||||
.await
|
||||
.expect("Authorize payment response");
|
||||
let txn_id = utils::get_connector_transaction_id(authorize_response.response);
|
||||
let response = CONNECTOR
|
||||
.psync_retry_till_status_matches(
|
||||
enums::AttemptStatus::Authorized,
|
||||
Some(types::PaymentsSyncData {
|
||||
connector_transaction_id: types::ResponseId::ConnectorTransactionId(
|
||||
txn_id.unwrap(),
|
||||
),
|
||||
..Default::default()
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.expect("PSync response");
|
||||
assert_eq!(response.status, enums::AttemptStatus::Authorized,);
|
||||
}
|
||||
|
||||
// Voids a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_void_authorized_payment() {
|
||||
let response = CONNECTOR
|
||||
.authorize_and_void_payment(
|
||||
payment_method_details(),
|
||||
Some(types::PaymentsCancelData {
|
||||
connector_transaction_id: String::from(""),
|
||||
cancellation_reason: Some("requested_by_customer".to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.expect("Void payment response");
|
||||
assert_eq!(response.status, enums::AttemptStatus::Voided);
|
||||
}
|
||||
|
||||
// Refunds a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_refund_manually_captured_payment() {
|
||||
let response = CONNECTOR
|
||||
.capture_payment_and_refund(
|
||||
payment_method_details(),
|
||||
None,
|
||||
None,
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap().refund_status,
|
||||
enums::RefundStatus::Success,
|
||||
);
|
||||
}
|
||||
|
||||
// Partially refunds a payment using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_partially_refund_manually_captured_payment() {
|
||||
let response = CONNECTOR
|
||||
.capture_payment_and_refund(
|
||||
payment_method_details(),
|
||||
None,
|
||||
Some(types::RefundsData {
|
||||
refund_amount: 50,
|
||||
..utils::PaymentRefundType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap().refund_status,
|
||||
enums::RefundStatus::Success,
|
||||
);
|
||||
}
|
||||
|
||||
// Synchronizes a refund using the manual capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_sync_manually_captured_refund() {
|
||||
let refund_response = CONNECTOR
|
||||
.capture_payment_and_refund(
|
||||
payment_method_details(),
|
||||
None,
|
||||
None,
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let response = CONNECTOR
|
||||
.rsync_retry_till_status_matches(
|
||||
enums::RefundStatus::Success,
|
||||
refund_response.response.unwrap().connector_refund_id,
|
||||
None,
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap().refund_status,
|
||||
enums::RefundStatus::Success,
|
||||
);
|
||||
}
|
||||
|
||||
// Creates a payment using the automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_make_payment() {
|
||||
let authorize_response = CONNECTOR
|
||||
.make_payment(payment_method_details(), get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
|
||||
}
|
||||
|
||||
// Synchronizes a payment using the automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_sync_auto_captured_payment() {
|
||||
let authorize_response = CONNECTOR
|
||||
.make_payment(payment_method_details(), get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
|
||||
let txn_id = utils::get_connector_transaction_id(authorize_response.response);
|
||||
assert_ne!(txn_id, None, "Empty connector transaction id");
|
||||
let response = CONNECTOR
|
||||
.psync_retry_till_status_matches(
|
||||
enums::AttemptStatus::Charged,
|
||||
Some(types::PaymentsSyncData {
|
||||
connector_transaction_id: types::ResponseId::ConnectorTransactionId(
|
||||
txn_id.unwrap(),
|
||||
),
|
||||
capture_method: Some(enums::CaptureMethod::Automatic),
|
||||
..Default::default()
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(response.status, enums::AttemptStatus::Charged,);
|
||||
}
|
||||
|
||||
// Refunds a payment using the automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_refund_auto_captured_payment() {
|
||||
let response = CONNECTOR
|
||||
.make_payment_and_refund(payment_method_details(), None, get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap().refund_status,
|
||||
enums::RefundStatus::Success,
|
||||
);
|
||||
}
|
||||
|
||||
// Partially refunds a payment using the automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_partially_refund_succeeded_payment() {
|
||||
let refund_response = CONNECTOR
|
||||
.make_payment_and_refund(
|
||||
payment_method_details(),
|
||||
Some(types::RefundsData {
|
||||
refund_amount: 50,
|
||||
..utils::PaymentRefundType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
refund_response.response.unwrap().refund_status,
|
||||
enums::RefundStatus::Success,
|
||||
);
|
||||
}
|
||||
|
||||
// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_refund_succeeded_payment_multiple_times() {
|
||||
CONNECTOR
|
||||
.make_payment_and_multiple_refund(
|
||||
payment_method_details(),
|
||||
Some(types::RefundsData {
|
||||
refund_amount: 50,
|
||||
..utils::PaymentRefundType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
// Synchronizes a refund using the automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_sync_refund() {
|
||||
let refund_response = CONNECTOR
|
||||
.make_payment_and_refund(payment_method_details(), None, get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
let response = CONNECTOR
|
||||
.rsync_retry_till_status_matches(
|
||||
enums::RefundStatus::Success,
|
||||
refund_response.response.unwrap().connector_refund_id,
|
||||
None,
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap().refund_status,
|
||||
enums::RefundStatus::Success,
|
||||
);
|
||||
}
|
||||
|
||||
// Cards Negative scenarios
|
||||
// Creates a payment with incorrect CVC.
|
||||
#[actix_web::test]
|
||||
async fn should_fail_payment_for_incorrect_cvc() {
|
||||
let response = CONNECTOR
|
||||
.make_payment(
|
||||
Some(types::PaymentsAuthorizeData {
|
||||
payment_method_data: PaymentMethodData::Card(Card {
|
||||
card_cvc: Secret::new("12345".to_string()),
|
||||
..utils::CCardType::default().0
|
||||
}),
|
||||
..utils::PaymentAuthorizeType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap_err().message,
|
||||
"Your card's security code is invalid.".to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
// Creates a payment with incorrect expiry month.
|
||||
#[actix_web::test]
|
||||
async fn should_fail_payment_for_invalid_exp_month() {
|
||||
let response = CONNECTOR
|
||||
.make_payment(
|
||||
Some(types::PaymentsAuthorizeData {
|
||||
payment_method_data: PaymentMethodData::Card(Card {
|
||||
card_exp_month: Secret::new("20".to_string()),
|
||||
..utils::CCardType::default().0
|
||||
}),
|
||||
..utils::PaymentAuthorizeType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap_err().message,
|
||||
"Your card's expiration month is invalid.".to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
// Creates a payment with incorrect expiry year.
|
||||
#[actix_web::test]
|
||||
async fn should_fail_payment_for_incorrect_expiry_year() {
|
||||
let response = CONNECTOR
|
||||
.make_payment(
|
||||
Some(types::PaymentsAuthorizeData {
|
||||
payment_method_data: PaymentMethodData::Card(Card {
|
||||
card_exp_year: Secret::new("2000".to_string()),
|
||||
..utils::CCardType::default().0
|
||||
}),
|
||||
..utils::PaymentAuthorizeType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap_err().message,
|
||||
"Your card's expiration year is invalid.".to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
// Voids a payment using automatic capture flow (Non 3DS).
|
||||
#[actix_web::test]
|
||||
async fn should_fail_void_payment_for_auto_capture() {
|
||||
let authorize_response = CONNECTOR
|
||||
.make_payment(payment_method_details(), get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
|
||||
let txn_id = utils::get_connector_transaction_id(authorize_response.response);
|
||||
assert_ne!(txn_id, None, "Empty connector transaction id");
|
||||
let void_response = CONNECTOR
|
||||
.void_payment(txn_id.unwrap(), None, get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
void_response.response.unwrap_err().message,
|
||||
"You cannot cancel this PaymentIntent because it has a status of succeeded."
|
||||
);
|
||||
}
|
||||
|
||||
// Captures a payment using invalid connector payment id.
|
||||
#[actix_web::test]
|
||||
async fn should_fail_capture_for_invalid_payment() {
|
||||
let capture_response = CONNECTOR
|
||||
.capture_payment("123456789".to_string(), None, get_default_payment_info())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
capture_response.response.unwrap_err().message,
|
||||
String::from("No such payment_intent: '123456789'")
|
||||
);
|
||||
}
|
||||
|
||||
// Refunds a payment with refund amount higher than payment amount.
|
||||
#[actix_web::test]
|
||||
async fn should_fail_for_refund_amount_higher_than_payment_amount() {
|
||||
let response = CONNECTOR
|
||||
.make_payment_and_refund(
|
||||
payment_method_details(),
|
||||
Some(types::RefundsData {
|
||||
refund_amount: 150,
|
||||
..utils::PaymentRefundType::default().0
|
||||
}),
|
||||
get_default_payment_info(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
response.response.unwrap_err().message,
|
||||
"Refund amount (₹1.50) is greater than charge amount (₹1.00)",
|
||||
);
|
||||
}
|
||||
|
||||
// Connector dependent test cases goes here
|
||||
|
||||
// [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests
|
||||
@ -43,6 +43,7 @@ mod gocardless;
|
||||
mod gpayments;
|
||||
mod helcim;
|
||||
mod iatapay;
|
||||
mod inespay;
|
||||
mod itaubank;
|
||||
mod jpmorgan;
|
||||
mod mifinity;
|
||||
|
||||
@ -287,6 +287,9 @@ api_secret = "Client Key"
|
||||
[thunes]
|
||||
api_key="API Key"
|
||||
|
||||
[inespay]
|
||||
api_key="API Key"
|
||||
|
||||
[jpmorgan]
|
||||
api_key="API Key"
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ pub struct ConnectorAuthentication {
|
||||
pub gpayments: Option<HeaderKey>,
|
||||
pub helcim: Option<HeaderKey>,
|
||||
pub iatapay: Option<SignatureKey>,
|
||||
pub inespay: Option<HeaderKey>,
|
||||
pub itaubank: Option<MultiAuthKey>,
|
||||
pub jpmorgan: Option<HeaderKey>,
|
||||
pub mifinity: Option<HeaderKey>,
|
||||
|
||||
@ -116,6 +116,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
|
||||
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
|
||||
helcim.base_url = "https://api.helcim.com/"
|
||||
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
|
||||
inespay.base_url = "https://apiflow.inespay.com/san/v21"
|
||||
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
|
||||
jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"
|
||||
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
|
||||
@ -215,6 +216,7 @@ cards = [
|
||||
"gpayments",
|
||||
"helcim",
|
||||
"iatapay",
|
||||
"inespay",
|
||||
"itaubank",
|
||||
"jpmorgan",
|
||||
"mollie",
|
||||
|
||||
@ -6,7 +6,7 @@ function find_prev_connector() {
|
||||
git checkout $self
|
||||
cp $self $self.tmp
|
||||
# Add new connector to existing list and sort it
|
||||
connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte globalpay globepay gocardless gpayments helcim iatapay itaubank jpmorgan klarna mifinity mollie multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")
|
||||
connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte globalpay globepay gocardless gpayments helcim iatapay inespay itaubank jpmorgan klarna mifinity mollie multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")
|
||||
IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS
|
||||
res="$(echo ${sorted[@]})"
|
||||
sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp
|
||||
|
||||
Reference in New Issue
Block a user