Documentation ¶
Index ¶
- func Create(ctx context.Context, db sqlx.ExtContext, order Order) error
- func CreateItem(ctx context.Context, db sqlx.ExtContext, item Item) error
- func HandlePaypalCapture(db *sqlx.DB, pp *paypal.Client) web.Handler
- func HandlePaypalCheckout(db *sqlx.DB, pp *paypal.Client) web.Handler
- func HandleStripeCapture(db *sqlx.DB, cfg config.Stripe) web.Handler
- func HandleStripeCheckout(db *sqlx.DB, strp *stripecl.API, cfg config.Stripe) web.Handler
- func UpdateStatus(ctx context.Context, db sqlx.ExtContext, up StatusUp) error
- type Item
- type Order
- type Status
- type StatusUp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateItem ¶
CreateItem adds a new item in an order.
func HandlePaypalCapture ¶
HandlePaypalCapture checks if the user's purchase has been successfully completed. After the capture, the money of the user will be transferred to our paypal account.
func HandlePaypalCheckout ¶
HandlePaypalCheckout starts the purchase flow with paypal.
func HandleStripeCapture ¶
HandleStripeCapture completes the user's purchase. Stripe webhooks must be configured to call this endpoint when a checkout is completed.
TODO: Remember to disable async payments. https://stripe.com/docs/payments/checkout/fulfill-orders#delayed-notification . TODO: rename in HandleStripeWebhooks.
func HandleStripeCheckout ¶
HandleStripeCheckout starts the purchase flow with stripe.
func UpdateStatus ¶
UpdateStatus updates only the status and the date of an order.
Types ¶
type Item ¶
type Item struct { OrderID string `json:"orderId" db:"order_id"` CourseID string `json:"courseId" db:"course_id"` Price int `json:"price" db:"price"` CreatedAt time.Time `json:"createdAt" db:"created_at"` }
Item models the item of an order. An item can only belong to one order. An order can have many items.
type Order ¶
type Order struct { ID string `json:"id" db:"order_id"` UserID string `json:"userId" db:"user_id"` ProviderID string `json:"providerId" db:"provider_id"` Status Status `json:"status" db:"status"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` }
Order models orders. Orders have a one-to-many relationship with items.
func FetchByProviderID ¶
FetchByProviderID retrieves the order with the specified provider id, if any.