Skip to content

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Jul 19, 2024

Type of Change

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

Description

Add billing country in klarna dynamic fields

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. Create a Klarna Payment Request via Klarna with with confirm=fasle
{
    "amount": 1800,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "customer_id": "cus_NwicjmCJbgafjhjfhHr6",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "9123456789",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "return_url": "https://duck.com",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "pay_later",
    "payment_method_type": "klarna",
    "payment_experience": "invoke_sdk_client",
    "payment_method_data": {
        "pay_later": {
            "klarna_sdk": {
                "token": "65bfb654-ef2c-6b39-942e-ffdc9a105d3cf"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "444, Stelar Enclave",
            "line2": "California",
            "line3": "Groningen",
            "city": "Groningen",
            "state": "Groningen",
            "zip": "94105",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "+4901761428434",
            "country_code": "+1"
        }
    },
    "shipping": {
        "address": {
            "line1": "444, Stelar Enclave",
            "line2": "California",
            "line3": "Groningen",
            "city": "Groningen",
            "state": "Groningen",
            "zip": "94105",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "446681800",
            "country_code": "+41"
        },
        "email": "[email protected]"
    },
    "metadata": {},
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 2,
            "amount": 1800,
            "account_name": "transaction_processing"
        }
    ],
    "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"
    }
}

Response:

{
    "payment_id": "pay_BtRF93AhE0erz2yHuryN",
    "merchant_id": "merchant_1717586050",
    "status": "requires_confirmation",
    "amount": 1800,
    "net_amount": 1800,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_BtRF93AhE0erz2yHuryN_secret_fzSL7QM3OB7TwlfKH5jC",
    "created": "2024-06-05T13:23:40.457Z",
    "currency": "USD",
    "customer_id": "cus_NwicjmCJbgafjhjfhHr6",
    "customer": {
        "id": "cus_NwicjmCJbgafjhjfhHr6",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "9123456789",
        "phone_country_code": "+65"
    },
    "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": "pay_later",
    "payment_method_data": {
        "pay_later": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "Groningen",
            "country": "US",
            "line1": "444, Stelar Enclave",
            "line2": "California",
            "line3": "Groningen",
            "zip": "94105",
            "state": "Groningen",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "446681800",
            "country_code": "+41"
        },
        "email": "[email protected]"
    },
    "billing": {
        "address": {
            "city": "Groningen",
            "country": "US",
            "line1": "444, Stelar Enclave",
            "line2": "California",
            "line3": "Groningen",
            "zip": "94105",
            "state": "Groningen",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "+4901761428434",
            "country_code": "+1"
        },
        "email": null
    },
    "order_details": [
        {
            "brand": null,
            "amount": 1800,
            "category": null,
            "quantity": 2,
            "product_id": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "requires_shipping": null
        }
    ],
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "9123456789",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": "invoke_sdk_client",
    "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": "cus_NwicjmCJbgafjhjfhHr6",
        "created_at": 1717593820,
        "expires": 1717597420,
        "secret": "epk_83b98d86e60a439e9cdf5e3ee3007e84"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {},
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_eVJTR1hn3FYTrnYncTdW",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-06-05T13:38:40.457Z",
    "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-06-05T13:23:40.489Z",
    "charges": null,
    "frm_metadata": null
}
  1. List Payment Methods for a Merchant
curl --location 'http://localhost:8080/account/payment_methods?client_secret=pay_BtRF93AhE0erz2yHuryN_secret_fzSL7QM3OB7TwlfKH5jC' \
--header 'Accept: application/json' \
--header 'api-key: {api_key}'

Response:
In response please check for "required_field": "payment_method_data.billing.address.country"

{
    "redirect_url": "https://google.com/success",
    "currency": "USD",
    "payment_methods": [
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": [
                        {
                            "payment_experience_type": "invoke_sdk_client",
                            "eligible_connectors": [
                                "klarna"
                            ]
                        },
                        {
                            "payment_experience_type": "redirect_to_url",
                            "eligible_connectors": [
                                "klarna"
                            ]
                        }
                    ],
                    "card_networks": null,
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_address_country": {
                                    "options": [
                                        "AU",
                                        "AT",
                                        "BE",
                                        "CA",
                                        "CZ",
                                        "DK",
                                        "FI",
                                        "FR",
                                        "DE",
                                        "GR",
                                        "IE",
                                        "IT",
                                        "NL",
                                        "NZ",
                                        "NO",
                                        "PL",
                                        "PT",
                                        "ES",
                                        "SE",
                                        "CH",
                                        "GB",
                                        "US"
                                    ]
                                }
                            },
                            "value": "US"
                        },
                        "shipping.phone.number": {
                            "required_field": "shipping.phone.number",
                            "display_name": "phone_number",
                            "field_type": "user_phone_number",
                            "value": "446681800"
                        },
                        "shipping.email": {
                            "required_field": "shipping.email",
                            "display_name": "email",
                            "field_type": "user_email_address",
                            "value": "[email protected]"
                        },
                        "shipping.phone.country_code": {
                            "required_field": "shipping.phone.country_code",
                            "display_name": "phone_country_code",
                            "field_type": "user_phone_number_country_code",
                            "value": "+41"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        }
    ],
    "mandate_payment": null,
    "merchant_name": "NewAge Retailer",
    "show_surcharge_breakup_screen": false,
    "payment_type": "normal",
    "request_external_three_ds_authentication": false,
    "collect_shipping_details_from_wallets": false,
    "collect_billing_details_from_wallets": false
}

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

@swangi-kumari swangi-kumari requested a review from a team as a code owner July 19, 2024 08:15
@swangi-kumari swangi-kumari self-assigned this Jul 19, 2024
@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration C-refactor Category: Refactor labels Jul 19, 2024
@swangi-kumari swangi-kumari changed the title refactor(connector): Add country in klarna dynamic fields refactor(connector): Add billing_country in klarna dynamic fields Jul 19, 2024
@likhinbopanna likhinbopanna enabled auto-merge July 22, 2024 10:40
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 22, 2024
Merged via the queue into main with commit 4838a86 Jul 22, 2024
@likhinbopanna likhinbopanna deleted the klarna-billing-country branch July 22, 2024 11:04
pixincreate added a commit that referenced this pull request Jul 24, 2024
* 'main' of github.com:juspay/hyperswitch: (27 commits)
  refactor(connector): added amount conversion framework for billwerk (#4972)
  feat(connector): [Itaubank] Add refund and rsync flow  (#5420)
  feat: create additional columns in organization table (#5380)
  refactor(merchant_id): create domain type for `merchant_id` (#5408)
  fix(euclid): remove business_profile routing feature flag (#5430)
  feat: add create retrieve and update api endpoints for organization resource (#5361)
  chore(version): 2024.07.24.0
  refactor(connector): [Itaubank] add dynamic fields for pix (#5419)
  Feat(connector): [WELLSFARGO] Add template code (#5333)
  fix(connector): [Datatrans] Handling for 4-Digit YYYY input and Correct 3DS Routing to no_3ds (#5410)
  refactor(connector):  add amount conversion framework to volt (#4985)
  chore(users): email templates footer icon style enhance (#5375)
  feat(customer): customer v2 refactor for customer create end point (#5350)
  chore(version): 2024.07.23.0
  fix(router): store `network_transaction_id` in stripe `authorize` flow (#5399)
  ci: handle packages to run are being empty (#5403)
  chore: add customer, shipping and billing details to payment_response for payment list api (#5401)
  refactor(dashboard_metadata): alter query for merchant scoped metadata (#5397)
  refactor(connector): Add billing_country in klarna dynamic fields (#5373)
  feat(connector): [Itau Bank] Add payment and sync flow for Pix (#5342)
  ...
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants