Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(connector): [AIRWALLEX, MULTISAFEPAY, RAZORPAY, SHIFT4, WORLDPAY, ZSL] Move connectors from router to hyperswitch_connectors crate #6369

Merged
merged 25 commits into from
Nov 4, 2024

Conversation

spritianeja03
Copy link
Contributor

@spritianeja03 spritianeja03 commented Oct 18, 2024

Type of Change

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

Description

Moved connector Airwallex, Multisafepay, Razorpay, Shift4, Worldpay and Zsl from Router crate to hyperswitch_connectors crate.

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?

Multisafepay

  1. Merchant Account Create
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{"merchant_id":"postman_merchant_GHAction_1065dc44-f94e-4744-b15c-feb9f63b144b","locker_id":"m0010","merchant_name":"NewAge Retailer","primary_business_details":[{"country":"US","business":"default"}],"merchant_details":{"primary_contact_person":"John Test","primary_email":"[email protected]","primary_phone":"sunt laborum","secondary_contact_person":"John Test2","secondary_email":"[email protected]","secondary_phone":"cillum do dolor id","website":"www.example.com","about_business":"Online Retail with a wide selection of organic products for North America","address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US"}},"return_url":"https://duck.com","webhook_details":{"webhook_version":"1.0.1","webhook_username":"ekart_retail","webhook_password":"password_ekart@123","payment_created_enabled":true,"payment_succeeded_enabled":true,"payment_failed_enabled":true},"sub_merchants_enabled":false,"metadata":{"city":"NY","unit":"245"}}'
  1. API Key Create
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{"merchant_id":"postman_merchant_GHAction_1065dc44-f94e-4744-b15c-feb9f63b144b","locker_id":"m0010","merchant_name":"NewAge Retailer","primary_business_details":[{"country":"US","business":"default"}],"merchant_details":{"primary_contact_person":"John Test","primary_email":"[email protected]","primary_phone":"sunt laborum","secondary_contact_person":"John Test2","secondary_email":"[email protected]","secondary_phone":"cillum do dolor id","website":"www.example.com","about_business":"Online Retail with a wide selection of organic products for North America","address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US"}},"return_url":"https://duck.com","webhook_details":{"webhook_version":"1.0.1","webhook_username":"ekart_retail","webhook_password":"password_ekart@123","payment_created_enabled":true,"payment_succeeded_enabled":true,"payment_failed_enabled":true},"sub_merchants_enabled":false,"metadata":{"city":"NY","unit":"245"}}'
  1. Payment connector create
curl --location 'http://localhost:8080/account/postman_merchant_GHAction_8ced15a4-5c29-43bb-bbaa-5dc3c96e20a0/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "multisafepay",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "86c0___"

    },
    "test_mode": false,
    "disabled": false,
    "business_country": "US",
    "business_label": "default",
    "payment_methods_enabled": [
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "affirm"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "afterpay_clearpay"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "klarna"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "invoke_sdk_client",
                    "payment_method_type": "klarna"
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                },
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                }
                
            ]
        },
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "ideal",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "giropay",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sofort",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "eps",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "becs",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sepa",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_transfer",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "bacs",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sepa",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "debit",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "google_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "google_pay": {
            "allowed_payment_methods": [
                {
                    "type": "CARD",
                    "parameters": {
                        "allowed_auth_methods": [
                            "PAN_ONLY",
                            "CRYPTOGRAM_3DS"
                        ],
                        "allowed_card_networks": [
                            "AMEX",
                            "DISCOVER",
                            "INTERAC",
                            "JCB",
                            "MASTERCARD",
                            "VISA"
                        ]
                    },
                    "tokenization_specification": {
                        "type": "PAYMENT_GATEWAY",
                        "parameters": {
                            "gateway": "example",
                            "gateway_merchant_id": ""
                        }
                    }
                }
            ],
            "merchant_info": {
                "merchant_name": "Narayan Bhat"
            }
        }
    }
}'
  1. Payment Create
    Request
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_TufBwOhnJi33KSmiu0UH6yK4YS0Lf1sCxMWQtsL6wA1ter2EOAEG6qyNB03kxXnz' \
--data-raw '{
  "amount": 1200,
  "currency": "USD",
  "confirm": true,
  "capture_method": "automatic",
  "capture_on": "2022-09-10T10:11:12Z",
  "amount_to_capture": 1200,
  "customer_id": "StripeCustomer",
  "email": "[email protected]",
  "name": "John Doe",
  "phone": "999999999",
  "phone_country_code": "+65",
  "description": "Its my first payment request",
  "authentication_type": "three_ds",
  "return_url": "https://hs-payments-test.netlify.app/payments",
  "setup_future_usage": "off_session",
  "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"
    }
  },
  "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": "127.0.0.1"
  },
  "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"
  },
  "payment_method": "wallet",
  "payment_method_type": "paypal",
  "payment_method_data": {
    "wallet": {
      "paypal_redirect": {}
    }
  }
}









