On this page
change_history
Code Blocks DRAFT
Code Block features and settings.
Syntax Highlighting
Syntax highlighting is supported by Prism (the default). It can be disabled in favour of Hugo’s builtin syntax highlighter, Chroma.
🡇 code fences - bash
curl -X POST -is "http://localhost:4242/create-checkout-session" -d ""
🡇 code fences - javascript
function foo(bar) {
var a = 42,
b = 'Prism';
return a + bar(b);
}
🡇 prism shortcode - javascript
function foo(bar) {
var a = 42,
b = 'Prism';
return a + bar(b);
}
🡇 code fences - html
<html>
<head>
<title>Buy cool new product</title>
</head>
<body>
<!-- Use action="/create-checkout-session.php" if your server is PHP based. -->
<form action="/create-checkout-session" method="POST">
<button type="submit">Checkout</button>
</form>
</body>
</html>
🡇 code fences - swift
let cardParams = STPCardParams()
cardParams.name = "Jenny Rosen"
cardParams.number = "4242424242424242"
cardParams.expMonth = 12
cardParams.expYear = 18
cardParams.cvc = "424"
let sourceParams = STPSourceParams.cardParams(withCard: cardParams)
STPAPIClient.shared.createSource(with: sourceParams) { (source, error) in
if let s = source, s.flow == .none && s.status == .chargeable {
self.createBackendChargeWithSourceID(s.stripeID)
}
}
🡇 prism shortcode - go
package main
import (
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/stripe/stripe-go/v72"
"github.com/stripe/stripe-go/v72/checkout/session"
)
// This example sets up an endpoint using the Echo framework.
// Watch this video to get started: https://youtu.be/ePmEVBu8w6Y.
func main() {
stripe.Key = "UfXXWzQ2B1yVX57GU3QV8EQyTizMUvUm"
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.POST("/create-checkout-session", createCheckoutSession)
e.Logger.Fatal(e.Start("localhost:4242"))
}
func createCheckoutSession(c echo.Context) (err error) {
params := &stripe.CheckoutSessionParams{
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
LineItems: []*stripe.CheckoutSessionLineItemParams{
&stripe.CheckoutSessionLineItemParams{
PriceData: &stripe.CheckoutSessionLineItemPriceDataParams{
Currency: stripe.String("usd"),
ProductData: &stripe.CheckoutSessionLineItemPriceDataProductDataParams{
Name: stripe.String("T-shirt"),
},
UnitAmount: stripe.Int64(2000),
},
Quantity: stripe.Int64(1),
},
},
SuccessURL: stripe.String("http://localhost:4242/success"),
CancelURL: stripe.String("http://localhost:4242/cancel"),
}
s, _ := session.New(params)
if err != nil {
return err
}
return c.Redirect(http.StatusSeeOther, s.URL)
}
🡇 code fences - treeview
├── fonts/
├── images/
├── js/
│ ├── vendor/
│ ├── app.js
│ └── index.js
├── lambda/
└── scss/
├── common/
├── components/
├── layouts/
├── vendor/
└── app.scss
Last updated 27 Nov 2022, 07:08 UTC.
Was this page helpful?