Serverless and Step-Functions at DAZN

Joseph Schofield
Dec 11, 2018 · 5 min read
“man jump about to hold ball near net” by ÁLVARO MENDOZA on Unsplash

The Problem

We want to offer valued customers many ways of paying for DAZN, so that they can subscribe in a way they feel most comfortable, familiar, and secure with. However, this means we need to display a single user-interface, while wiring up different payment providers behind the scenes.

How do we handle each payment provider separately, whilst maintaining the same UX flow? And how do we do all this while setting up the user’s subscription to DAZN?

The Solution


Choices are basically equivalent to a ‘switch’ statement. Based on the value of a variable, do something different. For example, if the value of the variable containing the user’s payment type is equal to ‘PayPal’, we will set the next ‘step’ to be the PayPal Lambda, which does everything specific to setting up recurring payments in PayPal.


Oh yes. How could we forget. We’ve only considered the ‘happy path’, what happens if something goes wrong?

Timeouts et al.

We’re calling many external APIs, connections are going to be slow, lost, or reset from time to time.

Type: Task
Comment: My demo step
Resource: <demo Lambda ARN>
Next: MyNextDemoStep
- ErrorEquals:
- MySpecificErrorType
IntervalSeconds: 120
MaxAttempts: 3
BackoffRate: 2.0

Permanent failures

Sometimes, a user might attempt to subscribe with a card that has no money, or a fraudulent card. In this case, we don’t want a subscription to be created, we just want to tell the user that they will need to use a different payment method.

Weird unknown failures

Did somebody say ‘Edge case’!?

success: false,
code: 42,
message: "This isn’t gonna work"

The Final Step

YLD Blog

YLD's latest thoughts on Software Engineering, Design and Digital Products

Thanks to Andrea Falzetti.

Joseph Schofield

Written by

YLD Blog

YLD Blog

YLD's latest thoughts on Software Engineering, Design and Digital Products