Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Misc updates.
Browse files Browse the repository at this point in the history
* Update READMEs with Go server details.
* Update Gcloud ignore.
* Use plural for /products/:product_id/skus route throughout.
  • Loading branch information
thorsten-stripe authored Apr 17, 2019
1 parent 7dfaa0c commit fcac2ab
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ STRIPE_ACCOUNT_COUNTRY=US
# Supported payment methods for the store.
# Some payment methods support only a subset of currencies.
# Make sure to check the docs: https://stripe.com/docs/sources
# Only used for the python server. For Node.js see the server/node/config.js file!
# Only used for servers that don't have a separate config/settings file.
# For Node.js see the server/node/config.js file!
PAYMENT_METHODS="alipay, bancontact, card, eps, ideal, giropay, multibanco, sofort, wechat"

# Optional ngrok configuration for development (if you have a paid ngrok account).
Expand Down
1 change: 1 addition & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
node_modules/

# Alternative server implementations
server/go/
server/java/
server/php/
server/python/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The [Sources API](https://stripe.com/docs/sources) provides a single integration

Instructions for running the Node.js server in [`server/node`](/server/node) are below. You can find alternative server implementations in the [`server`](/server) directory:

- Go, Echo: [`server/go`](/server/java)
- Java, Spark: [`server/java`](/server/java)
- Node, Express: [`server/node`](/server/node)
- PHP, Slim: [`server/php`](/server/php)
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Store {
// Retrieve a SKU for the Product where the API Version is newer and doesn't include them on v1/product
async loadSkus(product_id) {
try {
const response = await fetch(`/product/${product_id}/skus`);
const response = await fetch(`/products/${product_id}/skus`);
const skus = await response.json();
this.products[product_id].skus = skus;
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion server/go/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func buildEcho(publicDirectory string) *echo.Echo {
return c.JSON(http.StatusOK, listing{products})
})

e.GET("/product/:product_id/skus", func(c echo.Context) error {
e.GET("/products/:product_id/skus", func(c echo.Context) error {
skus, err := inventory.ListSKUs(c.Param("product_id"))
if err != nil {
return err
Expand Down
12 changes: 7 additions & 5 deletions server/go/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/stripe/stripe-go"
"github.com/stripe/stripe-go/product"
"github.com/stripe/stripe-go/sku"

"github.com/stripe/stripe-payments-demo/config"
)

func CreateData() error {
Expand All @@ -14,7 +16,7 @@ func CreateData() error {
return fmt.Errorf("setup: error creating products: %v", err)
}

err = createSKUs()
err = createSKUs(config.Default().Currency)
if err != nil {
return fmt.Errorf("setup: error creating products: %v", err)
}
Expand Down Expand Up @@ -87,7 +89,7 @@ func createProducts() error {
return nil
}

func createSKUs() error {
func createSKUs(currency string) error {
paramses := []*stripe.SKUParams{
{
ID: stripe.String("increment-03"),
Expand All @@ -96,7 +98,7 @@ func createSKUs() error {
"issue": "Issue #3 “Development”",
},
Price: stripe.Int64(399),
Currency: stripe.String(string(stripe.CurrencyUSD)),
Currency: stripe.String(currency),
Inventory: &stripe.InventoryParams{
Type: stripe.String(string(stripe.SKUInventoryTypeInfinite)),
},
Expand All @@ -109,7 +111,7 @@ func createSKUs() error {
"gender": "Woman",
},
Price: stripe.Int64(999),
Currency: stripe.String(string(stripe.CurrencyUSD)),
Currency: stripe.String(currency),
Inventory: &stripe.InventoryParams{
Type: stripe.String(string(stripe.SKUInventoryTypeInfinite)),
},
Expand All @@ -121,7 +123,7 @@ func createSKUs() error {
"set": "Collector Set",
},
Price: stripe.Int64(799),
Currency: stripe.String(string(stripe.CurrencyUSD)),
Currency: stripe.String(currency),
Inventory: &stripe.InventoryParams{
Quantity: stripe.Int64(500),
Type: stripe.String(string(stripe.SKUInventoryTypeFinite)),
Expand Down
2 changes: 1 addition & 1 deletion server/go/webhooks/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func HandlePaymentIntent(event stripe.Event, pi *stripe.PaymentIntent) (bool, er
if pi.LastPaymentError.PaymentMethod != nil {
fmt.Printf(
"🔔 Webhook received! Payment on %s %s for PaymentIntent %s failed\n",
"payment_intent",
"payment_method",
pi.LastPaymentError.PaymentMethod.ID,
pi.ID,
)
Expand Down
2 changes: 1 addition & 1 deletion server/java/src/main/java/app/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void main(String[] args) {
get("/config", ConfigController.getConfig);
get("/products", ProductController.getProducts);
get("/products/:id", ProductController.getProduct);
get("/product/:id/skus", ProductController.getSKUsForProduct);
get("/products/:id/skus", ProductController.getSKUsForProduct);
get("/payment_intents/:id/status", PaymentController.getPaymentIntent);
post("/payment_intents", PaymentController.createPaymentIntent);
post("/payment_intents/:id/shipping_change", PaymentController.updatePaymentIntent);
Expand Down
2 changes: 1 addition & 1 deletion server/ruby/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
end
end

get '/product/:product_id/skus' do
get '/products/:product_id/skus' do
content_type 'application/json'
skus = Inventory.list_skus(params['product_id'])
skus.to_json
Expand Down

0 comments on commit fcac2ab

Please sign in to comment.