mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-28 23:52:15 +00:00
refactor: Replace interface{} with any alias and optimize string formatting with fmt.Appendf
- Replace map[string]interface{} with map[string]any in GraphQL, metrics, payment gateway, and webhook handlers
- Replace []byte(fmt.Sprintf()) with fmt.Appendf(nil, ...) for cursor encoding in GraphQL resolvers and tests
- Replace strings.HasPrefix/TrimPrefix with strings.CutPrefix for webhook signature parsing
- Replace stripe.Int64/Bool with new() constructor for Stripe payment parameters
- Rename Error
This commit is contained in:
@@ -42,7 +42,7 @@ func NewStripeGateway(secretKey, webhookSecret string) *StripeGateway {
|
||||
func (g *StripeGateway) ProcessPayment(ctx context.Context, req *PaymentRequest) (*PaymentResponse, error) {
|
||||
// Create payment intent
|
||||
params := &stripe.PaymentIntentParams{
|
||||
Amount: stripe.Int64(int64(req.Amount * 100)), // Convert to cents
|
||||
Amount: new(int64(req.Amount * 100)), // Convert to cents
|
||||
Currency: stripe.String(string(req.Currency)),
|
||||
Metadata: map[string]string{
|
||||
"subscriber_id": fmt.Sprintf("%d", req.SubscriberID),
|
||||
@@ -132,7 +132,7 @@ func (g *StripeGateway) ProcessRefund(ctx context.Context, transactionID string,
|
||||
}
|
||||
|
||||
if amount > 0 {
|
||||
params.Amount = stripe.Int64(int64(amount * 100)) // Convert to cents
|
||||
params.Amount = new(int64(amount * 100)) // Convert to cents
|
||||
}
|
||||
|
||||
refund, err := refund.New(params)
|
||||
@@ -185,10 +185,10 @@ func (g *StripeGateway) CreateInvoice(ctx context.Context, customerID string, it
|
||||
for _, item := range items {
|
||||
itemParams := &stripe.InvoiceItemParams{
|
||||
Customer: stripe.String(customerID),
|
||||
Amount: stripe.Int64(int64(item.Amount * 100)),
|
||||
Amount: new(int64(item.Amount * 100)),
|
||||
Currency: stripe.String(string(item.Currency)),
|
||||
Description: stripe.String(item.Description),
|
||||
Quantity: stripe.Int64(int64(item.Quantity)),
|
||||
Quantity: new(int64(item.Quantity)),
|
||||
}
|
||||
|
||||
_, err := invoiceitem.New(itemParams)
|
||||
@@ -200,7 +200,7 @@ func (g *StripeGateway) CreateInvoice(ctx context.Context, customerID string, it
|
||||
// Create the invoice
|
||||
params := &stripe.InvoiceParams{
|
||||
Customer: stripe.String(customerID),
|
||||
AutoAdvance: stripe.Bool(true),
|
||||
AutoAdvance: new(true),
|
||||
}
|
||||
|
||||
inv, err := invoice.New(params)
|
||||
|
||||
Reference in New Issue
Block a user