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): [Novalnet] add webhooks for card #6033

Merged
merged 17 commits into from
Oct 8, 2024
Merged

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Sep 25, 2024

Type of Change

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

Description

  1. Implemented webhooks
  2. Fix for u16 deserialization error
  3. Fix for discrepancies in structs

Additional Changes

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

Motivation and Context

https://github.com/juspay/hyperswitch-cloud/issues/6806

How did you test it?

Tested the change manually for the following flows

  1. Automatic Capture
  2. Manual Capture
  3. Refunds
  4. Cancel

@Gnanasundari24 @likhinbopanna

For setting up source verificiation key, MCA cURL:

curl --location --request POST 'http://localhost:8080/account/merchant_1728025936/connectors' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: test_admin' \ --data-raw '{ "connector_type": "payment_processor", "connector_name": "novalnet", "connector_account_details": { "auth_type": "SignatureKey", "api_key": "7ibc7ob5|tuJEH3gNbeWJfIHah||nbobljbnmdli0poys|doU3HJVoym7MQ44qf7cpn7pc", "key1": "a87ff679a2f3e71d9181a67b7542122c", "api_secret": "10004" }, "test_mode": true, "disabled": false, "payment_methods_enabled": [ { "payment_method": "card", "payment_method_types": [ { "payment_method_type": "credit", "card_networks": [ "Visa", "Mastercard" ], "minimum_amount": 1, "maximum_amount": 68607706, "recurring_enabled": true, "installment_payment_enabled": true }, { "payment_method_type": "debit", "card_networks": [ "Visa", "Mastercard" ], "minimum_amount": 1, "maximum_amount": 68607706, "recurring_enabled": true, "installment_payment_enabled": true } ] }, { "payment_method": "wallet", "payment_method_types": [ { "payment_method_type": "paypal", "payment_experience": "redirect_to_url", "minimum_amount": 1, "maximum_amount": 68607706, "recurring_enabled": false, "installment_payment_enabled": false }, { "payment_method_type": "google_pay", "payment_experience": "redirect_to_url", "card_networks": null, "accepted_currencies": null, "accepted_countries": null, "minimum_amount": 0, "maximum_amount": 68607706, "recurring_enabled": true, "installment_payment_enabled": false } ] } ], "connector_webhook_details": { "merchant_secret": "a87ff679a2f3e71d9181a67b7542122c", "additional_secret": null }, "metadata": { "city": "Musterhausen", "unit": "245", "brand_id": "001" }, "business_country": "DE", "business_label": "food" }'

Outgoing webhooks body

1. Automatic Capture

{
    "merchant_id": "merchant_1728376939",
    "event_id": "evt_01926b6009ec7ba2a0a349a4229e525e",
    "event_type": "payment_succeeded",
    "content": {
        "type": "payment_details",
        "object": {
            "payment_id": "pay_dqOrPXUCMXHnfNN8sawU",
            "merchant_id": "merchant_1728376939",
            "status": "succeeded",
            "amount": 10000,
            "net_amount": 10000,
            "amount_capturable": 0,
            "amount_received": 10000,
            "connector": "novalnet",
            "client_secret": "pay_dqOrPXUCMXHnfNN8sawU_secret_ddpeGw6lNa6rSCrBiIeg",
            "created": "2024-10-08T09:04:49.787Z",
            "currency": "EUR",
            "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": null,
            "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_extended_bin": null,
                    "card_exp_month": "12",
                    "card_exp_year": "2025",
                    "card_holder_name": null,
                    "payment_checks": null,
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": null,
            "shipping": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "Musterstr",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            },
            "billing": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "1467",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "12345",
                    "state": "California",
                    "first_name": "Max",
                    "last_name": "Mustermann"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "test@novalnet.de"
            },
            "order_details": null,
            "email": "guest@example.com",
            "name": "John Doe",
            "phone": "999999999",
            "return_url": "https://google.com/",
            "authentication_type": "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": "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": "15044000045111625",
            "frm_message": null,
            "metadata": {
                "udf1": "value1",
                "login_date": "2019-09-10T10:11:12Z",
                "new_customer": "true"
            },
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": "15044000045111625",
            "payment_link": null,
            "profile_id": "pro_w96JcNqbyiYs94eLhLyP",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_r9XaAAw8ZosY8u8kntha",
            "incremental_authorization_allowed": null,
            "authorization_count": null,
            "incremental_authorizations": null,
            "external_authentication_details": null,
            "external_3ds_authentication_attempted": false,
            "expires_on": "2024-10-08T09:19:49.787Z",
            "fingerprint": null,
            "browser_info": {
                "language": "nl-NL",
                "time_zone": 0,
                "ip_address": "103.77.139.95",
                "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",
                "color_depth": 24,
                "java_enabled": true,
                "screen_width": 1536,
                "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8",
                "screen_height": 723,
                "java_script_enabled": true
            },
            "payment_method_id": null,
            "payment_method_status": null,
            "updated": "2024-10-08T09:05:09.080Z",
            "charges": null,
            "frm_metadata": null,
            "merchant_order_reference_id": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        }
    },
    "timestamp": "2024-10-08T09:05:09.100Z"
}

