Skip to content

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

Merged
Gnanasundari24 merged 7 commits intomainfrom
barclaycard-apple-pay-flow
Sep 9, 2025
Merged

feat(connector): [Barclaycard] Add Apple Pay Flow#8885
Gnanasundari24 merged 7 commits intomainfrom
barclaycard-apple-pay-flow

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

Hyperswitch Decryption Flow
  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": "something@gmail.com",
    "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": "something@gmail.com",
        "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": "something@gmail.com",
    "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
}
Connector Decryption Flow
  1. Payment Connector - Create

Request:

curl --location 'http://localhost:8080/account/merchant_1757312693/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tO4QhL39rQMDHYzzbfwpngxQRd7PfKBjb3H9h0ngxbMUeLjNovXFBbIRDfRhBkKk' \
--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",
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "ios",
                    "certificate": CERTIFICATE,
                    "display_name": "Barclaycard via Hyperswitch",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                },
                "payment_request_data": {
                    "label": "Cybersource via Hyperswitch",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "connector_webhook_details": {
        "merchant_secret": "MyWebhookSecret"
    },
    "business_country": "US",
    "business_label": "default"
}'

Response:

{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_label": "barclaycard_US_default",
    "merchant_connector_id": "mca_dQAvxu5nKalC1YM9Nh4c",
    "profile_id": "pro_PbbZjjifqFiYwIXrlBjq",
    "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": {
        "merchant_secret": "MyWebhookSecret",
        "additional_secret": null
    },
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "ios",
                    "certificate": CERTIFICATE,
                    "display_name": "Barclaycard via Hyperswitch",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                },
                "payment_request_data": {
                    "label": "Barclaycard via Hyperswitch",
                    "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": "Barclaycard via Hyperswitch"
                },
                "session_token_data": {
                    "certificate": CERTIFICATE,
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "display_name": MERCHANT_BUSINESS_COUNTRY,
                    "initiative": "ios",
                    "initiative_context": null,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                }
            }
        }
    }
}
  1. Payments - Create

Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tO4QhL39rQMDHYzzbfwpngxQRd7PfKBjb3H9h0ngxbMUeLjNovXFBbIRDfRhBkKk' \
--data-raw '{
    "amount": 2229,
    "currency": "USD",
    "confirm": true,
    "customer_id": "gmail",
    "email": "email@email.com",
    "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"
        },
        "email": "guest@example.com"
    },
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": PAYMENT_DATA,
                "payment_method": {
                    "display_name": "MasterCard 0049",
                    "network": "MasterCard",
                    "type": "credit"
                },
                "transaction_identifier": TRANSACTION_IDENTIFIER
            }
        }
    },
    "payment_method": "wallet",
    "payment_method_type": "apple_pay"
}'

Response:

{
    "payment_id": "pay_PGO6Zpfp4QqUUVrcV69m",
    "merchant_id": "merchant_1757312693",
    "status": "succeeded",
    "amount": 2229,
    "net_amount": 2229,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 2229,
    "connector": "barclaycard",
    "client_secret": "pay_PGO6Zpfp4QqUUVrcV69m_secret_4NqlDHVTMiECtyKhMRgN",
    "created": "2025-09-08T06:25:44.739Z",
    "currency": "USD",
    "customer_id": "gmail",
    "customer": {
        "id": "gmail",
        "name": null,
        "email": "email@email.com",
        "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": null,
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "last4": "0049",
                "card_network": "MasterCard",
                "type": "credit"
            }
        },
        "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",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "email@email.com",
    "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": "apple_pay",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "gmail",
        "created_at": 1757312744,
        "expires": 1757316344,
        "secret": "epk_972bbb09245349088a4f2eb20ffb472e"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7573127477466909504807",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "pay_PGO6Zpfp4QqUUVrcV69m_1",
    "payment_link": null,
    "profile_id": "pro_PbbZjjifqFiYwIXrlBjq",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_dQAvxu5nKalC1YM9Nh4c",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-09-08T06:40:44.739Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-09-08T06:25:48.784Z",
    "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
@semanticdiff-com
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
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 9, 2025
Merged via the queue into main with commit 77498ee Sep 9, 2025
25 of 29 checks passed
@Gnanasundari24 Gnanasundari24 deleted the barclaycard-apple-pay-flow branch September 9, 2025 09:45
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

4 participants