Skip to content

Conversation

swetasharma03
Copy link
Contributor

@swetasharma03 swetasharma03 commented Jan 17, 2025

Type of Change

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

Description

Add Support for Amazon Pay Redirect and Amazon Pay payment via Stripe

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 connector
curl --location 'http://localhost:8080/account/merchant_1737107777/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "stripe",
    "business_country": "US",
    "business_label": "default",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key":API_KEY_HERE
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "amazon_pay",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                }
            ]
        }

    ],
    "metadata": {}
}
        
'

Response

{
    "connector_type": "payment_processor",
    "connector_name": "stripe",
    "connector_label": "stripe_US_default",
    "merchant_connector_id": "mca_Y9GMWdiq1dIGbzUGr0cZ",
    "profile_id": "pro_PX125fppN7NPx0QnQ0kW",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "sk*******************************************************************************************************wS"
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "amazon_pay",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {},
    "test_mode": false,
    "disabled": false,
    "frm_configs": null,
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": null,
    "connector_wallets_details": null
}
  1. Authorization
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_0llKWUC3y5Z3vACDU324XIGXXvO8ANUm2FWWjJOPb7ifHOZBllSXLDleAeoXC1ui' \
--data-raw '{
    "amount": 1800,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "customer_id": "klarna",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "return_url": "https://google.com",
    "business_country": "US",
    "payment_method": "wallet",
    "payment_method_type": "amazon_pay",
    "payment_method_data": {
        "wallet": {
            "amazon_pay_redirect": {}
        }
    },
    "metadata": {
        "order_details": {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 1800,
            "account_name": "transaction_processing"
        }
    }
}'

Response

{
    "payment_id": "pay_Lcxnnod81tHdyOaL3rKN",
    "merchant_id": "merchant_1737039949",
    "status": "requires_customer_action",
    "amount": 1800,
    "net_amount": 1800,
    "shipping_cost": null,
    "amount_capturable": 1800,
    "amount_received": 0,
    "connector": "stripe",
    "client_secret": "pay_Lcxnnod81tHdyOaL3rKN_secret_koHNJ4k4iszxZGs7UvLS",
    "created": "2025-01-17T09:43:30.081Z",
    "currency": "USD",
    "customer_id": "klarna",
    "customer": {
        "id": "klarna",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "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": "wallet",
    "payment_method_data": {
        "wallet": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_Lcxnnod81tHdyOaL3rKN/merchant_1737039949/pay_Lcxnnod81tHdyOaL3rKN_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "amazon_pay",
    "connector_label": "stripe_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "klarna",
        "created_at": 1737107010,
        "expires": 1737110610,
        "secret": "epk_a49fc4c439174510b4916078a67daafc"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pi_3QiC5OAGHc77EJXX19qPFa6Z",
    "frm_message": null,
    "metadata": {
        "order_details": {
            "amount": 1800,
            "quantity": 1,
            "account_name": "transaction_processing",
            "product_name": "Apple iphone 15"
        }
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QiC5OAGHc77EJXX19qPFa6Z",
    "payment_link": null,
    "profile_id": "pro_HPdS7uUx46Q3kWNK6x0q",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5nADZHcVU5I934y0ikbp",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-17T09:58:30.081Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-17T09:43:31.230Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
  1. PSync
curl --location 'http://localhost:8080/payments/pay_Lcxnnod81tHdyOaL3rKN?force_sync=true&expand_captures=true&expand_attempts=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_0llKWUC3y5Z3vACDU324XIGXXvO8ANUm2FWWjJOPb7ifHOZBllSXLDleAeoXC1ui'

Response

{
    "payment_id": "pay_Lcxnnod81tHdyOaL3rKN",
    "merchant_id": "merchant_1737039949",
    "status": "succeeded",
    "amount": 1800,
    "net_amount": 1800,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 1800,
    "connector": "stripe",
    "client_secret": "pay_Lcxnnod81tHdyOaL3rKN_secret_koHNJ4k4iszxZGs7UvLS",
    "created": "2025-01-17T09:43:30.081Z",
    "currency": "USD",
    "customer_id": "klarna",
    "customer": {
        "id": "klarna",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "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": "wallet",
    "payment_method_data": {
        "wallet": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "amazon_pay",
    "connector_label": "stripe_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3QiC5OAGHc77EJXX19qPFa6Z",
    "frm_message": null,
    "metadata": {
        "order_details": {
            "amount": 1800,
            "quantity": 1,
            "account_name": "transaction_processing",
            "product_name": "Apple iphone 15"
        }
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QiC5OAGHc77EJXX19qPFa6Z",
    "payment_link": null,
    "profile_id": "pro_HPdS7uUx46Q3kWNK6x0q",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5nADZHcVU5I934y0ikbp",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-17T09:58:30.081Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-17T09:43:40.352Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "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

@swetasharma03 swetasharma03 requested review from a team as code owners January 17, 2025 10:00
Copy link

semanticdiff-com bot commented Jan 17, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/helpers.rs  76% smaller
  crates/router/src/connector/adyen.rs  67% smaller
  crates/router/src/types/transformers.rs  67% smaller
  crates/hyperswitch_domain_models/src/payment_method_data.rs  42% smaller
  crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs  41% smaller
  crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs  41% smaller
  crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs  41% smaller
  crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs  41% smaller
  crates/router/src/connector/noon/transformers.rs  40% smaller
  crates/router/src/connector/klarna.rs  39% smaller
  crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs  36% smaller
  crates/hyperswitch_connectors/src/connectors/globepay/transformers.rs  36% smaller
  crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs  36% smaller
  crates/router/src/connector/paypal/transformers.rs  35% smaller
  crates/router/src/connector/checkout/transformers.rs  32% smaller
  crates/router/src/connector/mifinity/transformers.rs  32% smaller
  crates/router/src/connector/nmi/transformers.rs  32% smaller
  crates/router/src/connector/nuvei/transformers.rs  32% smaller
  crates/router/src/connector/payme/transformers.rs  32% smaller
  crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs  31% smaller
  crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs  31% smaller
  crates/hyperswitch_connectors/src/connectors/square/transformers.rs  31% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs  31% smaller
  crates/hyperswitch_connectors/src/connectors/zen/transformers.rs  31% smaller
  crates/router/src/connector/aci/transformers.rs  26% smaller
  crates/router/src/connector/adyen/transformers.rs  26% smaller
  crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs  24% smaller
  crates/hyperswitch_connectors/src/connectors/boku/transformers.rs  24% smaller
  crates/hyperswitch_connectors/src/connectors/nexinets/transformers.rs  24% smaller
  crates/router/src/connector/authorizedotnet/transformers.rs  20% smaller
  crates/openapi/src/openapi.rs  15% smaller
  crates/openapi/src/openapi_v2.rs  15% smaller
  crates/api_models/src/payments.rs  6% smaller
  crates/router/src/connector/stripe/transformers.rs  5% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  api-reference/openapi_spec.json  0% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/common_enums/src/transformers.rs  0% smaller
  crates/connector_configs/toml/development.toml Unsupported file format
  crates/connector_configs/toml/production.toml Unsupported file format
  crates/connector_configs/toml/sandbox.toml Unsupported file format
  crates/euclid/src/frontend/dir/enums.rs  0% smaller
  crates/euclid/src/frontend/dir/lowering.rs  0% smaller
  crates/euclid/src/frontend/dir/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/utils.rs  0% smaller
  crates/kgraph_utils/src/mca.rs  0% smaller
  crates/kgraph_utils/src/transformers.rs  0% smaller
  crates/router/src/configs/defaults/payment_connector_required_fields.rs  0% smaller
  crates/router/src/connector/utils.rs  0% smaller

@swetasharma03 swetasharma03 force-pushed the stripe-amazonpay branch 2 times, most recently from 455af10 to 011d538 Compare January 17, 2025 10:41
@swetasharma03 swetasharma03 self-assigned this Jan 17, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 17, 2025
AkshayaFoiger
AkshayaFoiger previously approved these changes Jan 20, 2025
AkshayaFoiger
AkshayaFoiger previously approved these changes Jan 20, 2025
Chethan-rao
Chethan-rao previously approved these changes Jan 21, 2025
Copy link
Contributor

@ShankarSinghC ShankarSinghC left a comment

Choose a reason for hiding this comment

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

Does Amazon Pay requires session token ? If yes, please add the /session call test case.

Also update the pr commit message to
feat(router): Add Support for Amazon Pay Redirect and Amazon Pay payment via Stripe

@swetasharma03
Copy link
Contributor Author

Does Amazon Pay requires session token ? If yes, please add the /session call test case.

Also update the pr commit message to feat(router): Add Support for Amazon Pay Redirect and Amazon Pay payment via Stripe

For stripe, we don't require session token

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@cf82861). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/router/src/connector/stripe/transformers.rs 0.00% 7 Missing ⚠️
crates/api_models/src/payments.rs 0.00% 2 Missing ⚠️
...perswitch_domain_models/src/payment_method_data.rs 0.00% 2 Missing ⚠️
crates/common_enums/src/transformers.rs 0.00% 1 Missing ⚠️
crates/euclid/src/frontend/dir/lowering.rs 0.00% 1 Missing ⚠️
crates/euclid/src/frontend/dir/transformers.rs 0.00% 1 Missing ⚠️
crates/hyperswitch_connectors/src/utils.rs 0.00% 1 Missing ⚠️
crates/kgraph_utils/src/transformers.rs 0.00% 1 Missing ⚠️
crates/router/src/connector/utils.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7056   +/-   ##
=======================================
  Coverage        ?    4.12%           
=======================================
  Files           ?     1010           
  Lines           ?   207421           
  Branches        ?        0           
=======================================
  Hits            ?     8548           
  Misses          ?   198873           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Feb 5, 2025
Merged via the queue into main with commit b54a3f9 Feb 5, 2025
21 of 23 checks passed
@Gnanasundari24 Gnanasundari24 deleted the stripe-amazonpay branch February 5, 2025 15:25
Narayanbhat166 pushed a commit that referenced this pull request Feb 6, 2025
…Stripe (#7056)

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 M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FEAT: Add Support for Amazon Pay Redirect and Amazon Pay payment via Stripe
7 participants