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(constraint_graph): add setup_future_usage for mandate check in payments #6744

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

prajjwalkumar17
Copy link
Contributor

Type of Change

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

Description

Previously the mandate_details were enough to identify the payment as mandate payment but now it is optional so a payment can be mandate even if there is no mandate_details but the payment's setup_future_usage is off-session.

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?

This can be tested in the following way:

  1. Connector create (Fiuu)
curl --location 'http://127.0.0.1:8080/account/merchant_1733312955/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "fiuu",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": ".....",
        "key1": "......",
        "api_secret": "......"
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "online_banking_fpx",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": {
        "merchant_secret": ".....",
        "additional_secret": null
    }
}'
  1. Payment (off-session)
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Cookie;' \
--header 'api-key: .....' \
--data-raw '{
    "amount": 6540,
    "setup_future_usage": "off_session",
    "currency": "EUR",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "uiuiuiui",
    "email": "[email protected]",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "NL",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IN",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
  1. List payment methods
curl --location 'http://localhost:8080/account/payment_methods?client_secret=......' \
--header 'Accept: application/json' \
--header 'api-key: .....' \
--data ''

It shouldn't have any payment_method

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

@prajjwalkumar17 prajjwalkumar17 added C-refactor Category: Refactor A-routing Area: Routing labels Dec 4, 2024
@prajjwalkumar17 prajjwalkumar17 added this to the December 2024 Release milestone Dec 4, 2024
@prajjwalkumar17 prajjwalkumar17 self-assigned this Dec 4, 2024
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner December 4, 2024 12:53
Copy link

semanticdiff-com bot commented Dec 4, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payment_methods/utils.rs  84% smaller
  crates/router/src/core/payment_methods/cards.rs  20% smaller

@likhinbopanna
Copy link
Contributor

@prajjwalkumar17 Can we add this test case in cypress?

@prajjwalkumar17
Copy link
Contributor Author

@prajjwalkumar17 Can we add this test case in cypress?

This will be added in a new PR, here is the issue.

@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit 1aa4ad6 Dec 10, 2024
18 checks passed
@likhinbopanna likhinbopanna deleted the refactor_cgraph branch December 10, 2024 12:12
kashif-m pushed a commit that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-routing Area: Routing C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(constraint_graph): add setup_future_usage for mandate check in payments
4 participants