use jsonResponse & refund back
This commit is contained in:
		@ -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 := ""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user