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): store network_transaction_id in stripe authorize flow #5399

Merged
merged 3 commits into from
Jul 22, 2024

Conversation

ShankarSinghC
Copy link
Contributor

@ShankarSinghC ShankarSinghC commented Jul 22, 2024

Type of Change

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

Description

Now we are trying to store the network_transaction_id that comes in the latest_attempt of the authorize response instead we should be storing the network_transaction_id that comes in the latest_charge object.

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 mca for stripe
-> Create a payment with steup_future_usage: off_session 0 amount

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: dev_WQrUfhm6TWzpFVlFlDScYFQxn9lKKoGHhOXk6YHQpWkQZclxtkrRdQX5wmc0p2dO' \
--header 'Content-Type: application/json' \
--data-raw '{
    "amount": 0,
    "payment_type": "setup_mandate",
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "cu_1721649988",
    "email": "guest@example.com",
    "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",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "card_cvc": "737"
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX",
            "last_name": "ss"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "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,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "125.0.0.1"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {},
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 0,
            "account_name": "transaction_processing"
        }
    ]
}'
{
    "payment_id": "pay_0hw6op372qaaKsTiuY5W",
    "merchant_id": "merchant_1721642432",
    "status": "succeeded",
    "amount": 0,
    "net_amount": 0,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "stripe",
    "client_secret": "pay_0hw6op372qaaKsTiuY5W_secret_vKfsIm6wiiaQV1KtEMhA",
    "created": "2024-07-22T12:07:14.790Z",
    "currency": "USD",
    "customer_id": "cu_1721650035",
    "customer": {
        "id": "cu_1721650035",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "STRIPE PAYMENTS UK LIMITED",
            "card_issuing_country": "UNITEDKINGDOM",
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": null,
                "address_postal_code_check": null
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "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": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "ss"
        },
        "phone": null,
        "email": null
    },
    "order_details": [
        {
            "brand": null,
            "amount": 0,
            "category": null,
            "quantity": 1,
            "product_id": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "requires_shipping": null
        }
    ],
    "email": "guest@example.com",
    "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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1721650035",
        "created_at": 1721650034,
        "expires": 1721653634,
        "secret": "epk_eb1bb9c72ab04753bb3064b102e9b39c"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "seti_1PfL1MEOqOywnAIx12IOb9vg",
    "frm_message": null,
    "metadata": {},
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "seti_1PfL1MEOqOywnAIx12IOb9vg",
    "payment_link": null,
    "profile_id": "pro_BWZKN9cFmoG8XWaD3pAC",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_mTDAnjYImojwhWV5Lzfh",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-07-22T12:22:14.790Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "125.0.0.1",
        "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_dubT5ZFlL5rHPqNTUA1b",
    "payment_method_status": null,
    "updated": "2024-07-22T12:07:16.981Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}
image

-> Create a payment with steup_future_usage: off_session with some amount

