Skip to content

Conversation

awasthi21
Copy link
Contributor

Type of Change

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

Description

Added 3DS 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?

Request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_sBzGsZDNauMcWSI41iEiQEuPBoOSvmV8JJaZGHIwTr3M3iL43LL764gBbT9Ks3bL' \
--data-raw '{
    "amount": 500,
    "currency": "EUR",
    "confirm": true,
    "capture_method": "automatic",
    "authentication_type": "three_ds",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "BamboraCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        }
    },
    "phone_country_code": "+65",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5200000000000007",
            "card_exp_month": "01",
            "card_exp_year": "26",
            "card_holder_name": "John Doe",
            "card_cvc": "123"
        }
    }
}'

Response

{
    "payment_id": "pay_saaYhGG1Xe0GGVK5Xp15",
    "merchant_id": "postman_merchant_GHAction_d664cf3a-5bc7-4146-be80-389e3a01dd62",
    "status": "requires_customer_action",
    "amount": 500,
    "net_amount": 500,
    "amount_capturable": 500,
    "amount_received": null,
    "connector": "paybox",
    "client_secret": "pay_saaYhGG1Xe0GGVK5Xp15_secret_uiX1ovdNcBwi0Q0Uyu6w",
    "created": "2024-09-26T05:38:08.428Z",
    "currency": "EUR",
    "customer_id": "BamboraCustomer",
    "customer": {
        "id": "BamboraCustomer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "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": "card",
    "payment_method_data": {
        "card": {
            "last4": "0007",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "01",
            "card_exp_year": "26",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_MmqMOuV3VI21yVG7cOIK",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "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": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_saaYhGG1Xe0GGVK5Xp15/postman_merchant_GHAction_d664cf3a-5bc7-4146-be80-389e3a01dd62/pay_saaYhGG1Xe0GGVK5Xp15_1"
    },
    "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": "BamboraCustomer",
        "created_at": 1727329088,
        "expires": 1727332688,
        "secret": "epk_e33dcd99ffe543d49119f34531f82d00"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_Cg9CHIHfjAx0HS7oeO0b",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_SNsSbss3vX1x5K1ztI8J",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-09-26T05:53:08.428Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-09-26T05:38:09.429Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null
}

Redirect Response

{
    "payment_id": "pay_saaYhGG1Xe0GGVK5Xp15",
    "merchant_id": "postman_merchant_GHAction_d664cf3a-5bc7-4146-be80-389e3a01dd62",
    "status": "succeeded",
    "amount": 500,
    "net_amount": 500,
    "amount_capturable": 0,
    "amount_received": 500,
    "connector": "paybox",
    "client_secret": "pay_saaYhGG1Xe0GGVK5Xp15_secret_uiX1ovdNcBwi0Q0Uyu6w",
    "created": "2024-09-26T05:38:08.428Z",
    "currency": "EUR",
    "customer_id": "BamboraCustomer",
    "customer": {
        "id": "BamboraCustomer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "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": "card",
    "payment_method_data": null,
    "payment_token": "token_MmqMOuV3VI21yVG7cOIK",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "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": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "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": "credit",
    "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": "0079839093",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_Cg9CHIHfjAx0HS7oeO0b",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_SNsSbss3vX1x5K1ztI8J",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-09-26T05:53:08.428Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-09-26T05:39:29.324Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": 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

@awasthi21 awasthi21 added the A-connector-integration Area: Connector integration label Sep 26, 2024
@awasthi21 awasthi21 self-assigned this Sep 26, 2024
@awasthi21 awasthi21 requested review from a team as code owners September 26, 2024 05:40
Copy link

semanticdiff-com bot commented Sep 26, 2024

Review changes with SemanticDiff.

Analyzed 5 of 15 files.

Overall, the semantic diff is 15% smaller than the GitHub diff.

Filename Status
loadtest/config/development.toml Unsupported file format
✔️ crates/router/src/core/payments/flows.rs 20.36% smaller
✔️ crates/router/src/connector/paybox.rs 11.26% smaller
✔️ crates/router/src/connector/paybox/transformers.rs 25.07% smaller
✔️ crates/router/src/configs/defaults.rs Analyzed
✔️ crates/hyperswitch_interfaces/src/configs.rs Analyzed
crates/connector_configs/toml/development.toml Unsupported file format
crates/connector_configs/toml/production.toml Unsupported file format
crates/connector_configs/toml/sandbox.toml Unsupported file format
config/config.example.toml Unsupported file format
config/development.toml Unsupported file format
config/docker_compose.toml Unsupported file format
config/deployments/integration_test.toml Unsupported file format
config/deployments/production.toml Unsupported file format
config/deployments/sandbox.toml Unsupported file format

@@ -318,6 +319,7 @@ cybersource = { payment_method = "card" }
nmi = { payment_method = "card" }
payme = { payment_method = "card" }
deutschebank = { payment_method = "bank_debit" }
paybox = { payment_method = "card" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these URL's in loadtest/config/development.toml as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment on lines +701 to +708
PayboxResponse::Error(_) => Ok(Self {
response: Err(types::ErrorResponse {
code: response.response_code.clone(),
message: response.response_message.clone(),
reason: Some(response.response_message),
code: consts::NO_ERROR_CODE.to_string(),
message: consts::NO_ERROR_MESSAGE.to_string(),
reason: Some(consts::NO_ERROR_MESSAGE.to_string()),
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: Some(item.response.transaction_number),
connector_transaction_id: None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't we populating the error values here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only come when we are getting Error in html response

rank: auth_data.rang,
key: auth_data.cle,
})
if item.router_data.is_three_ds() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also test Capture, Psync and Refund Flow for 3DS transactions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested , Working

Comment on lines +105 to +128
pub struct ThreeDSPaymentsRequest {
id_merchant: Secret<String>,
id_session: String,
amount: MinorUnit,
currency: String,
#[serde(rename = "CCNumber")]
cc_number: cards::CardNumber,
#[serde(rename = "CCExpDate")]
cc_exp_date: Secret<String>,
#[serde(rename = "CVVCode")]
cvv_code: Secret<String>,
#[serde(rename = "URLRetour")]
url_retour: String,
#[serde(rename = "URLHttpDirect")]
url_http_direct: String,
email_porteur: common_utils::pii::Email,
first_name: Secret<String>,
last_name: Secret<String>,
address1: Secret<String>,
zip_code: Secret<String>,
city: String,
country_code: api_models::enums::CountryAlpha2,
total_quantity: i32,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make only required fields as mandatory and add the in crates/router/src/configs/defaults.rs.
Make strongly recommended fields as optional and add a comment highlighting those fields.

@@ -2285,6 +2285,112 @@ impl Default for super::settings::RequiredFields {
),
}
),
(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add email field and also add these fields for credit card payments

@likhinbopanna likhinbopanna added this pull request to the merge queue Sep 27, 2024
Merged via the queue into main with commit 354f530 Sep 27, 2024
15 of 16 checks passed
@likhinbopanna likhinbopanna deleted the 6853-featconnector-paybox-implement-3ds-flow branch September 27, 2024 13:46
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants