Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(router): add card expiry check in the network_transaction_id_and_card_details based MIT flow #6504

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

ShankarSinghC
Copy link
Contributor

@ShankarSinghC ShankarSinghC commented Nov 7, 2024

Type of Change

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

Description

Reference pr.

Add card expiry validation for the recurring_details = network_transaction_id_and_card_details based MIT flow

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?

-> Create the cybersource connector
-> Create payment with recurring details "type": "network_transaction_id_and_card_details" with expired card

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "amount": 499,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "email": "guest@example.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "off_session": true,
    "recurring_details": {
        "type": "network_transaction_id_and_card_details",
        "data": {
            "card_number": "5454545454545454",
            "card_exp_month": "11",
            "card_exp_year": "2023",
            "card_holder_name": "name name",
            "network_transaction_id": "737"
        }
    },
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    }
}'
{
    "error": {
        "type": "invalid_request",
        "message": "Invalid Expiry Year",
        "code": "IR_16"
    }
}

-> Create payment with recurring details "type": "network_transaction_id_and_card_details" with valid card

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "amount": 499,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "email": "guest@example.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "off_session": true,
    "recurring_details": {
        "type": "network_transaction_id_and_card_details",
        "data": {
            "card_number": "5454545454545454",
            "card_exp_month": "11",
            "card_exp_year": "2024",
            "card_holder_name": "name name",
            "network_transaction_id": "737"
        }
    },
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    }
}'
{
    "payment_id": "pay_1BG9IxreD8qApunv5xiB",
    "merchant_id": "merchant_1730973695",
    "status": "succeeded",
    "amount": 499,
    "net_amount": 499,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 499,
    "connector": "cybersource",
    "client_secret": "pay_1BG9IxreD8qApunv5xiB_secret_Kwrf2y7DNIo17tGrh4Ua",
    "created": "2024-11-07T11:04:36.886Z",
    "currency": "USD",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": null,
        "email": "guest@example.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "5454",
            "card_type": "CREDIT",
            "card_network": null,
            "card_issuer": "BANKHANDLOWYWWARSZAWIE.S.A.",
            "card_issuing_country": "POLAND",
            "card_isin": "545454",
            "card_extended_bin": null,
            "card_exp_month": "11",
            "card_exp_year": "2024",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "7309774770706430804953",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_1BG9IxreD8qApunv5xiB_1",
    "payment_link": null,
    "profile_id": "pro_nHm5ZVnwRP6Wixvy0bPZ",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_1Cr87i1MXNK3yoZsjM7q",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-07T11:19:36.886Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-11-07T11:04:37.995Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

-> Psync

curl --location 'http://localhost:8080/payments/pay_1BG9IxreD8qApunv5xiB?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: '
{
    "payment_id": "pay_1BG9IxreD8qApunv5xiB",
    "merchant_id": "merchant_1730973695",
    "status": "succeeded",
    "amount": 499,
    "net_amount": 499,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 499,
    "connector": "cybersource",
    "client_secret": "pay_1BG9IxreD8qApunv5xiB_secret_Kwrf2y7DNIo17tGrh4Ua",
    "created": "2024-11-07T11:04:36.886Z",
    "currency": "USD",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": null,
        "email": "guest@example.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "5454",
            "card_type": "CREDIT",
            "card_network": null,
            "card_issuer": "BANKHANDLOWYWWARSZAWIE.S.A.",
            "card_issuing_country": "POLAND",
            "card_isin": "545454",
            "card_extended_bin": null,
            "card_exp_month": "11",
            "card_exp_year": "2024",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "7309774770706430804953",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_1BG9IxreD8qApunv5xiB_1",
    "payment_link": null,
    "profile_id": "pro_nHm5ZVnwRP6Wixvy0bPZ",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_1Cr87i1MXNK3yoZsjM7q",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-07T11:19:36.886Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-11-07T11:04:37.995Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

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

@ShankarSinghC ShankarSinghC added C-bug Category: Bug A-payment-methods Area: Payment Methods A-payments Area: payments labels Nov 7, 2024
@ShankarSinghC ShankarSinghC self-assigned this Nov 7, 2024
@ShankarSinghC ShankarSinghC requested a review from a team as a code owner November 7, 2024 10:52
Copy link

semanticdiff-com bot commented Nov 7, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments.rs  0% smaller

@Gnanasundari24
Copy link
Contributor

Gnanasundari24 commented Nov 8, 2024

@ShankarSinghC Please add the network_transaction_id flow in cypress. Then only we will merge next PR.

CC : @jagan-jaya @pranav-arjunan

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 8, 2024
Merged via the queue into main with commit 5af532a Nov 8, 2024
30 of 33 checks passed
@Gnanasundari24 Gnanasundari24 deleted the proxy-api/add-card-exp-validation branch November 8, 2024 15:09
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-payment-methods Area: Payment Methods A-payments Area: payments C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add card expiry check in the network_transaction_id_and_card_details based MIT flow
4 participants