Skip to content

feat(connector): [Moneris] Implement mandate for Moneris#7322

Merged
likhinbopanna merged 7 commits intomainfrom
moneris-mandate
Mar 5, 2025
Merged

feat(connector): [Moneris] Implement mandate for Moneris#7322
likhinbopanna merged 7 commits intomainfrom
moneris-mandate

Conversation

@swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Feb 19, 2025

Type of Change

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

Description

Implement mandate for Moneris Card

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?

  1. Create Merchant Account
  2. Create API Key
  3. Create Moneris Connector
curl --location 'http://localhost:8080/account/merchant_1739967523/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "moneris",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "____",
        "key1": "__",
        "api_secret": "____"
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
                {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "AmericanExpress",
                        "Discover",
                        "Interac",
                        "JCB",
                        "Mastercard",
                        "Visa",
                        "DinersClub",
                        "UnionPay",
                        "RuPay"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "AmericanExpress",
                        "Discover",
                        "Interac",
                        "JCB",
                        "Mastercard",
                        "Visa",
                        "DinersClub",
                        "UnionPay",
                        "RuPay"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "connector_webhook_details": {
        "merchant_secret": "dce1d767-7c28-429c-b0fe-9e0b9e91f962"
    },
    "business_country": "US",
    "business_label": "food"
}'
  1. Create Moneris Card Payment (CIT)
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ____' \
--data-raw '{
    "amount": 5000,
    "currency": "USD",
    "confirm": true,
      "capture_method": "automatic",
      "capture_on": "2022-09-10T10:11:12Z",
      "amount_to_capture": 5000,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
      "authentication_type": "no_three_ds",
    "return_url": "https://www.google.com/",
    "payment_method": "card",
    "payment_method_type": "debit",
     "setup_future_usage": "off_session",
      "customer_acceptance": {
        "acceptance_type": "offline"
    },
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "card_exp_year": "28",
            "card_holder_name": "John",
            "card_cvc": "123"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "DE",
            "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": "DE",
            "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"
    }
}

Response

{
    "payment_id": "pay_7UP5gdycrXM3KW3YIUKB",
    "merchant_id": "merchant_1739967523",
    "status": "succeeded",
    "amount": 5000,
    "net_amount": 5000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 5000,
    "connector": "moneris",
    "client_secret": "pay_7UP5gdycrXM3KW3YIUKB_secret_u0DswE5N9JpuJlCXLcwy",
    "created": "2025-02-19T13:25:20.144Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "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": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "01",
            "card_exp_year": "28",
            "card_holder_name": "John",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "DE",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "DE",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://www.google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1739971520,
        "expires": 1739975120,
        "secret": "epk_77384504322540bea2c5f5278ef14a40"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi0001JMF64VDBD6K3EPRXS459JWPX",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi0001JMF64VDBD6K3EPRXS459JWPX",
    "payment_link": null,
    "profile_id": "pro_x31oMVWgJJBwVNXsjTBd",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_equI7KeYE9FM2OBeSJAo",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-19T13:40:20.144Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_LibSbChx3ELq8WvTZbIr",
    "payment_method_status": "active",
    "updated": "2025-02-19T13:25:23.064Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm0001JMF64VEB71ERCKXWBJJ20G1R",
    "card_discovery": "manual"
}
  1. Create a Payment Request using payment_method_id (MIT)
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ____' \
--data '{
    "amount": 77000,
    "currency": "USD",
    "confirm": true,
    "customer_id": "StripeCustomer",
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_LibSbChx3ELq8WvTZbIr"
    },
    "off_session": true
}'

Response

