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: check allowed payment method types in enabled options #7019

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrudulvajpayee4935
Copy link
Contributor

@mrudulvajpayee4935 mrudulvajpayee4935 commented Jan 10, 2025

Type of Change

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

Description

Using values in allowed_payment_method_types that were not configured during the creation of the connector results in breaking the SDK flow, as the PML call returned an empty payment method list. We need to apply this check during intent creation call.

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?

Tested manually by hitting payments create api

Curl:

curl --location 'localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_bA6dXFz2dKBE4zqZKCpZBoE26BpZgCZpzfF9LKOHhCP0W7WZ0NyeIjpzfHAOw3tc' \
--data-raw '{
    "amount": 10000,
    "currency": "EUR",
    "allowed_payment_method_types": ["online_banking_czech_republic","multibanco"],
    "confirm": true,
    "payment_link": false,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 10000,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000 0000 0000 1091",
            "card_exp_month": "12",
            "card_exp_year": "2026",
            "card_holder_name": "Max Mustermann",
            "card_cvc": "000"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "CA",
            "city": "Musterhausen",
            "state": "California",
            "zip": "12345",
            "country": "DE",
            "first_name": "Max",
            "last_name": "Mustermann"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "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,
        "ip_address": "103.77.139.95",
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

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

@mrudulvajpayee4935 mrudulvajpayee4935 added C-bug Category: Bug A-payment-methods Area: Payment Methods labels Jan 10, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 self-assigned this Jan 10, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 requested a review from a team as a code owner January 10, 2025 08:25
Copy link

semanticdiff-com bot commented Jan 10, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/operations/payment_create.rs  6% smaller
  crates/router/src/core/metrics.rs  0% smaller
  crates/router/src/core/payments/operations.rs  0% smaller

@mrudulvajpayee4935 mrudulvajpayee4935 changed the title check allowed payment method types in enabled options refactor: check allowed payment method types in enabled options Jan 10, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 force-pushed the handle-allowed-payment-method-types branch from a783ba7 to fad712c Compare January 10, 2025 12:47
);
}

if unsupported_payment_methods.len() == allowed_payment_method_types.len() {
Copy link
Member

Choose a reason for hiding this comment

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

use fp_utils::when

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payment-methods Area: Payment Methods C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants