Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(connector): remove default cases for Authorizedotnet, Braintree and Fiserv Connector #2796

Merged
merged 17 commits into from
Mar 5, 2024

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Nov 6, 2023

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Resolves 4376
Issue: defaults case in match shouldn't be handled using "_"

Solution: "_" will never let the developer know impact of his changes incase of new addition of enum variants. By having the all cases in match compiler itself will throw errors wherever new enums needs to be handled.

(In this PR it is done for Authorizrdotnet, Braintree and Fiserv Connector)

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Do payment create for Authorizedotnet, Braintree and Fiserv Connector for any payment method which is not implemented it should throw the error

here is payment request for PIX PM

{
    "amount": 6540,
    "currency": "BRL",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
     "payment_method": "bank_transfer",
    "payment_method_type": "pix",
    "payment_method_data": {
        "bank_transfer": {
            "pix": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "BR",
            "first_name": "PiX"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "BR",
            "first_name": "PiX"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}
Selected payment method is Not Implemented for <connector-name>

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration C-refactor Category: Refactor labels Nov 6, 2023
@swangi-kumari swangi-kumari self-assigned this Nov 6, 2023
@swangi-kumari swangi-kumari marked this pull request as ready for review November 6, 2023 15:20
@swangi-kumari swangi-kumari requested a review from a team as a code owner November 6, 2023 15:20
Sakilmostak
Sakilmostak previously approved these changes Nov 8, 2023
Sakilmostak
Sakilmostak previously approved these changes Nov 23, 2023
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be fiserv .

srujanchikke
srujanchikke previously approved these changes Dec 13, 2023
Comment on lines 322 to 323
| enums::CaptureMethod::ManualMultiple
| enums::CaptureMethod::Scheduled => Self::Final,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ManualMultiple and Scheduled is not supported by the connector. In such cases throw error

| SyncStatus::Voided
| SyncStatus::CouldNotVoid
| SyncStatus::GeneralError
| SyncStatus::FDSPendingReview => Self::Failure,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why FDSPendingReview, SettledSuccessfully, AuthorizedPendingCapture, CapturedPendingSettlement, Voided should be mapped to Failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepanshu-iiitu will handle the status mapping modifications in the pull request where he is addressing the connector audit fixes.

crates/router/src/connector/braintree/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/braintree/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/fiserv/transformers.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ArjunKarthik ArjunKarthik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes required

.map(|c| AuthorizationIndicator {
authorization_indicator: c.into(),
});
let authorization_indicator_type = match item.router_data.request.capture_method {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the CaptureMethod from from to try_from , in order to throw the error for ManualMultiple and Scheduled. this was a relative change for that

@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 5, 2024
Merged via the queue into main with commit dbac556 Mar 5, 2024
16 of 18 checks passed
@likhinbopanna likhinbopanna deleted the default-case branch March 5, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-refactor Category: Refactor
Projects
No open projects
Status: Under Development
Development

Successfully merging this pull request may close these issues.

6 participants