Skip to content

feat(connector): [payload] add webhook support #8558

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

Merged
merged 10 commits into from
Jul 11, 2025

Conversation

pixincreate
Copy link
Member

@pixincreate pixincreate commented Jul 6, 2025

Type of Change

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

Description

This PR:

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables
  1. crates/connector_configs/toml/development.toml
  2. crates/connector_configs/toml/production.toml
  3. crates/connector_configs/toml/sandbox.toml

Motivation and Context

Closes #8557

How did you test it?

Setup Webhooks in Merchant Account
curl --location 'https://pix-mbp.orthrus-monster.ts.net/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "merchant_id": "postman_merchant_GHAction_1751796781",
    "locker_id": "m0010",
    "merchant_name": "NewAge Retailer",
    "merchant_details": {
        "primary_contact_person": "John Test",
        "primary_email": "[email protected]",
        "primary_phone": "sunt laborum",
        "secondary_contact_person": "John Test2",
        "secondary_email": "[email protected]",
        "secondary_phone": "cillum do dolor id",
        "website": "www.example.com",
        "about_business": "Online Retail with a wide selection of organic products for North America"
        ,
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US"
        }
    },
    "return_url": "https://duck.com",
    "webhook_details": {
        "webhook_url": "https://webhook.site/02225e46-1016-4c2c-a492-efaaa5d41cf3",
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123"
    },
    "sub_merchants_enabled": false,
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "primary_business_details": [
        {
            "country": "US",
            "business": "default"
        }
    ]
}'
{
    "merchant_id": "postman_merchant_GHAction_1751738744",
    "merchant_name": "NewAge Retailer",
    "return_url": "https://duck.com/",
    "enable_payment_response_hash": true,
    "payment_response_hash_key": "wsJ8BLD1TuNdKjCCMpoonWCJduaS9CT1EperKUJVLOQftECdAK7d4a7otMdv2EMq",
    "redirect_to_merchant_with_http_post": false,
    "merchant_details": {
        "primary_contact_person": "John Test",
        "primary_phone": "sunt laborum",
        "primary_email": "[email protected]",
        "secondary_contact_person": "John Test2",
        "secondary_phone": "cillum do dolor id",
        "secondary_email": "[email protected]",
        "website": "www.example.com",
        "about_business": "Online Retail with a wide selection of organic products for North America",
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": null,
            "last_name": null
        }
    },
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "webhook_url": "https://webhook.site/02225e46-1016-4c2c-a492-efaaa5d41cf3",
        "payment_created_enabled": null,
        "payment_succeeded_enabled": null,
        "payment_failed_enabled": null,
        "payment_statuses_enabled": null,
        "refund_statuses_enabled": null,
        "payout_statuses_enabled": null
    },
    "payout_routing_algorithm": null,
    "sub_merchants_enabled": false,
    "parent_merchant_id": null,
    "publishable_key": "pk_dev_4ab91f8e35424d11acdd8c639a974f0c",
    "metadata": {
        "city": "NY",
        "unit": "245",
        "compatible_connector": null
    },
    "locker_id": "m0010",
    "primary_business_details": [
        {
            "country": "US",
            "business": "default"
        }
    ],
    "frm_routing_algorithm": null,
    "organization_id": "org_oZUZY7YEM9gts3EC4kbC",
    "is_recon_enabled": false,
    "default_profile": "pro_ZVgp4CWyKZKnx99AD7BL",
    "recon_status": "not_requested",
    "pm_collect_link_config": null,
    "product_type": "orchestration",
    "merchant_account_type": "standard"
}
Setup Webhooks at Connector's end below commands by referring to the [trigger docs](https://docs.payload.com/apis/webhooks/triggers/)
curl --location 'https://api.payload.com/webhooks/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: api_key' \
--data-urlencode 'trigger=processed' \
--data-urlencode 'url=<base_url>/webhooks/<merchant_id>/<mca_id/connector_name>'
{
    "attrs": null,
    "created_at": "Sun, 06 Jul 2025 07:24:29 GMT",
    "id": "<webhook_id>",
    "modified_at": "Sun, 06 Jul 2025 07:24:29 GMT",
    "oauth_params": null,
    "object": "webhook",
    "retries": 0,
    "trigger": "processed",
    "url": "<base_url>/webhooks/<merchant_id>/<mca_id/connector_name>"
}
Make Payment
curl --location 'https://pix-mbp.orthrus-monster.ts.net/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Accept-Language: ja' \
--header 'api-key: dev_PCJYsjpYCN6C9ECuYT5g9LR1epAx5Jeqc7WpsXzoxpTbCcHqSqJ5CdUPnxdEh29y' \
--data-raw '{
    "amount": 40,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 40,
    "customer_id": "customer",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "Joseph Doe",
            "card_cvc": "123"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US"
            ,
            "first_name": "PiX"
            ,
            "last_name": "THE"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "browser_info": {
        "color_depth": 24,
        "java_enabled": true,
        "java_script_enabled": true,
        "language": "en-GB",
        "screen_height": 720,
        "screen_width": 1280,
        "time_zone": -330,
        "ip_address": "208.127.127.193",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
    }
}'
{
    "payment_id": "pay_IMknbnvAK8MSCd1WXmrI",
    "merchant_id": "postman_merchant_GHAction_1751797139",
    "status": "succeeded",
    "amount": 40,
    "net_amount": 40,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 40,
    "connector": "payload",
    "client_secret": "pay_IMknbnvAK8MSCd1WXmrI_secret_Gj1Vtt77ai6KPzJ5AGHC",
    "created": "2025-07-06T10:20:56.697Z",
    "currency": "USD",
    "customer_id": "customer",
    "customer": {
        "id": "customer",
        "name": null,
        "email": "[email protected]",
        "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": "1111",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "JP Morgan",
            "card_issuing_country": "INDIA",
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "Joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "THE"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": null,
    "phone": "999999999",
    "return_url": "https://duck.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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer",
        "created_at": 1751797256,
        "expires": 1751800856,
        "secret": "epk_d97417b2937b49a98be4f3bab68e34b1"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "txn_3ephQ2TpDLsQSnekEK1a8",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "PL-M3P-9HY-9T7",
    "payment_link": null,
    "profile_id": "pro_VaPL7y7qI4IY0F9cvRU2",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_KOpDieOFRmWvh26OJ9OH",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-06T10:35:56.697Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-GB",
        "time_zone": -330,
        "ip_address": "208.127.127.193",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1280,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 720,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-07-06T10:20:57.632Z",
    "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": null,
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null
}
Check website for outgoing webhooks image
Check logs for incoming webhooks image image
Cypress

19 failures is because the connector marked them as duplicate even with 15 seconds timeout.

image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by just clippy && just clippy_v2
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@pixincreate pixincreate added this to the June 2025 Release milestone Jul 6, 2025
@pixincreate pixincreate self-assigned this Jul 6, 2025
@pixincreate pixincreate requested review from a team as code owners July 6, 2025 10:29
@pixincreate pixincreate added A-CI-CD Area: Continuous Integration/Deployment A-connector-integration Area: Connector integration C-bug Category: Bug C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Jul 6, 2025
Copy link

semanticdiff-com bot commented Jul 6, 2025

@pixincreate pixincreate force-pushed the connector/payload-webhooks branch from bf12adb to fdf166f Compare July 6, 2025 10:44
@pixincreate pixincreate requested a review from a team as a code owner July 7, 2025 11:17
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jul 8, 2025
@deepanshu-iiitu deepanshu-iiitu self-requested a review July 8, 2025 08:35
…ayload-webhooks

* 'main' of github.com:juspay/hyperswitch:
  refactor(connector): Move connector mappings and endpoints to dedicated modules (#8562)
  ci(cypress): fix `hipay` test cases (#8563)
  chore(version): 2025.07.09.0
  fix(payment_method): update entity id used for Vault to global customer id (#8380)
  refactor(routing): add conditional check for invoking DE routing flows (#8559)
  feat(connector): [AUTHIPAY] Integrate cards non 3ds payments (#8266)
  ci(cypress): add payu connector (#8567)
  feat(connector): [silverflow] template code (#8553)
  chore(version): 2025.07.08.0
  feat(cypress): [worldpayvantiv] add cypress test (#8234)
  feat(connectors): [worldpayvantiv] add connector mandate support  (#8546)
  feat(connector): [Celero] add Connector Template Code (#8489)
  feat(payment-methods): create payment_token in vault confirm / do payment-confirm with temp token from session (#8525)
  ci(cypress): Add Tsys,Square cypress test (#8543)
  chore(version): 2025.07.07.0
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 11, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 11, 2025
Merged via the queue into main with commit 2fe3132 Jul 11, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the connector/payload-webhooks branch July 11, 2025 12:58
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jul 11, 2025
@pixincreate pixincreate restored the connector/payload-webhooks branch July 11, 2025 16:14
pixincreate added a commit that referenced this pull request Jul 11, 2025
…ayload-webhooks

* 'main' of github.com:juspay/hyperswitch:
  feat(payments): propagate additional payment method data for apple pay during MIT (#7170)
  feat(core): Hyperswitch <|> UCS integration v2 (#8439)
  feat(connector): [payload] add webhook support (#8558)
  ci(cypress): Added Dlocal Connector Test (#8362)
  feat(connector): [AIRWALLEX] - Added Paypal, Trustly, Klarna , Atome, Blik Payment Methods (#8475)
  refactor(cypress): update skip logic and test flow for cypress incremental auth tests (#8594)
  chore(version): 2025.07.11.0
  chore: address Rust 1.88.0 clippy lints (#8607)
  chore(version): 2025.07.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CI-CD Area: Continuous Integration/Deployment A-connector-integration Area: Connector integration C-bug Category: Bug C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [CONNECTOR: PAYLOAD] Add Webhook support
5 participants