Improve (Payment Templates): Complete, Default, and Resolve Variables
Type of Change
- [x] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
This PR addresses several issues in the connector template files that could cause runtime errors or compilation failures when the templates are used to implement new payment connectors:
-
In
connector-template/mod.rs:- Replaced
todo!()inget_currency_unit()with a default implementation to prevent runtime panics - Fixed template variable in
base_url()method to properly include thedowncasefilter - Added implementations for empty
AccessTokenAuthinterface methods
- Replaced
-
In
connector-template/test.rs:- Implemented test helper functions that were previously returning
None - Added realistic test data for payment methods and payment information
- Added necessary imports for the new functionality
- Implemented test helper functions that were previously returning
-
In
connector-template/transformers.rs:- Added missing import for the
cardsmodule which is used for theCardNumbertype
- Added missing import for the
Additional Changes
- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
These template files serve as a starting point for implementing new payment connectors. The issues fixed in this PR would cause confusion or errors for developers trying to use these templates. By providing working defaults and fixing structural issues, we make the connector implementation process more straightforward and avoid the following problems:
- Runtime panics from
todo!()calls - Compilation errors due to missing imports
- Template rendering issues due to inconsistent variable formatting
- Test failures due to
Nonevalues in test helpers
How did you test it?
The template files were manually reviewed to ensure consistent formatting and proper default implementations. Since these are template files, the changes ensure that when an actual connector is implemented using these templates, the resulting code will compile and run without immediate errors.
Checklist
- [x] I formatted the code
cargo +nightly fmt --all - [x] I addressed lints thrown by
cargo clippy - [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
Hey @deepanshu-iiitu, Thank you for your review and feedback! I've made the changes you requested:
- Reverted the AccessToken implementation to keep it empty as in the original template
- Removed the unnecessary cards import from transformers.rs.
Let me know if you'd like to see any other modifications to the PR!
Hey @deepanshu-iiitu,
Could you take a look at this PR? It seems like it might have been missed. Thanks!