mirror of
https://github.com/rjNemo/go-wiki
synced 2026-06-12 13:36:38 +00:00
payment
This commit is contained in:
parent
17387f25a8
commit
25afd5916c
4 changed files with 27 additions and 0 deletions
1
go.mod
1
go.mod
|
|
@ -5,4 +5,5 @@ go 1.14
|
||||||
require (
|
require (
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/lib/pq v1.3.0
|
github.com/lib/pq v1.3.0
|
||||||
|
github.com/stripe/stripe-go v70.5.0+incompatible
|
||||||
)
|
)
|
||||||
|
|
|
||||||
3
go.sum
3
go.sum
|
|
@ -2,3 +2,6 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/stripe/stripe-go v1.0.3 h1:RHgK2FUKawVNBPJ15pNM4IWkEVVCg5Ju3xK5QZNhTwY=
|
||||||
|
github.com/stripe/stripe-go v70.5.0+incompatible h1:pvVmoGJRmiVCy0F+Oqk2s5YkxW4vSeF/rQQnxBGsOEQ=
|
||||||
|
github.com/stripe/stripe-go v70.5.0+incompatible/go.mod h1:A1dQZmO/QypXmsL0T8axYZkSN/uA/T/A64pfKdBAMiY=
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -5,9 +5,11 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/rjNemo/go-wiki/controller"
|
"github.com/rjNemo/go-wiki/controller"
|
||||||
|
"github.com/rjNemo/go-wiki/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
service.PaymentIntent(1000, "ruidy.nemausat@gmail.com")
|
||||||
startServer(controller.Port, controller.Router)
|
startServer(controller.Port, controller.Router)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
21
service/payment.go
Normal file
21
service/payment.go
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stripe/stripe-go"
|
||||||
|
"github.com/stripe/stripe-go/paymentintent"
|
||||||
|
)
|
||||||
|
|
||||||
|
// secret API key
|
||||||
|
var secretKey string = "sk_test_dyp7eLEq2KnxpWE0qIMihTYZ"
|
||||||
|
|
||||||
|
// PaymentIntent creates a payment intent
|
||||||
|
func PaymentIntent(a int64, m string) (*stripe.PaymentIntent, error) {
|
||||||
|
stripe.Key = secretKey
|
||||||
|
params := &stripe.PaymentIntentParams{
|
||||||
|
Amount: stripe.Int64(a),
|
||||||
|
Currency: stripe.String(string(stripe.CurrencyEUR)),
|
||||||
|
PaymentMethodTypes: stripe.StringSlice([]string{"card"}),
|
||||||
|
ReceiptEmail: stripe.String(m),
|
||||||
|
}
|
||||||
|
return paymentintent.New(params)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue