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 payments update-intent API for v2 #6490

Merged
merged 32 commits into from
Dec 9, 2024
Merged

Conversation

AnuthaDev
Copy link
Contributor

@AnuthaDev AnuthaDev commented Nov 6, 2024

Type of Change

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

Description

Added update-intent API for payments

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. Intent Create Response:
{
    "id": "12345_pay_01930aca908b76b086927c61ad1fb724",
    "status": "requires_payment_method",
    "amount_details": {
        "order_amount": 100,
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "skip_external_tax_calculation": "Skip",
        "skip_surcharge_calculation": "Skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null
    },
    "client_secret": "12345_pay_01930aca908b76b086927c61ad1fb724_secret_01930aca908c71c3b6233716f1caede1",
    "merchant_reference_id": null,
    "routing_algorithm_id": null,
    "capture_method": "automatic",
    "authentication_type": "no_three_ds",
    "billing": null,
    "shipping": null,
    "customer_id": null,
    "customer_present": "Present",
    "description": null,
    "return_url": null,
    "setup_future_usage": "on_session",
    "apply_mit_exemption": "Skip",
    "statement_descriptor": null,
    "order_details": null,
    "allowed_payment_method_types": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "default",
    "expires_on": "2024-11-08T08:16:07.724Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}

2a. Update Intent Request

curl --location --request PUT 'http://localhost:8080/v2/payments/12345_pay_0193921b3f687473ae7aa7e2b2cabc83/update-intent' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_tUJFXjqpFC8MaEF5t8zE' \
--header 'api-key: dev_FW2koArhbGpoUIZNrRPHNIbdgi7TZuCq5V3OHNlQYZOMuy8gU4hu5mrR5IivoOwh' \
--data-raw '{
 "amount_details": {
    "order_amount": 6590,
    "currency": "AED",
    "shipping_cost": 123,
    "order_tax_amount": 123,
    "skip_external_tax_calculation": "skip",
    "skip_surcharge_calculation": "skip",
    "surcharge_amount": 123,
    "tax_on_surcharge": 123
  },

  "capture_method": "automatic",
  "authentication_type": "three_ds",
  "billing": {
    "address": {
      "city": "New York",
      "country": "AF",
      "line1": "123, King Street",
      "line2": "Powelson Avenue",
      "line3": "Bridgewater",
      "zip": "08807",
      "state": "New York",
      "first_name": "John",
      "last_name": "Doe"
    },
    "phone": {
      "number": "9123456789",
      "country_code": "+1"
    },
    "email": "[email protected]"
  },
  "shipping": {
    "address": {
      "city": "New York",
      "country": "AF",
      "line1": "123, King Street",
      "line2": "Powelson Avenue",
      "line3": "Bridgewater",
      "zip": "08807",
      "state": "New York",
      "first_name": "John",
      "last_name": "Doe"
    },
    "phone": {
      "number": "9123456789",
      "country_code": "+1"
    },
    "email": "[email protected]"
  },
  "customer_present": "present",
  "description": "It'\''s my first payment request",
  "return_url": "https://hyperswitch.io",
  "setup_future_usage": "off_session",
  "apply_mit_exemption": "Apply",
  "statement_descriptor": "Hyperswitch Router",
  "order_details": [{
    "product_name": "Apple iPhone 16",
    "quantity": 1,
    "amount" : 69000,
    "product_img_link": "https://dummy-img-link.com"
  }],
  "allowed_payment_method_types": [
    "ach"
  ],
  "metadata": {},
  "connector_metadata": {
    "apple_pay": {
      "session_token_data": {
        "payment_processing_certificate": "<string>",
        "payment_processing_certificate_key": "<string>",
        "payment_processing_details_at": "Hyperswitch",
        "certificate": "<string>",
        "certificate_keys": "<string>",
        "merchant_identifier": "<string>",
        "display_name": "<string>",
        "initiative": "web",
        "initiative_context": "<string>",
        "merchant_business_country": "AF"
      }
    },
    "airwallex": {
      "payload": "<string>"
    },
    "noon": {
      "order_category": "<string>"
    }
  },
  "feature_metadata": {
    "redirect_response": {
      "param": "<string>",
      "json_payload": {}
    },
    "search_tags": [
      "<string>"
    ]
  },
  "payment_link_config": {
    "theme": "#4E6ADD",
    "logo": "https://i.pinimg.com/736x/4d/83/5c/4d835ca8aafbbb15f84d07d926fda473.jpg",
    "seller_name": "hyperswitch",
    "sdk_layout": "accordion",
    "display_sdk_only": true,
    "enabled_saved_payment_method": true,
    "transaction_details": [
      {
        "key": "Policy-Number",
        "value": "297472368473924",
        "ui_configuration": {
          "position": 5,
          "is_key_bold": true,
          "is_value_bold": true
        }
      }
    ]
  },
  "request_incremental_authorization": "true",
  "session_expiry": 1000,
  "frm_metadata": {},
  "request_external_three_ds_authentication": "Enable"
}'

2b. Update Intent Response

{
    "id": "12345_pay_0193921b3f687473ae7aa7e2b2cabc83",
    "status": "requires_payment_method",
    "amount_details": {
        "order_amount": 6590,
        "currency": "AED",
        "shipping_cost": 123,
        "order_tax_amount": 123,
        "external_tax_calculation": "skip",
        "surcharge_calculation": "skip",
        "surcharge_amount": 123,
        "tax_on_surcharge": 123
    },
    "client_secret": "12345_pay_0193921b3f687473ae7aa7e2b2cabc83_secret_0193921b3f727390b03af88afb886f68",
    "profile_id": "pro_tUJFXjqpFC8MaEF5t8zE",
    "merchant_reference_id": null,
    "routing_algorithm_id": null,
    "capture_method": "automatic",
    "authentication_type": "three_ds",
    "billing": {
        "address": {
            "city": "New York",
            "country": "AF",
            "line1": "123, King Street",
            "line2": "Powelson Avenue",
            "line3": "Bridgewater",
            "zip": "08807",
            "state": "New York",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+1"
        },
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "city": "New York",
            "country": "AF",
            "line1": "123, King Street",
            "line2": "Powelson Avenue",
            "line3": "Bridgewater",
            "zip": "08807",
            "state": "New York",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+1"
        },
        "email": "[email protected]"
    },
    "customer_id": null,
    "customer_present": "present",
    "description": "It's my first payment request",
    "return_url": "https://hyperswitch.io/",
    "setup_future_usage": "on_session",
    "apply_mit_exemption": "Apply",
    "statement_descriptor": "Hyperswitch Router",
    "order_details": [
        {
            "product_name": "Apple iPhone 16",
            "quantity": 1,
            "amount": 69000,
            "requires_shipping": null,
            "product_img_link": "https://dummy-img-link.com",
            "product_id": null,
            "category": null,
            "sub_category": null,
            "brand": null,
            "product_type": null,
            "product_tax_code": null
        }
    ],
    "allowed_payment_method_types": [
        "ach"
    ],
    "metadata": {},
    "connector_metadata": {
        "apple_pay": {
            "session_token_data": {
                "payment_processing_certificate": "<string>",
                "payment_processing_certificate_key": "<string>",
                "payment_processing_details_at": "Hyperswitch",
                "certificate": "<string>",
                "certificate_keys": "<string>",
                "merchant_identifier": "<string>",
                "display_name": "<string>",
                "initiative": "web",
                "initiative_context": "<string>",
                "merchant_business_country": "AF"
            }
        },
        "airwallex": {
            "payload": "<string>"
        },
        "noon": {
            "order_category": "<string>"
        }
    },
    "feature_metadata": {
        "redirect_response": {
            "param": "<string>",
            "json_payload": {}
        },
        "search_tags": [
            "e3846ee6d6368937023c2bbd84565e5fee999118fb8f5e16a31d1129471d130a"
        ]
    },
    "payment_link_enabled": "Enable",
    "payment_link_config": {
        "theme": "#4E6ADD",
        "logo": "https://i.pinimg.com/736x/4d/83/5c/4d835ca8aafbbb15f84d07d926fda473.jpg",
        "seller_name": "hyperswitch",
        "sdk_layout": "accordion",
        "display_sdk_only": true,
        "enabled_saved_payment_method": true,
        "hide_card_nickname_field": null,
        "show_card_form_by_default": null,
        "transaction_details": [
            {
                "key": "Policy-Number",
                "value": "297472368473924",
                "ui_configuration": {
                    "position": 5,
                    "is_key_bold": true,
                    "is_value_bold": true
                }
            }
        ]
    },
    "request_incremental_authorization": "true",
    "expires_on": "2024-12-04T14:54:39.539Z",
    "frm_metadata": {},
    "request_external_three_ds_authentication": "Enable"
}

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

Copy link

semanticdiff-com bot commented Nov 6, 2024

@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Nov 6, 2024
@AnuthaDev AnuthaDev changed the base branch from main to payment_sync_v2 November 6, 2024 09:27
@hyperswitch-bot hyperswitch-bot bot removed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Nov 6, 2024
@AnuthaDev AnuthaDev linked an issue Nov 6, 2024 that may be closed by this pull request
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 6, 2024
@AnuthaDev AnuthaDev force-pushed the update-intent-v2 branch 2 times, most recently from 923688d to 5465965 Compare November 6, 2024 11:25
@AnuthaDev AnuthaDev marked this pull request as ready for review November 7, 2024 08:38
@AnuthaDev AnuthaDev requested review from a team as code owners November 7, 2024 08:38
@AnuthaDev AnuthaDev added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 7, 2024
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/payment_intent.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/payment_intent.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
crates/router/src/routes/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/payment_intent.rs Outdated Show resolved Hide resolved
crates/hyperswitch_domain_models/src/payments.rs Outdated Show resolved Hide resolved
crates/openapi/src/routes/payments.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
Base automatically changed from payment_sync_v2 to main November 11, 2024 14:06
@AnuthaDev AnuthaDev requested review from a team as code owners November 11, 2024 14:06
Narayanbhat166
Narayanbhat166 previously approved these changes Dec 4, 2024
jarnura
jarnura previously approved these changes Dec 4, 2024
@AnuthaDev AnuthaDev removed the request for review from sai-harsha-vardhan December 4, 2024 16:31
SanchithHegde
SanchithHegde previously approved these changes Dec 4, 2024
SanchithHegde
SanchithHegde previously approved these changes Dec 5, 2024
Narayanbhat166
Narayanbhat166 previously approved these changes Dec 5, 2024
@AnuthaDev AnuthaDev removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 5, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 9, 2024
Merged via the queue into main with commit 19f810a Dec 9, 2024
18 checks passed
@likhinbopanna likhinbopanna deleted the update-intent-v2 branch December 9, 2024 07:45
kashif-m pushed a commit that referenced this pull request Dec 12, 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
api-v2 M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add payments update-intent API for v2
7 participants