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: Add Support for Amazon Pay Redirect and Amazon Pay payment via Stripe #7056

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

Conversation

Sweta-Kumari-Sharma
Copy link
Contributor

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma 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

https://github.com/juspay/hyperswitch-cloud/issues/8142

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

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma 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/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/bankofamerica/transformers.rs  36% smaller
  crates/router/src/connector/cybersource/transformers.rs  36% smaller
  crates/router/src/connector/wellsfargo/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

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma force-pushed the stripe-amazonpay branch 2 times, most recently from 455af10 to 011d538 Compare January 17, 2025 10:41
@Sweta-Kumari-Sharma Sweta-Kumari-Sharma 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

@Sweta-Kumari-Sharma
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

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
6 participants