WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@pixincreate
Copy link
Member

@pixincreate pixincreate commented Dec 4, 2025

Type of Change

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

Description

this is a minor refactor to use the existing util functions instead of re-inventing the wheel

Additional Changes

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

Motivation and Context

while working on ucs, observed this.

How did you test it?

psync and rsync should not be affected:

Payment
curl --location 'https://pix-mbp.orthrus-monster.ts.net/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_ZJJRGSQCryeRipWRWkDnjhse5GplWfj4iBoNZx5LA9yJdXezoXgJTmARbXOwxodz' \
--data-raw '{
    "amount": 60159,
	
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "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": "26",
            "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_BrlKK94mKFH3wP5Vmv1A",
	"merchant_id": "postman_merchant_GHAction_1765219033",
	"status": "succeeded",
	"amount": 60159,
	"net_amount": 60159,
	"shipping_cost": null,
	"amount_capturable": 0,
	"amount_received": 60159,
	"connector": "payload",
	"client_secret": "pay_BrlKK94mKFH3wP5Vmv1A_secret_yNl4ulRKiBsBQVuH1wvQ",
	"created": "2025-12-08T18:37:26.789Z",
	"modified_at": "2025-12-08T18:37:29.407Z",
	"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": "26",
			"card_holder_name": "Joseph Doe",
			"payment_checks": {
				"avs_result": "street_and_zip"
			},
			"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,
			"origin_zip": 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",
			"origin_zip": null
		},
		"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": 1765219046,
		"expires": 1765222646,
		"secret": "epk_406f0b86642641c0a32a6767e4803852"
	},
	"manual_retry_allowed": null,
	"connector_transaction_id": "txn_3f3D5P0q3P2t5nqOMJwDT",
	"frm_message": null,
	"metadata": {
		"udf1": "value1",
		"login_date": "2019-09-10T10:11:12Z",
		"new_customer": "true"
	},
	"connector_metadata": null,
	"feature_metadata": {
		"redirect_response": null,
		"search_tags": null,
		"apple_pay_recurring_details": null,
		"gateway_system": "direct"
	},
	"reference_id": "PL-UMV-PCV-TF5",
	"payment_link": null,
	"profile_id": "pro_3V2idKMuFgUCTiOjFUM0",
	"surcharge_details": null,
	"attempt_count": 1,
	"merchant_decision": null,
	"merchant_connector_id": "mca_LJWkcQEbnAOXgJ4WJZV0",
	"incremental_authorization_allowed": false,
	"authorization_count": null,
	"incremental_authorizations": null,
	"external_authentication_details": null,
	"external_3ds_authentication_attempted": false,
	"expires_on": "2025-12-08T18:52:26.789Z",
	"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_channel": null,
	"payment_method_id": null,
	"network_transaction_id": null,
	"payment_method_status": null,
	"updated": "2025-12-08T18:37:29.407Z",
	"split_payments": null,
	"frm_metadata": null,
	"extended_authorization_applied": null,
	"extended_authorization_last_applied_at": null,
	"request_extended_authorization": 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,
	"enable_partial_authorization": null,
	"enable_overcapture": null,
	"is_overcapture_enabled": null,
	"network_details": null,
	"is_stored_credential": null,
	"mit_category": null,
	"billing_descriptor": null,
	"tokenization": null,
	"partner_merchant_identifier_details": null,
	"payment_method_tokenization_details": null
}
PSync
curl --location 'https://pix-mbp.orthrus-monster.ts.net/payments/pay_BrlKK94mKFH3wP5Vmv1A?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_ZJJRGSQCryeRipWRWkDnjhse5GplWfj4iBoNZx5LA9yJdXezoXgJTmARbXOwxodz'
{
	"payment_id": "pay_BrlKK94mKFH3wP5Vmv1A",
	"merchant_id": "postman_merchant_GHAction_1765219033",
	"status": "succeeded",
	"amount": 60159,
	"net_amount": 60159,
	"shipping_cost": null,
	"amount_capturable": 0,
	"amount_received": 60159,
	"connector": "payload",
	"client_secret": "pay_BrlKK94mKFH3wP5Vmv1A_secret_yNl4ulRKiBsBQVuH1wvQ",
	"created": "2025-12-08T18:37:26.789Z",
	"modified_at": "2025-12-08T18:37:29.407Z",
	"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": "26",
			"card_holder_name": "Joseph Doe",
			"payment_checks": {
				"avs_result": "street_and_zip"
			},
			"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,
			"origin_zip": 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",
			"origin_zip": null
		},
		"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": null,
	"manual_retry_allowed": null,
	"connector_transaction_id": "txn_3f3D5P0q3P2t5nqOMJwDT",
	"frm_message": null,
	"metadata": {
		"udf1": "value1",
		"login_date": "2019-09-10T10:11:12Z",
		"new_customer": "true"
	},
	"connector_metadata": null,
	"feature_metadata": {
		"redirect_response": null,
		"search_tags": null,
		"apple_pay_recurring_details": null,
		"gateway_system": "direct"
	},
	"reference_id": "PL-UMV-PCV-TF5",
	"payment_link": null,
	"profile_id": "pro_3V2idKMuFgUCTiOjFUM0",
	"surcharge_details": null,
	"attempt_count": 1,
	"merchant_decision": null,
	"merchant_connector_id": "mca_LJWkcQEbnAOXgJ4WJZV0",
	"incremental_authorization_allowed": false,
	"authorization_count": null,
	"incremental_authorizations": null,
	"external_authentication_details": null,
	"external_3ds_authentication_attempted": false,
	"expires_on": "2025-12-08T18:52:26.789Z",
	"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_channel": null,
	"payment_method_id": null,
	"network_transaction_id": null,
	"payment_method_status": null,
	"updated": "2025-12-08T18:37:29.407Z",
	"split_payments": null,
	"frm_metadata": null,
	"extended_authorization_applied": null,
	"extended_authorization_last_applied_at": null,
	"request_extended_authorization": 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,
	"enable_partial_authorization": null,
	"enable_overcapture": null,
	"is_overcapture_enabled": null,
	"network_details": null,
	"is_stored_credential": null,
	"mit_category": null,
	"billing_descriptor": null,
	"tokenization": null,
	"partner_merchant_identifier_details": null,
	"payment_method_tokenization_details": null
}
Refund
curl --location 'https://pix-mbp.orthrus-monster.ts.net/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_ZJJRGSQCryeRipWRWkDnjhse5GplWfj4iBoNZx5LA9yJdXezoXgJTmARbXOwxodz' \
--data '{
    "payment_id": "pay_BrlKK94mKFH3wP5Vmv1A",
    "amount": 600,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
{
	"refund_id": "ref_7ZiTs56tnbzOifmj1ZX9",
	"payment_id": "pay_BrlKK94mKFH3wP5Vmv1A",
	"amount": 600,
	"currency": "USD",
	"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,
	"unified_code": null,
	"unified_message": null,
	"created_at": "2025-12-08T18:38:37.292Z",
	"updated_at": "2025-12-08T18:38:38.200Z",
	"connector": "payload",
	"profile_id": "pro_3V2idKMuFgUCTiOjFUM0",
	"merchant_connector_id": "mca_LJWkcQEbnAOXgJ4WJZV0",
	"split_refunds": null,
	"issuer_error_code": null,
	"issuer_error_message": null,
	"raw_connector_response": null
}
RSync
curl --location 'https://pix-mbp.orthrus-monster.ts.net/refunds/ref_7ZiTs56tnbzOifmj1ZX9?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_ZJJRGSQCryeRipWRWkDnjhse5GplWfj4iBoNZx5LA9yJdXezoXgJTmARbXOwxodz'
{
	"refund_id": "ref_7ZiTs56tnbzOifmj1ZX9",
	"payment_id": "pay_BrlKK94mKFH3wP5Vmv1A",
	"amount": 600,
	"currency": "USD",
	"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,
	"unified_code": null,
	"unified_message": null,
	"created_at": "2025-12-08T18:38:37.292Z",
	"updated_at": "2025-12-08T18:38:56.937Z",
	"connector": "payload",
	"profile_id": "pro_3V2idKMuFgUCTiOjFUM0",
	"merchant_connector_id": "mca_LJWkcQEbnAOXgJ4WJZV0",
	"split_refunds": null,
	"issuer_error_code": null,
	"issuer_error_message": null,
	"raw_connector_response": null
}

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 July 2025 Release milestone Dec 4, 2025
@pixincreate pixincreate self-assigned this Dec 4, 2025
Copilot AI review requested due to automatic review settings December 4, 2025 17:25
@pixincreate pixincreate added the A-connector-integration Area: Connector integration label Dec 4, 2025
@pixincreate pixincreate requested a review from a team as a code owner December 4, 2025 17:25
@pixincreate pixincreate added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Dec 4, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 4, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/payload.rs  68% smaller

Copilot finished reviewing on behalf of pixincreate December 4, 2025 17:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Payload connector implementation to use existing utility trait methods (PaymentsSyncRequestData::get_connector_transaction_id() and RefundsRequestData::get_connector_refund_id()) instead of manually extracting and error-handling these fields.

  • Simplifies payment sync and refund sync URL construction by delegating to utility methods
  • Updates imports to include the necessary trait methods
  • Reduces code duplication by leveraging existing utility functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@0582129). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...s/hyperswitch_connectors/src/connectors/payload.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10542   +/-   ##
=======================================
  Coverage        ?    6.46%           
=======================================
  Files           ?     1251           
  Lines           ?   311785           
  Branches        ?        0           
=======================================
  Hits            ?    20164           
  Misses          ?   291621           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

deepanshu-iiitu
deepanshu-iiitu previously approved these changes Dec 4, 2025
@pixincreate pixincreate changed the title refactor(connector): [payload] use existing util functions instead fix(connector): [payload] RSync throwing 404 and re-use existing util functions Dec 4, 2025
@Nithin1506200 Nithin1506200 self-requested a review December 5, 2025 10:18
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-refactor Category: Refactor S-waiting-on-review Status: This PR has been implemented and needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR][PAYLOAD] Re-use existing functions from utils instead of re-writing from scratch

5 participants