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): [Payme] Implement Card 3DS with sdk flow #2082

Merged
merged 31 commits into from
Sep 5, 2023
Merged

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Sep 4, 2023

Type of Change

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

Description

Payme 3DS includes four api calls to execute payment:
i) Tokenization flow for generating buyer_key which contain card details
ii) Pre processing flow for generating payme_sale_id which contains the details of the payment request
iii) Script run on user end to generate meta_data_jwt
iv) Pay sale call in complete authorize flow to create payment

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?

`{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://www.google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "03",
            "card_exp_year": "2024",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "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": "8056594427",
            "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": "8056594427",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "order_details": [
        {
            "product_name": "Socks",
            "amount": 7000,
            "quantity": 1
        }
    ],
    "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": "127.0.0.1"
    }
}`

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

@Sakilmostak Sakilmostak added A-connector-integration Area: Connector integration A-core Area: Core flows C-feature Category: Feature request or enhancement R-waiting-on-L1 Review: Waiting on L1 reviewer labels Sep 4, 2023
@Sakilmostak Sakilmostak requested a review from a team as a code owner September 4, 2023 17:14
@Sakilmostak Sakilmostak self-assigned this Sep 4, 2023
@Sakilmostak Sakilmostak requested review from a team as code owners September 4, 2023 17:14
crates/router/src/connector/payme.rs Show resolved Hide resolved
crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/services/api.rs Outdated Show resolved Hide resolved
label: "Apple Pay".to_string(),
total_type: None,
amount: amount_in_base_unit,
match item.data.auth_type {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this match statement? irrespective of the auth_type we are calling generate-sale in the flow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is to differentiate between the 3ds and non 3ds flow, since we are breaking at preprocessing at 3ds, we need redirection for 3ds. To show redirection we need authenticationpending status too. But in case of of non 3ds, we don't have redirection at preprocessing step, rather we move to authorize flow to complete the payment

Copy link
Contributor

Choose a reason for hiding this comment

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

This will not work in case of Apple Pay AuthenticationType is ThreeDs. Since Applepay is not yet supported I am approving this PR. But take this change in separate PR

crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
@ArjunKarthik ArjunKarthik added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Sep 4, 2023
@Sakilmostak Sakilmostak removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Sep 5, 2023
crates/router/src/connector/payme.rs Show resolved Hide resolved
config/development.toml Show resolved Hide resolved
crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/payme/transformers.rs Outdated Show resolved Hide resolved
@prasunna09 prasunna09 added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Sep 5, 2023
@Sakilmostak Sakilmostak removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Sep 5, 2023
label: "Apple Pay".to_string(),
total_type: None,
amount: amount_in_base_unit,
match item.data.auth_type {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not work in case of Apple Pay AuthenticationType is ThreeDs. Since Applepay is not yet supported I am approving this PR. But take this change in separate PR

@@ -507,6 +587,100 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayRequest {
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymePayloadData {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename this to PaymeRedirectResponseData. Take this in another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure👍

Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

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

Other than that, looks good to me!

language: String,
}

#[derive(Debug, Serialize)]
pub struct ThreeDS {
Copy link
Member

Choose a reason for hiding this comment

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

Nit(naming convention): ThreeDs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Raising a seperate PR to resolve this comments👍

}

#[derive(Debug, Serialize)]
pub enum ThreeDSType {
Copy link
Member

Choose a reason for hiding this comment

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

Nit(naming convention): ThreeDsType

}

#[derive(Debug, Serialize)]
pub struct ThreeDSSettings {
Copy link
Member

@SanchithHegde SanchithHegde Sep 5, 2023

Choose a reason for hiding this comment

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

Nit(naming convention): ThreeDsSettings

@ArjunKarthik
Copy link
Contributor

@Sakilmostak Please take mine and @SanchithHegde comments in separate PR

@ArjunKarthik ArjunKarthik added S-ready-for-merge and removed R-waiting-on-L1 Review: Waiting on L1 reviewer labels Sep 5, 2023
@ArjunKarthik ArjunKarthik added this pull request to the merge queue Sep 5, 2023
Merged via the queue into main with commit 99f1780 Sep 5, 2023
12 of 16 checks passed
@ArjunKarthik ArjunKarthik deleted the payme_3ds branch September 5, 2023 15:30
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 A-core Area: Core flows C-feature Category: Feature request or enhancement
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

5 participants