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(connector): [BANKOFAMERICA] Implement Samsung Pay #6888

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sweta-Kumari-Sharma
Copy link
Contributor

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma commented Dec 19, 2024

Type of Change

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

Description

Implemented Payment Method Samsung Pay for connector Bankofamerica

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/7903

How did you test it?

  1. Connector configuration with merhcant account
curl --location 'http://localhost:8080/account/merchant_1734596148/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "bankofamerica",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_secret": API_SECRET_HERE,
        "key1": KEY_1 here,
        "api_key": API_KEY here
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "samsung_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
     "connector_wallets_details": WALLET_DETAILS_HERE,
     "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "connector_webhook_details": {
        "merchant_secret": "merchant_secret"
    }
}'

Response:

{
    "connector_type": "payment_processor",
    "connector_name": "bankofamerica",
    "connector_label": "bankofamerica_US_default",
    "merchant_connector_id": "mca_tcLF8eNc3wyJyNa02NAY",
    "profile_id": "pro_PS3TEgINEPhzeeAjNjKV",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "d0********************************4c",
        "key1": "ju*************ox",
        "api_secret": "rK****************************************k="
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "samsung_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "connector_webhook_details": {
        "merchant_secret": "merchant_secret",
        "additional_secret": null
    },
    "connector_wallets_details": WALLET_DETAILS_HERE,
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "test_mode": true,
    "disabled": false,
    "frm_configs": null,
    "business_country": null,
    "business_label": null,
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": null,
 
}
  1. Create Payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_eJeiVMcAVr5URnyfwyv3LHLrSkfpwR44liTgmY3szossAbomjLpgsSmvN2H1ELMm' \
--data '{
  "amount": 6540,
  "currency": "USD",
  "capture_method": "automatic",
  "authentication_type": "no_three_ds",
  "confirm": false,
  "customer_id": "cu_1726743607",
  "metadata": {
        "city": "NY",
        "unit": "245"
    }
}'

Response:

{
    "payment_id": "pay_pUtMw6BcmjjRLpP6lS9J",
    "merchant_id": "merchant_1734693841",
    "status": "requires_payment_method",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_pUtMw6BcmjjRLpP6lS9J_secret_GD5uPWJmbU3YQiIcgoiN",
    "created": "2024-12-20T11:34:14.762Z",
    "currency": "USD",
    "customer_id": "cu_1726743607",
    "customer": {
        "id": "cu_1726743607",
        "name": null,
        "email": null,
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "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": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_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": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1726743607",
        "created_at": 1734694454,
        "expires": 1734698054,
        "secret": "epk_5d8ae327451c498182e4bb121edf3e81"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_mGLf47yYw0B9WO6PxMrD",
    "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-12-20T11:49:14.762Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-20T11:34:14.811Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
  1. Session-token
curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'api-key: pk_dev_42fcfebecc5247588101551310c2a586' \
--data '{
    "payment_id": "pay_pUtMw6BcmjjRLpP6lS9J",
    "wallets": [],
    "client_secret": "pay_pUtMw6BcmjjRLpP6lS9J_secret_GD5uPWJmbU3YQiIcgoiN"
}'

Response:

{
    "payment_id": "pay_WuoNKWqCMOQjFtcFP10z",
    "client_secret": "pay_WuoNKWqCMOQjFtcFP10z_secret_j1WL1mhlMmiO1Dr4Trr1",
    "session_token": [
        {
            "wallet_name": "samsung_pay",
            "version": "2",
              "service_id":  SERVICE_ID HERE,
            "order_number": "pay-WuoNKWqCMOQjFtcFP10z",
            "merchant": {
                "name": "Hyperswitch",
                "url": null,
                "country_code": "IN"
            },
            "amount": {
                "option": "FORMAT_TOTAL_PRICE_ONLY",
                "currency_code": "USD",
                "total": "65.40"
            },
            "protocol": "PROTOCOL3DS",
            "allowed_brands": [
                "visa",
                "masterCard",
                "amex",
                "discover"
            ]
        }
    ]
}
  1. Confirm payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_eJeiVMcAVr5URnyfwyv3LHLrSkfpwR44liTgmY3szossAbomjLpgsSmvN2H1ELMm' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6540,
    "customer_id": "custhype123",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "return_url": "https://google.com",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "samsung_pay",
    "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"
        }
    },
    "payment_method_data": {
        "wallet": {
            "samsung_pay": {
                "payment_credential": {
                    "card_brand": "visa",
                    "recurring_payment": false,
                    "card_last4digits": "1661",
                    "method": "3DS",
                    "3_d_s": {
                        "type": "S",
                        "version": "100",
                        "data": "encrypted samsung pay data"
                    }
                }
            }
        }
    }
}'

Response:

{
    "payment_id": "pay_eQfQYhbQVZnKHssZi8Cy",
    "merchant_id": "merchant_1734695014",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "bankofamerica",
    "client_secret": "pay_eQfQYhbQVZnKHssZi8Cy_secret_1e9yGbdzuXOujO4O9M0c",
    "created": "2024-12-20T11:43:46.370Z",
    "currency": "USD",
    "customer_id": "custhype123",
    "customer": {
        "id": "custhype123",
        "name": "Joseph 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": {
        "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": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_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": null,
    "payment_method_type": "samsung_pay",
    "connector_label": "bankofamerica_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "custhype123",
        "created_at": 1734695026,
        "expires": 1734698626,
        "secret": "epk_3e97a215f2164fbc9863c40e6eb07cc8"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7346950341956783604805",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_eQfQYhbQVZnKHssZi8Cy_1",
    "payment_link": null,
    "profile_id": "pro_0bJGEMcx9psh154x5fO7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_JuC5B3aiOWhy9nsJgwT1",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-12-20T11:58:46.370Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-20T11:43:58.483Z",
    "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 a review from a team as a code owner December 19, 2024 08:24
Copy link

semanticdiff-com bot commented Dec 19, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/bankofamerica/transformers.rs  2% smaller

@Sweta-Kumari-Sharma Sweta-Kumari-Sharma changed the title initial commit feat(connector): [BANKOFAMERICA] Implement Samsung Pay Dec 19, 2024
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.

From my understanding, we need to create a new service in Samsung Pay using the .cer provided by Bank of America to proceed with the testing. Additionally, samsung pay payment can only be test using a Samsung device.

Could you please confirm if a new service has been created for this purpose and specify which Samsung Pay developer account was used for it?

@Sweta-Kumari-Sharma
Copy link
Contributor Author

From my understanding, we need to create a new service in Samsung Pay using the .cer provided by Bank of America to proceed with the testing. Additionally, samsung pay payment can only be test using a Samsung device.

Could you please confirm if a new service has been created for this purpose and specify which Samsung Pay developer account was used for it?

From my understanding, we need to create a new service in Samsung Pay using the .cer provided by Bank of America to proceed with the testing. Additionally, samsung pay payment can only be test using a Samsung device.

Could you please confirm if a new service has been created for this purpose and specify which Samsung Pay developer account was used for it?

Both Bank of America and Cybersource have same creds and documentation, so I have used the same Samsung service which was used for Cybersource

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.

This pr is just a backend integration of samsung for BOA.
The dashboard changes are also needs to enable it for BOA connector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement Payment Method Samsung Pay for Connector BankOfAmerica
3 participants