Skip to content

Commit

Permalink
refactor(router): renamed Verify flow to SetupMandate (juspay#2455)
Browse files Browse the repository at this point in the history
  • Loading branch information
prajjwalkumar17 authored Oct 5, 2023
1 parent 5654684 commit 80f3b1e
Show file tree
Hide file tree
Showing 61 changed files with 458 additions and 241 deletions.
4 changes: 2 additions & 2 deletions connector-template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t

impl
ConnectorIntegration<
api::Verify,
types::VerifyRequestData,
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for {{project-name | downcase | pascal_case}}
{
Expand Down
6 changes: 3 additions & 3 deletions crates/router/src/compatibility/stripe/setup_intents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub async fn setup_intents_create(
&req,
create_payment_req,
|state, auth, req| {
payments::payments_core::<api_types::Verify, api_types::PaymentsResponse, _, _, _>(
payments::payments_core::<api_types::SetupMandate, api_types::PaymentsResponse, _, _, _>(
state,
auth.merchant_account,
auth.key_store,
Expand Down Expand Up @@ -178,7 +178,7 @@ pub async fn setup_intents_update(
&req,
payload,
|state, auth, req| {
payments::payments_core::<api_types::Verify, api_types::PaymentsResponse, _, _, _>(
payments::payments_core::<api_types::SetupMandate, api_types::PaymentsResponse, _, _, _>(
state,
auth.merchant_account,
auth.key_store,
Expand Down Expand Up @@ -244,7 +244,7 @@ pub async fn setup_intents_confirm(
&req,
payload,
|state, auth, req| {
payments::payments_core::<api_types::Verify, api_types::PaymentsResponse, _, _, _>(
payments::payments_core::<api_types::SetupMandate, api_types::PaymentsResponse, _, _, _>(
state,
auth.merchant_account,
auth.key_store,
Expand Down
6 changes: 3 additions & 3 deletions crates/router/src/connector/aci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ impl
// Not Implemented (R)
}

impl api::PreVerify for Aci {}
impl api::MandateSetup for Aci {}

impl
services::ConnectorIntegration<
api::Verify,
types::VerifyRequestData,
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Aci
{
Expand Down
36 changes: 19 additions & 17 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl api::PaymentAuthorize for Adyen {}
impl api::PaymentSync for Adyen {}
impl api::PaymentVoid for Adyen {}
impl api::PaymentCapture for Adyen {}
impl api::PreVerify for Adyen {}
impl api::MandateSetup for Adyen {}
impl api::ConnectorAccessToken for Adyen {}
impl api::PaymentToken for Adyen {}

Expand All @@ -140,19 +140,19 @@ impl

impl
services::ConnectorIntegration<
api::Verify,
types::VerifyRequestData,
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Adyen
{
fn get_headers(
&self,
req: &types::VerifyRouterData,
req: &types::SetupMandateRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
types::PaymentsVerifyType::get_content_type(self)
types::SetupMandateType::get_content_type(self)
.to_string()
.into(),
)];
Expand All @@ -163,14 +163,14 @@ impl

fn get_url(
&self,
_req: &types::VerifyRouterData,
_req: &types::SetupMandateRouterData,
connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}{}", self.base_url(connectors), "v68/payments"))
}
fn get_request_body(
&self,
req: &types::VerifyRouterData,
req: &types::SetupMandateRouterData,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
let authorize_req = types::PaymentsAuthorizeRouterData::from((
req,
Expand All @@ -193,32 +193,34 @@ impl
}
fn build_request(
&self,
req: &types::VerifyRouterData,
req: &types::SetupMandateRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
Ok(Some(
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsVerifyType::get_url(self, req, connectors)?)
.url(&types::SetupMandateType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsVerifyType::get_headers(
self, req, connectors,
)?)
.body(types::PaymentsVerifyType::get_request_body(self, req)?)
.headers(types::SetupMandateType::get_headers(self, req, connectors)?)
.body(types::SetupMandateType::get_request_body(self, req)?)
.build(),
))
}
fn handle_response(
&self,
data: &types::VerifyRouterData,
data: &types::SetupMandateRouterData,
res: types::Response,
) -> CustomResult<
types::RouterData<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>,
types::RouterData<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
>,
errors::ConnectorError,
>
where
api::Verify: Clone,
types::VerifyRequestData: Clone,
api::SetupMandate: Clone,
types::SetupMandateRequestData: Clone,
types::PaymentsResponseData: Clone,
{
let response: adyen::AdyenPaymentResponse = res
Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/airwallex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ impl ConnectorValidation for Airwallex {

impl api::Payment for Airwallex {}
impl api::PaymentsCompleteAuthorize for Airwallex {}
impl api::PreVerify for Airwallex {}
impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Airwallex
impl api::MandateSetup for Airwallex {}
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Airwallex
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,14 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
// Not Implemented (R)
}

impl api::PreVerify for Authorizedotnet {}
impl api::MandateSetup for Authorizedotnet {}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Authorizedotnet
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Authorizedotnet
{
// Issue: #173
}
Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/bambora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ impl
// Not Implemented (R)
}

impl api::PreVerify for Bambora {}
impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Bambora
impl api::MandateSetup for Bambora {}
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Bambora
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/bitpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl api::Payment for Bitpay {}
impl api::PaymentToken for Bitpay {}
impl api::PaymentSession for Bitpay {}
impl api::ConnectorAccessToken for Bitpay {}
impl api::PreVerify for Bitpay {}
impl api::MandateSetup for Bitpay {}
impl api::PaymentAuthorize for Bitpay {}
impl api::PaymentSync for Bitpay {}
impl api::PaymentCapture for Bitpay {}
Expand Down Expand Up @@ -133,8 +133,12 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
{
}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Bitpay
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Bitpay
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/bluesnap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ impl
// Not Implemented (R)
}

impl api::PreVerify for Bluesnap {}
impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Bluesnap
impl api::MandateSetup for Bluesnap {}
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Bluesnap
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/boku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct Boku;
impl api::Payment for Boku {}
impl api::PaymentSession for Boku {}
impl api::ConnectorAccessToken for Boku {}
impl api::PreVerify for Boku {}
impl api::MandateSetup for Boku {}
impl api::PaymentAuthorize for Boku {}
impl api::PaymentSync for Boku {}
impl api::PaymentCapture for Boku {}
Expand Down Expand Up @@ -162,8 +162,12 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
{
}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Boku
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Boku
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/braintree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,15 @@ impl
}
}

impl api::PreVerify for Braintree {}
impl api::MandateSetup for Braintree {}

#[allow(dead_code)]
impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Braintree
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Braintree
{
// Not Implemented (R)
}
Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/cashtocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct Cashtocode;
impl api::Payment for Cashtocode {}
impl api::PaymentSession for Cashtocode {}
impl api::ConnectorAccessToken for Cashtocode {}
impl api::PreVerify for Cashtocode {}
impl api::MandateSetup for Cashtocode {}
impl api::PaymentAuthorize for Cashtocode {}
impl api::PaymentSync for Cashtocode {}
impl api::PaymentCapture for Cashtocode {}
Expand Down Expand Up @@ -149,8 +149,12 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
{
}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Cashtocode
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Cashtocode
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,14 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
// Not Implemented (R)
}

impl api::PreVerify for Checkout {}
impl api::MandateSetup for Checkout {}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Checkout
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Checkout
{
// Issue: #173
}
Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl api::Payment for Coinbase {}
impl api::PaymentToken for Coinbase {}
impl api::PaymentSession for Coinbase {}
impl api::ConnectorAccessToken for Coinbase {}
impl api::PreVerify for Coinbase {}
impl api::MandateSetup for Coinbase {}
impl api::PaymentAuthorize for Coinbase {}
impl api::PaymentSync for Coinbase {}
impl api::PaymentCapture for Coinbase {}
Expand Down Expand Up @@ -148,8 +148,12 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
{
}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Coinbase
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Coinbase
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/cryptopay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Cryptopay;
impl api::Payment for Cryptopay {}
impl api::PaymentSession for Cryptopay {}
impl api::ConnectorAccessToken for Cryptopay {}
impl api::PreVerify for Cryptopay {}
impl api::MandateSetup for Cryptopay {}
impl api::PaymentAuthorize for Cryptopay {}
impl api::PaymentSync for Cryptopay {}
impl api::PaymentCapture for Cryptopay {}
Expand Down Expand Up @@ -183,8 +183,12 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
{
}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Cryptopay
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Cryptopay
{
}

Expand Down
10 changes: 7 additions & 3 deletions crates/router/src/connector/cybersource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl api::PaymentAuthorize for Cybersource {}
impl api::PaymentSync for Cybersource {}
impl api::PaymentVoid for Cybersource {}
impl api::PaymentCapture for Cybersource {}
impl api::PreVerify for Cybersource {}
impl api::MandateSetup for Cybersource {}
impl api::ConnectorAccessToken for Cybersource {}
impl api::PaymentToken for Cybersource {}

Expand All @@ -240,8 +240,12 @@ impl
// Not Implemented (R)
}

impl ConnectorIntegration<api::Verify, types::VerifyRequestData, types::PaymentsResponseData>
for Cybersource
impl
ConnectorIntegration<
api::SetupMandate,
types::SetupMandateRequestData,
types::PaymentsResponseData,
> for Cybersource
{
}

Expand Down
Loading

0 comments on commit 80f3b1e

Please sign in to comment.