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(router): make payment_instrument optional #4389

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

AkshayaFoiger
Copy link
Contributor

@AkshayaFoiger AkshayaFoiger commented Apr 17, 2024

Type of Change

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

Description

Fix simplified Applepay deserialization error

Test Case

  1. Applepay non mandate simplified payment
  2. Sanity
    2.1. Create a CIT
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:""' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "A",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "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": "13.232.74.226"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IN",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4622943127013705",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "metadata": {
        "city": "NY",
        "unit": "245",
        "account_name": "transaction_processing"
    },
    
    "setup_future_usage": "off_session",
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "13.232.74.226",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 799,
                "currency": "USD"
            }
        }
    }
}'

Response

{
    "payment_id": "pay_O6deOwZtZDunju0XX3pr",
    "merchant_id": "merchant_1713362818",
    "status": "succeeded",
    "amount": 100,
    "net_amount": 100,
    "amount_capturable": 0,
    "amount_received": 100,
    "connector": "bankofamerica",
    "client_secret": "pay_O6deOwZtZDunju0XX3pr_secret_XAItburO1K7Ol1lHWdOE",
    "created": "2024-04-17T14:10:11.963Z",
    "currency": "USD",
    "customer_id": "A",
    "customer": {
        "id": "A",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_riGsIDg0URkpJcsinLJs",
    "mandate_data": {
        "update_mandate_id": null,
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "13.232.74.226",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 799,
                "currency": "USD",
                "start_date": null,
                "end_date": null,
                "metadata": null
            }
        }
    },
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "3705",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "462294",
            "card_extended_bin": "46229431",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_3Hh9Yrb5k5wC7yslNE6R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "IN",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "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": {
        "customer_id": "A",
        "created_at": 1713363011,
        "expires": 1713366611,
        "secret": ""
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7133630139916053003954",
    "frm_message": null,
    "metadata": {
        "city": "NY",
        "unit": "245",
        "account_name": "transaction_processing"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_O6deOwZtZDunju0XX3pr_1",
    "payment_link": null,
    "profile_id": "pro_E4qXt9ixAiujSJMb7WFW",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_J6QWMKfE8dtQOVi3jfvq",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-17T14:25:11.963Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "13.232.74.226",
        "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",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": "pm_YB4q1nw7bcXCffCkMSc7",
    "payment_method_status": null,
    "updated": "2024-04-17T14:10:14.855Z"
}

2.2. Create a MIT

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:' \
--data '{
  "amount": 700,
  "currency": "USD",
  "off_session": true,
  "confirm": true,
  "capture_method": "automatic",
  "description": "Initiated by merchant",
  "mandate_id": "man_9IocBs7oFK45cixypsHQ",
  "customer_id": "A",
  "billing": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "US",
      "first_name": "John",
      "last_name": "Doe"
    }
  }
}'

Response

{
    "payment_id": "pay_VKzfi6ObZZxwnkEjGxTL",
    "merchant_id": "merchant_1713362818",
    "status": "succeeded",
    "amount": 700,
    "net_amount": 700,
    "amount_capturable": 0,
    "amount_received": 700,
    "connector": "bankofamerica",
    "client_secret": "pay_VKzfi6ObZZxwnkEjGxTL_secret_XAQJ5XwiPwMoYJtjeNyk",
    "created": "2024-04-17T14:08:01.502Z",
    "currency": "USD",
    "customer_id": "A",
    "customer": {
        "id": "A",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Initiated by merchant",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_9IocBs7oFK45cixypsHQ",
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": null,
    "payment_token": "a697b91d-abd0-4f06-be3a-436e366ced30",
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "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": {
        "customer_id": "A",
        "created_at": 1713362881,
        "expires": 1713366481,
        "secret": ""
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7133628821636901403954",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_VKzfi6ObZZxwnkEjGxTL_1",
    "payment_link": null,
    "profile_id": "pro_E4qXt9ixAiujSJMb7WFW",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_J6QWMKfE8dtQOVi3jfvq",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-17T14:23:01.502Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-04-17T14:08:03.089Z"
}

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

@AkshayaFoiger AkshayaFoiger requested a review from a team as a code owner April 17, 2024 13:14
@AkshayaFoiger AkshayaFoiger self-assigned this Apr 17, 2024
@AkshayaFoiger AkshayaFoiger added A-connector-compatibility Area: Connector compatibility A-connector-integration Area: Connector integration C-bug Category: Bug labels Apr 17, 2024
@SamraatBansal SamraatBansal added P-high Priority: High S-waiting-on-review Status: This PR has been implemented and needs to be reviewed and removed A-connector-compatibility Area: Connector compatibility labels Apr 17, 2024
@AkshayaFoiger AkshayaFoiger changed the title bug(router): make payment_instrument optional fix(router): make payment_instrument optional Apr 17, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 17, 2024
Merged via the queue into main with commit 450dd0f Apr 17, 2024
30 of 33 checks passed
@likhinbopanna likhinbopanna deleted the fix-boa-deserialization-error branch April 17, 2024 14:30
pixincreate added a commit that referenced this pull request Apr 18, 2024
…press-for-more-control

* 'main' of github.com:juspay/hyperswitch:
  feat(payments): add amount and connector id filter in list (#4354)
  feat(connector): [NMI] External 3DS flow for Cards (#4385)
  test(cypress): Update ConnectorAuth Details (#4386)
  chore(version): 2024.04.18.0
  fix(router): make payment_instrument optional (#4389)
  fix(config): remove `merchant_business_country` from the connector configs as enums can not be handled in this toml file (#4383)
  feat(payment_link): Add support for saved payment method option for payment link (#4373)
@SanchithHegde SanchithHegde removed P-high Priority: High S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Apr 21, 2024
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-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants