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(core): [Paypal] Add Preprocessing flow to CompleteAuthorize for Card 3DS Auth Verification #2757

Merged
merged 8 commits into from
Nov 28, 2023

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Nov 2, 2023

Type of Change

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

Description

  • An auth verification call is made to paypal after 3ds challenge to get the status on whether to continue payment.
  • Pre processing flow is being used for the call since we want to send the response in case of failure
  • Pre processing is being called from the complete auth flow.

Resolves - #3014

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?

Success Case:
{ "amount": 300, "currency": "PLN", "confirm": true, "business_country": "US", "business_label": "default", "amount_to_capture": 97, "customer_id": "custhype1232", "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "authentication_type": "three_ds", "return_url": "https://www.google.com", "email": "something@gmail.com", "name": "Joseph Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "statement_descriptor_name": "Juspay", "statement_descriptor_suffix": "Router", "payment_method": "card", "payment_method_type": "credit", "payment_method_data": { "card": { "card_number": "4000000000001091", "card_exp_month": "01", "card_exp_year": "2026", "card_holder_name": "joseph Doe", "card_cvc": "100" } }, "billing": { "address": { "line1": "1467", "line2": "CA", "line3": "Harrison Street", "city": "San Fransico", "state": "CA", "zip": "94122", "country": "PL", "first_name": "joseph", "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": "109.71.40.0" }, "metadata": { "order_category": "applepay" }, "order_details": [ { "product_name": "Apple iphone 15", "quantity": 1, "amount": 101, "account_name": "transaction_processing" } ] }

The Psync response would be,
{ "payment_id": "pay_pL135krSvsJmN6m8Xgsb", "merchant_id": "merchant_1701164351", "status": "processing", "amount": 300, "amount_capturable": 0, "amount_received": null, "connector": "paypal", "client_secret": "pay_pL135krSvsJmN6m8Xgsb_secret_I6W73CQ9KFndxMsRpweV", "created": "2023-11-28T10:47:44.381Z", "currency": "USD", "customer_id": "", "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": "1091", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "400000", "card_exp_month": "01", "card_exp_year": "2026", "card_holder_name": "joseph Doe" } }, "payment_token": null, "shipping": null, "billing": { "address": { "city": "San Fransico", "country": "PL", "line1": "1467", "line2": "CA", "line3": "Harrison Street", "zip": "94122", "state": "CA", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "order_details": [ { "amount": 300, "quantity": 1, "product_name": "Apple iphone 15", "product_img_link": null } ], "email": "something@gmail.com", "name": "Joseph Doe", "phone": "999999999", "return_url": "https://www.google.com/", "authentication_type": "three_ds", "statement_descriptor_name": "Juspay", "statement_descriptor_suffix": "Router", "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": "paypal_US_default", "business_country": "US", "business_label": "default", "business_sub_label": null, "allowed_payment_method_types": null, "ephemeral_key": null, "manual_retry_allowed": false, "connector_transaction_id": "0K946454X9731031W", "frm_message": null, "metadata": { "order_category": "applepay" }, "connector_metadata": null, "feature_metadata": null, "reference_id": "pay_pL135krSvsJmN6m8Xgsb_1", "payment_link": null, "profile_id": "pro_WGLGmf79GMN4G7NwlOrJ", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_srpPyEcifCEYXGgXyp3e" }

Failure Case:
{ "amount": 300, "currency": "PLN", "confirm": true, "business_country": "US", "business_label": "default", "amount_to_capture": 97, "customer_id": "custhype1232", "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "authentication_type": "three_ds", "return_url": "https://www.google.com", "email": "something@gmail.com", "name": "Joseph Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "statement_descriptor_name": "Juspay", "statement_descriptor_suffix": "Router", "payment_method": "card", "payment_method_type": "credit", "payment_method_data": { "card": { "card_number": "4868719081564153", "card_exp_month": "01", "card_exp_year": "2025", "card_holder_name": "joseph Doe", "card_cvc": "123" } }, "billing": { "address": { "line1": "1467", "line2": "CA", "line3": "Harrison Street", "city": "San Fransico", "state": "CA", "zip": "94122", "country": "PL", "first_name": "joseph", "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": "109.71.40.0" }, "metadata": { "order_category": "applepay" }, "order_details": [ { "product_name": "Apple iphone 15", "quantity": 1, "amount": 101, "account_name": "transaction_processing" } ] }

The Psync response would be,
{ "payment_id": "pay_GNv9KCmgHS1xhQuf19dv", "merchant_id": "merchant_1701164351", "status": "failed", "amount": 300, "amount_capturable": 0, "amount_received": null, "connector": "paypal", "client_secret": "pay_GNv9KCmgHS1xhQuf19dv_secret_UKJeIbiD03YxCG0I4q8K", "created": "2023-11-28T10:22:55.080Z", "currency": "USD", "customer_id": "", "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": "4153", "card_type": null, "card_network": null, "card_issuer": null, "card_issuing_country": null, "card_isin": "486871", "card_exp_month": "01", "card_exp_year": "2025", "card_holder_name": "joseph Doe" } }, "payment_token": null, "shipping": null, "billing": { "address": { "city": "San Fransico", "country": "PL", "line1": "1467", "line2": "CA", "line3": "Harrison Street", "zip": "94122", "state": "CA", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "order_details": [ { "amount": 300, "quantity": 1, "product_name": "Apple iphone 15", "product_img_link": null } ], "email": "something@gmail.com", "name": "Joseph Doe", "phone": "999999999", "return_url": "https://www.google.com/", "authentication_type": "three_ds", "statement_descriptor_name": "Juspay", "statement_descriptor_suffix": "Router", "next_action": null, "cancellation_reason": null, "error_code": "No error code", "error_message": "Cannot continue with Authorization due to failed Liability Shift. Connector Responsded with LiabilityShift: No, EnrollmentStatus: Ready, and AuthenticationStatus: Rejected", "unified_code": null, "unified_message": null, "payment_experience": null, "payment_method_type": "credit", "connector_label": "paypal_US_default", "business_country": "US", "business_label": "default", "business_sub_label": null, "allowed_payment_method_types": null, "ephemeral_key": null, "manual_retry_allowed": true, "connector_transaction_id": "7AG80836YF6630004", "frm_message": null, "metadata": { "order_category": "applepay" }, "connector_metadata": null, "feature_metadata": null, "reference_id": null, "payment_link": null, "profile_id": "pro_WGLGmf79GMN4G7NwlOrJ", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": "mca_srpPyEcifCEYXGgXyp3e" }

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 S-waiting-on-review Status: This PR has been implemented and needs to be reviewed R-waiting-on-L1 Review: Waiting on L1 reviewer labels Nov 2, 2023
@Sakilmostak Sakilmostak self-assigned this Nov 2, 2023
@Sakilmostak Sakilmostak requested review from a team as code owners November 2, 2023 07:01
crates/router/src/connector/paypal/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/paypal/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/paypal.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 Nov 2, 2023
@Sakilmostak Sakilmostak removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Nov 2, 2023
}
_ => Ok(types::PaymentsPreProcessingRouterData {
response: Err(ErrorResponse {
attempt_status: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Mark failed status


#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AuthenticationStatus {
Null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check if this is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are being used for the propagation of error response when the respective field is none


#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EnrollementStatus {
Null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check if this is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are being used for the propagation of error response when the respective field is none

@likhinbopanna likhinbopanna removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 28, 2023
@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 28, 2023
Merged via the queue into main with commit 77fc92c Nov 28, 2023
14 of 16 checks passed
@likhinbopanna likhinbopanna deleted the paypal_3ds_check branch November 28, 2023 11:29
@SanchithHegde SanchithHegde removed the R-waiting-on-L1 Review: Waiting on L1 reviewer label Dec 3, 2023
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