feat(connector): [Bambora Apac] Template for integration (#5062)

This commit is contained in:
Sakil Mostak
2024-07-01 16:28:36 +05:30
committed by GitHub
parent 2688d24d49
commit 1b8946321b
21 changed files with 1300 additions and 10 deletions

View File

@ -4,6 +4,7 @@ pub mod adyenplatform;
pub mod airwallex;
pub mod authorizedotnet;
pub mod bambora;
pub mod bamboraapac;
pub mod bankofamerica;
pub mod billwerk;
pub mod bitpay;
@ -69,15 +70,16 @@ pub mod zsl;
pub use self::dummyconnector::DummyConnector;
pub use self::{
aci::Aci, adyen::Adyen, adyenplatform::Adyenplatform, airwallex::Airwallex,
authorizedotnet::Authorizedotnet, bambora::Bambora, bankofamerica::Bankofamerica,
billwerk::Billwerk, bitpay::Bitpay, bluesnap::Bluesnap, boku::Boku, braintree::Braintree,
cashtocode::Cashtocode, checkout::Checkout, coinbase::Coinbase, cryptopay::Cryptopay,
cybersource::Cybersource, datatrans::Datatrans, dlocal::Dlocal, ebanx::Ebanx, fiserv::Fiserv,
forte::Forte, globalpay::Globalpay, globepay::Globepay, gocardless::Gocardless,
gpayments::Gpayments, helcim::Helcim, iatapay::Iatapay, klarna::Klarna, mifinity::Mifinity,
mollie::Mollie, multisafepay::Multisafepay, netcetera::Netcetera, nexinets::Nexinets, nmi::Nmi,
noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, payeezy::Payeezy, payme::Payme,
payone::Payone, paypal::Paypal, payu::Payu, placetopay::Placetopay, powertranz::Powertranz,
authorizedotnet::Authorizedotnet, bambora::Bambora, bamboraapac::Bamboraapac,
bankofamerica::Bankofamerica, billwerk::Billwerk, bitpay::Bitpay, bluesnap::Bluesnap,
boku::Boku, braintree::Braintree, cashtocode::Cashtocode, checkout::Checkout,
coinbase::Coinbase, cryptopay::Cryptopay, cybersource::Cybersource, datatrans::Datatrans,
dlocal::Dlocal, ebanx::Ebanx, fiserv::Fiserv, forte::Forte, globalpay::Globalpay,
globepay::Globepay, gocardless::Gocardless, gpayments::Gpayments, helcim::Helcim,
iatapay::Iatapay, klarna::Klarna, mifinity::Mifinity, mollie::Mollie,
multisafepay::Multisafepay, netcetera::Netcetera, nexinets::Nexinets, nmi::Nmi, noon::Noon,
nuvei::Nuvei, opayo::Opayo, opennode::Opennode, payeezy::Payeezy, payme::Payme, payone::Payone,
paypal::Paypal, payu::Payu, placetopay::Placetopay, powertranz::Powertranz,
prophetpay::Prophetpay, rapyd::Rapyd, riskified::Riskified, shift4::Shift4, signifyd::Signifyd,
square::Square, stax::Stax, stripe::Stripe, threedsecureio::Threedsecureio, trustpay::Trustpay,
tsys::Tsys, volt::Volt, wise::Wise, worldline::Worldline, worldpay::Worldpay, zen::Zen,

View File

@ -0,0 +1,580 @@
pub mod transformers;
use common_utils::{
self,
types::{AmountConvertor, MinorUnit, MinorUnitForConnector},
};
use error_stack::{report, ResultExt};
use masking::ExposeInterface;
use transformers as bamboraapac;
use super::utils as connector_utils;
use crate::{
configs::settings,
core::errors::{self, CustomResult},
events::connector_api_logs::ConnectorEvent,
headers,
services::{
self,
request::{self, Mask},
ConnectorIntegration, ConnectorValidation,
},
types::{
self,
api::{self, ConnectorCommon, ConnectorCommonExt},
ErrorResponse, RequestContent, Response,
},
utils::BytesExt,
};
#[derive(Clone)]
pub struct Bamboraapac {
amount_converter: &'static (dyn AmountConvertor<Output = MinorUnit> + Sync),
}
impl Bamboraapac {
pub const fn new() -> &'static Self {
&Self {
amount_converter: &MinorUnitForConnector,
}
}
}
impl api::Payment for Bamboraapac {}
impl api::PaymentSession for Bamboraapac {}
impl api::ConnectorAccessToken for Bamboraapac {}
impl api::MandateSetup for Bamboraapac {}
impl api::PaymentAuthorize for Bamboraapac {}
impl api::PaymentSync for Bamboraapac {}
impl api::PaymentCapture for Bamboraapac {}
impl api::PaymentVoid for Bamboraapac {}
impl api::Refund for Bamboraapac {}
impl api::RefundExecute for Bamboraapac {}
impl api::RefundSync for Bamboraapac {}
impl api::PaymentToken for Bamboraapac {}
impl
ConnectorIntegration<
api::PaymentMethodToken,
types::PaymentMethodTokenizationData,
types::PaymentsResponseData,
> for Bamboraapac
{
// Not Implemented (R)
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Bamboraapac
where
Self: ConnectorIntegration<Flow, Request, Response>,
{
fn build_headers(
&self,
req: &types::RouterData<Flow, Request, Response>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::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 Bamboraapac {
fn id(&self) -> &'static str {
"bamboraapac"
}
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Minor
}
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.bamboraapac.base_url.as_ref()
}
fn get_auth_header(
&self,
auth_type: &types::ConnectorAuthType,
) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
let auth = bamboraapac::BamboraapacAuthType::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: bamboraapac::BamboraapacErrorResponse = res
.response
.parse_struct("BamboraapacErrorResponse")
.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 Bamboraapac {
//TODO: implement functions when support enabled
}
impl ConnectorIntegration<api::Session, types::PaymentsSessionData, types::PaymentsResponseData>
for Bamboraapac
{
//TODO: implement sessions flow
}
impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, types::AccessToken>
for Bamboraapac
{
}
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Bamboraapac
{
}
impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::PaymentsResponseData>
for Bamboraapac
{
fn get_headers(
&self,
req: &types::PaymentsAuthorizeRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::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: &types::PaymentsAuthorizeRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
req: &types::PaymentsAuthorizeRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = connector_utils::convert_amount(
self.amount_converter,
req.request.minor_amount,
req.request.currency,
)?;
let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?;
let connector_req =
bamboraapac::BamboraapacPaymentsRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &types::PaymentsAuthorizeRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
Ok(Some(
services::RequestBuilder::new()
.method(services::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: &types::PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: bamboraapac::BamboraapacPaymentsResponse = res
.response
.parse_struct("Bamboraapac PaymentsAuthorizeResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::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<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>
for Bamboraapac
{
fn get_headers(
&self,
req: &types::PaymentsSyncRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::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: &types::PaymentsSyncRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn build_request(
&self,
req: &types::PaymentsSyncRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
Ok(Some(
services::RequestBuilder::new()
.method(services::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: &types::PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
let response: bamboraapac::BamboraapacPaymentsResponse = res
.response
.parse_struct("bamboraapac PaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::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<api::Capture, types::PaymentsCaptureData, types::PaymentsResponseData>
for Bamboraapac
{
fn get_headers(
&self,
req: &types::PaymentsCaptureRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::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: &types::PaymentsCaptureRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
_req: &types::PaymentsCaptureRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
}
fn build_request(
&self,
req: &types::PaymentsCaptureRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
Ok(Some(
services::RequestBuilder::new()
.method(services::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: &types::PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsCaptureRouterData, errors::ConnectorError> {
let response: bamboraapac::BamboraapacPaymentsResponse = res
.response
.parse_struct("Bamboraapac PaymentsCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::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<api::Void, types::PaymentsCancelData, types::PaymentsResponseData>
for Bamboraapac
{
}
impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponseData>
for Bamboraapac
{
fn get_headers(
&self,
req: &types::RefundsRouterData<api::Execute>,
connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::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: &types::RefundsRouterData<api::Execute>,
_connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
req: &types::RefundsRouterData<api::Execute>,
_connectors: &settings::Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let refund_amount = connector_utils::convert_amount(
self.amount_converter,
req.request.minor_refund_amount,
req.request.currency,
)?;
let connector_router_data =
bamboraapac::BamboraapacRouterData::try_from((refund_amount, req))?;
let connector_req =
bamboraapac::BamboraapacRefundRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &types::RefundsRouterData<api::Execute>,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
let request = services::RequestBuilder::new()
.method(services::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: &types::RefundsRouterData<api::Execute>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::RefundsRouterData<api::Execute>, errors::ConnectorError> {
let response: bamboraapac::RefundResponse = res
.response
.parse_struct("bamboraapac RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::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<api::RSync, types::RefundsData, types::RefundsResponseData>
for Bamboraapac
{
fn get_headers(
&self,
req: &types::RefundSyncRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::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: &types::RefundSyncRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn build_request(
&self,
req: &types::RefundSyncRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
Ok(Some(
services::RequestBuilder::new()
.method(services::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: &types::RefundSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {
let response: bamboraapac::RefundResponse = res
.response
.parse_struct("bamboraapac RefundSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::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 api::IncomingWebhook for Bamboraapac {
fn get_webhook_object_reference_id(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api::webhooks::ObjectReferenceId, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
fn get_webhook_event_type(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api::IncomingWebhookEvent, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
fn get_webhook_resource_object(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
}

View File

@ -0,0 +1,234 @@
use masking::Secret;
use serde::{Deserialize, Serialize};
use crate::{
connector::utils::PaymentsAuthorizeRequestData,
core::errors,
types::{self, api, domain, storage::enums, MinorUnit},
};
//TODO: Fill the struct with respective fields
pub struct BamboraapacRouterData<T> {
pub amount: MinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
pub router_data: T,
}
impl<T> TryFrom<(MinorUnit, T)> for BamboraapacRouterData<T> {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from((amount, item): (MinorUnit, T)) -> Result<Self, Self::Error> {
//Todo : use utils to convert the amount to the type of amount that a connector accepts
Ok(Self {
amount,
router_data: item,
})
}
}
//TODO: Fill the struct with respective fields
#[derive(Default, Debug, Serialize, Eq, PartialEq)]
pub struct BamboraapacPaymentsRequest {
amount: MinorUnit,
card: BamboraapacCard,
}
#[derive(Default, Debug, Serialize, Eq, PartialEq)]
pub struct BamboraapacCard {
number: cards::CardNumber,
expiry_month: Secret<String>,
expiry_year: Secret<String>,
cvc: Secret<String>,
complete: bool,
}
impl TryFrom<&BamboraapacRouterData<&types::PaymentsAuthorizeRouterData>>
for BamboraapacPaymentsRequest
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &BamboraapacRouterData<&types::PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
match item.router_data.request.payment_method_data.clone() {
domain::PaymentMethodData::Card(req_card) => {
let card = BamboraapacCard {
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.to_owned(),
card,
})
}
_ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
}
}
}
//TODO: Fill the struct with respective fields
// Auth Struct
pub struct BamboraapacAuthType {
pub(super) api_key: Secret<String>,
}
impl TryFrom<&types::ConnectorAuthType> for BamboraapacAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
types::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 BamboraapacPaymentStatus {
Succeeded,
Failed,
#[default]
Processing,
}
impl From<BamboraapacPaymentStatus> for enums::AttemptStatus {
fn from(item: BamboraapacPaymentStatus) -> Self {
match item {
BamboraapacPaymentStatus::Succeeded => Self::Charged,
BamboraapacPaymentStatus::Failed => Self::Failure,
BamboraapacPaymentStatus::Processing => Self::Authorizing,
}
}
}
//TODO: Fill the struct with respective fields
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BamboraapacPaymentsResponse {
status: BamboraapacPaymentStatus,
id: String,
}
impl<F, T>
TryFrom<
types::ResponseRouterData<F, BamboraapacPaymentsResponse, T, types::PaymentsResponseData>,
> for types::RouterData<F, T, types::PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: types::ResponseRouterData<
F,
BamboraapacPaymentsResponse,
T,
types::PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
Ok(Self {
status: enums::AttemptStatus::from(item.response.status),
response: Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
redirection_data: None,
mandate_reference: 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 BamboraapacRefundRequest {
pub amount: MinorUnit,
}
impl<F> TryFrom<&BamboraapacRouterData<&types::RefundsRouterData<F>>> for BamboraapacRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &BamboraapacRouterData<&types::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<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
for types::RefundsRouterData<api::Execute>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(types::RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
refund_status: enums::RefundStatus::from(item.response.status),
}),
..item.data
})
}
}
impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>
for types::RefundsRouterData<api::RSync>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(types::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 BamboraapacErrorResponse {
pub status_code: u16,
pub code: String,
pub message: String,
pub reason: Option<String>,
}

View File

@ -1898,6 +1898,10 @@ pub(crate) fn validate_auth_and_metadata_type_with_connector(
bambora::transformers::BamboraAuthType::try_from(val)?;
Ok(())
}
// api_enums::Connector::Bamboraapac => {
// bamboraapac::transformers::BamboraapacAuthType::try_from(val)?;
// Ok(())
// }
api_enums::Connector::Boku => {
boku::transformers::BokuAuthType::try_from(val)?;
Ok(())

View File

@ -161,6 +161,7 @@ default_imp_for_complete_authorize!(
connector::Adyenplatform,
connector::Aci,
connector::Adyen,
connector::Bamboraapac,
connector::Billwerk,
connector::Bitpay,
connector::Boku,
@ -239,6 +240,7 @@ default_imp_for_webhook_source_verification!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -331,6 +333,7 @@ default_imp_for_create_customer!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -420,6 +423,7 @@ default_imp_for_connector_redirect_response!(
connector::Adyenplatform,
connector::Aci,
connector::Adyen,
connector::Bamboraapac,
connector::Bitpay,
connector::Bankofamerica,
connector::Billwerk,
@ -485,6 +489,7 @@ default_imp_for_connector_request_id!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -578,6 +583,7 @@ default_imp_for_accept_dispute!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -692,6 +698,7 @@ default_imp_for_file_upload!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -783,6 +790,7 @@ default_imp_for_submit_evidence!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -874,6 +882,7 @@ default_imp_for_defend_dispute!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -964,6 +973,7 @@ default_imp_for_pre_processing_steps!(
connector::Aci,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Billwerk,
connector::Bitpay,
connector::Bluesnap,
@ -1029,6 +1039,7 @@ default_imp_for_payouts!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1116,6 +1127,7 @@ default_imp_for_payouts_create!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1208,6 +1220,7 @@ default_imp_for_payouts_eligibility!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1298,6 +1311,7 @@ default_imp_for_payouts_fulfill!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1385,6 +1399,7 @@ default_imp_for_payouts_cancel!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1476,6 +1491,7 @@ default_imp_for_payouts_quote!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1568,6 +1584,7 @@ default_imp_for_payouts_recipient!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1662,6 +1679,7 @@ default_imp_for_payouts_recipient_account!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1754,6 +1772,7 @@ default_imp_for_approve!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1847,6 +1866,7 @@ default_imp_for_reject!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -1924,6 +1944,7 @@ default_imp_for_fraud_check!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2017,6 +2038,7 @@ default_imp_for_frm_sale!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2110,6 +2132,7 @@ default_imp_for_frm_checkout!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2203,6 +2226,7 @@ default_imp_for_frm_transaction!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2296,6 +2320,7 @@ default_imp_for_frm_fulfillment!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2389,6 +2414,7 @@ default_imp_for_frm_record_return!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2480,6 +2506,7 @@ default_imp_for_incremental_authorization!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2570,6 +2597,7 @@ default_imp_for_revoking_mandates!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2720,6 +2748,7 @@ default_imp_for_connector_authentication!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,
@ -2807,6 +2836,7 @@ default_imp_for_authorize_session_token!(
connector::Airwallex,
connector::Authorizedotnet,
connector::Bambora,
connector::Bamboraapac,
connector::Bankofamerica,
connector::Billwerk,
connector::Bitpay,

View File

@ -217,6 +217,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
api_enums::Connector::Airwallex => Self::Airwallex,
api_enums::Connector::Authorizedotnet => Self::Authorizedotnet,
api_enums::Connector::Bambora => Self::Bambora,
// api_enums::Connector::Bamboraapac => Self::Bamboraapac, commented for template
api_enums::Connector::Bankofamerica => Self::Bankofamerica,
api_enums::Connector::Billwerk => Self::Billwerk,
api_enums::Connector::Bitpay => Self::Bitpay,