Skip to content

Commit

Permalink
use stripe.PaymentIntentParams directly
Browse files Browse the repository at this point in the history
  • Loading branch information
pilinux committed Aug 15, 2023
1 parent df8ecf4 commit 08f4300
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
12 changes: 1 addition & 11 deletions paymentintent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions paymentintent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 08f4300

Please sign in to comment.