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

feat(connector): Added a new CaptureMethod SequentialAutomatic to Support CIT Mandates for Paybox #6587

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

Conversation

awasthi21
Copy link
Contributor

@awasthi21 awasthi21 commented Nov 15, 2024

Type of Change

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

Description

  1. Added a new CaptureMethod : SequentialAutomatic -> does Auth and capture in two api calls one after the other
  1. For Paybox:

    • If the payment is a Customer-Initiated Transaction (CIT), two API calls will be made:
      • First for Authorization (Auth)
      • Followed by Capture (Capture)
    • For all other payment types, SequentialAutomatic will function the same as Automatic.
  2. For other connectors:

Additional Changes

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

Motivation and Context

For Customer-Initiated Transactions (CIT) with Paybox, authorization and capture must be performed as two separate operations. Paybox does not support a combined authorization and capture in a single request. To avoid requiring the merchant to handle this process, we introduced a new capture method: SequentialAutomatic, which ensures that two API calls are made automatically.

How did you test it?

  1. CIT Payment + 3DS Test
    • Request:
      curl --location 'http://localhost:8080/payments'
      --header 'Content-Type: application/json'
      --header 'Accept: application/json'
      --header 'api-key: dev_wmCOQW4LM2BHYugFWaU8crmipDtmGDsq0iozaQhe17CtM59tqCHSAtD8w646AkZU'
      --data '{
      "amount": 501,
      "currency": "EUR",
      "confirm": true,
      "capture_method": "sequential_automatic",
      "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"
      }
      },
      "customer_acceptance": {
      "acceptance_type": "online",
      "accepted_at":"1963-05-03T04:07:52.723Z",
      "online": {
      "ip_address":"127.0.0.1",
      "user_agent": "amet irure esse"
      }
      },
      "payment_method": "card",
      "payment_method_data": {
      "card": {
      "card_number": "5200000000000007",
      "card_exp_month": "01",
      "card_exp_year": "26",
      "card_holder_name": "John T",
      "card_cvc": "123"
      }
      },
      "customer_id":"test_mit",
      "authentication_type": "three_ds",
      "return_url": "https://google.com",
      "setup_future_usage": "off_session"
      }'
  • Response:
    {
    "payment_id": "pay_Q75JaLo7wPiCAh8nrkZc",
    "merchant_id": "postman_merchant_GHAction_3a560136-e947-4667-bb84-2f015fcc1196",
    "status": "requires_customer_action",
    "amount": 501,
    "net_amount": 501,
    "shipping_cost": null,
    "amount_capturable": 501,
    "amount_received": null,
    "connector": "paybox",
    "client_secret": "pay_Q75JaLo7wPiCAh8nrkZc_secret_Qa4XYmBSyuDUbaqKtJ7r",
    "created": "2024-11-19T03:58:16.513Z",
    "currency": "EUR",
    "customer_id": "test_mit",
    "customer": {
    "id": "test_mit",
    "name": "Joseph Doe",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+65"
    },
    "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": "sequential_automatic",
    "payment_method": "card",
    "payment_method_data": {
    "card": {
    "last4": "0007",
    "card_type": null,
    "card_network": null,
    "card_issuer": null,
    "card_issuing_country": null,
    "card_isin": "520000",
    "card_extended_bin": null,
    "card_exp_month": "01",
    "card_exp_year": "26",
    "card_holder_name": null,
    "payment_checks": null,
    "authentication_data": null
    },
    "billing": null
    },
    "payment_token": "token_9qL6FgoOzIVLvviNRNwL",
    "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"
    },
    "phone": {
    "number": "8056594427",
    "country_code": "+91"
    },
    "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
    "type": "redirect_to_url",
    "redirect_to_url": "http://localhost:8080/payments/redirect/pay_Q75JaLo7wPiCAh8nrkZc/postman_merchant_GHAction_3a560136-e947-4667-bb84-2f015fcc1196/pay_Q75JaLo7wPiCAh8nrkZc_1"
    },
    "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": {
    "customer_id": "test_mit",
    "created_at": 1731988696,
    "expires": 1731992296,
    "secret": "epk_e83b819668e84eb99ab249e855471ed8"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_hl5seUYAuPOk5MN8bSGO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_DsQkwRcnsQVWJ7jbsSZl",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-19T04:13:16.513Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_vdP2g5rwDJBoKDubJPvQ",
    "payment_method_status": "inactive",
    "updated": "2024-11-19T03:58:17.469Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
    }

1.1. Payment Sync

  • Request:
    curl --location 'http://localhost:8080/payments/pay_DMkbjecVspKCAf7Sjl2o'
    --header 'Accept: application/json'
    --header 'api-key: dev_wmCOQW4LM2BHYugFWaU8crmipDtmGDsq0iozaQhe17CtM59tqCHSAtD8w646AkZU'
  • Response:
    {
    "payment_id": "pay_Q75JaLo7wPiCAh8nrkZc",
    "merchant_id": "postman_merchant_GHAction_3a560136-e947-4667-bb84-2f015fcc1196",
    "status": "succeeded",
    "amount": 501,
    "net_amount": 501,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 501,
    "connector": "paybox",
    "client_secret": "pay_Q75JaLo7wPiCAh8nrkZc_secret_Qa4XYmBSyuDUbaqKtJ7r",
    "created": "2024-11-19T03:58:16.513Z",
    "currency": "EUR",
    "customer_id": "test_mit",
    "customer": {
    "id": "test_mit",
    "name": "Joseph Doe",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+65"
    },
    "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": "sequential_automatic",
    "payment_method": "card",
    "payment_method_data": {
    "card": {
    "last4": "0007",
    "card_type": null,
    "card_network": null,
    "card_issuer": null,
    "card_issuing_country": null,
    "card_isin": "520000",
    "card_extended_bin": null,
    "card_exp_month": "01",
    "card_exp_year": "26",
    "card_holder_name": null,
    "payment_checks": null,
    "authentication_data": null
    },
    "billing": null
    },
    "payment_token": "token_9qL6FgoOzIVLvviNRNwL",
    "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"
    },
    "phone": {
    "number": "8056594427",
    "country_code": "+91"
    },
    "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": 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": "0080164085",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_hl5seUYAuPOk5MN8bSGO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_DsQkwRcnsQVWJ7jbsSZl",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-19T04:13:16.513Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_vdP2g5rwDJBoKDubJPvQ",
    "payment_method_status": "active",
    "updated": "2024-11-19T03:59:47.678Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
    }

1.3. MIT payment

  • Request
    curl --location 'http://localhost:8080/payments'
    --header 'Content-Type: application/json'
    --header 'Accept: application/json'
    --header 'api-key: dev_wmCOQW4LM2BHYugFWaU8crmipDtmGDsq0iozaQhe17CtM59tqCHSAtD8w646AkZU'
    --data-raw '{
    "amount": 7100,
    "currency": "EUR",
    "confirm": true,
    "customer_id": "test_mit",
    "email": "[email protected]",
    "off_session": true,
    "recurring_details": {
    "type": "payment_method_id",
    "data": "pm_vdP2g5rwDJBoKDubJPvQ"
    },
    "payment_method": "card",
    "billing": {
    "address": {
    "city": "test",
    "country": "US",
    "line1": "here",
    "line2": "there",
    "line3": "anywhere",
    "zip": "560095",
    "state": "Washington",
    "first_name": "One",
    "last_name": "Two"
    },
    "phone": {
    "number": "1234567890",
    "country_code": "+1"
    },
    "email": "[email protected]"
    }
    }'
    -Response
    {
    "payment_id": "pay_DMkbjecVspKCAf7Sjl2o",
    "merchant_id": "postman_merchant_GHAction_3a560136-e947-4667-bb84-2f015fcc1196",
    "status": "succeeded",
    "amount": 7100,
    "net_amount": 7100,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 7100,
    "connector": "paybox",
    "client_secret": "pay_DMkbjecVspKCAf7Sjl2o_secret_Ub8XUCMAUqgIdWYgDN2N",
    "created": "2024-11-19T04:01:26.747Z",
    "currency": "EUR",
    "customer_id": "test_mit",
    "customer": {
    "id": "test_mit",
    "name": "Joseph Doe",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+65"
    },
    "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": "0007",
    "card_type": null,
    "card_network": null,
    "card_issuer": null,
    "card_issuing_country": null,
    "card_isin": "520000",
    "card_extended_bin": null,
    "card_exp_month": "01",
    "card_exp_year": "26",
    "card_holder_name": "John T",
    "payment_checks": null,
    "authentication_data": null
    },
    "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
    "address": {
    "city": "test",
    "country": "US",
    "line1": "here",
    "line2": "there",
    "line3": "anywhere",
    "zip": "560095",
    "state": "Washington",
    "first_name": "One",
    "last_name": "Two"
    },
    "phone": {
    "number": "1234567890",
    "country_code": "+1"
    },
    "email": "[email protected]"
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph 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": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
    "customer_id": "test_mit",
    "created_at": 1731988886,
    "expires": 1731992486,
    "secret": "epk_d193d4bab05147aea937bdd6c5c84568"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "0080164087",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_hl5seUYAuPOk5MN8bSGO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_DsQkwRcnsQVWJ7jbsSZl",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-19T04:16:26.747Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_vdP2g5rwDJBoKDubJPvQ",
    "payment_method_status": "active",
    "updated": "2024-11-19T04:01:28.480Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "SM@LpCp@L@C"
    }
  1. CIT Payment + No3DS Test
    2.1 -Request
    curl --location 'http://localhost:8080/payments'
    --header 'Content-Type: application/json'
    --header 'Accept: application/json'
    --header 'api-key: dev_wmCOQW4LM2BHYugFWaU8crmipDtmGDsq0iozaQhe17CtM59tqCHSAtD8w646AkZU'
    --data '{
    "amount": 501,
    "currency": "EUR",
    "confirm": true,
    "capture_method": "sequential_automatic",
    "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"
    }
    },
    "customer_acceptance": {
    "acceptance_type": "online",
    "accepted_at":"1963-05-03T04:07:52.723Z",
    "online": {
    "ip_address":"127.0.0.1",
    "user_agent": "amet irure esse"
    }
    },
    "payment_method": "card",
    "payment_method_data": {
    "card": {
    "card_number": "5200000000000007",
    "card_exp_month": "01",
    "card_exp_year": "26",
    "card_holder_name": "John T",
    "card_cvc": "123"
    }
    },
    "customer_id":"test_mit",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "setup_future_usage": "off_session"
    }'
    -Response
    {
    "payment_id": "pay_Adusyo4wM4lvxsG9G8Og",
    "merchant_id": "postman_merchant_GHAction_3a560136-e947-4667-bb84-2f015fcc1196",
    "status": "succeeded",
    "amount": 501,
    "net_amount": 501,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 501,
    "connector": "paybox",
    "client_secret": "pay_Adusyo4wM4lvxsG9G8Og_secret_zxcn25iSAsbZ8HKAIokb",
    "created": "2024-11-19T04:08:34.637Z",
    "currency": "EUR",
    "customer_id": "test_mit",
    "customer": {
    "id": "test_mit",
    "name": "Joseph Doe",
    "email": "[email protected]",
    "phone": "999999999",
    "phone_country_code": "+65"
    },
    "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": "sequential_automatic",
    "payment_method": "card",
    "payment_method_data": {
    "card": {
    "last4": "0007",
    "card_type": null,
    "card_network": null,
    "card_issuer": null,
    "card_issuing_country": null,
    "card_isin": "520000",
    "card_extended_bin": null,
    "card_exp_month": "01",
    "card_exp_year": "26",
    "card_holder_name": null,
    "payment_checks": null,
    "authentication_data": null
    },
    "billing": null
    },
    "payment_token": "token_R1rt2mhmfi7yN57PFJuO",
    "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"
    },
    "phone": {
    "number": "8056594427",
    "country_code": "+91"
    },
    "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": 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": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
    "customer_id": "test_mit",
    "created_at": 1731989314,
    "expires": 1731992914,
    "secret": "epk_6727367741724d5fbf3e027fe31653a2"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "0080164102",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_hl5seUYAuPOk5MN8bSGO",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_DsQkwRcnsQVWJ7jbsSZl",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-11-19T04:23:34.637Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_fjGE1FjOztrWm26w5gfS",
    "payment_method_status": "active",
    "updated": "2024-11-19T04:08:37.521Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "SM@LpCp@L@C"
    }

2.2MIT payment
-Request
curl --location 'http://localhost:8080/payments'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'api-key: dev_wmCOQW4LM2BHYugFWaU8crmipDtmGDsq0iozaQhe17CtM59tqCHSAtD8w646AkZU'
--data-raw '{
"amount": 7100,
"currency": "EUR",
"confirm": true,
"customer_id": "test_mit",
"email": "[email protected]",
"off_session": true,
"recurring_details": {
"type": "payment_method_id",
"data": "pm_fjGE1FjOztrWm26w5gfS"
},
"payment_method": "card",
"billing": {
"address": {
"city": "test",
"country": "US",
"line1": "here",
"line2": "there",
"line3": "anywhere",
"zip": "560095",
"state": "Washington",
"first_name": "One",
"last_name": "Two"
},
"phone": {
"number": "1234567890",
"country_code": "+1"
},
"email": "[email protected]"
}
}'
-Response
{
"payment_id": "pay_ozT3qe38r1krdHLhyfDS",
"merchant_id": "postman_merchant_GHAction_3a560136-e947-4667-bb84-2f015fcc1196",
"status": "succeeded",
"amount": 7100,
"net_amount": 7100,
"shipping_cost": null,
"amount_capturable": 0,
"amount_received": 7100,
"connector": "paybox",
"client_secret": "pay_ozT3qe38r1krdHLhyfDS_secret_RRTrzdf41k8C5J8CXFc4",
"created": "2024-11-19T04:09:39.712Z",
"currency": "EUR",
"customer_id": "test_mit",
"customer": {
"id": "test_mit",
"name": "Joseph Doe",
"email": "[email protected]",
"phone": "999999999",
"phone_country_code": "+65"
},
"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": "0007",
"card_type": null,
"card_network": null,
"card_issuer": null,
"card_issuing_country": null,
"card_isin": "520000",
"card_extended_bin": null,
"card_exp_month": "01",
"card_exp_year": "26",
"card_holder_name": "John T",
"payment_checks": null,
"authentication_data": null
},
"billing": null
},
"payment_token": null,
"shipping": null,
"billing": {
"address": {
"city": "test",
"country": "US",
"line1": "here",
"line2": "there",
"line3": "anywhere",
"zip": "560095",
"state": "Washington",
"first_name": "One",
"last_name": "Two"
},
"phone": {
"number": "1234567890",
"country_code": "+1"
},
"email": "[email protected]"
},
"order_details": null,
"email": "[email protected]",
"name": "Joseph 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": null,
"connector_label": null,
"business_country": null,
"business_label": "default",
"business_sub_label": null,
"allowed_payment_method_types": null,
"ephemeral_key": {
"customer_id": "test_mit",
"created_at": 1731989379,
"expires": 1731992979,
"secret": "epk_ad52b99e9b23445f8f7688e4941b84c2"
},
"manual_retry_allowed": false,
"connector_transaction_id": "0080164108",
"frm_message": null,
"metadata": null,
"connector_metadata": null,
"feature_metadata": null,
"reference_id": null,
"payment_link": null,
"profile_id": "pro_hl5seUYAuPOk5MN8bSGO",
"surcharge_details": null,
"attempt_count": 1,
"merchant_decision": null,
"merchant_connector_id": "mca_DsQkwRcnsQVWJ7jbsSZl",
"incremental_authorization_allowed": null,
"authorization_count": null,
"incremental_authorizations": null,
"external_authentication_details": null,
"external_3ds_authentication_attempted": false,
"expires_on": "2024-11-19T04:24:39.712Z",
"fingerprint": null,
"browser_info": null,
"payment_method_id": "pm_fjGE1FjOztrWm26w5gfS",
"payment_method_status": "active",
"updated": "2024-11-19T04:09:41.363Z",
"charges": null,
"frm_metadata": null,
"merchant_order_reference_id": null,
"order_tax_amount": null,
"connector_mandate_id": "SM@LpCp@L@C"
}

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

@awasthi21 awasthi21 added A-connector-integration Area: Connector integration A-core Area: Core flows labels Nov 15, 2024
@awasthi21 awasthi21 self-assigned this Nov 15, 2024
@awasthi21 awasthi21 requested review from a team as code owners November 15, 2024 19:30
Copy link

semanticdiff-com bot commented Nov 15, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs  85% smaller
  crates/hyperswitch_connectors/src/connectors/elavon.rs  85% smaller
  crates/hyperswitch_connectors/src/connectors/fiuu.rs  85% smaller
  crates/hyperswitch_connectors/src/connectors/payeezy.rs  85% smaller
  crates/router/src/connector/datatrans.rs  85% smaller
  crates/router/src/connector/rapyd/transformers.rs  85% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/fiservemea/transformers.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/airwallex.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/bambora.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/cashtocode.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/coinbase.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/deutschebank.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/dlocal.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/fiserv.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/fiservemea.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/forte.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/helcim.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/nexixpay.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/novalnet.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/payu.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/powertranz.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/shift4.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/square.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/stax.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/tsys.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/worldline.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay.rs  84% smaller
  crates/router/src/connector/authorizedotnet.rs  84% smaller
  crates/router/src/connector/bamboraapac.rs  84% smaller
  crates/router/src/connector/bankofamerica.rs  84% smaller
  crates/router/src/connector/bluesnap.rs  84% smaller
  crates/router/src/connector/boku.rs  84% smaller
  crates/router/src/connector/braintree.rs  84% smaller
  crates/router/src/connector/cybersource.rs  84% smaller
  crates/router/src/connector/dummyconnector.rs  84% smaller
  crates/router/src/connector/klarna.rs  84% smaller
  crates/router/src/connector/nmi.rs  84% smaller
  crates/router/src/connector/noon.rs  84% smaller
  crates/router/src/connector/nuvei.rs  84% smaller
  crates/router/src/connector/opayo.rs  84% smaller
  crates/router/src/connector/paybox.rs  84% smaller
  crates/router/src/connector/payme.rs  84% smaller
  crates/router/src/connector/paypal.rs  84% smaller
  crates/router/src/connector/rapyd.rs  84% smaller
  crates/router/src/connector/wellsfargo.rs  84% smaller
  crates/router/src/core/payments.rs  84% smaller
  crates/hyperswitch_connectors/src/connectors/billwerk.rs  83% smaller
  crates/hyperswitch_connectors/src/connectors/nexinets.rs  83% smaller
  crates/router/src/core/utils.rs  83% smaller
  crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs  83% smaller
  crates/router/src/connector/wellsfargo/transformers.rs  83% smaller
  crates/hyperswitch_connectors/src/utils.rs  82% smaller
  crates/router/src/connector/checkout/transformers.rs  82% smaller
  crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs  81% smaller
  crates/router/src/connector/globalpay.rs  79% smaller
  crates/router/src/connector/stripe.rs  75% smaller
  crates/hyperswitch_connectors/src/connectors/globepay.rs  74% smaller
  crates/router/src/connector/paybox/transformers.rs  74% smaller
  crates/router/src/connector/authorizedotnet/transformers.rs  72% smaller
  api-reference-v2/openapi_spec.json  67% smaller
  api-reference/openapi_spec.json  67% smaller
  crates/router/src/connector/adyen.rs  67% smaller
  crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs  64% smaller
  crates/router/src/connector/stripe/transformers.rs  64% smaller
  crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs  64% smaller
  crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs  63% smaller
  crates/router/src/connector/utils.rs  50% smaller
  crates/router/src/connector/checkout.rs  26% smaller
  crates/router/src/core/payments/helpers.rs  11% smaller
  crates/router/src/core/payments/flows/authorize_flow.rs  8% smaller
  crates/hyperswitch_domain_models/src/router_response_types.rs  4% smaller
  crates/hyperswitch_interfaces/src/api.rs  3% smaller
  crates/router/src/core/fraud_check/operation/fraud_check_post.rs  3% smaller
  crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs  3% smaller
  crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs  3% smaller
  crates/hyperswitch_connectors/src/connectors/multisafepay.rs  3% smaller
  crates/hyperswitch_connectors/src/connectors/zsl.rs  3% smaller
  crates/router/src/connector/gocardless.rs  3% smaller
  crates/router/src/connector/placetopay.rs  3% smaller
  crates/router/src/types.rs  2% smaller
  crates/router/src/core/payments/flows/complete_authorize_flow.rs  1% smaller
  crates/router/src/core/payments/flows.rs  1% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs  0% smaller
  crates/router/src/core/payments/routing/transformers.rs  0% smaller
  migrations/2024-11-15-171347_add_capture_method_sequential_automatic/down.sql Unsupported file format
  migrations/2024-11-15-171347_add_capture_method_sequential_automatic/up.sql Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Nov 15, 2024
