juspay / hyperswitch

An open source payments switch written in Rust to make payments fast, reliable and affordable
https://hyperswitch.io/
Apache License 2.0
12.64k stars 1.36k forks source link

Klarna checkout #6522

Open Sweta-Kumari-Sharma opened 2 weeks ago

Sweta-Kumari-Sharma commented 2 weeks ago

Type of Change

Description

Klarna Kustom Checkout (KCO) integration (upto authorization) Klarna provides two payment methods:

  1. Klarna Payments
  2. Klarna Kustom Checkout

Any one of the methods can be used at a time and switching between Klarna Payments and Klarna Checkout is been done

Additional Changes

Motivation and Context

This change is required because Klarna KCO provides some additional features (such as shipping address change callback), along with location differences than Klarna Payments.

Link to the issue: https://github.com/juspay/hyperswitch/issues/6521

How did you test it?

I tested it using postman by hitting the required endpoints. Curl to the postman setup: curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_tMhVA6fMp8BFTmxi1BgtoeKC0SGTpwn4E7Lg3YOlo8E8Jr2niX2LWzyijupRGfOQ' \ --data-raw '{ "amount": 5000, "order_tax_amount": 0, "currency": "USD", "amount_to_capture": 5000, "confirm": false, "payment_experience":"invoke_sdk_client", "profile_id": null, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "authentication_type": "no_three_ds", "setup_future_usage":"on_session", "customer": { "id": "customer123", "name": "John Doe", "email": "customer@gmail.com", "phone": "9999999999", "phone_country_code": "+1" }, "customer_id": "customer123", "phone_country_code": "+1", "routing": { "type": "single", "data": "stripe" }, "description": "Its my first payment request", "return_url": "https://google.com", "payment_method": "pay_later", "payment_method_type": "klarna_checkout", "payment_method_data": { "pay_later": { "klarna_checkout":{} }, "billing":null }, "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" }, "email": "guest@example.com" }, "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" }, "email": "guest@example.com" }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "order_details": [ { "product_name": "Red T-Shirt", "quantity": 1, "amount": 5000, "account_name": "transaction_processing", "total_tax_amount": 0, "tax_rate": 0, "total_amount": 5000 } ], "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" }, "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": "128.0.0.1" }, "customer_acceptance": { "acceptance_type": "offline", "accepted_at": "1963-05-03T04:07:52.723Z", "online": { "ip_address": "125.0.0.1", "user_agent": "amet irure esse" } }, "connector_metadata": { "noon": { "order_category": "pay" } }, "payment_link": false, "payment_link_config": { "theme": "", "logo": "", "seller_name": "", "sdk_layout": "", "display_sdk_only": false, "enabled_saved_payment_method": false }, "payment_type": "normal", "request_incremental_authorization": false, "merchant_order_reference_id": "test_ord",

} '

Checklist

semanticdiff-com[bot] commented 2 weeks ago

Review changes with  SemanticDiff

Changed Files
| File | Status | | :--- | :--- | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/multisafepay/transformers.rs)  [crates/router/src/connector/multisafepay/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/multisafepay/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/multisafepay/transformers.rs)  40% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/adyen.rs)  [crates/router/src/connector/adyen\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/adyen.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/adyen.rs)  36% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/nuvei/transformers.rs)  [crates/router/src/connector/nuvei/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/nuvei/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/nuvei/transformers.rs)  32% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_connectors/src/connectors/square/transformers.rs)  [crates/hyperswitch\_connectors/src/connectors/square/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_connectors/src/connectors/square/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_connectors/src/connectors/square/transformers.rs)  32% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/klarna/transformers.rs)  [crates/router/src/connector/klarna/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/klarna/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/klarna/transformers.rs)  31% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/paypal/transformers.rs)  [crates/router/src/connector/paypal/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/paypal/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/paypal/transformers.rs)  27% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/core/payments/transformers.rs)  [crates/router/src/core/payments/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/core/payments/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/core/payments/transformers.rs)  25% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/types/transformers.rs)  [crates/router/src/types/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/types/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/types/transformers.rs)  25% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/zen/transformers.rs)  [crates/router/src/connector/zen/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/zen/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/zen/transformers.rs)  21% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir.rs)  [crates/euclid/src/frontend/dir\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir.rs)  21% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/api_models/src/payments.rs)  [crates/api\_models/src/payments\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/api_models/src/payments.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/api_models/src/payments.rs)  19% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/core/payments/helpers.rs)  [crates/router/src/core/payments/helpers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/core/payments/helpers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/core/payments/helpers.rs)  16% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/stripe/transformers.rs)  [crates/router/src/connector/stripe/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/stripe/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/stripe/transformers.rs)  14% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/klarna.rs)  [crates/router/src/connector/klarna\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/klarna.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/klarna.rs)  4% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/common_enums/src/enums.rs)  [crates/common\_enums/src/enums\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/common_enums/src/enums.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/common_enums/src/enums.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/common_enums/src/transformers.rs)  [crates/common\_enums/src/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/common_enums/src/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/common_enums/src/transformers.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/enums.rs)  [crates/euclid/src/frontend/dir/enums\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/enums.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/enums.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/lowering.rs)  [crates/euclid/src/frontend/dir/lowering\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/lowering.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/lowering.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/transformers.rs)  [crates/euclid/src/frontend/dir/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/euclid/src/frontend/dir/transformers.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_connectors/src/utils.rs)  [crates/hyperswitch\_connectors/src/utils\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_connectors/src/utils.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_connectors/src/utils.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/payment_method_data.rs)  [crates/hyperswitch\_domain\_models/src/payment\_method\_data\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/payment_method_data.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/payment_method_data.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/router_data.rs)  [crates/hyperswitch\_domain\_models/src/router\_data\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/router_data.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/router_data.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/router_request_types.rs)  [crates/hyperswitch\_domain\_models/src/router\_request\_types\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/router_request_types.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/hyperswitch_domain_models/src/router_request_types.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/kgraph_utils/src/mca.rs)  [crates/kgraph\_utils/src/mca\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/kgraph_utils/src/mca.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/kgraph_utils/src/mca.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/kgraph_utils/src/transformers.rs)  [crates/kgraph\_utils/src/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/kgraph_utils/src/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/kgraph_utils/src/transformers.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/adyen/transformers.rs)  [crates/router/src/connector/adyen/transformers\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/adyen/transformers.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/adyen/transformers.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/utils.rs)  [crates/router/src/connector/utils\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/utils.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6522/changes#crates/router/src/connector/utils.rs)  0% smaller |
cookieg13 commented 1 week ago

@Sweta-Kumari-Sharma Add a linked issue with this PR, also rename the PR title. You can take this PR as ref: https://github.com/juspay/hyperswitch/pull/6560

cookieg13 commented 1 week ago

In your description, also add the response json for your cURL