{
    "amount": 1000,

    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "cu_{{$timestamp}}",
    "email": "guest@example.com",
    "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",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "card_cvc": "737"
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX",
            "last_name": "ss"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "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,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "125.0.0.1"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {},
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 0,
            "account_name": "transaction_processing"
        }
    ]
}
{
    "payment_id": "pay_2ZcZeTrSRop8Sbbc6sYa",
    "merchant_id": "merchant_1721642432",
    "status": "succeeded",
    "amount": 1000,
    "net_amount": 1000,
    "amount_capturable": 0,
    "amount_received": 1000,
    "connector": "stripe",
    "client_secret": "pay_2ZcZeTrSRop8Sbbc6sYa_secret_qPvPMsEI5XDx5Fi7ZRL5",
    "created": "2024-07-22T12:10:40.889Z",
    "currency": "USD",
    "customer_id": "cu_1721650241",
    "customer": {
        "id": "cu_1721650241",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "STRIPE PAYMENTS UK LIMITED",
            "card_issuing_country": "UNITEDKINGDOM",
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": "pass",
                "address_postal_code_check": "pass"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "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": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "ss"
        },
        "phone": null,
        "email": null
    },
    "order_details": [
        {
            "brand": null,
            "amount": 0,
            "category": null,
            "quantity": 1,
            "product_id": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "requires_shipping": null
        }
    ],
    "email": "guest@example.com",
    "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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1721650241",
        "created_at": 1721650240,
        "expires": 1721653840,
        "secret": "epk_adc1f18ee9044b5885104683a7ae3cf2"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3PfL4gEOqOywnAIx0F7mw5Mp",
    "frm_message": null,
    "metadata": {},
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3PfL4gEOqOywnAIx0F7mw5Mp",
    "payment_link": null,
    "profile_id": "pro_BWZKN9cFmoG8XWaD3pAC",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_mTDAnjYImojwhWV5Lzfh",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-07-22T12:25:40.889Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "125.0.0.1",
        "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_fA3gdoIyYaSQGW6WoHer",
    "payment_method_status": null,
    "updated": "2024-07-22T12:10:43.437Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}
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

@ShankarSinghC ShankarSinghC self-assigned this Jul 22, 2024
@ShankarSinghC ShankarSinghC requested a review from a team as a code owner July 22, 2024 11:52
@ShankarSinghC ShankarSinghC linked an issue Jul 22, 2024 that may be closed by this pull request
AkshayaFoiger
AkshayaFoiger previously approved these changes Jul 22, 2024
@ShankarSinghC ShankarSinghC force-pushed the nrid/save-ntid-in-auth-flow branch from a2ace43 to 60895db Compare July 22, 2024 13:11
@ShankarSinghC ShankarSinghC requested a review from a team as a code owner July 22, 2024 14:25
@ShankarSinghC ShankarSinghC force-pushed the nrid/save-ntid-in-auth-flow branch from ab01a20 to 60895db Compare July 22, 2024 14:26
@ShankarSinghC ShankarSinghC removed the request for review from a team July 22, 2024 14:27
@likhinbopanna likhinbopanna enabled auto-merge July 22, 2024 16:58
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 22, 2024
Merged via the queue into main with commit be78dfc Jul 22, 2024
13 checks passed
@likhinbopanna likhinbopanna deleted the nrid/save-ntid-in-auth-flow branch July 22, 2024 17:27
pixincreate added a commit that referenced this pull request Jul 24, 2024
* 'main' of github.com:juspay/hyperswitch: (27 commits)
  refactor(connector): added amount conversion framework for billwerk (#4972)
  feat(connector): [Itaubank] Add refund and rsync flow  (#5420)
  feat: create additional columns in organization table (#5380)
  refactor(merchant_id): create domain type for `merchant_id` (#5408)
  fix(euclid): remove business_profile routing feature flag (#5430)
  feat: add create retrieve and update api endpoints for organization resource (#5361)
  chore(version): 2024.07.24.0
  refactor(connector): [Itaubank] add dynamic fields for pix (#5419)
  Feat(connector): [WELLSFARGO] Add template code (#5333)
  fix(connector): [Datatrans] Handling for 4-Digit YYYY input and Correct 3DS Routing to no_3ds (#5410)
  refactor(connector):  add amount conversion framework to volt (#4985)
  chore(users): email templates footer icon style enhance (#5375)
  feat(customer): customer v2 refactor for customer create end point (#5350)
  chore(version): 2024.07.23.0
  fix(router): store `network_transaction_id` in stripe `authorize` flow (#5399)
  ci: handle packages to run are being empty (#5403)
  chore: add customer, shipping and billing details to payment_response for payment list api (#5401)
  refactor(dashboard_metadata): alter query for merchant scoped metadata (#5397)
  refactor(connector): Add billing_country in klarna dynamic fields (#5373)
  feat(connector): [Itau Bank] Add payment and sync flow for Pix (#5342)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

store network_transaction_id in stripe authorize flow
4 participants