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

fix(payment_methods): insert locker_id as null in case of payment method not getting stored in locker #3919

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Mar 1, 2024

Type of Change

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

Description

If the payment is made with payment methods other than card and bank_transfer and is asked to save the payment method, we should store locker_id column as NULL in payment_methods table.

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?

  1. Create an MCA
curl --location 'http://localhost:8080/account/merchant_1709304245/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "fiz_operations",
    "connector_name": "stripe",
    "business_label": "default",
    "business_country": "US",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "abc"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "affirm"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "afterpay_clearpay"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "klarna"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "invoke_sdk_client",
                    "payment_method_type": "klarna"
                }
            ]
        },
       {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "debit",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "google_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "przelewy24",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "blik",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "ideal",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "eps",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sofort",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "giropay",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "sepa",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "ach",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "bacs",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_transfer",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sepa",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "bacs",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ]
}'
  1. Create a bank debit payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_U44vOQtigGfoj1w2A0F0B9kLlXdZqTR8RRg3JwfPUJhLywIG4PdR1HZD0inVkS2f' \
--data-raw '{
    "amount": 1800,
    "currency": "USD",
    "confirm": true,
    "business_label": "default",
    "capture_method": "automatic",
    "customer_id": "klarna",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "email": "guest1@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "return_url": "https://google.com",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "setup_future_usage": "off_session",
    "business_country": "US",
    "payment_method": "bank_debit",
    "payment_method_type": "ach",
    "payment_method_data": {
        "bank_debit": {
            "ach_bank_debit": {
                "billing_details": {
                    "name": "John Doe",
                    "email": "johndoe@example.com"
                },
                "account_number": "000123456789",
                "routing_number": "110000000"
            }
        }
    },
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "online",
            "accepted_at": "2022-09-10T10:11:12Z",
            "online": {
                "ip_address": "123.32.25.123",
                "user_agent": "Mozilla/5.0 (Linux; Android 12; SM-S906N Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.119 Mobile Safari/537.36"
            }
        },
        "mandate_type": {
            "single_use": {
                "amount": 6540,
                "currency": "USD"
            }
        }
    },
    "metadata": {
        "order_details": {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 1800,
            "account_name": "transaction_processing"
        }
    }
}'

In this case locker_id has to be NULL in payment_methods table

image

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

@Chethan-rao Chethan-rao added C-bug Category: Bug A-payment-methods Area: Payment Methods labels Mar 1, 2024
@Chethan-rao Chethan-rao added this to the February 2024 Release milestone Mar 1, 2024
@Chethan-rao Chethan-rao requested a review from vspecky March 1, 2024 14:58
@Chethan-rao Chethan-rao self-assigned this Mar 1, 2024
@Chethan-rao Chethan-rao requested a review from a team as a code owner March 1, 2024 14:58
@Chethan-rao Chethan-rao changed the title fix(payment_methods): insert locker_id as null in case of payment method not getting stored in locker fix(payment_methods): insert locker_id as null in case of payment method not getting stored in locker Mar 1, 2024
@Chethan-rao Chethan-rao force-pushed the remove-locker-id-creation branch 2 times, most recently from 2335350 to 184a9d3 Compare March 1, 2024 15:31
@Chethan-rao Chethan-rao requested a review from Aprabhat19 March 1, 2024 15:57
@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 2, 2024
Merged via the queue into main with commit 9917dd0 Mar 2, 2024
34 of 36 checks passed
@likhinbopanna likhinbopanna deleted the remove-locker-id-creation branch March 2, 2024 20:39
@Chethan-rao Chethan-rao changed the title fix(payment_methods): insert locker_id as null in case of payment method not getting stored in locker fix(payment_methods): insert locker_id as null in case of payment method not getting stored in locker Mar 3, 2024
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.

[BUG] insert locker_id as null in case of payment method not getting stored in locker
4 participants