ducky/subscriptions

Paddy 2015-06-22 Parent:56a2bef197cd Child:1ff031bebf9e

3:b240b6123548 Go to Latest

ducky/subscriptions/memstore.go

Export all subscriptionStore methods. We're not going to wrap all our subscriptionStore interactions in a Context type, so we need to expose all the functions so other packages can call them. Also, it's now SubscriptionStore. Also creates a SubscriptionRequest type that is used to create a new Subscription instance, along with a Validate method on it, to detect errors when creating a SubscriptionRequest. Update our CreateSubscription function to be New, and have it take a SubscriptionRequest, a Stripe instance, and a SubscriptionStore as arguments. It'll create the Subscription in the SubscriptionStore, create a customer in Stripe, and create the subscription in Stripe, then associate the Stripe subscription with the created Subscription. Also, fix our StripeSubscriptionChange function to correctly equate a missing/zero Unix timestamp from Stripe with a missing/zero time.Time.

History
     1.1 --- a/memstore.go	Tue Jun 16 23:09:59 2015 -0400
     1.2 +++ b/memstore.go	Mon Jun 22 18:34:07 2015 -0400
     1.3 @@ -19,7 +19,7 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 -func (m *Memstore) reset() error {
     1.8 +func (m *Memstore) Reset() error {
     1.9  	m.subscriptionLock.Lock()
    1.10  	defer m.subscriptionLock.Unlock()
    1.11