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(klarna): Klarna Kustom Checkout Integration #6590

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Sweta-Kumari-Sharma
Copy link

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma commented Nov 18, 2024

Type of Change

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

Description

Klarna Kustom Checkout (KCO) integration

Klarna provides two payment methods:

  1. Klarna Payments (for US)
  2. Klarna Kustom Checkout (for EU)

Any one of the methods can be used at a time and switching between Klarna Payments and Klarna Checkout is been done. Based on the PML got, there will be a switching between Klarna Payments and Klarna Checkout.
The redirect_to_url link from response is used to complete the payment.

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?

I tested it using postman by hitting the required endpoints. Curl to the postman setup:

  1. Create a Klarna Checkout Payment request
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_p0hGvu5HDFg1SujZzgk306N282a6Q1ZIjWu9GwtLETMxhx6MO8Yg8z4oru5AQc3D' \
--data-raw '{
    "amount": 5000,
    "order_tax_amount": 0,
    "currency": "EUR",
    "amount_to_capture": 5000,
    "confirm": true,
    "payment_experience":"redirect_to_url",
    "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": "[email protected]",
        "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",
    "payment_method_data": { 
        "pay_later": {
            "klarna_checkout":{}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "FR",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "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": "[email protected]"
    },
    "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"
}
'

Response:

{
    "payment_id": "pay_lpZlfBfQxCxwa6hgKyIn",
    "merchant_id": "merchant_1732104439",
    "status": "requires_customer_action",
    "amount": 5000,
    "net_amount": 5000,
    "shipping_cost": null,
    "amount_capturable": 5000,
    "amount_received": null,
    "connector": "klarna",
    "client_secret": "pay_lpZlfBfQxCxwa6hgKyIn_secret_Bqa2rvAAvYP08KiNykgJ",
    "created": "2024-11-20T19:28:57.452Z",
    "currency": "EUR",
    "customer_id": "customer123",
    "customer": {
        "id": "customer123",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "9999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "pay_later",
    "payment_method_data": {
        "pay_later": {
            "klarna_sdk": null,
            "klarna_checkout": 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": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "FR",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "order_details": [
        {
            "brand": null,
            "amount": 5000,
            "category": null,
            "quantity": 1,
            "tax_rate": 0,
            "product_id": null,
            "product_name": "Red T-Shirt",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "product_tax_code": null,
            "total_tax_amount": 0,
            "requires_shipping": null
        }
    ],
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "9999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_lpZlfBfQxCxwa6hgKyIn/merchant_1732104439/pay_lpZlfBfQxCxwa6hgKyIn_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": "redirect_to_url",
    "payment_method_type": "klarna",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer123",
        "created_at": 1732130937,
        "expires": 1732134537,
        "secret": "epk_ae7bc3aa0b15489187388fff166727db"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "9d75f40e-c9a4-45d2-88ce-42d579d321df",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_z1ZWEo2uxzLIbKL4AWUH",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_jLkIq3zq2uGR8sSEfBRT",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-20T19:43:57.451Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "128.0.0.1",
        "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",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-11-20T19:28:58.606Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": "test_ord",
    "order_tax_amount": null,
    "connector_mandate_id": null
}
  1. Retrieve the payment details:
curl --location 'http://localhost:8080/payments/pay_lpZlfBfQxCxwa6hgKyIn?force_sync=true&expand_captures=true&expand_attempts=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_p0hGvu5HDFg1SujZzgk306N282a6Q1ZIjWu9GwtLETMxhx6MO8Yg8z4oru5AQc3D'

Response:

{
    "payment_id": "pay_lpZlfBfQxCxwa6hgKyIn",
    "merchant_id": "merchant_1732104439",
    "status": "succeeded",
    "amount": 5000,
    "net_amount": 5000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 5000,
    "connector": "klarna",
    "client_secret": "pay_lpZlfBfQxCxwa6hgKyIn_secret_Bqa2rvAAvYP08KiNykgJ",
    "created": "2024-11-20T19:28:57.452Z",
    "currency": "EUR",
    "customer_id": "customer123",
    "customer": {
        "id": "customer123",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "9999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "attempts": [
        {
            "attempt_id": "pay_lpZlfBfQxCxwa6hgKyIn_1",
            "status": "authentication_pending",
            "amount": 5000,
            "currency": "EUR",
            "connector": "klarna",
            "error_message": null,
            "payment_method": "pay_later",
            "connector_transaction_id": "9d75f40e-c9a4-45d2-88ce-42d579d321df",
            "capture_method": "automatic",
            "authentication_type": "no_three_ds",
            "created_at": "2024-11-20T19:28:57.454Z",
            "modified_at": "2024-11-20T19:29:25.701Z",
            "cancellation_reason": null,
            "mandate_id": null,
            "error_code": null,
            "payment_token": null,
            "connector_metadata": null,
            "payment_experience": "redirect_to_url",
            "payment_method_type": "klarna",
            "reference_id": "9d75f40e-c9a4-45d2-88ce-42d579d321df",
            "unified_code": null,
            "unified_message": null,
            "client_source": null,
            "client_version": null
        }
    ],
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "pay_later",
    "payment_method_data": {
        "pay_later": {
            "klarna_sdk": null,
            "klarna_checkout": 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": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "FR",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "order_details": [
        {
            "brand": null,
            "amount": 5000,
            "category": null,
            "quantity": 1,
            "tax_rate": 0,
            "product_id": null,
            "product_name": "Red T-Shirt",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "product_tax_code": null,
            "total_tax_amount": 0,
            "requires_shipping": null
        }
    ],
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "9999999999",
    "return_url": "https://google.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": "redirect_to_url",
    "payment_method_type": "klarna",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "9d75f40e-c9a4-45d2-88ce-42d579d321df",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": "9d75f40e-c9a4-45d2-88ce-42d579d321df",
    "payment_link": null,
    "profile_id": "pro_z1ZWEo2uxzLIbKL4AWUH",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_jLkIq3zq2uGR8sSEfBRT",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-20T19:43:57.451Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "128.0.0.1",
        "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",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": "pm_Y5qn0soGBzIqD9pgrWB5",
    "payment_method_status": "inactive",
    "updated": "2024-11-20T19:30:10.959Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": "test_ord",
    "order_tax_amount": null,
    "connector_mandate_id": null
}

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 18, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs  61% smaller
  crates/router/src/connector/klarna/transformers.rs  37% smaller
  crates/router/src/connector/nuvei/transformers.rs  32% smaller
  crates/hyperswitch_connectors/src/connectors/square/transformers.rs  32% smaller
  crates/hyperswitch_connectors/src/connectors/zen/transformers.rs  32% smaller
  crates/router/src/connector/paypal/transformers.rs  27% smaller
  crates/router/src/connector/stripe/transformers.rs  27% smaller
  crates/router/src/core/payments/helpers.rs  21% smaller
  crates/api_models/src/payments.rs  18% smaller
  crates/router/src/connector/klarna.rs  3% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  api-reference/openapi_spec.json  0% smaller
  crates/diesel_models/src/payment_attempt.rs  0% smaller
  crates/diesel_models/src/types.rs  0% smaller
  crates/hyperswitch_connectors/src/utils.rs  0% smaller
  crates/hyperswitch_domain_models/src/lib.rs  0% smaller
  crates/hyperswitch_domain_models/src/payment_method_data.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_data.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_response_types.rs  0% smaller
  crates/openapi/src/openapi.rs  0% smaller
  crates/openapi/src/openapi_v2.rs  0% smaller
  crates/router/src/connector/adyen/transformers.rs  0% smaller
  crates/router/src/connector/utils.rs  0% smaller
  crates/router/src/core/payments/transformers.rs  0% smaller
  crates/router/src/services/api.rs  0% smaller
  crates/router/src/types.rs  0% smaller
  crates/router/src/types/api/verify_connector.rs  0% smaller
  crates/router/tests/connectors/payme.rs  0% smaller
  crates/router/tests/connectors/utils.rs  0% smaller
  crates/router/tests/connectors/zen.rs  0% smaller

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma self-assigned this Nov 18, 2024
@Sweta-Kumari-Sharma Sweta-Kumari-Sharma linked an issue Nov 18, 2024 that may be closed by this pull request
2 tasks
@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration A-core Area: Core flows C-feature Category: Feature request or enhancement labels Nov 18, 2024
@Sweta-Kumari-Sharma Sweta-Kumari-Sharma changed the title Klarna checkout [FEATURE]: [KLARNA] Klarna Kustom Checkout Integration #6590 Nov 18, 2024
@Sweta-Kumari-Sharma Sweta-Kumari-Sharma changed the title [FEATURE]: [KLARNA] Klarna Kustom Checkout Integration #6590 [FEATURE]: [KLARNA] Klarna Kustom Checkout Integration Nov 18, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 18, 2024
@Sweta-Kumari-Sharma Sweta-Kumari-Sharma changed the title [FEATURE]: [KLARNA] Klarna Kustom Checkout Integration feat(klarna): Klarna Kustom Checkout Integration Nov 18, 2024
@@ -84,7 +84,7 @@ pub struct RouterData<Flow, Request, Response> {
pub additional_merchant_data: Option<api_models::admin::AdditionalMerchantData>,

pub header_payload: Option<payments::HeaderPayload>,

// pub html_snippet: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove the commented lines?

Choose a reason for hiding this comment

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

fixed

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct KlarnaCheckoutResponse {
pub payment_type: Option<String>,
// pub html_snippet: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -70,6 +71,7 @@ pub struct PaymentsAuthorizeData {
/// 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>,
// pub merchant_urls: Option<MerchantURLs>,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

AdditionalPaymentData::PayLater { klarna_sdk } => match klarna_sdk {
Some(sdk) => Self::PayLater(Box::new(PaylaterResponse::from(sdk))),
None => Self::PayLater(Box::new(PaylaterResponse { klarna_sdk: None })),
// AdditionalPaymentData::PayLater { klarna_sdk } => match klarna_sdk {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@@ -5273,6 +5326,8 @@ pub struct OrderDetailsWithAmount {
pub quantity: u16,
/// the amount per quantity of product
pub amount: MinorUnit,
pub tax_rate: Option<i64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to add these 2 fields?

.merchant_order_reference_id
.clone(),
merchant_urls:None,
auto_capture: request.is_auto_capture()?,
Copy link
Contributor

Choose a reason for hiding this comment

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

run cargo +nightly fmt --all

Choose a reason for hiding this comment

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

fixed

purchase_country: item.router_data.get_billing_country()?,
purchase_currency: request.currency,
order_amount: item.amount,
order_tax_amount: Some(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we hardcoding to 0?

Choose a reason for hiding this comment

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

fixed

..item.data
})
},
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Card(_card) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

combine the cases with the same outcome using the | operator

Choose a reason for hiding this comment

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

fixed

},
}
}
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Card(_card) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

combine the cases with the same outcome using the | operator

// domain::PaymentMethodData::PayLater(_) => Ok(Some(
// api_models::payments::AdditionalPaymentData::PayLater { klarna_sdk: None },
// )),
domain::PaymentMethodData::PayLater(pay_later) => match pay_later {
Copy link
Contributor

Choose a reason for hiding this comment

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

we dont need match pay_later if outcome is always the same

Choose a reason for hiding this comment

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

fixed

@@ -2252,6 +2252,12 @@ impl<'a>

Ok(AdyenPaymentMethod::AdyenKlarna(Box::new(klarna)))
}
domain::payments::PayLaterData::KlarnaCheckout { .. } => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add KlarnaCheckout at the last of this function using or to avoid throwing the same error twice

domain::payments::PayLaterData::KlarnaSdk { .. } 
| domain::payments::PayLaterData::KlarnaCheckout { .. } => {
                Err(errors::ConnectorError::NotImplemented(
                    utils::get_unimplemented_payment_method_error_message("Adyen"),
                )
                .into())
            }

@@ -445,8 +449,26 @@ impl
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
let checkout_endpoint = get_klarna_checkout_endpoint(self.base_url(connectors));
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need get_klarna_checkout_endpoint function, this case is already handled in build_region_specific_endpoint function, so you can use endpoint for both case.

@@ -531,6 +552,8 @@ impl
.ok_or_else(connector_utils::missing_field_err("payment_method_type"))?;
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
let checkout_endpoint = get_klarna_checkout_endpoint(self.base_url(connectors));
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

quantity: data.quantity,
unit_price: data.amount,
total_amount: data.amount * data.quantity,
tax_amount: data.total_tax_amount,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we sending tax_amount and tax_rate for KlarnaSdk

}
},
);
let payment_method_data = item.data.request.payment_method_data.clone();

match payment_method_data {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can match directly on the response type, similar to how you handled the psync response.

@@ -2252,6 +2253,9 @@ pub fn change_order_details_to_new_type(
brand: order_details.brand,
product_type: order_details.product_type,
product_tax_code: order_details.product_tax_code,
tax_rate: order_details.tax_rate,
// total_amount: Some(order_details.total_amount),
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this comment

@@ -2474,6 +2479,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
integrity_object: None,
additional_payment_method_data,
shipping_cost,
// merchant_urls:None,
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this comment

@@ -59,6 +60,7 @@ impl VerifyConnectorData {
integrity_object: None,
additional_payment_method_data: None,
shipping_cost: None,
// merchant_urls:None
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this comment

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 C-feature Category: Feature request or enhancement 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]: [KLARNA] Klarna Kustom Checkout Integration
3 participants