@awasthi21 awasthi21 force-pushed the 7473-feature-core-add-new-type-sequentialautomatic-for-capturemethod-to-support-paybox-mandates branch from 886e20b to 259c776 Compare November 15, 2024 19:51
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 15, 2024
@awasthi21 awasthi21 changed the title init-commit Feature(core): Added a new CaptureMethod : SequentialAutomatic to Support CIT Mandates for Paybox Nov 15, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 15, 2024
@awasthi21 awasthi21 changed the title Feature(core): Added a new CaptureMethod : SequentialAutomatic to Support CIT Mandates for Paybox feat(core): Added a new CaptureMethod : SequentialAutomatic to Support CIT Mandates for Paybox Nov 19, 2024
@awasthi21 awasthi21 changed the title feat(core): Added a new CaptureMethod : SequentialAutomatic to Support CIT Mandates for Paybox feat(core): Added a new CaptureMethod SequentialAutomatic to Support CIT Mandates for Paybox Nov 19, 2024
@awasthi21 awasthi21 changed the title feat(core): Added a new CaptureMethod SequentialAutomatic to Support CIT Mandates for Paybox feat(connector): Added a new CaptureMethod SequentialAutomatic to Support CIT Mandates for Paybox Nov 19, 2024
new_router_data.status,
) {
// Convert Authorize RouterData into Capture RouterData
let mut capture_router_data = convert_auth_to_capture(&new_router_data)?;
Copy link
Member

Choose a reason for hiding this comment

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

use router_data_type_conversion function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

implemented the suggested change.

&post_capture_resp,
));
}
(_, _, _) => {
Copy link
Member

Choose a reason for hiding this comment

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

log the error here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

logged the errors

}
}
}
Err(_) => {
Copy link
Member

Choose a reason for hiding this comment

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

here too, log the error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

implemented the suggested change.

}
}

/// Function to check if the Capture API should be called
Copy link
Member

Choose a reason for hiding this comment

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

provide better description as to why / who / when this function can be called. A detailed description as to why we are matching over the params.

Comment on lines 6177 to 6181
*connector_name == router_types::Connector::Paybox
&& (off_session == Some(true) || setup_future_usage == Some(enums::FutureUsage::OffSession))
&& customer_acceptance.is_some()
&& capture_method == Some(enums::CaptureMethod::SequentialAutomatic)
&& status == common_enums::AttemptStatus::Authorized
Copy link
Member

Choose a reason for hiding this comment

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

Do not add all the conditions in a single condition, you can first check for the status, then the capture method. After that match on the connector, then the other conditions. Using this it will be extensible to add other connectors as well

&& status == common_enums::AttemptStatus::Authorized
}

pub fn merge_transaction_responses(
Copy link
Member

Choose a reason for hiding this comment

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

can you provide this as a impl on the PaymentsResponseData? Please check if that is possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

) => {
new_router_data.status = common_enums::AttemptStatus::Charged;
new_router_data.response =
Ok(helpers::merge_transaction_responses(
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to consider the auth response as well here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we get the connector_metadata in the auth response

connector_meta: helpers::get_connector_metadata(item.response),
browser_info: None,
metadata: None,
capture_method: Some(common_enums::CaptureMethod::Manual),
Copy link
Member

Choose a reason for hiding this comment

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

why are we changing the capture method here?

Ok(Self {
amount_to_capture: item.request.amount,
currency: item.request.currency,
connector_transaction_id: helpers::get_connector_transaction_id(item.response.clone())?,
Copy link
Member

Choose a reason for hiding this comment

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

do not use helpers, impl these functions on the type i.e PaymentsResponseData in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

connector_transaction_id: helpers::get_connector_transaction_id(item.response.clone())?,
payment_amount: item.request.amount,
multiple_capture_data: None,
connector_meta: helpers::get_connector_metadata(item.response),
Copy link
Member

Choose a reason for hiding this comment

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

same here, do not use helpers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the function from the helpers

Copy link
Member

Choose a reason for hiding this comment

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

Try as much as possible to not define any hanging functions in this file. Impl the functions on the type itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

},
)
// Determine the match criteria based on the connector
let match_criteria = if connector.as_deref() == Some("paybox") {
Copy link
Member

Choose a reason for hiding this comment

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

do not convert to string and equate, use the connector enum

Copy link
Member

Choose a reason for hiding this comment

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

why are we not allowing sequential_automatic for other connectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed that check

Copy link
Member

@Narayanbhat166 Narayanbhat166 left a comment

Choose a reason for hiding this comment

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

Can you please add a detailed design which includes the problem statemtent and the solution?

@awasthi21 awasthi21 force-pushed the 7473-feature-core-add-new-type-sequentialautomatic-for-capturemethod-to-support-paybox-mandates branch from 0c53a66 to c9bc150 Compare November 19, 2024 11:58
Narayanbhat166
Narayanbhat166 previously approved these changes Nov 21, 2024
SanchithHegde
SanchithHegde previously approved these changes Nov 21, 2024
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
SELECT 1;
Copy link
Member

Choose a reason for hiding this comment

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

we should remove the enum variant from the type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will keep it for now

@@ -119,6 +122,88 @@ impl CaptureSyncResponse {
}
}
}
impl PaymentsResponseData {
pub fn get_connector_metadata(&self) -> Option<serde_json::Value> {
Copy link
Member

Choose a reason for hiding this comment

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

make serde value as secret

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

charge_id: capture_charge_id.clone().or(auth_charge_id.clone()),
}
} else {
auth_response.clone()
Copy link
Member

Choose a reason for hiding this comment

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

why we are not handling other combination of responses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will raise error for this if we get any other transaction response

new_router_data.status,
) {
// Convert Authorize RouterData into Capture RouterData
let mut capture_router_data = helpers::router_data_type_conversion(
Copy link
Member

Choose a reason for hiding this comment

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

make separate two seperate, one till decide_flow and another one for handling response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added
two seperate functions in the flows.rs

&post_capture_resp,
));
}
(Err(new_resp_error), _, current_status) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why in all response we are not handing merge response? how status are handled in these cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the unnecessary branches

@awasthi21 awasthi21 force-pushed the 7473-feature-core-add-new-type-sequentialautomatic-for-capturemethod-to-support-paybox-mandates branch from 7d0ca45 to 4b6c526 Compare December 3, 2024 12:08
@awasthi21 awasthi21 force-pushed the 7473-feature-core-add-new-type-sequentialautomatic-for-capturemethod-to-support-paybox-mandates branch from 4accecb to fb19a03 Compare December 3, 2024 12:26
@awasthi21 awasthi21 force-pushed the 7473-feature-core-add-new-type-sequentialautomatic-for-capturemethod-to-support-paybox-mandates branch from 6d2c7f0 to 21fab94 Compare December 3, 2024 12:40
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 A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants