mirror of
https://github.com/tavo-wasd-gh/conex-builder.git
synced 2025-06-07 04:03:29 -06:00
price from env
This commit is contained in:
parent
e357a8c270
commit
c711b6707d
2 changed files with 6 additions and 6 deletions
|
@ -69,7 +69,7 @@ func main() {
|
||||||
returnURL = os.Getenv("RETURN_URL")
|
returnURL = os.Getenv("RETURN_URL")
|
||||||
cancelURL = os.Getenv("CANCEL_URL")
|
cancelURL = os.Getenv("CANCEL_URL")
|
||||||
port = os.Getenv("PORT")
|
port = os.Getenv("PORT")
|
||||||
// price = os.Getenv("PRICE")
|
amount = os.Getenv("PRICE")
|
||||||
)
|
)
|
||||||
|
|
||||||
if baseURL == "" ||
|
if baseURL == "" ||
|
||||||
|
@ -124,7 +124,7 @@ func main() {
|
||||||
|
|
||||||
s3Client = s3.NewFromConfig(cfg)
|
s3Client = s3.NewFromConfig(cfg)
|
||||||
|
|
||||||
http.HandleFunc("/api/orders", CreateOrderHandler(db))
|
http.HandleFunc("/api/orders", CreateOrderHandler(db, amount))
|
||||||
http.HandleFunc("/api/orders/", CaptureOrderHandler(db))
|
http.HandleFunc("/api/orders/", CaptureOrderHandler(db))
|
||||||
http.HandleFunc("/api/update", UpdateSiteHandler(db))
|
http.HandleFunc("/api/update", UpdateSiteHandler(db))
|
||||||
http.HandleFunc("/api/confirm", ConfirmChangesHandler(db))
|
http.HandleFunc("/api/confirm", ConfirmChangesHandler(db))
|
||||||
|
@ -169,7 +169,7 @@ func fatal(err error, notice string) {
|
||||||
log.Fatalf("%s: %v", notice, err)
|
log.Fatalf("%s: %v", notice, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateOrderHandler(db *sql.DB) http.HandlerFunc {
|
func CreateOrderHandler(db *sql.DB, amount string) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var cart struct {
|
var cart struct {
|
||||||
Directory string `json:"directory"`
|
Directory string `json:"directory"`
|
||||||
|
@ -191,7 +191,7 @@ func CreateOrderHandler(db *sql.DB) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
orderID, err := CreateOrder()
|
orderID, err := CreateOrder(amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpErrorAndLog(w, err, errCreateOrder, "Error creating order")
|
httpErrorAndLog(w, err, errCreateOrder, "Error creating order")
|
||||||
return
|
return
|
||||||
|
|
|
@ -91,7 +91,7 @@ func Token() (string, error) {
|
||||||
return response.AccessToken, nil
|
return response.AccessToken, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateOrder() (string, error) {
|
func CreateOrder(amount string) (string, error) {
|
||||||
token, err := Token()
|
token, err := Token()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("%s: %v", errToken, err)
|
return "", fmt.Errorf("%s: %v", errToken, err)
|
||||||
|
@ -129,7 +129,7 @@ func CreateOrder() (string, error) {
|
||||||
Intent: "CAPTURE",
|
Intent: "CAPTURE",
|
||||||
PurchaseUnits: []PurchaseUnits{{Amount: Amount{
|
PurchaseUnits: []PurchaseUnits{{Amount: Amount{
|
||||||
CurrencyCode: "USD",
|
CurrencyCode: "USD",
|
||||||
Value: os.Getenv("PRICE"),
|
Value: amount,
|
||||||
}}},
|
}}},
|
||||||
PaymentSource: PaymentSource{Paypal: Paypal{Address: Address{
|
PaymentSource: PaymentSource{Paypal: Paypal{Address: Address{
|
||||||
CountryCode: "CR",
|
CountryCode: "CR",
|
||||||
|
|
Loading…
Reference in a new issue