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

feat(connector): [Adyen] add PMD validation in validate_capture_method method for all the implemented PM’s #3584

Merged
merged 11 commits into from
Feb 14, 2024

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Feb 7, 2024

Type of Change

add PMD validation in validate_capture_method method for all the implemented PM’s

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

Description

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?

Run Postman whole postman collection for Adyen
Screenshot 2024-02-07 at 5 58 08 PM

Test for Pix PM and "capture_method": "manual"

{
    "amount": 16000,
    "currency": "BRL",
    "confirm": true,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 16000,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "profile_id": "pro_sx78reJN0zgRzB5UGicx",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
            "payment_method": "bank_transfer",
    "payment_method_type": "pix",
    "payment_method_data": {
        "bank_transfer": {
            "pix": {}
        }
    }
    "billing": {
        "address": {
            "first_name": "John",
            "last_name": "Doe",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "BR"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "127.0.0.1"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "BR",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}

In response we should get error

{
    "error": {
        "type": "invalid_request",
        "message": "Payment method type not supported",
        "code": "HE_03",
        "reason": "manual for pix is not supported by adyen"
    }
}
Screenshot 2024-02-07 at 5 51 16 PM

Test for Ach PM and "capture_method": "manual"

{
    "amount": 10000,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual_multiple",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "setup_future_usage": "off_session",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US"
        }
    },
     "payment_method": "bank_debit",
    "payment_method_type": "ach",
    "payment_method_data": {
        "bank_debit": {
            "ach_bank_debit": {
                "account_number": "40308669",
                "routing_number": "121000358",
                "sort_code": "560036",
                "shopper_email": "[email protected]",
                "card_holder_name": "joseph Doe",
                "bank_account_holder_name": "David Archer",
                "billing_details": {
                    "houseNumberOrName": "50",
                    "street": "Test Street",
                    "city": "Amsterdam",
                    "stateOrProvince": "NY",
                    "postalCode": "12010",
                    "country": "US",
                    "name": "A. Klaassen",
                    "email": "[email protected]"
                },
                "reference": "daslvcgbaieh"
            }
        }
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "127.0.0.1"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}

In response we should get

{
    "error": {
        "type": "invalid_request",
        "message": "Payment method type not supported",
        "code": "HE_03",
        "reason": "manual_multiple for ach is not supported by adyen"
    }
}
Screenshot 2024-02-07 at 5 50 27 PM

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-feature Category: Feature request or enhancement labels Feb 7, 2024
@swangi-kumari swangi-kumari self-assigned this Feb 7, 2024
@swangi-kumari swangi-kumari requested review from a team as code owners February 7, 2024 13:31
@@ -50,6 +50,31 @@ macro_rules! impl_error_display {
};
}

#[macro_export]
macro_rules! not_supported {
Copy link
Contributor

Choose a reason for hiding this comment

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

@swangi-kumari Let's create diff macro_rules for different purposes, rename this to capture_method_not_supported. and handle error related to capture_methods

@likhinbopanna likhinbopanna added this pull request to the merge queue Feb 14, 2024
Merged via the queue into main with commit 0c46f39 Feb 14, 2024
10 of 12 checks passed
@likhinbopanna likhinbopanna deleted the adyen-capture-validation branch February 14, 2024 11:20
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-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants