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

feat(connector): implement pre auth flow for gpayments #4692

Merged
merged 29 commits into from
May 30, 2024

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented May 17, 2024

Type of Change

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

Description

implement pre auth flow for gpayments

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?

Manual.

  1. Create a merchant with checkout payment connector and gpayments authentication connector.
curl --location 'http://localhost:8080/account/postman_merchant_GHAction_184925e6-5bcf-48b7-9863-faa5f74ff0a5/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "fiz_operations",
    "connector_name": "checkout",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "",
        "api_secret": "",
        "key1": ""
    },
    "test_mode": false,
    "disabled": false,
    "business_country": "US",
    "business_label": "default",
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "metadata": {
        "acquirer_bin": "438309",
        "acquirer_merchant_id": "00002000000",
        "city": "NY",
        "unit": "245"
    }
}'
curl --location 'http://localhost:8080/account/postman_merchant_GHAction_184925e6-5bcf-48b7-9863-faa5f74ff0a5/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "authentication_processor",
    "business_country": "US",
    "business_label": "default",
    "connector_name": "gpayments",
    "connector_account_details": {
        "auth_type": "CertificateAuth",
        "certificate": "",
        "private_key": "="
    },
    "test_mode": true,
    "disabled": false,
    "metadata": {
        "mcc": "5411",
        "merchant_country_code": "840",
        "merchant_name": "Dummy Merchant",
        "endpoint_prefix": "hyperswitch",
        "merchant_id": "123456789012345",
        "three_ds_requestor_name": "juspay-prev",
        "three_ds_requestor_id": "juspay-prev"
    }
}'
  1. Create a payment with "request_external_three_ds_authentication": true,
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_uUxE0Jyfdziw9ZvBoF7NxH06M0ny7P3gtCJXFTbC9GSXWx1KqYgMlQsLr9q0HYHg' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        }
    },
    "request_external_three_ds_authentication": true,
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
  1. Confirm the payment (should get three_ds_invoke as next action type).
curl --location 'http://localhost:8080/payments/pay_gw37bOcJ8d0SmUSjEW3G/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_27c2226e51514a1ca1f0842bee794ef1' \
--data '{
    "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": "115.99.183.2"
    },
    "client_secret": "pay_gw37bOcJ8d0SmUSjEW3G_secret_DFfmbty5pCaoht5JsI1C",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4100000000600008",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    }
}'

Should get three_ds_method_invode as next action type in payment respone. And status should be requires_customer_action.

Payment response should look like this

{
    "payment_id": "pay_jiO1tY3EV90hebt2qckE",
    "merchant_id": "postman_merchant_GHAction_e0414c14-fe48-49e6-8f45-8e28f5a2eb32",
    "status": "requires_customer_action",
    "amount": 6540,
    "net_amount": 6540,
    "amount_capturable": 6540,
    "amount_received": null,
    "connector": "checkout",
    "client_secret": "pay_jiO1tY3EV90hebt2qckE_secret_QrR1Yhdq9JOF57dIY6x0",
    "created": "2024-05-29T13:00:22.147Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": null,
    "payment_method_data": null,
    "payment_token": "token_bTfzD6IO8dmhCrGgXa4b",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        },
        "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": null
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "three_ds_invoke",
        "three_ds_data": {
            "three_ds_authentication_url": "http://localhost:8080/payments/pay_jiO1tY3EV90hebt2qckE/3ds/authentication",
            "three_ds_authorize_url": "http://localhost:8080/payments/pay_jiO1tY3EV90hebt2qckE/postman_merchant_GHAction_e0414c14-fe48-49e6-8f45-8e28f5a2eb32/authorize/checkout",
            "three_ds_method_details": {
                "three_ds_method_key": "threeDSMethodData",
                "three_ds_method_data_submission": true,
                "three_ds_method_data": "eyJ0aHJlZURTU2VydmVyVHJhbnNJRCI6IjY5ZmJjNWExLTlmNGYtNGI4Ny1iMjA5LTM2YzkyZDBlYWIxNyIsInRocmVlRFNNZXRob2ROb3RpZmljYXRpb25VUkwiOiJodHRwczovL3dlYmhvb2suc2l0ZS9iZDA2ODYzZC04MmMyLTQyZWEtYjM1Yi01ZmZkNWVjZWNlNzEifQ==",
                "three_ds_method_url": "https://acs-challenge.testlab.3dsecure.cloud/acs/tdsmethodaction"
            },
            "poll_config": {
                "poll_id": "external_authentication_pay_jiO1tY3EV90hebt2qckE",
                "delay_in_secs": 2,
                "frequency": 5
            },
            "message_version": "2.2.0",
            "directory_server_id": 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": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_jnTRVUadt7vdxhdC4DSk",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_0NshOYlui5L4igYEZj5c",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": {
        "authentication_flow": null,
        "electronic_commerce_indicator": null,
        "status": "started",
        "ds_transaction_id": "69fbc5a1-9f4f-4b87-b209-36c92d0eab17",
        "version": "2.2.0",
        "error_code": null,
        "error_message": null
    },
    "external_3ds_authentication_attempted": true,
    "expires_on": "2024-05-29T13:15:22.147Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "115.99.183.2",
        "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": null,
    "payment_method_status": null,
    "updated": "2024-05-29T13:00:27.790Z",
    "charges": null,
    "frm_metadata": 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

@hrithikesh026 hrithikesh026 self-assigned this May 17, 2024
@hrithikesh026 hrithikesh026 requested review from a team as code owners May 17, 2024 15:53
Base automatically changed from add-support-for-3ds-connectors-with-separate-version-call to main May 21, 2024 17:22
@hrithikesh026 hrithikesh026 added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-database-changes Metadata: This PR involves database schema changes labels May 22, 2024
@hrithikesh026 hrithikesh026 added this to the May 2024 Release milestone May 22, 2024
SamraatBansal
SamraatBansal previously approved these changes May 23, 2024
SamraatBansal
SamraatBansal previously approved these changes May 29, 2024
@likhinbopanna likhinbopanna removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 29, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue May 29, 2024
@likhinbopanna likhinbopanna removed this pull request from the merge queue due to a manual request May 29, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue May 29, 2024
@likhinbopanna likhinbopanna removed this pull request from the merge queue due to a manual request May 29, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 30, 2024
Merged via the queue into main with commit bed42ce May 30, 2024
10 checks passed
@Gnanasundari24 Gnanasundari24 deleted the implement-pre-auth-flow-gpayments branch May 30, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants