MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / sessionCompleted

Function sessionCompleted

controller/topup_stripe.go:156–174  ·  view source on GitHub ↗
(event stripe.Event)

Source from the content-addressed store, hash-verified

154}
155
156func sessionCompleted(event stripe.Event) {
157 customerId := event.GetObjectValue("customer")
158 referenceId := event.GetObjectValue("client_reference_id")
159 status := event.GetObjectValue("status")
160 if "complete" != status {
161 log.Println("错误的Stripe Checkout完成状态:", status, ",", referenceId)
162 return
163 }
164
165 err := model.Recharge(referenceId, customerId)
166 if err != nil {
167 log.Println(err.Error(), referenceId)
168 return
169 }
170
171 total, _ := strconv.ParseFloat(event.GetObjectValue("amount_total"), 64)
172 currency := strings.ToUpper(event.GetObjectValue("currency"))
173 log.Printf("收到款项:%s, %.2f(%s)", referenceId, total/100, currency)
174}
175
176func sessionExpired(event stripe.Event) {
177 referenceId := event.GetObjectValue("client_reference_id")

Callers 1

StripeWebhookFunction · 0.85

Calls 2

RechargeFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected