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(core): add merchant order reference id #5197

Merged
merged 9 commits into from
Jul 4, 2024

Conversation

SamraatBansal
Copy link
Contributor

@SamraatBansal SamraatBansal commented Jul 3, 2024

Type of Change

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

Description

Add support for accepting merchant_order_reference_id and subsequently pass it to the connector if connector supports accepting multiple reference.
This is being added for merchant to locate the payment using their id in the connector dashboard

Additional Changes

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

Motivation and Context

#5198

How did you test it?

Do Payments Create and Update the merchant_order_reference_id, check this in DB

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data-raw '{
    "amount": 6100,
    "currency": "USD",
    "confirm": false,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6100,
    
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    
    "return_url": "https://google.com",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "merchant_order_reference_id": "cust_order_id"
}'
curl --location 'http://localhost:8080/payments/pay_BCFeb1tpuJWad7PElBM1' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data '{
  "amount": 6540,
  "confirm" :false,
  "amount_to_capture": 6540,
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    }
    ,
"merchant_order_reference_id": "true"
}'

Create Paypal Payment

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data-raw '{
    "amount": 6100,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6100,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "return_url": "https://google.com",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "merchant_order_reference_id": "cust_order_id"
}' 
Screenshot 2024-07-04 at 2 57 04 PM

Create Adyen Payment

curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: dev_tRtH96ICztwLahErT89hnUwUjGNvNUSA6zZqpedyIruXledDUHfp5o0yQLRNCPB8' \
--header 'x-feature: router-custom' \
--header 'Content-Type: application/json' \
--data-raw '{
	"amount": 1337,
	"currency": "USD",
	"confirm": true,
	"capture_method": "manual",
	"capture_on": "2022-09-10T10:11:12Z",
	"amount_to_capture": 1337,
	"customer_id": "customerg12",
	"email": "[email protected]",
	"name": "John Doe",
	"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_type": "credit",
	"payment_method_data": {
		"card": {
			"card_number": "4111111145551142",
			"card_exp_month": "03",
			"card_exp_year": "2030",
			"card_holder_name": "joseph Doe",
			"card_cvc": "737"
		}
	},
	"billing": {
		"address": {
			"line1": "1",
			"line2": "Stargatan",
			
			"city": "Stockholm",
			
			"zip": "11 148",
			"country": "SE",
			"first_name": "Alice",
			"last_name": "Test"
		}
	},
	"shipping": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
    "browser_info": {
        "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",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled":true,
        "ip_address": "127.0.0.1"
    },
	"statement_descriptor_name": "joseph",
	"statement_descriptor_suffix": "JS",
    "metadata": {
        "test": "ket"
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ],
    "merchant_order_reference_id": "cust_order_adyen"
}'
Screenshot 2024-07-04 at 3 08 44 PM

Create klarna Payment

Add merchant_order_reference_id in the request field from SDK

image

Test webhooks for Adyen and Paypal

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

@SamraatBansal SamraatBansal added A-connector-integration Area: Connector integration A-core Area: Core flows P-high Priority: High S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Jul 3, 2024
@SamraatBansal SamraatBansal self-assigned this Jul 3, 2024
@SamraatBansal SamraatBansal requested review from a team as code owners July 3, 2024 19:49
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Jul 3, 2024
@SamraatBansal SamraatBansal linked an issue Jul 3, 2024 that may be closed by this pull request
2 tasks
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jul 3, 2024
@@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS merchant_order_reference_id VARCHAR DEFAULT NULL;
Copy link
Member

Choose a reason for hiding this comment

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

should we not have limit to the number of characters to this column?

/// Merchant's identifier for the payment/invoice. This will be sent to the connector
/// if the connector provides support to accept multiple reference ids.
/// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
pub merchant_order_reference_id: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

why is this added to router data directly? this can be added in the respective requests where it is required only right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the field to PaymentsAuthorizeData

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 4, 2024
Merged via the queue into main with commit f4665d2 Jul 4, 2024
11 checks passed
@Gnanasundari24 Gnanasundari24 deleted the add-merchant-order-reference branch July 4, 2024 13:05
pixincreate added a commit that referenced this pull request Jul 5, 2024
…ify-cypress

* 'main' of github.com:juspay/hyperswitch: (22 commits)
  refactor: Adding millisecond to Kafka timestamp (#5202)
  chore(version): 2024.07.05.0
  fix(user_auth_method): make id option in auth select (#5213)
  Docs: Updated API - ref for payments (#5172)
  feat(core): add merchant order reference id (#5197)
  feat(analytics): Refund status serialization issue for ckh analytics (#5199)
  fix(router): `override setup_future_usage` filed to on_session based on merchant config (#5195)
  feat(cypress): make tests forcefully skippable (#5176)
  feat(core): Added integrity framework for Authorize and Sync flow with connector as Stripe (#5109)
  ci(cypress): Update card number for adyen and status for paypal (#5192)
  refactor(cypress): error handling and add sync refunds in places where missing (#5128)
  feat(analytics): FRM Analytics (#4880)
  chore(version): 2024.07.04.0
  feat(pm_auth): Added balance check for PM auth bank account (#5054)
  refactor(payment_methods): add appropriate missing logs (#5190)
  refactor(migrations): add commands to make file to run migrations for api v2 (#5169)
  chore(version): 2024.07.03.0
  fix(event): Updated the ApiEventMetric (#5126)
  feat(router): add refunds manual-update api (#5094)
  refactor(payment_link): logs payment links logs coverage (#4918)
  ...
@SanchithHegde SanchithHegde removed P-high Priority: High S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Jul 7, 2024
Narayanbhat166 pushed a commit that referenced this pull request Jul 8, 2024
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
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 A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add support for merchant order reference id
6 participants