Skip to content

fix(connector): [GLOBALPAY] Added Tokenization Flow for CITs#8568

Merged
likhinbopanna merged 18 commits intomainfrom
global/mandates
Jul 29, 2025
Merged

fix(connector): [GLOBALPAY] Added Tokenization Flow for CITs#8568
likhinbopanna merged 18 commits intomainfrom
global/mandates

Conversation

@bsayak03
Copy link
Contributor

@bsayak03 bsayak03 commented Jul 7, 2025

Type of Change

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

Description

In One-off payments, we donot need to create the token. Just passing raw cards would be enough.
In CITs, we need to create a token and store it in connector_mandate_id for future MITs but while executing the CIT, raw cards need to be passed.
In MITs, we need to use that previously stored token in CIT and no more need to hit the tokenization endpoint at connector.

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?

  1. Payments Create - One-off

cURL:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_v5jp7Ow9W5g6tgWaDHs4UR385iFfpg9dXQGYQkxxRXQdHlcvR70WmjJRPWJt7Xe7' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data-raw '{
    "currency":"USD",
    "amount": 300,
    "confirm": true,
    "amount_to_capture": 300,
    
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "return_url": "https://www.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",
    "payment_method": "card",
    
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "CA",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "109.71.40.0"
    },
    "metadata": {
        "order_category": "applepay"
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 300,
            "account_name": "transaction_processing"
        }
    ]   
}'

Response:

{
    "payment_id": "pay_j2mMaanCWkdCD2ytx5gg",
    "merchant_id": "merchant_1751871882",
    "status": "succeeded",
    "amount": 300,
    "net_amount": 300,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 300,
    "connector": "globalpay",
    "client_secret": "pay_j2mMaanCWkdCD2ytx5gg_secret_CqzsQEqF82ClZdEAoVF3",
    "created": "2025-07-07T11:03:44.204Z",
    "currency": "USD",
    "customer_id": null,
    "customer": {
        "id": null,
        "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": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "CA",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "CA",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": [
        {
            "brand": null,
            "amount": 300,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null
        }
    ],
    "email": null,
    "name": null,
    "phone": null,
    "return_url": "https://www.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": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "TRN_IORyBbPseO4Qiy0L2v8YpZpgWA9auN_dCD2ytx5gg_1",
    "frm_message": null,
    "metadata": {
        "order_category": "applepay"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_j2mMaanCWkdCD2ytx5gg_1",
    "payment_link": null,
    "profile_id": "pro_GIxd8tTl8PWNt9L2ynbr",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_ghTQYltef3iCpp4cdsVu",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-07T11:18:44.204Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "109.71.40.0",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-07-07T11:03:46.731Z",
    "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": "manual",
    "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
}
  1. CIT using mandate_id

Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_otcCi6DyRzeDWx38OH5BTLBjBK1WS7Jt1BbsMpPepSR2Rr5dIPgVgPMoeekaqoXL' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data-raw '{
    "amount": 6000,
    "all_keys_required": true,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://example.com",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "single_use": {
                "amount": 8000,
                "currency": "USD"
            }
        }
    },
    "payment_type": "new_mandate",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "john",
            "last_name": "Doe"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "john",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "browser_info": {
        "ip_address": "129.0.0.1",
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "en-US",
        "color_depth": 32,
        "screen_height": 1117,
        "screen_width": 1728,
        "time_zone": -330,
        "java_enabled": true,
        "java_script_enabled": true
    }
}'

Response:

{
    "payment_id": "pay_pgbcY6mXYI4IYk2Zt5kc",
    "merchant_id": "merchant_1753277415",
    "status": "succeeded",
    "amount": 6000,
    "net_amount": 6000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6000,
    "connector": "globalpay",
    "client_secret": "pay_pgbcY6mXYI4IYk2Zt5kc_secret_H0sK1auIjNZsIcfjVE1d",
    "created": "2025-07-23T17:30:07.918Z",
    "currency": "USD",
    "customer_id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
    "customer": {
        "id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_bRinPSQhGM8Pky90uBNb",
    "mandate_data": {
        "update_mandate_id": null,
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "single_use": {
                "amount": 8000,
                "currency": "USD",
                "start_date": null,
                "end_date": null,
                "metadata": null
            }
        }
    },
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "john",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "john",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://example.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
        "created_at": 1753291807,
        "expires": 1753295407,
        "secret": "epk_222a00737e6c47d181b899d8afc76813"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "TRN_gBpefdKHlBxfmgVgFSlfPuCQXj86TT_4IYk2Zt5kc_1",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_pgbcY6mXYI4IYk2Zt5kc_1",
    "payment_link": null,
    "profile_id": "pro_roCz974ra9LQxsifUris",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5Y545k7TI4upQYSbJJ9L",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-23T17:45:07.918Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-US",
        "time_zone": -330,
        "ip_address": "129.0.0.1",
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
        "color_depth": 32,
        "java_enabled": true,
        "screen_width": 1728,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 1117,
        "java_script_enabled": true
    },
    "payment_method_id": "pm_uDtgQsunDERQMrEXxbcy",
    "payment_method_status": null,
    "updated": "2025-07-23T17:30:11.412Z",
    "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": "manual",
    "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": "{\"id\":\"TRN_gBpefdKHlBxfmgVgFSlfPuCQXj86TT_4IYk2Zt5kc_1\",\"time_created\":\"2025-07-23T17:30:11.323Z\",\"type\":\"SALE\",\"status\":\"CAPTURED\",\"channel\":\"CNP\",\"capture_mode\":\"AUTO\",\"amount\":\"6000\",\"currency\":\"USD\",\"country\":\"US\",\"merchant_id\":\"MER_7e3e2c7df34f42819b3edee31022ee3f\",\"merchant_name\":\"Sandbox_merchant_3\",\"account_id\":\"TRA_c9967ad7d8ec4b46b6dd44a61cde9a91\",\"account_name\":\"transaction_processing\",\"reference\":\"pay_pgbcY6mXYI4IYk2Zt5kc_1\",\"payment_method\":{\"result\":\"00\",\"message\":\"(00)[ test system ] Authorised\",\"entry_mode\":\"ECOM\",\"card\":{\"brand\":\"VISA\",\"masked_number_last4\":\"XXXXXXXXXXXX1111\",\"authcode\":\"123456\",\"brand_reference\":\"R0LEZpZE51h4fEcD\",\"brand_time_created\":\"\",\"cvv_result\":\"MATCHED\",\"provider\":{\"result\":\"00\",\"cvv_result\":\"M\",\"avs_address_result\":\"M\",\"avs_postal_code_result\":\"M\"}}},\"risk_assessment\":[{\"mode\":\"ACTIVE\",\"result\":\"ACCEPTED\",\"rules\":[{\"reference\":\"0c93a6c9-7649-4822-b5ea-1efa356337fd\",\"description\":\"Cardholder Name Rule\",\"mode\":\"ACTIVE\",\"result\":\"ACCEPTED\"},{\"reference\":\"a539d51a-abc1-4fff-a38e-b34e00ad0cc3\",\"description\":\"CardNumber block\",\"mode\":\"ACTIVE\",\"result\":\"ACCEPTED\"},{\"reference\":\"d023a19e-6985-4fda-bb9b-5d4e0dedbb1e\",\"description\":\"Amount test\",\"mode\":\"ACTIVE\",\"result\":\"ACCEPTED\"}]}],\"batch_id\":\"BAT_1558804\",\"action\":{\"id\":\"ACT_gBpefdKHlBxfmgVgFSlfPuCQXj86TT\",\"type\":\"AUTHORIZE\",\"time_created\":\"2025-07-23T17:30:11.323Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"OXKlGGm6ecZLIqMyRgPHRfMxdUAiEcp8\",\"app_name\":\"rotate_again\"}}"
}
  1. MIT using mandate_id

Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_otcCi6DyRzeDWx38OH5BTLBjBK1WS7Jt1BbsMpPepSR2Rr5dIPgVgPMoeekaqoXL' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data '{
    "amount": 6000,
    "currency": "USD",
    "capture_method": "automatic",
    "off_session": true,
    "confirm": true,
    "description": "Initiated by merchant",
    "mandate_id": "man_bRinPSQhGM8Pky90uBNb",
    "customer_id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU"
}'

Response:

{
    "payment_id": "pay_RI5mPEtiRZOUPPBEckqZ",
    "merchant_id": "merchant_1753277415",
    "status": "succeeded",
    "amount": 6000,
    "net_amount": 6000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6000,
    "connector": "globalpay",
    "client_secret": "pay_RI5mPEtiRZOUPPBEckqZ_secret_Aj61vZbZEdJkamRrE2EK",
    "created": "2025-07-23T17:30:20.230Z",
    "currency": "USD",
    "customer_id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
    "customer": {
        "id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Initiated by merchant",
    "refunds": null,
    "disputes": null,
    "mandate_id": "man_bRinPSQhGM8Pky90uBNb",
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "23420a93-c0ad-435f-885f-2d57c30c14d9",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cus_LI9DQMmb1tHRjnfnkjwknjfXtonFkU",
        "created_at": 1753291820,
        "expires": 1753295420,
        "secret": "epk_ceed93e4ac414b0ea6c2f454b9187067"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "TRN_VlfWAjrCer1pEZaQ7BRJsxE9tqGHnn_OUPPBEckqZ_1",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_RI5mPEtiRZOUPPBEckqZ_1",
    "payment_link": null,
    "profile_id": "pro_roCz974ra9LQxsifUris",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5Y545k7TI4upQYSbJJ9L",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-23T17:45:20.230Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_uDtgQsunDERQMrEXxbcy",
    "payment_method_status": "active",
    "updated": "2025-07-23T17:30:23.884Z",
    "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": "PMT_9fd7c105-65f1-4b54-9b3f-d3f34c35100d",
    "card_discovery": "manual",
    "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
}
  1. CIT using payment_method_id

cURL:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_otcCi6DyRzeDWx38OH5BTLBjBK1WS7Jt1BbsMpPepSR2Rr5dIPgVgPMoeekaqoXL' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data-raw '{
    "amount": 1650,
    "currency": "USD",
    "connector": ["globalpay"],
    "confirm": true,
    "customer_id": "customer123ffffa",
    "setup_future_usage": "off_session",
    "payment_method_type": "debit",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737"
        }
    },
    "billing": {
        "address": {
            "first_name": "joseph",
            "last_name": "Doe",
            "country": "US"
        }
    },
    "email": "something@example.com",
    "customer_acceptance": {
        "acceptance_type": "offline"
    }
}'

Response:

{
    "payment_id": "pay_CNM35m7O7JfdmH9qYyFq",
    "merchant_id": "merchant_1753277415",
    "status": "succeeded",
    "amount": 1650,
    "net_amount": 1650,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 1650,
    "connector": "globalpay",
    "client_secret": "pay_CNM35m7O7JfdmH9qYyFq_secret_uz67njQIBT8dhkSR2jcr",
    "created": "2025-07-23T17:29:50.150Z",
    "currency": "USD",
    "customer_id": "customer123ffffa",
    "customer": {
        "id": "customer123ffffa",
        "name": null,
        "email": "something@example.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": null,
            "country": "US",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": null,
            "state": null,
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "something@example.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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer123ffffa",
        "created_at": 1753291790,
        "expires": 1753295390,
        "secret": "epk_b79f5365965648aea900af73ee98fc51"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "TRN_hR9reO0fbf15HP7SDBznXeKNnhvb6u_fdmH9qYyFq_1",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_CNM35m7O7JfdmH9qYyFq_1",
    "payment_link": null,
    "profile_id": "pro_roCz974ra9LQxsifUris",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5Y545k7TI4upQYSbJJ9L",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-23T17:44:50.150Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_P66KYq7rG0B7f7RENNf2",
    "payment_method_status": "active",
    "updated": "2025-07-23T17:29:53.258Z",
    "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": "PMT_d6001c7b-6150-404d-92f3-56b217fb8a3d",
    "card_discovery": "manual",
    "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
}
  1. MIT using payment_method_id

cURL:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_otcCi6DyRzeDWx38OH5BTLBjBK1WS7Jt1BbsMpPepSR2Rr5dIPgVgPMoeekaqoXL' \
--header 'Cookie: PHPSESSID=0b47db9d7de94c37b6b272087a9f2fa7' \
--data '{
    "amount": 179,
    "currency": "USD",
    "confirm": true,
    "customer_id": "customer123ffffa",
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_P66KYq7rG0B7f7RENNf2"
    },
    "off_session": true
}'

Response:

{
    "payment_id": "pay_6pONwGPfaI6X8zmyOPcS",
    "merchant_id": "merchant_1753277415",
    "status": "succeeded",
    "amount": 179,
    "net_amount": 179,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 179,
    "connector": "globalpay",
    "client_secret": "pay_6pONwGPfaI6X8zmyOPcS_secret_XRjvCntYf6esUICifOQg",
    "created": "2025-07-23T17:30:01.371Z",
    "currency": "USD",
    "customer_id": "customer123ffffa",
    "customer": {
        "id": "customer123ffffa",
        "name": null,
        "email": "something@example.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": true,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "something@example.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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer123ffffa",
        "created_at": 1753291801,
        "expires": 1753295401,
        "secret": "epk_66d9de3b79db4ee3b35e9dd6db9c18e4"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "TRN_xgxrFV1PkebYZKabeA2R4qN63rqTka_6X8zmyOPcS_1",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_6pONwGPfaI6X8zmyOPcS_1",
    "payment_link": null,
    "profile_id": "pro_roCz974ra9LQxsifUris",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_5Y545k7TI4upQYSbJJ9L",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-07-23T17:45:01.371Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_P66KYq7rG0B7f7RENNf2",
    "payment_method_status": "active",
    "updated": "2025-07-23T17:30:05.264Z",
    "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": "PMT_d6001c7b-6150-404d-92f3-56b217fb8a3d",
    "card_discovery": "manual",
    "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

Globalpay Screenshot 2025-07-15 at 7 31 52 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 review from a team as code owners July 7, 2025 11:53
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jul 7, 2025

@bsayak03 bsayak03 self-assigned this Jul 7, 2025
@bsayak03 bsayak03 changed the title feat(connector): [GLOBALPAY] Implemented CIT & MIT feat(connector): [GLOBALPAY] Implemented Mandates Jul 7, 2025
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jul 7, 2025
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jul 7, 2025
@bsayak03 bsayak03 linked an issue Jul 7, 2025 that may be closed by this pull request
@bsayak03 bsayak03 changed the title feat(connector): [GLOBALPAY] Implemented Mandates fix(connector): [GLOBALPAY] Added Tokenization Flow for CITs Jul 7, 2025
@bsayak03 bsayak03 linked an issue Jul 7, 2025 that may be closed by this pull request
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jul 7, 2025
Chethan-rao
Chethan-rao previously approved these changes Jul 7, 2025
@bsayak03 bsayak03 dismissed stale reviews from Chethan-rao and deepanshu-iiitu via 3f3ed11 July 9, 2025 05:07
@bsayak03 bsayak03 requested a review from a team as a code owner July 9, 2025 05:07
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jul 9, 2025
@bsayak03 bsayak03 requested a review from a team as a code owner July 10, 2025 21:26
@bsayak03 bsayak03 added C-bug Category: Bug P-high Priority: High A-tokenization Area: Network Tokenization A-mandates Area: Mandate Flows Rust Pull requests that update Rust code labels Jul 10, 2025
@bsayak03
Copy link
Contributor Author

also, please fix the typos in globalpay/request and update the labels in the pr.

Which typo are you referring to particularly? @pixincreate

@pixincreate
Copy link
Member

image

Comment on lines +402 to +412
impl From<GlobalpayPaymentMethodStatus> for common_enums::PaymentMethodStatus {
fn from(item: GlobalpayPaymentMethodStatus) -> Self {
match item {
GlobalpayPaymentMethodStatus::Active => Self::Active,
GlobalpayPaymentMethodStatus::Inactive | GlobalpayPaymentMethodStatus::Delete => {
Self::Inactive
}
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused function

Comment on lines +603 to +611
let connector_mandate_request_reference_id =
item.request.mandate_id.as_ref().and_then(|mandate_ids| {
match &mandate_ids.mandate_reference_id {
Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
connector_mandate_ids,
)) => connector_mandate_ids.get_connector_mandate_request_reference_id(),
_ => None,
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not req, removed

Comment on lines +587 to +592
type MandateDetails = (
Option<Initiator>,
Option<StoredCredential>,
Option<String>,
Option<String>,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the function get_mandate_details
move entire logic to GlobalpayPaymentsRequest try_from

_ => None,
}
});
let connector_mandate_request_reference_id =
Copy link
Contributor

Choose a reason for hiding this comment

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

Test the payment_method_id flow for globalpay mandates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested, the curls in description working fine.

@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 29, 2025
Merged via the queue into main with commit f7bc33c Jul 29, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the global/mandates branch July 29, 2025 12:54
pixincreate added a commit that referenced this pull request Aug 1, 2025
…rver

* 'main' of github.com:juspay/hyperswitch: (25 commits)
  chore: `xof` currency to cybersource cards (#8799)
  chore(version): 2025.08.01.0
  feat(core): Implement UCS based  upi for  paytm and phonepe (#8732)
  feat(connector): [katapult]add template code for katapult (#8783)
  feat(router): introduce `feature`  and `feature_data` to gsm (#7771)
  feat(connector): [cybersource] add changes for field CybersourceConsumerAuthInformation (#8768)
  feat(authentication): added authentication sync api (#8596)
  feat(connector): [facilitapay] fix refunds, add webhook and void support (#8778)
  feat(connector): [payload] add recurring payments (#8597)
  chore(version): 2025.07.31.0
  feat(connector): [Flexiti]Add support for flexiti connector  (#8743)
  chore(router): events enhancement for kafka (#8780)
  ci(cypress): Making a mandate payment with large customer user agents (#8790)
  fix(openapi): update create_platform endpoint in api-reference docs (#8782)
  chore(version): 2025.07.30.0
  fix(connector): [GLOBALPAY] Added Tokenization Flow for CITs (#8568)
  feat(routing): Add api-refs for new decision engine endpoints (#8709)
  fix: replace xtrim with xdel to support  older redis version (#8515)
  fix(connector): [Worldpay] handle multiple ddc submission for CompleteAuthorize (#8741)
  feat(connector): [Adyen] receive incoming webhooks for pix expiry (#8720)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mandates Area: Mandate Flows A-tokenization Area: Network Tokenization C-bug Category: Bug P-high Priority: High Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] GlobalPay throws 501 for mandates

8 participants