Skip to content

feat(connector): [FISERV] Added PayPal Redirect Payment Method #8669

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

Merged
merged 9 commits into from
Aug 8, 2025

Conversation

bsayak03
Copy link
Contributor

@bsayak03 bsayak03 commented Jul 17, 2025

Type of Change

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

Description

Added PayPal Redirect Payment Flow. First we Create an Order and then in the return_url, customer gets redirected. After that we Capture the funds.

Note: We are getting a missing fields error from the connector, possibly because this particular payment method hasn't been enabled from the connector dashboard.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Ref: https://developer.fiserv.com/product/CommerceHub/api/?type=post&path=/checkouts/v1/orders&branch=main&version=1.25.1000

How did you test it?

Payments Create Paypal Redirect

cURL:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_JYKTXJwwDWQuGPW0WjUKFXMJmJP468CKJE4U6qddT8LddLXpll9t8e0yWSLczCVm' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data-raw '{
    "amount": 700,
    "all_keys_required": true,
    "currency": "EUR",
    "connector": [
        "fiserv"
    ],
    "confirm": true,
    "payment_link": false,
    "capture_on": "2029-09-10T10:11:12Z",
    "amount_to_capture": 700,
    "name": "John Doe",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "browser_info": {
        "color_depth": 24,
        "java_enabled": true,
        "java_script_enabled": true,
        "language": "en-GB",
        "screen_height": 720,
        "screen_width": 1280,
        "time_zone": -330,
        "ip_address": "208.127.127.193",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
    },
    "metadata": {
        "disable_avs": true,
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "order_details": [
        {
            "product_name": "Tea",
            "quantity": 1,
            "amount": 110,
            "product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg"
        },
        {
            "product_name": "Tea",
            "quantity": 1,
            "amount": 110,
            "product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg"
        },
        {
            "product_name": "Tea",
            "quantity": 1,
            "amount": 110,
            "product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg"
        }
    ]
}'

Response:

{
    "payment_id": "pay_UgwJ8sF0UpM0AiP9Jund",
    "merchant_id": "merchant_1752634536",
    "status": "failed",
    "amount": 700,
    "net_amount": 700,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "fiserv",
    "client_secret": "pay_UgwJ8sF0UpM0AiP9Jund_secret_MaGdtIVJCWsY9Jv6oM24",
    "created": "2025-07-17T05:06:13.199Z",
    "currency": "EUR",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "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": null,
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": [
        {
            "brand": null,
            "amount": 110,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "product_name": "Tea",
            "product_type": null,
            "sub_category": null,
            "product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg",
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null
        },
        {
            "brand": null,
            "amount": 110,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "product_name": "Tea",
            "product_type": null,
            "sub_category": null,
            "product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg",
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null
        },
        {
            "brand": null,
            "amount": 110,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "product_name": "Tea",
            "product_type": null,
            "sub_category": null,
            "product_img_link": "https://thumbs.dreamstime.com/b/indian-tea-spices-masala-chai-33827904.jpg",
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null
        }
    ],
    "email": null,
    "name": null,
    "phone": null,
    "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": "Resource not found.",
    "unified_code": "UE_9000",
    "unified_message": "Something went wrong",
    "payment_experience": null,
    "payment_method_type": "paypal",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": true,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "disable_avs": true,
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_dRUTV6w1cX2PDwySmqkO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5pfIFZaGnx79rGU6ttO6",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-17T05:21:13.199Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-GB",
        "time_zone": -330,
        "ip_address": "208.127.127.193",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1280,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 720,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-07-17T05:06:14.371Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": null,
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null
}

Cypress test

Fiserv Screenshot 2025-08-04 at 4 05 05 PM
## 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

@bsayak03 bsayak03 requested a review from a team as a code owner July 17, 2025 04:19
Copy link

semanticdiff-com bot commented Jul 17, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs  21% smaller
  crates/hyperswitch_connectors/src/connectors/fiserv.rs  19% smaller
  config/config.example.toml Unsupported file format
  config/deployments/integration_test.toml Unsupported file format
  config/deployments/production.toml Unsupported file format
  config/deployments/sandbox.toml Unsupported file format
  config/development.toml Unsupported file format
  config/docker_compose.toml Unsupported file format
  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
  loadtest/config/development.toml Unsupported file format

@bsayak03 bsayak03 self-assigned this Jul 17, 2025
@dgeee13 dgeee13 self-requested a review July 17, 2025 08:44
@@ -959,6 +991,17 @@ static FISERV_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = Laz
},
);

fiserv_supported_payment_methods.add(
enums::PaymentMethod::Wallet,
enums::PaymentMethodType::Paypal,
Copy link
Contributor

@dgeee13 dgeee13 Jul 17, 2025

Choose a reason for hiding this comment

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

Please add

  1. the changes in crates/connector_configs/toml as well for both googlepay, paypal
    (dashboard ui wasm changes)
  2. the changes in config/deployments/toml (country,currency changes)

},
interactions: FiservInteractions {
channel: "WEB".to_string(),
customer_confirmation: "REVIEW_AND_PAY".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Could we replace the hardcoded strings with enums + Serde renames for better type safety?

Something like:

#[derive(Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
enum CustomerConfirmation {
    ReviewAndPay,
    PayNow, // can be added later
}

Using enums here is a good-to-have — it avoids potential bugs from typos in string literals (which the compiler won't catch) and makes future changes easier to manage

@bsayak03 bsayak03 requested a review from a team as a code owner July 17, 2025 18:24
@bsayak03 bsayak03 requested review from a team as code owners July 28, 2025 06:15
@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Jul 28, 2025
@bsayak03 bsayak03 removed request for a team July 28, 2025 06:15
@bsayak03 bsayak03 removed the request for review from a team July 28, 2025 06:15
@bsayak03 bsayak03 changed the base branch from fiserv/gpay to main July 28, 2025 06:16
@hyperswitch-bot hyperswitch-bot bot removed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Jul 28, 2025
@bsayak03 bsayak03 changed the base branch from main to fiserv/gpay July 28, 2025 06:16
@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Jul 28, 2025
@bsayak03 bsayak03 changed the base branch from fiserv/gpay to main July 28, 2025 10:13
@hyperswitch-bot hyperswitch-bot bot removed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Jul 28, 2025
@@ -651,17 +917,29 @@ impl TryFrom<&FiservRouterData<&types::PaymentsCaptureRouterData>> for FiservCap
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "Merchant connector account metadata",
})?;

let order_id = item
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this order id field added in capture request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

order_id gotten from Authorize response needs to be passed in Capture call.
Ref: https://developer.fiserv.com/product/CommerceHub/api/?type=post&path=/checkouts/v1/orders&branch=main&version=1.25.1000
(Click on the Capture dropdown)

@deepanshu-iiitu
Copy link
Contributor

Dashboard config changes missing for Fiserv Paypal

dgeee13
dgeee13 previously approved these changes Aug 1, 2025
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Aug 4, 2025
jagan-jaya
jagan-jaya previously approved these changes Aug 5, 2025
@bsayak03 bsayak03 dismissed stale reviews from jagan-jaya, deepanshu-iiitu, and dgeee13 via a6fda18 August 6, 2025 13:44
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Aug 8, 2025
Merged via the queue into main with commit b0b7193 Aug 8, 2025
17 of 22 checks passed
@Gnanasundari24 Gnanasundari24 deleted the fiserv/paypal branch August 8, 2025 09:29
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.

5 participants