Skip to content

Commit 08f4300

Browse files
committed
use stripe.PaymentIntentParams directly
1 parent df8ecf4 commit 08f4300

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

paymentintent.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,8 @@ func CreatePaymentIntent(sk string, piReq stripe.PaymentIntentParams) (piRes *st
1010
// stripe secret key
1111
stripe.Key = sk
1212

13-
// create PaymentIntentParams with amount and currency
14-
params := &stripe.PaymentIntentParams{
15-
Amount: piReq.Amount,
16-
Currency: piReq.Currency,
17-
// enable all payment methods
18-
AutomaticPaymentMethods: &stripe.PaymentIntentAutomaticPaymentMethodsParams{
19-
Enabled: stripe.Bool(true),
20-
},
21-
}
22-
2313
// create a PaymentIntent
24-
piRes, err = paymentintent.New(params)
14+
piRes, err = paymentintent.New(&piReq)
2515
return
2616
}
2717

paymentintent_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func TestCreatePaymentIntent(t *testing.T) {
2727
piReq := stripe.PaymentIntentParams{}
2828
piReq.Amount = stripe.Int64(PaymentIntentAmount)
2929
piReq.Currency = stripe.String(Currency)
30+
piReq.AutomaticPaymentMethods = &stripe.PaymentIntentAutomaticPaymentMethodsParams{
31+
Enabled: stripe.Bool(true),
32+
}
3033

3134
piRes, err := stripego.CreatePaymentIntent(StripeSK, piReq)
3235
if err != nil {

0 commit comments

Comments
 (0)