-
Notifications
You must be signed in to change notification settings - Fork 1
feat: added payment method resource and data endpoint #74
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive Terraform provider support for payment method resources, enabling users to manage payment methods through infrastructure-as-code. The implementation follows the established pattern used for other resources in the provider.
Key Changes:
- Added payment method resource with full CRUD operations (Create, Read, Update, Delete)
- Implemented payment method data source for querying existing payment methods
- Integrated payment method endpoints into the provider client
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/provider/provider.go | Registered payment method resource and data source with the provider |
| internal/provider/payment_method_resource.go | Complete payment method resource implementation with CRUD operations and import support |
| internal/provider/payment_method_data_source.go | Data source implementation for reading payment methods |
| client/payment_method.go | HTTP client methods for payment method API operations |
| client/client.go | Added payment methods endpoint to the API client configuration |
| examples/resources/meshstack_payment_method/resource.tf | Example Terraform configuration for creating payment methods |
| examples/resources/meshstack_payment_method/import.sh | Example import command demonstrating import syntax |
| examples/data-sources/meshstack_payment_method/data-source.tf | Example Terraform configuration for data source usage |
| docs/resources/payment_method.md | Generated documentation for the payment method resource |
| docs/data-sources/payment_method.md | Generated documentation for the payment method data source |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nroi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a few comments and also found a bug unfortunately, but perhaps it's a valid approach to merge it now and fix the API at a later point? we can also discuss this via slack.
|
|
||
| spec = { | ||
| display_name = "My Payment Method" | ||
| expiration_date = "2025-12-31T23:59:59Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Country = ["US"] | ||
| Type = ["production"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d: the tags seem to be set a bit arbitrarily. What's a "production" payment method? 😄 perhaps there are other tags that reflect more closely how customers use meshStack in production (maybe a costCenter tag?)
docs/resources/payment_method.md
Outdated
|
|
||
| spec = { | ||
| display_name = "My Payment Method" | ||
| expiration_date = "2025-12-31T23:59:59Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f: see my other comment about the expiration date, afaik this will be automatically fixed when you fix it in the examples directory. Just double check that this markdown file is then also fixed.
|
|
||
| type MeshPaymentMethodSpec struct { | ||
| DisplayName string `json:"displayName" tfsdk:"display_name"` | ||
| ExpirationDate *string `json:"expirationDate,omitempty" tfsdk:"expiration_date"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d: one issue I've noticed is the following:
when you use the terraform provider to first create a payment method with an expiration date, and then remove it, you run into an error (see screenshot). But the problem imho is not the terraform provider, it's the API design. The expiration date is nullable in our meshPaymentMethod model, and if the expiration date is null in an update request, we just ignore it completely (instead of setting the expiration date to null).
imho this has to be fixed by introducing a new meshPaymentMethod version with proper null handling, meaning, nullable properties like tags, amount and expirationDate are explicitly set to null if they're null in the request.

added terraform provider endpoint for payment methods including resource creation, deletion and data reads