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: add fallback to reverselookup error #3025

Merged
merged 8 commits into from
Dec 5, 2023
Merged

Conversation

dracarys18
Copy link
Member

Type of Change

  • Bugfix

Description

  • Added a fallback to reverse lookup if not found it will fallback to the DB implementation of the function.
  • Moved macros to common_utils
  • Execute reverse_lookup before executing the actual DB functions.

Motivation and Context

For the old data's which are created with PostgresOnly will not have a Reverselookup inserted so if you try to fetch it , It will throw an error. So added a fallback to account for such cases it should directly go to the DB implementation of the function.

How did you test it?

  • Create a payment with KV disabled in the merchant.
    • Disabling KV
    curl --location 'http://localhost:8080/accounts/mer_1701350579/kv' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: test_admin' \
    --header 'Cookie: token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDYwZTg1NjUtM2E5Yy00ZDA4LTlmNDktMGQ1NzIzNTZkZDdiIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzAxMjUyODc2Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcwMTQyNjA0NSwib3JnX2lkIjoib3JnX2pUeGFQRVJvZVp3czJha3dmTXBiIn0.ZnZodoBk8ZLSYwf-5fH4y376vvWjvwHABOTmAJKZZes' \
    --data '{
        "kv_enabled": false
    }'
    
    • Payment
     	curl --location 'http://localhost:8080/payments' \
     	--header 'Content-Type: application/json' \
     	--header 'Accept: application/json' \
     	--header 'api-key: dev_s0ET4iGJVBkHsWXnPYHasMZCV0QPttxFWakz6o8zmwsaOjzj4v7ap8oaOICGnAS9' \
     	--header 'Cookie: token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDYwZTg1NjUtM2E5Yy00ZDA4LTlmNDktMGQ1NzIzNTZkZDdiIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzAxMjUyODc2Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcwMTQyNjA0NSwib3JnX2lkIjoib3JnX2pUeGFQRVJvZVp3czJha3dmTXBiIn0.ZnZodoBk8ZLSYwf-5fH4y376vvWjvwHABOTmAJKZZes' \
     	--data-raw '{
     	    "amount": 6540,
     	    "currency": "USD",
     	    "confirm": true,
     	    "capture_method": "automatic",
     	    "customer_id": "HScustomer1234",
     	    "email": "[email protected]",
     	    "amount_to_capture": 6540,
     	    "description": "Its my first payment request",
     	    "capture_on": "2022-09-10T10:11:12Z",
     	    "return_url": "https://google.com",
     	    "name": "Preetam",
     	    "phone": "999999999",
     	    "setup_future_usage": "off_session",
     	    "phone_country_code": "+65",
     	    "authentication_type": "three_ds",
     	    "payment_method": "card",
     	    "payment_method_type": "debit",
     	    "payment_method_data": {
     	        "card": {
     	            "card_number": "4111111111111111",
     	            "card_exp_month": "03",
     	            "card_exp_year": "2030",
     	            "card_holder_name": "joseph Doe",
     	            "card_cvc": "737"
     	        }
     	    },
     	    "connector_metadata": {
     	        "noon": {
     	            "order_category": "applepay"
     	        }
     	    },
     	    "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": "128.0.0.1"
     	    },
     	    "billing": {
     	        "address": {
     	            "line1": "1467",
     	            "line2": "Harrison Street",
     	            "line3": "Harrison Street",
     	            "city": "San Fransico",
     	            "state": "California",
     	            "zip": "94122",
     	            "country": "US",
     	            "first_name": "preetam",
     	            "last_name": "revankar"
     	        },
     	        "phone": {
     	            "number": "8056594427",
     	            "country_code": "+91"
     	        }
     	    },
     	    "shipping": {
     	        "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"
     	        }
     	    },
     	    "order_details": [
     	        {
     	            "product_name": "Apple iphone 15",
     	            "quantity": 1,
     	            "amount": 6540,
     	            "account_name": "transaction_processing"
     	        }
     	    ],
     	    "statement_descriptor_name": "joseph",
     	    "statement_descriptor_suffix": "JS",
     	    "metadata": {
     	        "udf1": "value1",
     	        "new_customer": "true",
     	        "login_date": "2019-09-10T10:11:12Z"
     	    }
     	}'
    
  • Enable KV
curl --location 'http://localhost:8080/accounts/mer_1701350579/kv' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--header 'Cookie: token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDYwZTg1NjUtM2E5Yy00ZDA4LTlmNDktMGQ1NzIzNTZkZDdiIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzAxMjUyODc2Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcwMTQyNjA0NSwib3JnX2lkIjoib3JnX2pUeGFQRVJvZVp3czJha3dmTXBiIn0.ZnZodoBk8ZLSYwf-5fH4y376vvWjvwHABOTmAJKZZes' \
--data '{
    "kv_enabled": false
}'
  • Do a refund on the same payment
curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_s0ET4iGJVBkHsWXnPYHasMZCV0QPttxFWakz6o8zmwsaOjzj4v7ap8oaOICGnAS9' \
--header 'Cookie: token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDYwZTg1NjUtM2E5Yy00ZDA4LTlmNDktMGQ1NzIzNTZkZDdiIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzAxMjUyODc2Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcwMTQyNjA0NSwib3JnX2lkIjoib3JnX2pUeGFQRVJvZVp3czJha3dmTXBiIn0.ZnZodoBk8ZLSYwf-5fH4y376vvWjvwHABOTmAJKZZes' \
--data '{
    "payment_id": "pay_ui0nG9hCuhTQZ7mEuKT9",
    "amount": 600,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
Screenshot 2023-11-30 at 7 34 06 PM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code

@dracarys18 dracarys18 added A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Nov 30, 2023
@dracarys18 dracarys18 added this to the November 2023 Release milestone Nov 30, 2023
@dracarys18 dracarys18 self-assigned this Nov 30, 2023
@dracarys18 dracarys18 requested a review from a team as a code owner November 30, 2023 14:04
akshay-97
akshay-97 previously approved these changes Dec 1, 2023
jarnura
jarnura previously approved these changes Dec 4, 2023
@dracarys18 dracarys18 dismissed stale reviews from akshay-97 and jarnura via 70aed75 December 4, 2023 10:05
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 5, 2023
Merged via the queue into main with commit ba392f5 Dec 5, 2023
10 of 12 checks passed
@likhinbopanna likhinbopanna deleted the reverse_lookup_fallback branch December 5, 2023 07:31
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants