HandleWebhook function
(payload map[string]interface{}, event stripe.Event)
| 21 | |
| 22 | // HandleWebhook function |
| 23 | func (webhookService *WebhookService) HandleWebhook(payload map[string]interface{}, event stripe.Event) (success bool, err error) { |
| 24 | go func(payload map[string]interface{}) { |
| 25 | webhook := &models.Webhook{} |
| 26 | webhook.Payload = payload |
| 27 | mgm.CollectionByName("webhook").Create(webhook) |
| 28 | }(payload) |
| 29 | if event.Type == "invoice.paid" { |
| 30 | success, err = webhookService.PaymentSuccessful(event) |
| 31 | } else if event.Type == "invoice.payment_failed" { |
| 32 | success, err = webhookService.PaymentFailed(event) |
| 33 | } else if event.Type == "customer.subscription.created" { |
| 34 | success, err = webhookService.SubscriptionUpdated(event) |
| 35 | } else if event.Type == "customer.subscription.updated" { |
| 36 | success, err = webhookService.SubscriptionUpdated(event) |
| 37 | } |
| 38 | return success, err |
| 39 | } |
| 40 | |
| 41 | // PaymentSucceeded function |
| 42 | func (webhookService *WebhookService) PaymentSuccessful(event stripe.Event) (success bool, err error) { |
nothing calls this directly
no test coverage detected