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

Fix(connector): [BOA/CYBS] make rsync status optional #4570

Merged
merged 2 commits into from
May 8, 2024

Conversation

AkshayaFoiger
Copy link
Contributor

@AkshayaFoiger AkshayaFoiger commented May 7, 2024

Type of Change

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

Description

BOA's Rsync response may or may not contain status. But status is a mandatory field in the connector response, hence when the connector response do not contain status, it results in a de serialization error.
This PR fixes the de-serialization error, by marking refund status as pending if connector do not send us the status.

How did you test it?

1.Create a card payment with BOA

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:""' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "A",
    "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://google.com",
    "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": "13.232.74.226"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IN",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number":  "4622943127013705", 
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },  
      "connector_metadata": {
            "noon": {
                "order_category": "pay"
            }
        },
    "metadata": {
        "city": "NY",
        "unit": "245",
        "account_name": "transaction_processing"
    }    
}'

Response

{
    "payment_id": "pay_CynccL5DmW1ETflUPxEa",
    "merchant_id": "merchant_1715083581",
    "status": "succeeded",
    "amount": 100,
    "net_amount": 100,
    "amount_capturable": 0,
    "amount_received": 100,
    "connector": "bankofamerica",
    "client_secret": "pay_CynccL5DmW1ETflUPxEa_secret_SBM9CrhhVKtnvPb3c0PN",
    "created": "2024-05-07T12:06:34.173Z",
    "currency": "USD",
    "customer_id": "A",
    "customer": {
        "id": "A",
        "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": "3705",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "462294",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "avs_response": {
                    "code": "Y",
                    "codeRaw": "Y"
                },
                "card_verification": {
                    "resultCode": "M",
                    "resultCodeRaw": "M"
                },
                "approval_code": "831000",
                "consumer_authentication_response": {
                    "code": "2",
                    "codeRaw": "2"
                },
                "cavv": null,
                "eci": null,
                "eci_raw": null
            },
            "authentication_data": {
                "retrieval_reference_number": "412812167299",
                "acs_transaction_id": null,
                "system_trace_audit_number": "167299"
            }
        },
        "billing": null
    },
    "payment_token": "token_4OB1T6AKesZztuDf8jlt",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "IN",
            "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://google.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": "A",
        "created_at": 1715083594,
        "expires": 1715087194,
        "secret": "epk_42b404783640408aa110028ca10a848c"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7150835957926310904953",
    "frm_message": null,
    "metadata": {
        "city": "NY",
        "unit": "245",
        "account_name": "transaction_processing"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": "pay_CynccL5DmW1ETflUPxEa_1",
    "payment_link": null,
    "profile_id": "pro_T2wjq3SsGuXZ5fdUene6",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_otyt4b6GdbCisxI2tTTu",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-07T12:21:34.173Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "13.232.74.226",
        "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-05-07T12:06:36.806Z"
}
  1. Refund the payment
curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'api-key: ""' \
--data '{
    "payment_id": "pay_CynccL5DmW1ETflUPxEa",
    "amount": 100,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

Response

{
    "refund_id": "ref_ycNxoYyhoEskxFyuUtjo",
    "payment_id": "pay_CynccL5DmW1ETflUPxEa",
    "amount": 100,
    "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,
    "created_at": "2024-05-07T12:08:16.183Z",
    "updated_at": "2024-05-07T12:08:16.183Z",
    "connector": "bankofamerica",
    "profile_id": "pro_T2wjq3SsGuXZ5fdUene6",
    "merchant_connector_id": "mca_otyt4b6GdbCisxI2tTTu"
}
  1. Do a Rsync
curl --location 'http://localhost:8080/refunds/ref_ycNxoYyhoEskxFyuUtjo?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key:""'

Response - Should not give a De-serialization error

    "refund_id": "ref_ycNxoYyhoEskxFyuUtjo",
    "payment_id": "pay_CynccL5DmW1ETflUPxEa",
    "amount": 100,
    "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,
    "created_at": "2024-05-07T12:08:16.183Z",
    "updated_at": "2024-05-07T12:08:16.183Z",
    "connector": "bankofamerica",
    "profile_id": "pro_T2wjq3SsGuXZ5fdUene6",
    "merchant_connector_id": "mca_otyt4b6GdbCisxI2tTTu"
}
  1. Do a card payment with Cybersource
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ""' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    
    "capture_method": "automatic",
    "customer_id": "abc",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "setup_future_usage": "off_session",
    "payment_method": "card",
    "payment_method_type": "credit",
    
    "payment_method_data": {
        "card": {
            
            "card_number": "4622943127013705",
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "card_cvc": "838"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "CA",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "New York",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "125.0.0.1"
    },
    "metadata": {
        "order_details": {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 3200,
            "account_name": "transaction_processing"
        }
    }  
}'

Response

{
    "payment_id": "pay_ZtpG9t02Is8hmgg0Pt2k",
    "merchant_id": "merchant_1715085079",
    "status": "succeeded",
    "amount": 100,
    "net_amount": 100,
    "amount_capturable": 0,
    "amount_received": 100,
    "connector": "cybersource",
    "client_secret": "pay_ZtpG9t02Is8hmgg0Pt2k_secret_h4KlYF818tbvDdAFv2rU",
    "created": "2024-05-07T12:31:33.884Z",
    "currency": "USD",
    "customer_id": "abc",
    "customer": {
        "id": "abc",
        "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": "card",
    "payment_method_data": {
        "card": {
            "last4": "3705",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "462294",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "avs_response": {
                    "code": "Y",
                    "codeRaw": "Y"
                },
                "card_verification": null
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_QgMwzlAuhvZ8oZ0TyCnG",
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "CA",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "New York",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://hs-payments-test.netlify.app/payments",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": "cybersource_US_default_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "abc",
        "created_at": 1715085093,
        "expires": 1715088693,
        "secret": "epk_4fc527fec5034f52874e26668ccfd461"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7150850943306542603955",
    "frm_message": null,
    "metadata": {
        "order_details": {
            "amount": 3200,
            "quantity": 1,
            "account_name": "transaction_processing",
            "product_name": "Apple iphone 15"
        }
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_ZtpG9t02Is8hmgg0Pt2k_1",
    "payment_link": null,
    "profile_id": "pro_jy1hXETZpOTtyo48f2rP",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_mzXYICVAcgq5mCPlf4p9",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-05-07T12:46:33.884Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "125.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-05-07T12:31:35.424Z"
}
  1. Refund the payment
curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'api-key:""' \
--data '{
    "payment_id": "pay_ZtpG9t02Is8hmgg0Pt2k",
    "amount": 100,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

Response

{
    "refund_id": "ref_LhLapTLkO0lUxgROysYF",
    "payment_id": "pay_ZtpG9t02Is8hmgg0Pt2k",
    "amount": 100,
    "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,
    "created_at": "2024-05-07T12:32:35.452Z",
    "updated_at": "2024-05-07T12:32:35.452Z",
    "connector": "cybersource",
    "profile_id": "pro_jy1hXETZpOTtyo48f2rP",
    "merchant_connector_id": "mca_mzXYICVAcgq5mCPlf4p9"
}
  1. Do a Rsync
curl --location 'http://localhost:8080/refunds/ref_ycNxoYyhoEskxFyuUtjo?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: "" '

Response

{
    "refund_id": "ref_ycNxoYyhoEskxFyuUtjo",
    "payment_id": "pay_CynccL5DmW1ETflUPxEa",
    "amount": 100,
    "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,
    "created_at": "2024-05-07T12:08:16.183Z",
    "updated_at": "2024-05-07T12:08:16.183Z",
    "connector": "bankofamerica",
    "profile_id": "pro_T2wjq3SsGuXZ5fdUene6",
    "merchant_connector_id": "mca_otyt4b6GdbCisxI2tTTu"
}

Note: there is no particular scenario where status is not sent in rsync connector response. This can happen randomly

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

@AkshayaFoiger AkshayaFoiger added A-connector-integration Area: Connector integration C-bug Category: Bug labels May 7, 2024
@AkshayaFoiger AkshayaFoiger self-assigned this May 7, 2024
@AkshayaFoiger AkshayaFoiger requested a review from a team as a code owner May 7, 2024 12:35
@AkshayaFoiger AkshayaFoiger changed the title Fix(connector): [BOA/CYBS] make status optional Fix(connector): [BOA/CYBS] make Rsync status optional May 7, 2024
@AkshayaFoiger AkshayaFoiger changed the title Fix(connector): [BOA/CYBS] make Rsync status optional Fix(connector): [BOA/CYBS] make rsync status optional May 7, 2024
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu left a comment

Choose a reason for hiding this comment

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

LGTM

@likhinbopanna likhinbopanna added this pull request to the merge queue May 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 7, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 8, 2024
Merged via the queue into main with commit 339da8b May 8, 2024
9 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the boa/handle-rsync-status branch May 8, 2024 09:13
pixincreate added a commit that referenced this pull request May 10, 2024
…efactor

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.05.10.0
  fix(router): [NETCETERA] skip sending browser_information in authentication request for app device_channel (#4613)
  fix(users): Fix bugs caused by the new token only flows (#4607)
  ci(cypress): Fix card expiry for savecard flows (#4585)
  refactor(billing): store `payment_method_data_billing` for recurring payments (#4513)
  feat(users): new routes to accept invite and list merchants (#4591)
  fix(connector): [BAMBORA] Audit Fixes for Bambora (#4604)
  fix(connector): [iatapay]handle empty error response in case of 401 (#4291)
  feat(connector): [Payone] add connector template code (#4469)
  feat(users): Create API to Verify TOTP (#4597)
  chore(version): 2024.05.09.0
  chore(postman): update Postman collection files
  fix(core): drop three_dsserver_trans_id from authentication table (#4587)
  refactor(db): Add TenantId field to the KafkaStore struct (#4512)
  feat(users): Create `user_key_store` table and `begin_totp` API (#4577)
  Fix(connector): [BOA/CYBS] make rsync status optional (#4570)
  fix(users): Correct the condition for `verify_email` flow in decision manger (#4580)
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-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [BOA/CYBERSOURCE] Make status optional in BankOfAmericaRsyncResponse/CybersourceRsyncResponse
4 participants