use jsonResponse & refund back

This commit is contained in:
2024-08-22 13:38:51 +02:00
parent 479183ea13
commit d271e23861
5 changed files with 69 additions and 24 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/stripe/stripe-go/v79/customer"
"github.com/stripe/stripe-go/v79/paymentintent"
"github.com/stripe/stripe-go/v79/paymentmethod"
"github.com/stripe/stripe-go/v79/refund"
"github.com/stripe/stripe-go/v79/subscription"
)
@ -118,6 +119,22 @@ func (c *Card) CreateCustomer(pm, email string) (*stripe.Customer, string, error
return cust, "", nil
}
func (c *Card) Refund(pi string, amount int) error {
stripe.Key = c.Secret
amountToRefund := int64(amount)
refundParams := &stripe.RefundParams{
Amount: &amountToRefund,
PaymentIntent: &pi,
}
_, err := refund.New(refundParams)
if err != nil {
return err
}
return nil
}
func cardErrorMessage(code stripe.ErrorCode) string {
msg := ""