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): [AUTHORIZEDOTNET] Implement non-zero mandates #4758

Merged
merged 5 commits into from
May 27, 2024

Conversation

deepanshu-iiitu
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu commented May 24, 2024

Type of Change

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

Description

Non-zero dollar mandates are implemented for connector Authorizedotnet.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

#4703

How did you test it?

  • Payment Intent Create (Non-Zero Mandate):

Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE' \
--data-raw '{
    "amount": 370,
    "currency": "USD",
    "confirm": false,
    "customer_id": "cust6",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "description": "Its my first payment request",
    "setup_future_usage":"off_session"
}'

Response:

 {
    "payment_id": "pay_lx2DcRsYllb2QenBQfze",
    "merchant_id": "merchant_1716370796",
    "status": "requires_payment_method",
    "amount": 370,
    "net_amount": 370,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_lx2DcRsYllb2QenBQfze_secret_X1riA15AgjzqEahbR8mv",
    "created": "2024-05-27T11:07:15.600Z",
    "currency": "USD",
    "customer_id": "cust6",
    "customer": {
        "id": "cust6",
        "name": "Joseph Doe",
        "email": "[email protected]",
        "phone": null,
        "phone_country_code": null
    },
    "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": null,
    "payment_method": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": null,
    "return_url": null,
    "authentication_type": null,
    "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": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cust6",
        "created_at": 1716808035,
        "expires": 1716811635,
        "secret": "epk_339c8ebb1d9f430796cf8273ef72f78f"
    },
    "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_ZjmEyV32O7pOQkBlB510",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-27T11:22:15.600Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-05-27T11:07:15.690Z",
    "charges": null,
    "frm_metadata": null
}
  • Payment Confirm:

Request:

curl --location 'http://localhost:8080/payments/pay_lx2DcRsYllb2QenBQfze/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE' \
--data '{
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "07",
            "card_exp_year": "26",
            "card_holder_name": "Joseph Does",
            "card_cvc": "123"
        }
    },
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "125.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 68607706,
                "currency": "USD",
                "start_date": "2023-04-21T00:00:00Z",
                "end_date": "2023-05-21T00:00:00Z",
                "metadata": {
                    "frequency": "13"
                }
            }
        }
    }
}'

Response:

{
    "payment_id": "pay_lx2DcRsYllb2QenBQfze",
    "merchant_id": "merchant_1716370796",
    "status": "succeeded",
    "amount": 370,
    "net_amount": 370,
    "amount_capturable": 0,
    "amount_received": 370,
    "connector": "authorizedotnet",
    "client_secret": "pay_lx2DcRsYllb2QenBQfze_secret_X1riA15AgjzqEahbR8mv",
    "created": "2024-05-27T11:07:15.600Z",
    "currency": "USD",
    "customer_id": "cust6",
    "customer": {
        "id": "cust6",
        "name": "Joseph Doe",
        "email": "[email protected]",
        "phone": null,
        "phone_country_code": null
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_wxTMvSxaQPFC5uvg7Qmm",
    "mandate_data": {
        "update_mandate_id": null,
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "125.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 68607706,
                "currency": "USD",
                "start_date": "2023-04-21T00:00:00.000Z",
                "end_date": "2023-05-21T00:00:00.000Z",
                "metadata": {
                    "frequency": "13"
                }
            }
        }
    },
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "07",
            "card_exp_year": "26",
            "card_holder_name": "Joseph Does",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": null,
    "return_url": null,
    "authentication_type": "no_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": "80019080368",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80019080368",
    "payment_link": null,
    "profile_id": "pro_ZjmEyV32O7pOQkBlB510",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_6wtrG4tIah8tNezhNkT9",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-27T11:22:15.600Z",
    "fingerprint": null,
    "browser_info": {
        "language": null,
        "time_zone": null,
        "ip_address": "::1",
        "user_agent": null,
        "color_depth": null,
        "java_enabled": null,
        "screen_width": null,
        "accept_header": null,
        "screen_height": null,
        "java_script_enabled": null
    },
    "payment_method_id": "pm_ZN7bB0d33KWNWIUgVWod",
    "payment_method_status": null,
    "updated": "2024-05-27T11:07:32.165Z",
    "charges": null,
    "frm_metadata": null
}
  • Payment Create (Using Mandate ID):

Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE' \
--data '{
    "amount": 141,
    "currency": "USD",
    "confirm": true,
    "customer_id": "cust6",
    "capture_method": "automatic",
    "mandate_id": "man_wxTMvSxaQPFC5uvg7Qmm",
    "off_session": true
}'

Response:

{
    "payment_id": "pay_8aI2C6oCZosMy1CQf2X9",
    "merchant_id": "merchant_1716370796",
    "status": "succeeded",
    "amount": 141,
    "net_amount": 141,
    "amount_capturable": 0,
    "amount_received": 141,
    "connector": "authorizedotnet",
    "client_secret": "pay_8aI2C6oCZosMy1CQf2X9_secret_gnro3S1Hlru3sUsAcdik",
    "created": "2024-05-27T11:07:53.638Z",
    "currency": "USD",
    "customer_id": "cust6",
    "customer": {
        "id": "cust6",
        "name": "Joseph Doe",
        "email": "[email protected]",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_wxTMvSxaQPFC5uvg7Qmm",
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "07",
            "card_exp_year": "26",
            "card_holder_name": "Joseph Does",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "fa0a6a44-2e80-4953-971d-c70702e889d7",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": null,
    "return_url": null,
    "authentication_type": "no_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": {
        "customer_id": "cust6",
        "created_at": 1716808073,
        "expires": 1716811673,
        "secret": "epk_95141b60e629482ea657f64053afa3d2"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "80019080384",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80019080384",
    "payment_link": null,
    "profile_id": "pro_ZjmEyV32O7pOQkBlB510",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_6wtrG4tIah8tNezhNkT9",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-27T11:22:53.638Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_ZN7bB0d33KWNWIUgVWod",
    "payment_method_status": "active",
    "updated": "2024-05-27T11:07:54.663Z",
    "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

@deepanshu-iiitu deepanshu-iiitu added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels May 24, 2024
@deepanshu-iiitu deepanshu-iiitu self-assigned this May 24, 2024
@deepanshu-iiitu deepanshu-iiitu requested a review from a team as a code owner May 24, 2024 09:28
@deepanshu-iiitu deepanshu-iiitu linked an issue May 24, 2024 that may be closed by this pull request
2 tasks
Copy link
Contributor

@SamraatBansal SamraatBansal left a comment

Choose a reason for hiding this comment

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

Refactor the code with clear try_froms

Comment on lines 607 to 610
})),
Some(ProcessingOptions {
is_subsequent_auth: true,
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled

Ok(Self {
transaction_type: TransactionType::try_from(item.router_data.request.capture_method)?,
amount: item.amount,
currency_code: item.router_data.request.currency.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this currency type to common_enums::Currency from string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

PaymentDetails::CreditCard(CreditCardDetails {
card_number: (*ccard.card_number).clone(),
expiration_date: ccard.get_expiry_date_as_yyyymm("-"),
card_code: 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 is this card_code set to None ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

card_code is not required for payments which are done using network_trans_id

currency_code: item.router_data.request.currency.to_string(),
payment: Some(PaymentDetails::CreditCard(CreditCardDetails {
card_number: (*ccard.card_number).clone(),
// expiration_date: format!("{expiry_year}-{expiry_month}").into(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this commented code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@likhinbopanna likhinbopanna added this pull request to the merge queue May 27, 2024
Merged via the queue into main with commit ed82af8 May 27, 2024
10 checks passed
@likhinbopanna likhinbopanna deleted the adn-mandate branch May 27, 2024 17:11
ghost pushed a commit that referenced this pull request May 29, 2024
…actor

* 'main' of github.com:juspay/hyperswitch: (39 commits)
  Fix(Cypress): Fixing 3DS payment failure in headless mode (#4807)
  feat(users): Add redis in Begin and Verify TOTP and create a new API that updates TOTP (#4765)
  refactor(connector): [Klarna] Refactor Authorize call and configs for prod (#4750)
  fix: implement StrongEq for Vec<u8> (#4795)
  refactor(core): move router data response and request models to hyperswitch domain models crate (#4789)
  chore(version): 2024.05.29.0
  refactor: retrieve extended card info config during business profile get call (#4784)
  refactor(payment_methods): add support for passing ttl to locker entries (#4690)
  feat(connector): [CRYPTOPAY] Pass network details in payment request (#4779)
  fix: include client columns in payment attempts response struct (#4761)
  fix(docker-compose): fix docker compose syntax (#4782)
  feat(connector): [Iatapay] add upi qr support (#4728)
  docs(analytics): Add documentation for setting up data services and enabling data features in control center (#4741)
  chore(version): 2024.05.28.0
  feat(connector): [AUTHORIZEDOTNET] Implement non-zero mandates (#4758)
  feat(core): [Paypal] Add session_token flow for Paypal sdk (#4697)
  chore(version): 2024.05.27.0
  chore: add missing migrations for recently added currencies (#4760)
  Refactor(core): Inclusion of constraint graph for merchant Payment Method list (#4626)
  chore(version): 2024.05.24.1
  ...
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 C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [AUTHORIZEDOTNET] Implement non-zero mandates
4 participants