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): [AUTHORIZEDOTNET] Add metadata information to connector request #7011

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

Conversation

Debarshi-Gupta
Copy link
Contributor

@Debarshi-Gupta Debarshi-Gupta commented Jan 8, 2025

Type of Change

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

Description

This PR is for code changes which sends the metadata passed in payment intent create to authorizedotnet as request payload, as per merchant requirements.

The merchant receives a receipt of the transaction through email, which contains the metadata passed by the merchant in payment intent create request.

image

Additional Changes

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

Motivation and Context

All flows have been tested as per the authorizedotnet developer docs:
https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-credit-card

How did you test it?

Postman Tests

1. Authorize (Manual)

  • Request
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer1",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "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": "likhin",
            "last_name": "bopanna"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "likhin",
            "last_name": "bopanna"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    }
}'
  • Response
{
    "payment_id": "pay_aMR57wTed0e8hKIvqEXk",
    "merchant_id": "postman_merchant_GHAction_4bc8cb40-6e2b-4474-a4ba-662cce1e8224",
    "status": "requires_capture",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 6540,
    "amount_received": null,
    "connector": "authorizedotnet",
    "client_secret": "pay_aMR57wTed0e8hKIvqEXk_secret_7ClGeHihtfOkLr17zmY6",
    "created": "2025-01-08T12:18:38.236Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "manual",
    "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": "10",
            "card_exp_year": "25",
            "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": "likhin",
            "last_name": "bopanna"
        },
        "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": "likhin",
            "last_name": "bopanna"
        },
        "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": {
        "customer_id": "StripeCustomer1",
        "created_at": 1736338718,
        "expires": 1736342318,
        "secret": "epk_a3fa4b96efa94fbe817dd39b634b4b10"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "80033079979",
    "frm_message": null,
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80033079979",
    "payment_link": null,
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-08T12:33:38.236Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-08T12:18:40.884Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

2. Capture (Manual)

  • Request
curl --location 'http://localhost:8080/payments/pay_aMR57wTed0e8hKIvqEXk/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu' \
--data '{
    "amount_to_capture": 6540,
    "statement_descriptor_name": "Joseph",
    "statement_descriptor_suffix": "JS"
}'
  • Response
{
    "payment_id": "pay_aMR57wTed0e8hKIvqEXk",
    "merchant_id": "postman_merchant_GHAction_4bc8cb40-6e2b-4474-a4ba-662cce1e8224",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "authorizedotnet",
    "client_secret": "pay_aMR57wTed0e8hKIvqEXk_secret_7ClGeHihtfOkLr17zmY6",
    "created": "2025-01-08T12:18:38.236Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "manual",
    "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": "10",
            "card_exp_year": "25",
            "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": "likhin",
            "last_name": "bopanna"
        },
        "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": "likhin",
            "last_name": "bopanna"
        },
        "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": "80033079979",
    "frm_message": null,
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80033079979",
    "payment_link": null,
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-08T12:33:38.236Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-08T12:20:16.395Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

3. Authorize + Capture

  • Request
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu' \
--data-raw '{
    "amount": 6550,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6550,
    "customer_id": "StripeCustomer1",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "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": "sundari",
            "last_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "sundari",
            "last_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    }
}'
  • Response
{
    "payment_id": "pay_EbFXhSWxwVQ0996FxZdt",
    "merchant_id": "postman_merchant_GHAction_4bc8cb40-6e2b-4474-a4ba-662cce1e8224",
    "status": "succeeded",
    "amount": 6550,
    "net_amount": 6550,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6550,
    "connector": "authorizedotnet",
    "client_secret": "pay_EbFXhSWxwVQ0996FxZdt_secret_3J0fmk53qE22LeKiGIGx",
    "created": "2025-01-08T12:21:59.998Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": 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": "01",
            "card_exp_year": "25",
            "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": "sundari",
            "last_name": "sundari"
        },
        "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": "sundari",
            "last_name": "sundari"
        },
        "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": "debit",
    "connector_label": "authorizedotnet_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer1",
        "created_at": 1736338919,
        "expires": 1736342519,
        "secret": "epk_a1b2ad7e39a14673a4e01692f76e5193"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "80033080191",
    "frm_message": null,
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80033080191",
    "payment_link": null,
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-08T12:36:59.998Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-08T12:22:02.624Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

4. PSync

  • Request
curl --location 'http://localhost:8080/payments/pay_EbFXhSWxwVQ0996FxZdt?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu'
  • Response
{
    "payment_id": "pay_EbFXhSWxwVQ0996FxZdt",
    "merchant_id": "postman_merchant_GHAction_4bc8cb40-6e2b-4474-a4ba-662cce1e8224",
    "status": "succeeded",
    "amount": 6550,
    "net_amount": 6550,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6550,
    "connector": "authorizedotnet",
    "client_secret": "pay_EbFXhSWxwVQ0996FxZdt_secret_3J0fmk53qE22LeKiGIGx",
    "created": "2025-01-08T12:21:59.998Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": 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": "01",
            "card_exp_year": "25",
            "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": "sundari",
            "last_name": "sundari"
        },
        "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": "sundari",
            "last_name": "sundari"
        },
        "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": "debit",
    "connector_label": "authorizedotnet_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "80033080191",
    "frm_message": null,
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80033080191",
    "payment_link": null,
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-08T12:36:59.998Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-08T12:22:02.624Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

5. Refund

  • Request
curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu' \
--data '{
    "payment_id": "pay_LdFELbsSHWr31UxLX51l",
    "amount": 5000,
    "reason": "Customer returned product",
    "refund_type": "scheduled",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
  • Response
{
    "refund_id": "ref_ht8iD8smYnJl5sDF0BEn",
    "payment_id": "pay_LdFELbsSHWr31UxLX51l",
    "amount": 5000,
    "currency": "USD",
    "status": "pending",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "unified_code": null,
    "unified_message": null,
    "created_at": "2025-01-08T12:31:33.642Z",
    "updated_at": "2025-01-08T12:31:33.642Z",
    "connector": "authorizedotnet",
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "split_refunds": null
}

6. RSync

  • Request
curl --location 'http://localhost:8080/refunds/ref_ht8iD8smYnJl5sDF0BEn' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu'
  • Response
{
    "refund_id": "ref_ht8iD8smYnJl5sDF0BEn",
    "payment_id": "pay_LdFELbsSHWr31UxLX51l",
    "amount": 5000,
    "currency": "USD",
    "status": "pending",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "unified_code": null,
    "unified_message": null,
    "created_at": "2025-01-08T12:31:33.642Z",
    "updated_at": "2025-01-08T12:31:33.642Z",
    "connector": "authorizedotnet",
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "split_refunds": null
}

7. Cancel/Void

  • Request
curl --location 'http://localhost:8080/payments/pay_LdFELbsSHWr31UxLX51l/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_0vV4HvaBn68pmZTvXLzU9V7hR79lgEjiarEG2IDxveccjZ6ypKjpPaRrdeQRHhKu' \
--data '{"cancellation_reason":"requested_by_customer"}'
  • Response
{
    "payment_id": "pay_wM2Pf7TjLVabcAj41aDz",
    "merchant_id": "postman_merchant_GHAction_4bc8cb40-6e2b-4474-a4ba-662cce1e8224",
    "status": "cancelled",
    "amount": 5000,
    "net_amount": 5000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "authorizedotnet",
    "client_secret": "pay_wM2Pf7TjLVabcAj41aDz_secret_vjFJJKmyoVaNqOmQ0Bge",
    "created": "2025-01-08T12:29:07.232Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "manual",
    "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": "10",
            "card_exp_year": "25",
            "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": "likhin",
            "last_name": "bopanna"
        },
        "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": "likhin",
            "last_name": "bopanna"
        },
        "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": "requested_by_customer",
    "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": "80033080543",
    "frm_message": null,
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590045"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "80033080543",
    "payment_link": null,
    "profile_id": "pro_54auzGTSaZOQ9xIUOEn8",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_tFxUMA2vfBlte3s7jSw7",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-08T12:44:07.232Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-08T12:29:28.533Z",
    "split_payments": 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

@Debarshi-Gupta Debarshi-Gupta added the A-connector-integration Area: Connector integration label Jan 8, 2025
@Debarshi-Gupta Debarshi-Gupta self-assigned this Jan 8, 2025
@Debarshi-Gupta Debarshi-Gupta requested a review from a team as a code owner January 8, 2025 08:42
Copy link

semanticdiff-com bot commented Jan 8, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/authorizedotnet/transformers.rs  0% smaller

@deepanshu-iiitu deepanshu-iiitu added the C-refactor Category: Refactor label Jan 8, 2025
@Debarshi-Gupta Debarshi-Gupta changed the title refactor(authorizedotnet): add metadata information to connector request refactor(connector): [AUTHORIZEDOTNET] Add metadata information to connector request Jan 8, 2025
awasthi21
awasthi21 previously approved these changes Jan 10, 2025
Copy link
Contributor

@awasthi21 awasthi21 left a comment

Choose a reason for hiding this comment

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

nit : should we use Btree's here @deepanshu-iiitu?

impl ForeignFrom<Value> for Vec<UserField> {
fn foreign_from(metadata: Value) -> Self {
let hashmap: BTreeMap<String, Value> =
serde_json::from_str(&metadata.to_string()).unwrap_or(BTreeMap::new());
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using unwrap_or and handling this with a default value throw a deserialization 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.

I have resolved it

awasthi21
awasthi21 previously approved these changes Jan 13, 2025
type Error = error_stack::Report<errors::ConnectorError>;
fn foreign_try_from(metadata: Value) -> Result<Self, Self::Error> {
let hashmap: BTreeMap<String, Value> = serde_json::from_str(&metadata.to_string())
.change_context(errors::ConnectorError::ResponseDeserializationFailed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we throwing ResponseDeserializationFailed error here?

Lets use RequestEncodingFailedWithReason 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.

Thanks, I have resolved it.

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.

[FEATURE] [Authorizedotnet]: Add metadata information to connector request
3 participants