2. Manual Capture

{
    "merchant_id": "merchant_1728376939",
    "event_id": "evt_01926b5278187ff1a150e490413e3edd",
    "event_type": "payment_authorized",
    "content": {
        "type": "payment_details",
        "object": {
            "payment_id": "pay_96OBZbMpWNCRZ0jT162z",
            "merchant_id": "merchant_1728376939",
            "status": "requires_capture",
            "amount": 10000,
            "net_amount": 10000,
            "amount_capturable": 10000,
            "amount_received": null,
            "connector": "novalnet",
            "client_secret": "pay_96OBZbMpWNCRZ0jT162z_secret_Jxo77vf88Za491dKge78",
            "created": "2024-10-08T08:49:27.095Z",
            "currency": "EUR",
            "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": null,
            "off_session": null,
            "capture_on": null,
            "capture_method": "manual",
            "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_extended_bin": null,
                    "card_exp_month": "12",
                    "card_exp_year": "2025",
                    "card_holder_name": null,
                    "payment_checks": null,
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": null,
            "shipping": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "Musterstr",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            },
            "billing": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "1467",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "12345",
                    "state": "California",
                    "first_name": "Max",
                    "last_name": "Mustermann"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "test@novalnet.de"
            },
            "order_details": null,
            "email": "guest@example.com",
            "name": "John Doe",
            "phone": "999999999",
            "return_url": "https://google.com/",
            "authentication_type": "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": "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": "15044000043616722",
            "frm_message": null,
            "metadata": {
                "udf1": "value1",
                "login_date": "2019-09-10T10:11:12Z",
                "new_customer": "true"
            },
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": "15044000043616722",
            "payment_link": null,
            "profile_id": "pro_w96JcNqbyiYs94eLhLyP",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_r9XaAAw8ZosY8u8kntha",
            "incremental_authorization_allowed": null,
            "authorization_count": null,
            "incremental_authorizations": null,
            "external_authentication_details": null,
            "external_3ds_authentication_attempted": false,
            "expires_on": "2024-10-08T09:04:27.094Z",
            "fingerprint": null,
            "browser_info": {
                "language": "nl-NL",
                "time_zone": 0,
                "ip_address": "103.77.139.95",
                "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",
                "color_depth": 24,
                "java_enabled": true,
                "screen_width": 1536,
                "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8",
                "screen_height": 723,
                "java_script_enabled": true
            },
            "payment_method_id": null,
            "payment_method_status": null,
            "updated": "2024-10-08T08:50:19.790Z",
            "charges": null,
            "frm_metadata": null,
            "merchant_order_reference_id": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        }
    },
    "timestamp": "2024-10-08T08:50:19.800Z"
}
{
    "merchant_id": "merchant_1728376939",
    "event_id": "evt_01926b597b6e7e708b8423442f00ce5a",
    "event_type": "payment_succeeded",
    "content": {
        "type": "payment_details",
        "object": {
            "payment_id": "pay_96OBZbMpWNCRZ0jT162z",
            "merchant_id": "merchant_1728376939",
            "status": "succeeded",
            "amount": 10000,
            "net_amount": 10000,
            "amount_capturable": 0,
            "amount_received": 10000,
            "connector": "novalnet",
            "client_secret": "pay_96OBZbMpWNCRZ0jT162z_secret_Jxo77vf88Za491dKge78",
            "created": "2024-10-08T08:49:27.095Z",
            "currency": "EUR",
            "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": null,
            "off_session": null,
            "capture_on": null,
            "capture_method": "manual",
            "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_extended_bin": null,
                    "card_exp_month": "12",
                    "card_exp_year": "2025",
                    "card_holder_name": null,
                    "payment_checks": null,
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": null,
            "shipping": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "Musterstr",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            },
            "billing": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "1467",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "12345",
                    "state": "California",
                    "first_name": "Max",
                    "last_name": "Mustermann"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "test@novalnet.de"
            },
            "order_details": null,
            "email": "guest@example.com",
            "name": "John Doe",
            "phone": "999999999",
            "return_url": "https://google.com/",
            "authentication_type": "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": "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": "15044000043616722",
            "frm_message": null,
            "metadata": {
                "udf1": "value1",
                "login_date": "2019-09-10T10:11:12Z",
                "new_customer": "true"
            },
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": "15044000043616722",
            "payment_link": null,
            "profile_id": "pro_w96JcNqbyiYs94eLhLyP",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_r9XaAAw8ZosY8u8kntha",
            "incremental_authorization_allowed": null,
            "authorization_count": null,
            "incremental_authorizations": null,
            "external_authentication_details": null,
            "external_3ds_authentication_attempted": false,
            "expires_on": "2024-10-08T09:04:27.094Z",
            "fingerprint": null,
            "browser_info": {
                "language": "nl-NL",
                "time_zone": 0,
                "ip_address": "103.77.139.95",
                "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",
                "color_depth": 24,
                "java_enabled": true,
                "screen_width": 1536,
                "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8",
                "screen_height": 723,
                "java_script_enabled": true
            },
            "payment_method_id": null,
            "payment_method_status": null,
            "updated": "2024-10-08T08:57:59.389Z",
            "charges": null,
            "frm_metadata": null,
            "merchant_order_reference_id": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        }
    },
    "timestamp": "2024-10-08T08:57:59.406Z"
}

3. Refund

{
    "merchant_id": "merchant_1728376939",
    "event_id": "evt_01926b5e520274a3a548833b02693def",
    "event_type": "refund_succeeded",
    "content": {
        "type": "refund_details",
        "object": {
            "refund_id": "ref_JRDFCLYzTnz1FEBs5Fgg",
            "payment_id": "pay_96OBZbMpWNCRZ0jT162z",
            "amount": 10000,
            "currency": "EUR",
            "status": "succeeded",
            "reason": "Customer returned product",
            "metadata": {
                "udf1": "value1",
                "new_customer": "true",
                "login_date": "2019-09-10T10:11:12Z"
            },
            "error_message": null,
            "error_code": null,
            "created_at": "2024-10-08T09:02:51.621Z",
            "updated_at": "2024-10-08T09:03:16.480Z",
            "connector": "novalnet",
            "profile_id": "pro_w96JcNqbyiYs94eLhLyP",
            "merchant_connector_id": "mca_r9XaAAw8ZosY8u8kntha",
            "charges": null
        }
    },
    "timestamp": "2024-10-08T09:03:16.483Z"
}

4. Cancel

{
    "merchant_id": "merchant_1728376939",
    "event_id": "evt_01926b62f4807a909c32d832bfa0186e",
    "event_type": "payment_cancelled",
    "content": {
        "type": "payment_details",
        "object": {
            "payment_id": "pay_ip4elFgLhUCS7b6W18AL",
            "merchant_id": "merchant_1728376939",
            "status": "cancelled",
            "amount": 10000,
            "net_amount": 10000,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "novalnet",
            "client_secret": "pay_ip4elFgLhUCS7b6W18AL_secret_qbNmC94838Q0ubD7wm5c",
            "created": "2024-10-08T09:07:16.753Z",
            "currency": "EUR",
            "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": null,
            "off_session": null,
            "capture_on": null,
            "capture_method": "manual",
            "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_extended_bin": null,
                    "card_exp_month": "12",
                    "card_exp_year": "2025",
                    "card_holder_name": null,
                    "payment_checks": null,
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": null,
            "shipping": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "Musterstr",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            },
            "billing": {
                "address": {
                    "city": "Musterhausen",
                    "country": "DE",
                    "line1": "1467",
                    "line2": "CA",
                    "line3": "CA",
                    "zip": "12345",
                    "state": "California",
                    "first_name": "Max",
                    "last_name": "Mustermann"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "test@novalnet.de"
            },
            "order_details": null,
            "email": "guest@example.com",
            "name": "John Doe",
            "phone": "999999999",
            "return_url": "https://google.com/",
            "authentication_type": "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": "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": "15044000045217111",
            "frm_message": null,
            "metadata": {
                "udf1": "value1",
                "login_date": "2019-09-10T10:11:12Z",
                "new_customer": "true"
            },
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": "15044000045217111",
            "payment_link": null,
            "profile_id": "pro_w96JcNqbyiYs94eLhLyP",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_r9XaAAw8ZosY8u8kntha",
            "incremental_authorization_allowed": null,
            "authorization_count": null,
            "incremental_authorizations": null,
            "external_authentication_details": null,
            "external_3ds_authentication_attempted": false,
            "expires_on": "2024-10-08T09:22:16.753Z",
            "fingerprint": null,
            "browser_info": {
                "language": "nl-NL",
                "time_zone": 0,
                "ip_address": "103.77.139.95",
                "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",
                "color_depth": 24,
                "java_enabled": true,
                "screen_width": 1536,
                "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8",
                "screen_height": 723,
                "java_script_enabled": true
            },
            "payment_method_id": null,
            "payment_method_status": null,
            "updated": "2024-10-08T09:07:46.667Z",
            "charges": null,
            "frm_metadata": null,
            "merchant_order_reference_id": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        }
    },
    "timestamp": "2024-10-08T09:08:20.225Z"
}

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

@cookieg13 cookieg13 added A-connector-integration Area: Connector integration R-waiting-on-L1 Review: Waiting on L1 reviewer labels Sep 25, 2024
@cookieg13 cookieg13 self-assigned this Sep 25, 2024
@cookieg13 cookieg13 requested a review from a team as a code owner September 25, 2024 18:12
Copy link

semanticdiff-com bot commented Sep 25, 2024

Review changes with SemanticDiff.

Analyzed 2 of 5 files.

Overall, the semantic diff is 10% smaller than the GitHub diff.

Filename Status
✔️ crates/hyperswitch_connectors/src/connectors/novalnet.rs 1.47% smaller
✔️ crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs 15.62% smaller
crates/connector_configs/toml/development.toml Unsupported file format
crates/connector_configs/toml/production.toml Unsupported file format
crates/connector_configs/toml/sandbox.toml Unsupported file format

@cookieg13 cookieg13 added the C-feature Category: Feature request or enhancement label Sep 25, 2024
pub vendor: u32,
pub project: Option<i64>,
pub project_name: Option<String>,
pub project_url: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the significance of this url, Can we also have this type as url::Url

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 related to the merchant's project url, it should be configurable in the novalnet dashboard

Comment on lines 850 to 851
let notif = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please throw appropriate error here

Comment on lines 880 to 874
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
Ok(Box::new(notif))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
Ok(Box::new(notif))
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?;
Ok(Box::new(notif))

.unwrap_or("".to_string());

let secret_auth = String::from_utf8(connector_webhook_secrets.secret.to_vec())
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
.change_context(errors::ConnectorError::WebhookVerificationSecretInvalid)

}
#[derive(Serialize, Deserialize, Debug)]
pub struct NovalnetWebhookNotificationResponse {
pub customer: Option<NovalnetResponseCustomer>,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we consume all the fields in response ? like customer from webhooks body, if not can you remove them?

Comment on lines 830 to 820
api_models::webhooks::RefundIdType::ConnectorRefundId(parent_tid.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.

what is parent_tid here ? connector refund id or connector transaction id?

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum NovalnetWebhookTransactionData {
OtherTransactionData(NovalnetSyncResponseTransactionData),
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 rename this field better ?

NovalnetTransactionStatus::OnHold => {
IncomingWebhookEvent::PaymentIntentAuthorizationSuccess
}
NovalnetTransactionStatus::Pending | NovalnetTransactionStatus::Progress => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We get progress incase of authentication pending in payments response, are you sure you want to update this to Processing ?

@cookieg13 cookieg13 requested a review from a team as a code owner September 26, 2024 19:10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

made changes in this file due to warning thrown by cargo clippy

@@ -311,7 +312,8 @@ pub enum NovalnetTransactionStatus {
}

#[derive(Debug, Copy, Display, Clone, Default, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[strum(serialize_all = "UPPERCASE")]
#[serde(rename_all = "UPPERCASE")]
pub enum NovalnetAPIStatus {
Success,
#[default]
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also remove defaults in status enums

@cookieg13 cookieg13 force-pushed the novalnetWebhooks branch 2 times, most recently from ab4d2df to d3d34d4 Compare September 27, 2024 18:20
srujanchikke
srujanchikke previously approved these changes Oct 1, 2024
Copy link
Contributor

@sai-harsha-vardhan sai-harsha-vardhan left a comment

Choose a reason for hiding this comment

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

We need to implement get_dispute_details for chargeback webhooks. Please test the dispute webhooks too cc: @srujanchikke

fn get_webhook_object_from_body(
body: &[u8],
) -> CustomResult<novalnet::NovalnetWebhookNotificationResponse, errors::ConnectorError> {
let novalnet_webhook_notification_response = std::str::from_utf8(body)
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 instead use parse_struct from common_utils here?

@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 8, 2024
Merged via the queue into main with commit d61ebef Oct 8, 2024
41 checks passed
@likhinbopanna likhinbopanna deleted the novalnetWebhooks branch October 8, 2024 09:47
@SanchithHegde SanchithHegde removed the R-waiting-on-L1 Review: Waiting on L1 reviewer label Oct 13, 2024
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.

5 participants