Skip to content

writing / 2020 /

Weeknotes 2020 WK 50

Updating the DSF Stripe integration

We need to update Django’s Stripe integration for the new Strong Customer Authentication (SCA) flows that come into force at the end of this year. This wasn’t on our radar at all until called-out by Ben Balder Bach, of the Django-Denmark org — Thanks Ben! 😅

As such, I spent most of a couple of days looking at the Stripe integration this week. The individual bits are not super-complex I’d say, but there are a lot of moving parts. Beyond that it’s important: it has to work. And, finally, the existing integration is around 5 years old, and doesn't necessarily map to the new flows in the can we do it the obvious way route.

More or less the breakdown went:

  • Review existing implementation, in comparison to the sample Ben provided on the issue report.
  • Review the Stripe docs. In contrast to how they’ve done it in the past, you now essentially want to be using their fully hosted checkout page, with a web hook callback for the result of the payment. (If you’re big, and you can justify the developer time, sure create a custom checkout flow, but that’s not us, and I’d bet it’s not you either.)
  • Assess the integration: all the Stripe docs want you to create the Customer object before creating the payment, especially for subscriptions. That’s not how the existing implementation does it. (Too much detail: the previous flow would give you the customer email when you posted the checkout token in order to collect the payment; the new flow doesn’t, so some time™ was spent reviewing whether we needed a bigger change in structure here — ultimately we don’t, a Session will create a customer for you if you don’t provide one, but none of the sample docs show that flow.)
  • Final Plan: OK, which forms, views, and tests are we changing and exactly how?

Having spent the time, I’m at the final plan stage, and will put it in place next week. I consider that good going.

There was a couple of things that came to mind in the week.

The first was the Basecamp team’s analogy of task work being like hill climbing. (This is from their excellent Shape Up guide to project management.)

The idea is that there are two phases to a task: Figuring out what to do and Getting it done.

The key insight (I think) is that one of the main reasons we struggle as software developers to come up with accurate estimates is that we fail to acknowledge the Figuring it out stage. As such, we identify some tasks, estimate on that basis, start work, discover a whole load of more tasks, and then (understandably) miss our original estimates. By using the Hill Chart, you force yourself to at least think about whether you’ve done the necessary discovery here.

(This idea isn’t original to the Basecamp team: essentially the same thing under the idea of the Cone of Uncertainty is a staple of project management texts.)

The second thought, then, was a post by a fella called Wil Shipley, from 2005, that was influential to me, all that time ago.

The bit that came to mind (looking it up) was this:

The Way of the Code Samurai

Now, I don't actually know much about real samurai, but the basic thing I've heard is they stand and stare at each other for hours, and then suddenly BAM strike once and the other guy is down.

That's how you should code.

That’s kind of how it felt, digging ever deeper into the integration before making any changes. (I did think I’d get the PR actually off this week.)

The whole article is called Free Programming Tips are Worth Every Penny. It’s great. Highly recommended.

Trying hard to like Lightsail

Lightsail is AWS’s easier environment. It’s less work to spin up an instance that the traditional (?) EC2 route. (Mainly the difference is in the networking pre-config: you don’t need to set up a VPC, and all that jazz.)

In theory I should like this. Button is all about doing things more easily.

Reality is, more-or-less, I don’t.

Main issue for me is the separation from the standard compute environment.

Using the term loosely, since there are lots of differences, in general, I quite like PaaS type environments, App Engine, App Service, Heroku, DO’s new thing (which I’m yet to give a run), and so on. Lightsail fits in here.

My complaint with such things is that whilst I think they’re actually a specialist use-case, they’re marketed as beginner friendly. Sure, they’re easy to set up but you hit limits and then need to back out, and you’re at square one again. On Python Bytes, I described them as a deployment cul-de-sac for this reason.

My hope with Lightsail was that it would offer the ease of setup but with a growth path into the full environment. I don’t see that. Yes you can export instance images and then fire those up in EC2, and you can pair your network to your default VPC, to connect to RDS and so on, but it’s all pain.

Take DNS. It has a whole different set-up to Route53. You can create up to three zones and manage them in Lightsail, but what you really want is a simplified shim on top of Route53, that lets you take the trainer wheels off when you’re ready.

Take AMIs: you want to be able to launch any AMI, but all there are base OS images (which are great, but then you need to provision them, which is a lot of what puts folks off VMs in the first place) or a set of approved template images (which you know are that awful nearly right that you don’t want to deal with).

And so on...

Slightly too expensive, I can live with. Flip-side of that, under-resourced, I can live with. But the lack of flexibility across the board, coupled with the lack of a clear (or better easy) upgrade path leaves me a little disappointed.

I’m guessing AWS will improve this over time.

The instance APIs are also pretty simple, and similar enough to EC2 to make Lightsail worth supporting in Button, but it won’t be first priority, or the recommended option.

Whilst I have you, Button is progressing nicely. I intend to send out a call for early adopters to give it a run around the new year. AWS is the first target. If you’re on iOS or Mac as an individual user, or if you're a startup, agency or other Team who have shared ops then early access will be most relevant to you. Do sign up to the email list for the announcements.

90 Day Move Streak

Lockdown in March was fatal for my exercise. Bar essential shopping, we weren’t allowed out of the house for 6 weeks. (The kids literally didn’t leave the house once.)

Bad habits then slipped in.

End of the Summer, I was like right. Got to do something about this.

Yesterday marked 90 days straight hitting my Move goal. So 🔥

Most days it’s been OK. One day, about a month in, I had to do a 7 minute workout at bedtime to hit the target.