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 zero mandates #4704

Merged
merged 8 commits into from
May 22, 2024

Conversation

deepanshu-iiitu
Copy link
Contributor

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

Type of Change

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

Description

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

#4702

How did you test it?

Note: test_mode should be set to true while testing.

  • Create Zero Amount 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": 0,
    "currency": "USD",
    "confirm": true,
    "customer_id": "tester123",
    "email": "johndoe@gmail.com",
    "setup_future_usage": "off_session",
    "payment_type": "setup_mandate",
    "off_session": true,
    "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": 1000,
                "currency": "USD",
                "start_date": "2023-04-21T00:00:00Z",
                "end_date": "2023-05-21T00:00:00Z",
                "metadata": {
                    "frequency": "13"
                }
            }
        }
    }
}'

Response:

{
    "payment_id": "pay_BUTzOloWgy5ZjPUjOhDR",
    "merchant_id": "merchant_1709720492",
    "status": "succeeded",
    "amount": 0,
    "net_amount": 0,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "authorizedotnet",
    "client_secret": "pay_BUTzOloWgy5ZjPUjOhDR_secret_aQaDNrV3HKhGHZnLcWet",
    "created": "2024-05-21T13:43:09.180Z",
    "currency": "USD",
    "customer_id": "tester123",
    "customer": {
        "id": "tester123",
        "name": null,
        "email": "johndoe@gmail.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_SJ0R3Dx1krNV2OYYXqK8",
    "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": 1000,
                "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": "johndoe@gmail.com",
    "name": null,
    "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": "tester123",
        "created_at": 1716298989,
        "expires": 1716302589,
        "secret": "epk_1cdb048e685f43f9ad8b1f1c20b5142b"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_4aXJeUeyy9BzdhcV9Xue",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_3mX9fbzXfxIkG0uwmy2D",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-21T13:58:09.180Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_eAcvFw4WhUlfAGyeya52",
    "payment_method_status": null,
    "updated": "2024-05-21T13:43:09.865Z",
    "frm_metadata": null
}
  • Create Payment Using Mandate:

Request:

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

Response:

{
    "payment_id": "pay_BYA7GLOyizx2lXr7HY8l",
    "merchant_id": "merchant_1709720492",
    "status": "succeeded",
    "amount": 400,
    "net_amount": 400,
    "amount_capturable": 0,
    "amount_received": 400,
    "connector": "authorizedotnet",
    "client_secret": "pay_BYA7GLOyizx2lXr7HY8l_secret_eyykmbXcMfPnc4m9Vbid",
    "created": "2024-05-21T13:47:00.958Z",
    "currency": "USD",
    "customer_id": "tester123",
    "customer": {
        "id": "tester123",
        "name": null,
        "email": "johndoe@gmail.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_SJ0R3Dx1krNV2OYYXqK8",
    "mandate_data": null,
    "setup_future_usage": null,
    "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": "3906c467-f517-40a1-bb0f-a10c4e6f9878",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "johndoe@gmail.com",
    "name": null,
    "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": "tester123",
        "created_at": 1716299220,
        "expires": 1716302820,
        "secret": "epk_866be4c4a3de481b808853b80a5c5198"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "80018772612",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80018772612",
    "payment_link": null,
    "profile_id": "pro_4aXJeUeyy9BzdhcV9Xue",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_3mX9fbzXfxIkG0uwmy2D",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-21T14:02:00.957Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_eAcvFw4WhUlfAGyeya52",
    "payment_method_status": "active",
    "updated": "2024-05-21T13:47:03.437Z",
    "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 self-assigned this May 20, 2024
@deepanshu-iiitu deepanshu-iiitu requested a review from a team as a code owner May 20, 2024 10:00
@deepanshu-iiitu deepanshu-iiitu linked an issue May 20, 2024 that may be closed by this pull request
2 tasks
&item.request,
)?,
payment_profiles: PaymentProfiles {
customer_type: CustomerType::Individual,
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 hardcoded ?

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 is hardcoded because we are not differentiating between business customers and individual customers while creating mandates.

}),
},
},
validation_mode: ValidationMode::TestMode,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this meant to be in testmode in production too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

let mut error_code = String::new();
let mut error_reason = String::new();
for val in item.response.messages.message.iter() {
error_code.push_str(&val.code);
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 use map(), iter() and collect() instead ?

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

srujanchikke
srujanchikke previously approved these changes May 22, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 8afeda5 May 22, 2024
10 checks passed
@likhinbopanna likhinbopanna deleted the adn-zero-mandate branch May 22, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [AUTHORIZEDOTNET] Implement zero mandates
4 participants