'

Response

{
    "payment_id": "pay_TzGlHb6BNbeiWs8oCcUo",
    "merchant_id": "postman_merchant_GHAction_8ced15a4-5c29-43bb-bbaa-5dc3c96e20a0",
    "status": "requires_customer_action",
    "amount": 1200,
    "net_amount": 1200,
    "shipping_cost": null,
    "amount_capturable": 1200,
    "amount_received": null,
    "connector": "multisafepay",
    "client_secret": "pay_TzGlHb6BNbeiWs8oCcUo_secret_AyESdhRFL4faKyzRuhT9",
    "created": "2024-10-30T10:17:38.682Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John 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": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {},
        "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": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_TzGlHb6BNbeiWs8oCcUo/postman_merchant_GHAction_8ced15a4-5c29-43bb-bbaa-5dc3c96e20a0/pay_TzGlHb6BNbeiWs8oCcUo_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "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": {
        "customer_id": "StripeCustomer",
        "created_at": 1730283458,
        "expires": 1730287058,
        "secret": "epk_42ec8e85781f47e9905f7ea5a6e1d83d"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pay_TzGlHb6BNbeiWs8oCcUo_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_TzGlHb6BNbeiWs8oCcUo_1",
    "payment_link": null,
    "profile_id": "pro_pElUALDEgI6YV9vkF3k1",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_FxkTFmTgQqpjTEEoCRye",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-10-30T10:32:38.682Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "127.0.0.1",
        "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": "2024-10-30T10:17:40.362Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
  1. Payments Retreive
    Request
curl --location 'http://localhost:8080/payments/pay_TzGlHb6BNbeiWs8oCcUo' \
--header 'Accept: application/json' \
--header 'api-key: dev_TufBwOhnJi33KSmiu0UH6yK4YS0Lf1sCxMWQtsL6wA1ter2EOAEG6qyNB03kxXnz'

Response

{
    "payment_id": "pay_TzGlHb6BNbeiWs8oCcUo",
    "merchant_id": "postman_merchant_GHAction_8ced15a4-5c29-43bb-bbaa-5dc3c96e20a0",
    "status": "requires_customer_action",
    "amount": 1200,
    "net_amount": 1200,
    "shipping_cost": null,
    "amount_capturable": 1200,
    "amount_received": null,
    "connector": "multisafepay",
    "client_secret": "pay_TzGlHb6BNbeiWs8oCcUo_secret_AyESdhRFL4faKyzRuhT9",
    "created": "2024-10-30T10:17:38.682Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John 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": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {},
        "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": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_TzGlHb6BNbeiWs8oCcUo/postman_merchant_GHAction_8ced15a4-5c29-43bb-bbaa-5dc3c96e20a0/pay_TzGlHb6BNbeiWs8oCcUo_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "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": null,
    "connector_transaction_id": "pay_TzGlHb6BNbeiWs8oCcUo_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_TzGlHb6BNbeiWs8oCcUo_1",
    "payment_link": null,
    "profile_id": "pro_pElUALDEgI6YV9vkF3k1",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_FxkTFmTgQqpjTEEoCRye",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-10-30T10:32:38.682Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "127.0.0.1",
        "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": "2024-10-30T10:17:40.362Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Shift4

  1. Merchant Account Create
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "merchant_id": "merchant_1730283636",
    "locker_id": "m0010",
    "merchant_name": "NewAge Retailer",
    "merchant_details": {
        "primary_contact_person": "John Test",
        "primary_email": "[email protected]",
        "primary_phone": "sunt laborum",
        "secondary_contact_person": "John Test2",
        "secondary_email": "[email protected]",
        "secondary_phone": "cillum do dolor id",
        "website": "www.example.com",
        "about_business": "Online Retail with a wide selection of organic products for North America",
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US"
        }
    },
    "return_url": "https://duck.com",
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "payment_created_enabled": true,
        "payment_succeeded_enabled": true,
        "payment_failed_enabled": true
    },
    "primary_business_details": [
        {
            "country": "US",
            "business": "default"
        }
    ],
    "sub_merchants_enabled": false,
    "metadata": {
        "city": "NY",
        "unit": "245"
    }
}'
  1. API Key Create
curl --location 'http://localhost:8080/api_keys/merchant_1730283633' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{"name":"API Key 1","description":null,"expiration":"2069-09-23T01:02:03.000Z"}'
  1. Payment Connector Create
curl --location 'http://localhost:8080/account/merchant_1730283633/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "shift4",
    "business_country": "US",
    "business_label": "default",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "Basic c2t__"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "gpay": {
            "allowed_payment_methods": [
                {
                    "type": "CARD",
                    "parameters": {
                        "allowed_auth_methods": [
                            "PAN_ONLY",
                            "CRYPTOGRAM_3DS"
                        ],
                        "allowed_card_networks": [
                            "AMEX",
                            "DISCOVER",
                            "INTERAC",
                            "JCB",
                            "MASTERCARD",
                            "VISA"
                        ]
                    },
                    "tokenization_specification": {
                        "type": "PAYMENT_GATEWAY",
                        "parameters": {
                            "gateway": "example",
                            "gateway_merchant_id": "exampleGatewayMerchantId"
                        }
                    }
                }
            ],
            "merchant_info": {
                "merchant_name": "Narayan Bhat"
            }
        }
    }
}'
  1. Payment Create
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_DeHgzgycPF7hN0rYtqMvYwyDDSCLxq6iShtEa30GmwF3sMkEs3L6epMHVWJ4mVww' \
--data-raw '{"amount":6540,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","amount_to_capture":6540,"customer_id":"StripeCustomer","email":"[email protected]","name":"John Doe","phone":"999999999","phone_country_code":"+1","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://duck.com","payment_method":"card","payment_method_data":{"card":{"card_number":"4242424242424242","card_exp_month":"10","card_exp_year":"25","card_holder_name":"joseph Doe","card_cvc":"123"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US","first_name":"PiX","last_name":"Fix"}},"shipping":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US","first_name":"PiX","last_name":"Fix"}},"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"}}'
  1. Payment Retreive
    Request
curl --location 'http://localhost:8080/payments/pay_KmHxye9RoexrG6f6bydq' \
--header 'Accept: application/json' \
--header 'api-key: dev_DeHgzgycPF7hN0rYtqMvYwyDDSCLxq6iShtEa30GmwF3sMkEs3L6epMHVWJ4mVww'

Response

{
    "payment_id": "pay_KmHxye9RoexrG6f6bydq",
    "merchant_id": "merchant_1730283633",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "shift4",
    "client_secret": "pay_KmHxye9RoexrG6f6bydq_secret_VWlULL4D41zPLenyfWhC",
    "created": "2024-10-30T10:21:50.017Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "STRIPE PAYMENTS UK LIMITED",
            "card_issuing_country": "UNITEDKINGDOM",
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_1lKy27KbQfeoblowcPEZ",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "Fix"
        },
        "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": "PiX",
            "last_name": "Fix"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.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": null,
    "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": "char_hD8dPxtkAfXYPBEX5zhIFHBp",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "char_hD8dPxtkAfXYPBEX5zhIFHBp",
    "payment_link": null,
    "profile_id": "pro_HqPBEPdGu6DThZSFnDSB",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_SkAZvF7cbc7XPqGZaCbz",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-10-30T10:36:50.017Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-10-30T10:21:50.894Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@spritianeja03 spritianeja03 self-assigned this Oct 18, 2024
Copy link

semanticdiff-com bot commented Oct 18, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector.rs  82% smaller
  crates/hyperswitch_connectors/src/connectors/zsl/transformers.rs  81% smaller
  crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs  66% smaller
  crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs  64% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs  59% smaller
  crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs  55% smaller
  crates/hyperswitch_connectors/src/connectors.rs  53% smaller
  crates/hyperswitch_connectors/src/connectors/zsl.rs  52% smaller
  crates/hyperswitch_connectors/src/connectors/multisafepay.rs  49% smaller
  crates/hyperswitch_domain_models/src/types.rs  48% smaller
  crates/hyperswitch_connectors/src/connectors/shift4.rs  47% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay.rs  47% smaller
  crates/hyperswitch_connectors/src/connectors/airwallex.rs  45% smaller
  crates/hyperswitch_connectors/src/connectors/razorpay.rs  45% smaller
  crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs  40% smaller
  crates/router/src/core/payments/flows.rs  35% smaller
  crates/hyperswitch_connectors/src/utils.rs  33% smaller
  crates/hyperswitch_connectors/src/default_implementations.rs  29% smaller
  crates/hyperswitch_connectors/src/default_implementations_v2.rs  27% smaller
  crates/router/src/core/payments/connector_integration_v2_impls.rs  14% smaller
  crates/hyperswitch_connectors/src/types.rs  13% smaller
  Cargo.lock Unsupported file format
  crates/hyperswitch_connectors/Cargo.toml Unsupported file format
  crates/hyperswitch_connectors/src/connectors/worldpay/requests.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay/response.rs  0% smaller
  crates/hyperswitch_connectors/src/constants.rs  0% smaller
  crates/hyperswitch_connectors/src/lib.rs  0% smaller
  crates/hyperswitch_connectors/src/metrics.rs  0% smaller

@spritianeja03 spritianeja03 marked this pull request as ready for review October 25, 2024 11:58
@spritianeja03 spritianeja03 requested review from a team as code owners October 25, 2024 11:58
@spritianeja03 spritianeja03 changed the title refactor(connector): [AIRWALLEX] Move Airwallex from Router to hyperswitch_connectors Crate refactor(connector): [AIRWALLEX, MULTISAFEPAY, RAZORPAY, SHIFT4, SIGNIFYD, WORLDPAY, ZSL] Move Airwallex, Multisafepay, Razorpay, Shift4, Signifyd, Worldpay and Zsl from Router to hyperswitch_connectors Crate Oct 28, 2024
@spritianeja03 spritianeja03 changed the title refactor(connector): [AIRWALLEX, MULTISAFEPAY, RAZORPAY, SHIFT4, SIGNIFYD, WORLDPAY, ZSL] Move Airwallex, Multisafepay, Razorpay, Shift4, Signifyd, Worldpay and Zsl from Router to hyperswitch_connectors Crate refactor(connector): [AIRWALLEX, MULTISAFEPAY, RAZORPAY, SHIFT4, WORLDPAY, ZSL] Move Airwallex, Multisafepay, Razorpay, Shift4, Worldpay and Zsl from Router to hyperswitch_connectors Crate Oct 29, 2024
.as_ref()
.and_then(|billing_address| billing_address.get_optional_full_name())
}
}
pub trait PaymentsPreProcessingRequestData {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub trait PaymentsPreProcessingRequestData {
pub trait PaymentsPreProcessingData {

Rename this trait to PaymentsPreProcessingData

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another struct with the name PaymentsPreProcessingData already exists in [router_request_types.rs] file
So upon renaming the trait PaymentsPreProcessingRequestData to this name, it gives an error

Comment on lines 18 to 19
/// Worldpay's unique reference ID for a request TODO: Move to hyperswitch_connectors/constants once Worldpay is moved to connectors crate
pub const WP_CORRELATION_ID: &str = "WP-CorrelationId";
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this const definition to crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs

@@ -1310,7 +1310,7 @@ pub fn get_connector_label(
format!("{connector_name}_{business_country}_{business_label}");

// Business sub label is currently being used only for cybersource
// To ensure backwards compatibality, cybersource mca's created before this change
// To ensure backwards compatibality, cybersource mca's created be this change
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 done? Remove this change if not required.

connectors::Zen,
connectors::Zsl,
Copy link
Contributor

Choose a reason for hiding this comment

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

Values for default_imp_for_calculate_tax are not sorted alphabetically.

@SanchithHegde SanchithHegde changed the title refactor(connector): [AIRWALLEX, MULTISAFEPAY, RAZORPAY, SHIFT4, WORLDPAY, ZSL] Move Airwallex, Multisafepay, Razorpay, Shift4, Worldpay and Zsl from Router to hyperswitch_connectors Crate refactor(connector): [AIRWALLEX, MULTISAFEPAY, RAZORPAY, SHIFT4, WORLDPAY, ZSL] Move connectors from router to hyperswitch_connectors crate Oct 30, 2024
@SanchithHegde SanchithHegde added the A-connector-integration Area: Connector integration label Oct 30, 2024
@SanchithHegde SanchithHegde added the C-refactor Category: Refactor label Oct 30, 2024
@spritianeja03 spritianeja03 added this to the October 2024 Release milestone Oct 30, 2024
crates/hyperswitch_connectors/src/constants.rs Outdated Show resolved Hide resolved
crates/hyperswitch_connectors/src/metrics.rs Outdated Show resolved Hide resolved
crates/hyperswitch_interfaces/src/consts.rs Outdated Show resolved Hide resolved
strum = { version = "0.26", features = ["derive"] }
time = "0.3.35"
url = "2.5.0"
urlencoding = "2.1.3"
Copy link
Member

Choose a reason for hiding this comment

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

Can we confirm if we can use the url_encode() utility method instead of the urlencoding crate?

Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu Oct 30, 2024

Choose a reason for hiding this comment

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

This function url_encode() supports serialization only for maps and structs, hence we cannot use this.

SanchithHegde
SanchithHegde previously approved these changes Oct 30, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 4, 2024
Merged via the queue into main with commit 72ee434 Nov 4, 2024
15 of 17 checks passed
@likhinbopanna likhinbopanna deleted the move-connector branch November 4, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants