Skip to content

feat(connector): [Barclaycard] Add Apple Pay Flow #8885

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

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

Conversation

Anurag-05-prog
Copy link
Contributor

@Anurag-05-prog Anurag-05-prog commented Aug 8, 2025

Type of Change

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

Closes this issue

Description

Added Apple Pay Flow for Barclaycard

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?

Postman Test

  1. Payment Connector - Create

Request:

curl --location 'http://localhost:8080/account/merchant_1755085109/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_taZoWveMbydxSkllyD5IB1sPHXNYOLLR2iveHgisLDodWCnHUkaXOF5k8RS8jMFC' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_account_details": {
        "auth_type":"SignatureKey",
        "api_secret": API_SECRET
        "api_key": API_KEY,
        "key1": KEY1
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
     "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "web",
                    "certificate": CERTIFICATE,
                    "display_name": "Applepay",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_identifier": MERCHANT_IDENTIFIER
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY,
                },
                "payment_request_data": {
                    "label": "Applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "business_country": "US",
    "business_label": "default"
}'

Response:

{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_label": "barclaycard_US_default",
    "merchant_connector_id": "mca_eS9yhJMxUdKy4eZJ1Ea1",
    "profile_id": "pro_v4sNqtQqIhqC7zNvjBna",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": API_KEY,
        "key1": KEY1,
        "api_secret": API_SECRET
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "web",
                    "certificate": CERTIFICATE,
                    "display_name": "Applepay",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY
                },
                "payment_request_data": {
                    "label": "Applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "test_mode": true,
    "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": {
        "apple_pay_combined": {
            "manual": {
                "payment_request_data": {
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ],
                    "label": "Applepay"
                },
                "session_token_data": {
                    "certificate": CERTIFICATE,
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "display_name": "Applepay",
                    "initiative": "web",
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY
                }
            }
        }
    }
}
  1. Payments - Create

Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_taZoWveMbydxSkllyD5IB1sPHXNYOLLR2iveHgisLDodWCnHUkaXOF5k8RS8jMFC' \
--data-raw '{
    "amount": 650,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 650,
    "customer_id": "cu_1752502119",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "setup_future_usage": "off_session",
    "authentication_type": "no_three_ds",
    "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",
    "billing": {
        "address": {
            "line1": "1467",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": NUMBER
            "country_code": "+91"
        }
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "payment_method": "wallet",
    "payment_method_type": "apple_pay",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": PAYMENT_DATA,
                    "display_name": "MasterCard 0049",
                    "network": "MasterCard",
                    "type": "credit"
                },
                "transaction_identifier": TRANSACTION_IDENTIFIER
            }
        }
    },
    "shipping": {
        "phone": {
            "number": "4081234567"
        },
        "email": EMAIL
    }
}'

Response:

{
    "payment_id": "pay_ytnuQR2VsUo0pTAPUlvy",
    "merchant_id": "merchant_1755085109",
    "status": "succeeded",
    "amount": 650,
    "net_amount": 650,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 650,
    "connector": "barclaycard",
    "client_secret": "pay_ytnuQR2VsUo0pTAPUlvy_secret_pdWZPEULnUSv9XOzVUaF",
    "created": "2025-08-13T11:38:39.949Z",
    "currency": "USD",
    "customer_id": "cu_1752502119",
    "customer": {
        "id": "cu_1752502119",
        "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": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "last4": "0049",
                "card_network": "MasterCard",
                "type": "credit"
            }
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": null,
        "phone": {
            "number": "4081234567",
            "country_code": null
        },
        "email": EMAIL
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": null,
            "line3": null,
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": NUMBER,
            "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": "apple_pay",
    "connector_label": "barclaycard_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1752502119",
        "created_at": 1755085119,
        "expires": 1755088719,
        "secret": "SECRET
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7550851222606001203813",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_ytnuQR2VsUo0pTAPUlvy_1",
    "payment_link": null,
    "profile_id": "pro_v4sNqtQqIhqC7zNvjBna",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_eS9yhJMxUdKy4eZJ1Ea1",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-13T11:53:39.949Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-13T11:38:43.164Z",
    "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,
    "enable_partial_authorization": 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

@Anurag-05-prog Anurag-05-prog self-assigned this Aug 8, 2025
@Anurag-05-prog Anurag-05-prog requested a review from a team as a code owner August 8, 2025 20:13
Copy link

semanticdiff-com bot commented Aug 8, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs  2% 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
  crates/hyperswitch_connectors/src/connectors/barclaycard.rs  0% smaller

@Anurag-05-prog Anurag-05-prog marked this pull request as draft August 8, 2025 20:13
@Anurag-05-prog Anurag-05-prog linked an issue Aug 8, 2025 that may be closed by this pull request
2 tasks
@Anurag-05-prog Anurag-05-prog marked this pull request as ready for review August 13, 2025 12:02
@Anurag-05-prog Anurag-05-prog requested a review from a team as a code owner August 13, 2025 12:02
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] Add Apple Pay Payment Method In Barclaycard
1 participant