@@ -17,8 +17,6 @@ import (
17
17
18
18
type stripePaymentProvider struct {
19
19
client * client.API
20
-
21
- usePaymentIntents bool
22
20
}
23
21
24
22
type stripeBodyParams struct {
@@ -28,8 +26,7 @@ type stripeBodyParams struct {
28
26
29
27
// Config contains the Stripe-specific configuration for payment providers.
30
28
type Config struct {
31
- SecretKey string `mapstructure:"secret_key" json:"secret_key"`
32
- UsePaymentIntents bool `mapstructure:"use_payment_intents" json:"use_payment_intents"`
29
+ SecretKey string `mapstructure:"secret_key" json:"secret_key"`
33
30
}
34
31
35
32
// NewPaymentProvider creates a new Stripe payment provider using the provided configuration.
@@ -40,8 +37,6 @@ func NewPaymentProvider(config Config) (payments.Provider, error) {
40
37
41
38
s := stripePaymentProvider {
42
39
client : & client.API {},
43
-
44
- usePaymentIntents : config .UsePaymentIntents ,
45
40
}
46
41
s .client .Init (config .SecretKey , nil )
47
42
return & s , nil
@@ -62,16 +57,6 @@ func (s *stripePaymentProvider) NewCharger(ctx context.Context, r *http.Request,
62
57
return nil , err
63
58
}
64
59
65
- if ! s .usePaymentIntents {
66
- log .Warning (`Deprecation Warning: Payment Intents are not enabled. Stripe requires those after Sep 14th 2019. Enable by setting "payment.stripe.use_payment_intents" to true` )
67
- if bp .StripeToken == "" {
68
- return nil , errors .New ("Stripe requires a stripe_token for creating a payment" )
69
- }
70
- return func (amount uint64 , currency string , order * models.Order , invoiceNumber int64 ) (string , error ) {
71
- return s .chargeDeprecated (bp .StripeToken , amount , currency , order , invoiceNumber )
72
- }, nil
73
- }
74
-
75
60
if bp .StripePaymentMethodID == "" {
76
61
return nil , errors .New ("Stripe requires a stripe_payment_method_id for creating a payment intent" )
77
62
}
@@ -94,30 +79,6 @@ func prepareShippingAddress(addr models.Address) *stripe.ShippingDetailsParams {
94
79
}
95
80
}
96
81
97
- func (s * stripePaymentProvider ) chargeDeprecated (token string , amount uint64 , currency string , order * models.Order , invoiceNumber int64 ) (string , error ) {
98
- stripeAmount := int64 (amount )
99
- stripeDescription := fmt .Sprintf ("Invoice No. %d" , invoiceNumber )
100
- ch , err := s .client .Charges .New (& stripe.ChargeParams {
101
- Amount : & stripeAmount ,
102
- Source : & stripe.SourceParams {Token : & token },
103
- Currency : & currency ,
104
- Description : & stripeDescription ,
105
- Shipping : prepareShippingAddress (order .ShippingAddress ),
106
- Params : stripe.Params {
107
- Metadata : map [string ]string {
108
- "order_id" : order .ID ,
109
- "invoice_number" : fmt .Sprintf ("%d" , invoiceNumber ),
110
- },
111
- },
112
- })
113
-
114
- if err != nil {
115
- return "" , err
116
- }
117
-
118
- return ch .ID , nil
119
- }
120
-
121
82
func (s * stripePaymentProvider ) chargePaymentIntent (paymentMethodID string , amount uint64 , currency string , order * models.Order , invoiceNumber int64 ) (string , error ) {
122
83
params := & stripe.PaymentIntentParams {
123
84
PaymentMethod : stripe .String (paymentMethodID ),
@@ -176,10 +137,6 @@ func (s *stripePaymentProvider) NewPreauthorizer(ctx context.Context, r *http.Re
176
137
}
177
138
178
139
func (s * stripePaymentProvider ) NewConfirmer (ctx context.Context , r * http.Request , log logrus.FieldLogger ) (payments.Confirmer , error ) {
179
- if ! s .usePaymentIntents {
180
- return nil , errors .New ("Cannot confirm a payment if not using payment intents" )
181
- }
182
-
183
140
return s .confirm , nil
184
141
}
185
142
0 commit comments