feat(connector): [COINGATE] Add Template PR (#7052)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
awasthi21
2025-02-06 19:13:36 +05:30
committed by GitHub
parent 775dcc5a4e
commit dddb1b06be
21 changed files with 1323 additions and 27 deletions

View File

@ -196,6 +196,7 @@ cashtocode.base_url = "https://cluster05.api-test.cashtocode.com"
chargebee.base_url = "https://$.chargebee.com/api/"
checkout.base_url = "https://api.sandbox.checkout.com/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api-sandbox.coingate.com/v2"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
@ -310,6 +311,7 @@ cards = [
"adyenplatform",
"authorizedotnet",
"coinbase",
"coingate",
"cryptopay",
"braintree",
"checkout",

View File

@ -42,6 +42,7 @@ cashtocode.base_url = "https://cluster05.api-test.cashtocode.com"
chargebee.base_url = "https://$.chargebee.com/api/"
checkout.base_url = "https://api.sandbox.checkout.com/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api-sandbox.coingate.com/v2"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"

View File

@ -46,6 +46,7 @@ cashtocode.base_url = "https://cluster14.api.cashtocode.com"
chargebee.base_url = "https://$.chargebee.com/api/"
checkout.base_url = "https://api.checkout.com/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api.coingate.com/v2"
cryptopay.base_url = "https://business.cryptopay.me/"
cybersource.base_url = "https://api.cybersource.com/"
datatrans.base_url = "https://api.datatrans.com/"

View File

@ -46,6 +46,7 @@ cashtocode.base_url = "https://cluster05.api-test.cashtocode.com"
checkout.base_url = "https://api.sandbox.checkout.com/"
chargebee.base_url = "https://$.chargebee.com/api/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api-sandbox.coingate.com/v2"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"

View File

@ -108,6 +108,7 @@ cards = [
"braintree",
"checkout",
"coinbase",
"coingate",
"cryptopay",
"cybersource",
"datatrans",
@ -215,6 +216,7 @@ cashtocode.base_url = "https://cluster05.api-test.cashtocode.com"
chargebee.base_url = "https://$.chargebee.com/api/"
checkout.base_url = "https://api.sandbox.checkout.com/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api-sandbox.coingate.com/v2"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"

View File

@ -128,6 +128,7 @@ cashtocode.base_url = "https://cluster05.api-test.cashtocode.com"
chargebee.base_url = "https://$.chargebee.com/api/"
checkout.base_url = "https://api.sandbox.checkout.com/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api-sandbox.coingate.com/v2"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
@ -233,6 +234,7 @@ cards = [
"braintree",
"checkout",
"coinbase",
"coingate",
"cryptopay",
"cybersource",
"datatrans",

View File

@ -68,6 +68,7 @@ pub enum RoutableConnectors {
// Chargebee,
Checkout,
Coinbase,
// Coingate,
Cryptopay,
Cybersource,
Datatrans,

View File

@ -10,6 +10,7 @@ pub mod boku;
pub mod cashtocode;
pub mod chargebee;
pub mod coinbase;
pub mod coingate;
pub mod cryptopay;
pub mod ctp_mastercard;
pub mod cybersource;
@ -61,16 +62,16 @@ pub use self::{
airwallex::Airwallex, amazonpay::Amazonpay, bambora::Bambora, bamboraapac::Bamboraapac,
bankofamerica::Bankofamerica, billwerk::Billwerk, bitpay::Bitpay, bluesnap::Bluesnap,
boku::Boku, cashtocode::Cashtocode, chargebee::Chargebee, coinbase::Coinbase,
cryptopay::Cryptopay, ctp_mastercard::CtpMastercard, cybersource::Cybersource,
datatrans::Datatrans, deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal,
elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte,
globepay::Globepay, gocardless::Gocardless, helcim::Helcim, inespay::Inespay,
jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay, nexinets::Nexinets,
nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, paybox::Paybox, payeezy::Payeezy,
payu::Payu, placetopay::Placetopay, powertranz::Powertranz, prophetpay::Prophetpay,
rapyd::Rapyd, razorpay::Razorpay, redsys::Redsys, shift4::Shift4, square::Square, stax::Stax,
taxjar::Taxjar, thunes::Thunes, tsys::Tsys,
unified_authentication_service::UnifiedAuthenticationService, volt::Volt,
coingate::Coingate, cryptopay::Cryptopay, ctp_mastercard::CtpMastercard,
cybersource::Cybersource, datatrans::Datatrans, deutschebank::Deutschebank,
digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon, fiserv::Fiserv,
fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay, gocardless::Gocardless,
helcim::Helcim, inespay::Inespay, jpmorgan::Jpmorgan, mollie::Mollie,
multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay,
novalnet::Novalnet, paybox::Paybox, payeezy::Payeezy, payu::Payu, placetopay::Placetopay,
powertranz::Powertranz, prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay,
redsys::Redsys, shift4::Shift4, square::Square, stax::Stax, taxjar::Taxjar, thunes::Thunes,
tsys::Tsys, unified_authentication_service::UnifiedAuthenticationService, volt::Volt,
wellsfargo::Wellsfargo, worldline::Worldline, worldpay::Worldpay, xendit::Xendit, zen::Zen,
zsl::Zsl,
};

View File

@ -0,0 +1,571 @@
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, ConnectorSpecifications,
ConnectorValidation,
},
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
webhooks,
};
use masking::{ExposeInterface, Mask};
use transformers as coingate;
use crate::{constants::headers, types::ResponseRouterData, utils};
#[derive(Clone)]
pub struct Coingate {
amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
}
impl Coingate {
pub fn new() -> &'static Self {
&Self {
amount_converter: &StringMinorUnitForConnector,
}
}
}
impl api::Payment for Coingate {}
impl api::PaymentSession for Coingate {}
impl api::ConnectorAccessToken for Coingate {}
impl api::MandateSetup for Coingate {}
impl api::PaymentAuthorize for Coingate {}
impl api::PaymentSync for Coingate {}
impl api::PaymentCapture for Coingate {}
impl api::PaymentVoid for Coingate {}
impl api::Refund for Coingate {}
impl api::RefundExecute for Coingate {}
impl api::RefundSync for Coingate {}
impl api::PaymentToken for Coingate {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Coingate
{
// Not Implemented (R)
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Coingate
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 Coingate {
fn id(&self) -> &'static str {
"coingate"
}
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.coingate.base_url.as_ref()
}
fn get_auth_header(
&self,
auth_type: &ConnectorAuthType,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let auth = coingate::CoingateAuthType::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: coingate::CoingateErrorResponse = res
.response
.parse_struct("CoingateErrorResponse")
.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 Coingate {
//TODO: implement functions when support enabled
}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Coingate {
//TODO: implement sessions flow
}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Coingate {}
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Coingate
{
}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Coingate {
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 = coingate::CoingateRouterData::from((amount, req));
let connector_req = coingate::CoingatePaymentsRequest::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: coingate::CoingatePaymentsResponse = res
.response
.parse_struct("Coingate 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 Coingate {
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: coingate::CoingatePaymentsResponse = res
.response
.parse_struct("coingate 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 Coingate {
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: coingate::CoingatePaymentsResponse = res
.response
.parse_struct("Coingate 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 Coingate {}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Coingate {
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 = coingate::CoingateRouterData::from((refund_amount, req));
let connector_req = coingate::CoingateRefundRequest::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: coingate::RefundResponse = res
.response
.parse_struct("coingate 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 Coingate {
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: coingate::RefundResponse = res
.response
.parse_struct("coingate 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 Coingate {
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))
}
}
impl ConnectorSpecifications for Coingate {}

View File

@ -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 CoingateRouterData<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 CoingateRouterData<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 CoingatePaymentsRequest {
amount: StringMinorUnit,
card: CoingateCard,
}
#[derive(Default, Debug, Serialize, Eq, PartialEq)]
pub struct CoingateCard {
number: cards::CardNumber,
expiry_month: Secret<String>,
expiry_year: Secret<String>,
cvc: Secret<String>,
complete: bool,
}
impl TryFrom<&CoingateRouterData<&PaymentsAuthorizeRouterData>> for CoingatePaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &CoingateRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
match item.router_data.request.payment_method_data.clone() {
PaymentMethodData::Card(req_card) => {
let card = CoingateCard {
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 CoingateAuthType {
pub(super) api_key: Secret<String>,
}
impl TryFrom<&ConnectorAuthType> for CoingateAuthType {
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 CoingatePaymentStatus {
Succeeded,
Failed,
#[default]
Processing,
}
impl From<CoingatePaymentStatus> for common_enums::AttemptStatus {
fn from(item: CoingatePaymentStatus) -> Self {
match item {
CoingatePaymentStatus::Succeeded => Self::Charged,
CoingatePaymentStatus::Failed => Self::Failure,
CoingatePaymentStatus::Processing => Self::Authorizing,
}
}
}
//TODO: Fill the struct with respective fields
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct CoingatePaymentsResponse {
status: CoingatePaymentStatus,
id: String,
}
impl<F, T> TryFrom<ResponseRouterData<F, CoingatePaymentsResponse, T, PaymentsResponseData>>
for RouterData<F, T, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: ResponseRouterData<F, CoingatePaymentsResponse, 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 CoingateRefundRequest {
pub amount: StringMinorUnit,
}
impl<F> TryFrom<&CoingateRouterData<&RefundsRouterData<F>>> for CoingateRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &CoingateRouterData<&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 CoingateErrorResponse {
pub status_code: u16,
pub code: String,
pub message: String,
pub reason: Option<String>,
}

View File

@ -107,6 +107,7 @@ default_imp_for_authorize_session_token!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -181,6 +182,7 @@ default_imp_for_calculate_tax!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -255,6 +257,7 @@ default_imp_for_session_update!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -330,6 +333,7 @@ default_imp_for_post_session_tokens!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -404,6 +408,7 @@ default_imp_for_complete_authorize!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Datatrans,
connectors::Dlocal,
@ -470,6 +475,7 @@ default_imp_for_incremental_authorization!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Datatrans,
connectors::Deutschebank,
@ -544,6 +550,7 @@ default_imp_for_create_customer!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -617,6 +624,7 @@ default_imp_for_connector_redirect_response!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -685,6 +693,7 @@ default_imp_for_pre_processing_steps!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Datatrans,
connectors::Deutschebank,
@ -757,6 +766,7 @@ default_imp_for_post_processing_steps!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -833,6 +843,7 @@ default_imp_for_approve!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -909,6 +920,7 @@ default_imp_for_reject!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -985,6 +997,7 @@ default_imp_for_webhook_source_verification!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1062,6 +1075,7 @@ default_imp_for_accept_dispute!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1138,6 +1152,7 @@ default_imp_for_submit_evidence!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1214,6 +1229,7 @@ default_imp_for_defend_dispute!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1299,6 +1315,7 @@ default_imp_for_file_upload!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1370,6 +1387,7 @@ default_imp_for_payouts!(
connectors::Cryptopay,
connectors::Datatrans,
connectors::Coinbase,
connectors::Coingate,
connectors::Deutschebank,
connectors::Digitalvirgo,
connectors::Dlocal,
@ -1444,6 +1462,7 @@ default_imp_for_payouts_create!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1522,6 +1541,7 @@ default_imp_for_payouts_retrieve!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1600,6 +1620,7 @@ default_imp_for_payouts_eligibility!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1678,6 +1699,7 @@ default_imp_for_payouts_fulfill!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Datatrans,
connectors::Deutschebank,
@ -1755,6 +1777,7 @@ default_imp_for_payouts_cancel!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1833,6 +1856,7 @@ default_imp_for_payouts_quote!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1911,6 +1935,7 @@ default_imp_for_payouts_recipient!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -1989,6 +2014,7 @@ default_imp_for_payouts_recipient_account!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -2067,6 +2093,7 @@ default_imp_for_frm_sale!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -2145,6 +2172,7 @@ default_imp_for_frm_checkout!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -2223,6 +2251,7 @@ default_imp_for_frm_transaction!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -2301,6 +2330,7 @@ default_imp_for_frm_fulfillment!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -2379,6 +2409,7 @@ default_imp_for_frm_record_return!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Cybersource,
connectors::Datatrans,
@ -2454,6 +2485,7 @@ default_imp_for_revoking_mandates!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::Datatrans,
connectors::Deutschebank,
@ -2528,6 +2560,7 @@ default_imp_for_uas_pre_authentication!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -2602,6 +2635,7 @@ default_imp_for_uas_post_authentication!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -2676,6 +2710,7 @@ default_imp_for_uas_authentication!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,

View File

@ -217,6 +217,7 @@ default_imp_for_new_connector_integration_payment!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -294,6 +295,7 @@ default_imp_for_new_connector_integration_refund!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -366,6 +368,7 @@ default_imp_for_new_connector_integration_connector_access_token!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -444,6 +447,7 @@ default_imp_for_new_connector_integration_accept_dispute!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Datatrans,
@ -520,6 +524,7 @@ default_imp_for_new_connector_integration_submit_evidence!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Datatrans,
@ -596,6 +601,7 @@ default_imp_for_new_connector_integration_defend_dispute!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -683,6 +689,7 @@ default_imp_for_new_connector_integration_file_upload!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -762,6 +769,7 @@ default_imp_for_new_connector_integration_payouts_create!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -841,6 +849,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -920,6 +929,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -999,6 +1009,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1078,6 +1089,7 @@ default_imp_for_new_connector_integration_payouts_quote!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1157,6 +1169,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1236,6 +1249,7 @@ default_imp_for_new_connector_integration_payouts_sync!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1315,6 +1329,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1392,6 +1407,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1471,6 +1487,7 @@ default_imp_for_new_connector_integration_frm_sale!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1550,6 +1567,7 @@ default_imp_for_new_connector_integration_frm_checkout!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1629,6 +1647,7 @@ default_imp_for_new_connector_integration_frm_transaction!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1708,6 +1727,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1787,6 +1807,7 @@ default_imp_for_new_connector_integration_frm_record_return!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
@ -1863,6 +1884,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(
connectors::Cashtocode,
connectors::Chargebee,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,

View File

@ -27,6 +27,7 @@ pub struct Connectors {
pub chargebee: ConnectorParams,
pub checkout: ConnectorParams,
pub coinbase: ConnectorParams,
pub coingate: ConnectorParams,
pub cryptopay: ConnectorParams,
pub ctp_mastercard: NoParams,
pub cybersource: ConnectorParams,

View File

@ -37,22 +37,22 @@ pub use hyperswitch_connectors::connectors::{
bamboraapac, bamboraapac::Bamboraapac, bankofamerica, bankofamerica::Bankofamerica, billwerk,
billwerk::Billwerk, bitpay, bitpay::Bitpay, bluesnap, bluesnap::Bluesnap, boku, boku::Boku,
cashtocode, cashtocode::Cashtocode, chargebee::Chargebee, coinbase, coinbase::Coinbase,
cryptopay, cryptopay::Cryptopay, ctp_mastercard, ctp_mastercard::CtpMastercard, cybersource,
cybersource::Cybersource, datatrans, datatrans::Datatrans, 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, gocardless,
gocardless::Gocardless, 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, paybox, paybox::Paybox, payeezy, payeezy::Payeezy, payu, payu::Payu,
placetopay, placetopay::Placetopay, powertranz, powertranz::Powertranz, prophetpay,
prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay, razorpay::Razorpay, redsys,
redsys::Redsys, shift4, shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar,
taxjar::Taxjar, thunes, thunes::Thunes, tsys, tsys::Tsys, unified_authentication_service,
unified_authentication_service::UnifiedAuthenticationService, volt, volt::Volt, wellsfargo,
wellsfargo::Wellsfargo, worldline, worldline::Worldline, worldpay, worldpay::Worldpay, xendit,
xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,
coingate, coingate::Coingate, cryptopay, cryptopay::Cryptopay, ctp_mastercard,
ctp_mastercard::CtpMastercard, cybersource, cybersource::Cybersource, datatrans,
datatrans::Datatrans, 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, gocardless, gocardless::Gocardless, 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, paybox, paybox::Paybox, payeezy,
payeezy::Payeezy, payu, payu::Payu, placetopay, placetopay::Placetopay, powertranz,
powertranz::Powertranz, prophetpay, prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay,
razorpay::Razorpay, redsys, redsys::Redsys, shift4, shift4::Shift4, square, square::Square,
stax, stax::Stax, taxjar, taxjar::Taxjar, thunes, thunes::Thunes, tsys, tsys::Tsys,
unified_authentication_service, unified_authentication_service::UnifiedAuthenticationService,
volt, volt::Volt, wellsfargo, wellsfargo::Wellsfargo, worldline, worldline::Worldline,
worldpay, worldpay::Worldpay, xendit, xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,
};
#[cfg(feature = "dummy_connector")]

View File

@ -435,6 +435,7 @@ default_imp_for_connector_request_id!(
connector::Chargebee,
connector::Checkout,
connector::Coinbase,
connector::Coingate,
connector::Cryptopay,
connector::Cybersource,
connector::Datatrans,
@ -1528,6 +1529,7 @@ default_imp_for_fraud_check!(
connector::Cryptopay,
connector::Cybersource,
connector::Coinbase,
connector::Coingate,
connector::Datatrans,
connector::Deutschebank,
connector::Digitalvirgo,
@ -2117,6 +2119,7 @@ default_imp_for_connector_authentication!(
connector::Checkout,
connector::Cryptopay,
connector::Coinbase,
connector::Coingate,
connector::Cybersource,
connector::Datatrans,
connector::Deutschebank,

View File

@ -368,6 +368,7 @@ impl ConnectorData {
enums::Connector::Coinbase => {
Ok(ConnectorEnum::Old(Box::new(&connector::Coinbase)))
}
// enums::Connector::Coingate => Ok(ConnectorEnum::Old(Box::new(connector::Coingate))),
enums::Connector::Cryptopay => {
Ok(ConnectorEnum::Old(Box::new(connector::Cryptopay::new())))
}

View File

@ -228,6 +228,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
// api_enums::Connector::Chargebee => Self::Chargebee,
api_enums::Connector::Checkout => Self::Checkout,
api_enums::Connector::Coinbase => Self::Coinbase,
// api_enums::Connector::Coingate => Self::Coingate,
api_enums::Connector::Cryptopay => Self::Cryptopay,
api_enums::Connector::CtpMastercard => {
Err(common_utils::errors::ValidationError::InvalidValue {

View File

@ -0,0 +1,420 @@
use masking::Secret;
use router::types::{self, api, storage::enums};
use crate::utils::{self, ConnectorActions};
use test_utils::connector_auth;
#[derive(Clone, Copy)]
struct CoingateTest;
impl ConnectorActions for CoingateTest {}
impl utils::Connector for CoingateTest {
fn get_data(&self) -> api::ConnectorData {
use router::connector::Coingate;
api::ConnectorData {
connector: Box::new(Coingate::new()),
connector_name: types::Connector::Coingate,
get_token: types::api::GetToken::Connector,
merchant_connector_id: None,
}
}
fn get_auth_token(&self) -> types::ConnectorAuthType {
utils::to_connector_auth_type(
connector_auth::ConnectorAuthentication::new()
.coingate
.expect("Missing connector authentication configuration")
.into(),
)
}
fn get_name(&self) -> String {
"coingate".to_string()
}
}
static CONNECTOR: CoingateTest = CoingateTest {};
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: types::api::PaymentMethodData::Card(api::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: api::PaymentMethodData::Card(api::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: api::PaymentMethodData::Card(api::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

View File

@ -30,6 +30,7 @@ pub struct ConnectorAuthentication {
pub chargebee: Option<HeaderKey>,
pub checkout: Option<SignatureKey>,
pub coinbase: Option<HeaderKey>,
pub coingate: Option<HeaderKey>,
pub cryptopay: Option<BodyKey>,
pub cybersource: Option<SignatureKey>,
pub datatrans: Option<HeaderKey>,

View File

@ -94,6 +94,7 @@ cashtocode.base_url = "https://cluster05.api-test.cashtocode.com"
chargebee.base_url = "https://$.chargebee.com/api/"
checkout.base_url = "https://api.sandbox.checkout.com/"
coinbase.base_url = "https://api.commerce.coinbase.com"
coingate.base_url = "https://api-sandbox.coingate.com/v2"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
@ -199,6 +200,7 @@ cards = [
"braintree",
"checkout",
"coinbase",
"coingate",
"cryptopay",
"cybersource",
"datatrans",

View File

@ -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 chargebee 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 redsys shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys unified_authentication_service 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 chargebee checkout coinbase coingate 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 redsys shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys unified_authentication_service 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