From 08f4300ac987c1448eae1d63383104987c9405dc Mon Sep 17 00:00:00 2001 From: pilinux Date: Tue, 15 Aug 2023 11:51:05 +0200 Subject: [PATCH] use `stripe.PaymentIntentParams` directly --- paymentintent.go | 12 +----------- paymentintent_test.go | 3 +++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/paymentintent.go b/paymentintent.go index 2d3b7d4..ea0792e 100644 --- a/paymentintent.go +++ b/paymentintent.go @@ -10,18 +10,8 @@ func CreatePaymentIntent(sk string, piReq stripe.PaymentIntentParams) (piRes *st // stripe secret key stripe.Key = sk - // create PaymentIntentParams with amount and currency - params := &stripe.PaymentIntentParams{ - Amount: piReq.Amount, - Currency: piReq.Currency, - // enable all payment methods - AutomaticPaymentMethods: &stripe.PaymentIntentAutomaticPaymentMethodsParams{ - Enabled: stripe.Bool(true), - }, - } - // create a PaymentIntent - piRes, err = paymentintent.New(params) + piRes, err = paymentintent.New(&piReq) return } diff --git a/paymentintent_test.go b/paymentintent_test.go index 93b78f3..8035c9a 100644 --- a/paymentintent_test.go +++ b/paymentintent_test.go @@ -27,6 +27,9 @@ func TestCreatePaymentIntent(t *testing.T) { piReq := stripe.PaymentIntentParams{} piReq.Amount = stripe.Int64(PaymentIntentAmount) piReq.Currency = stripe.String(Currency) + piReq.AutomaticPaymentMethods = &stripe.PaymentIntentAutomaticPaymentMethodsParams{ + Enabled: stripe.Bool(true), + } piRes, err := stripego.CreatePaymentIntent(StripeSK, piReq) if err != nil {