hyperswitch
hyperswitch copied to clipboard
fix: conditionally add reverse lookup in update mandate
Type of Change
- [ x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
there might be a chance that for same mandate entry , reverse lookup for connector mandate id is attempted to be inserted twice, causing an error in the second reverse lookup insert
adding a condition in update mandate to add reverse lookup only when existing object doesnt have the value
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
there might be a chance that for same mandate entry , reverse lookup for connector mandate id is attempted to be inserted twice, causing an error in the second reverse lookup insert
adding a condition in update mandate to add reverse lookup only when existing object doesnt have the value
How did you test it?
create mandate
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key:**' \ --data-raw '{ "amount": 0, "currency": "USD", "confirm": true, "capture_method": "manual", "capture_on": "2022-09-10T10:11:12Z", "customer_id": "customer0977", "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": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "card_cvc": "123" } }, "setup_future_usage": "off_session", "mandate_data": { "customer_acceptance": { "acceptance_type": "offline", "accepted_at": "1963-05-03T04:07:52.723Z", "online": { "ip_address": "127.0.0.1", "user_agent": "amet irure esse" } }, "mandate_type": { "single_use": { "amount": 8000, "currency": "USD" } } }, "payment_type":"new_mandate", "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" } }, "shipping": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "US", "first_name": "john", "last_name": "Doe" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" }, "browser_info": { "ip_address": "129.0.0.1", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "language": "en-US", "color_depth": 30, "screen_height": 1117, "screen_width": 1728, "time_zone": -330, "java_enabled": true, "java_script_enabled": true } }'
recur
curl --location 'http://localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: dev_uU1CMrJwVpVNLZsX1l02Oguxxi3JI0iT8b9BQBizGDDwxNJ8asfhRwZWrNJUFdeW' \ --data ' { "amount": 999, "currency": "USD", "confirm": true, "customer_id" : "customer0977", "return_url": "https://google.com", "payment_method":"card", "recurring_details": { "type": "mandate_id", "data": "man_9oDWRDlfip0f6lBNSGxo" }, "off_session": true }'
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
- [ ] I added a CHANGELOG entry if applicable