{
    "payment_id": "pay_jMUZOfWDGPeUXheKhzTx",
    "merchant_id": "merchant_1739967523",
    "status": "succeeded",
    "amount": 77000,
    "net_amount": 77000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 77000,
    "connector": "moneris",
    "client_secret": "pay_jMUZOfWDGPeUXheKhzTx_secret_CQC1uJBCsIstN30YsIoP",
    "created": "2025-02-19T13:31:45.833Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "01",
            "card_exp_year": "28",
            "card_holder_name": "John",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1739971905,
        "expires": 1739975505,
        "secret": "epk_6c1f970404204fa891890bedb1373b88"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi0001JMF6GKSPZNEYR39MDTYC39DN",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi0001JMF6GKSPZNEYR39MDTYC39DN",
    "payment_link": null,
    "profile_id": "pro_x31oMVWgJJBwVNXsjTBd",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_equI7KeYE9FM2OBeSJAo",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-19T13:46:45.833Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_LibSbChx3ELq8WvTZbIr",
    "payment_method_status": "active",
    "updated": "2025-02-19T13:31:48.362Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm0001JMF64VEB71ERCKXWBJJ20G1R",
    "card_discovery": "manual"
}

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

@swangi-kumari swangi-kumari added A-connector-compatibility Area: Connector compatibility C-feature Category: Feature request or enhancement labels Feb 19, 2025
@swangi-kumari swangi-kumari self-assigned this Feb 19, 2025
@swangi-kumari swangi-kumari requested a review from a team as a code owner February 19, 2025 14:12
@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 19, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/moneris/transformers.rs  12% smaller
  crates/hyperswitch_connectors/src/connectors/moneris.rs  1% smaller

#[serde(rename_all = "camelCase")]
pub struct PaymentMethodId {
payment_method_source: PaymentMethodSource,
payment_method_id: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this secret.

#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MonerisPaymentMethodData {
payment_method_id: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this secret.

@swangi-kumari swangi-kumari requested a review from a team as a code owner February 24, 2025 08:32
@swangi-kumari swangi-kumari removed the request for review from a team February 24, 2025 09:55
Comment on lines +182 to +188
store_payment_method: match item.router_data.request.setup_future_usage {
Some(setup_future_usage) => match setup_future_usage {
enums::FutureUsage::OffSession => StorePaymentMethod::MerchantInitiated,
enums::FutureUsage::OnSession => StorePaymentMethod::DoNotStore,
},
None => StorePaymentMethod::DoNotStore,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we passing store_payment_method in mandate payments?

@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 5, 2025
Merged via the queue into main with commit ba84b00 Mar 5, 2025
17 of 20 checks passed
@likhinbopanna likhinbopanna deleted the moneris-mandate branch March 5, 2025 12:25
pixincreate added a commit that referenced this pull request Mar 7, 2025
…juspay/hyperswitch into connector/gpay-mandates-authorizedotnet

* 'connector/gpay-mandates-authorizedotnet' of github.com:juspay/hyperswitch: (25 commits)
  ci(cypress): address lints and refactor redirection handler (#7437)
  chore: make v1 merchant account forward compatible (#7426)
  fix(dashboard): Added auth key to juspay threeds server (#7457)
  feat(hipay): Add Template PR (#7360)
  chore(version): 2025.03.07.0
  chore(postman): update Postman collection files
  feat(analytics): add new filters, dimensions and metrics for authentication analytics (#7451)
  feat(router): add capability to force challenge for 3DS Payments through Netcetera and send few optional fields (#7429)
  feat(analytics): refactor and rewrite authentication related analytics (#7433)
  refactor(core): Added payment id in authentication router data (#7441)
  feat(connector): Added ThreeDs server integration template pr (#7424)
  fix(xendit): Fix wasm changes (#7419)
  chore(postman): postman tests fixes (#7159)
  ci(cypress): move customer acceptance in configs to a const within commons (#7435)
  feat(core): add additional revenue recovery call flow (#7402)
  chore(version): 2025.03.06.0
  feat(payment_link): expose payment link configs for SDK UI rules and payment button (#7427)
  feat(connector): [EFT] Add EFT as a payment method (#7304)
  chore(version): 2025.03.05.1
  feat(connector): [Moneris] Implement mandate for Moneris (#7322)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-connector-compatibility Area: Connector compatibility C-feature Category: Feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants