How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

57
How we create APIs to manage complexity 1 Horia Jurcut [email protected] Spotify Payments

Transcript of How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Page 1: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

How we create APIs to manage complexity

1

Horia [email protected]

Spotify Payments

Page 2: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

History of Spotify

Page 3: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Credit Cards

2008

FinlandFrance

NorwaySpain

Sweden

2008

2006

Initial launch

2016

Page 4: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Credit Cards

2008PayPal

2011

FinlandFrance

NorwaySpain

Sweden

2008 AustriaBelgium

DenmarkGreat BritainSwitzerland

The NetherlandsUSA

2011

2006

Initial launch Growth

2016

Page 5: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Credit Cards

2008PayPal

2011

FinlandFrance

NorwaySpain

Sweden

2008 AustriaBelgium

DenmarkGreat BritainSwitzerland

The NetherlandsUSA

2011

2006

Initial launch Growth

BokuSofort Klarna

Google iAPFacebook payments

2013

ArgentinaAustralia

ColombiaHong Kong

IrelandGermany

...

2013

+ 37 markets

Global Company

2016

Page 6: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Credit Cards

2008PayPal

2011

FinlandFrance

NorwaySpain

Sweden

2008 AustriaBelgium

DenmarkGreat BritainSwitzerland

The NetherlandsUSA

2011

2006

Initial launch Growth

BokuSofort Klarna

Google iAPFacebook payments

2013

ArgentinaAustralia

ColombiaHong Kong

IrelandGermany

...

2013

+ 37 markets

Global Company

AdyenPaySafe Card

OxxoiDeal

dotPay DragonPay SafetyPay

DirectDebitBoleto

iOS iAP

2015

BrazilCanada

Philippines

2015

Localization

2016

Page 7: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Credit Cards

2008PayPal

2011

FinlandFrance

NorwaySpain

Sweden

2008 AustriaBelgium

DenmarkGreat BritainSwitzerland

The NetherlandsUSA

2011

2006

Initial launch Growth

BokuSofort Klarna

Google iAPFacebook payments

2013

ArgentinaAustralia

ColombiaHong Kong

IrelandGermany

...

2013

+ 37 markets

Global Company

AdyenPaySafe Card

OxxoiDeal

dotPay DragonPay SafetyPay

DirectDebitBoleto

iOS iAP

2015

Localization

FortumoDoku

econtext

2016

40 millionsubscribers

2016

IndonesiaJapan

2016

60 markets

2016

Optimization

BrazilCanada

Philippines

2015

Page 8: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

What are Payments?

Page 9: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Payments @ Spotify

Page 10: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Checkout

Go to spotify.com

2

Payments @ Spotify

Page 11: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Checkout

Go to spotify.com Validate card

2Payment Backend

Payments @ Spotify

Page 12: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Checkout

Payment

Provider

Go to spotify.com Validate details Authorize payment

2Payment Backend

Payments @ Spotify

Page 13: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Checkout

Payment

Provider

Credit Network

Go to spotify.com Validate card

Contact bank

2Authorize payment

Payment Backend

Payments @ Spotify

Page 14: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Checkout

Payment

Provider

Credit Network

Go to spotify.com Validate card

Valid card

Contact bank

Authorize payment

Valid card

2

3

Payment Backend

Payments @ Spotify

Page 15: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Bank

Users

1

Checkout

Payment

Provider

Credit Network

Go to spotify.com Validate card

Valid card

Contact bank

Authorize payment

Valid card

Access to Spotify Premium

2

3

Payment Backend

Payments @ Spotify

Page 16: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout

Payment

Provider

Payments @ Spotify

Payment Backend

Page 17: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout

Payments @ Spotify

Payment Providers

...

Payment Backend

Page 18: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout

Checkout API

Payments @ Spotify

Payment Providers

...

Payment Backend

Page 19: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout

Checkout API Billing API

Payments @ Spotify

Payment Providers

...

Payment Backend

Page 20: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Page 21: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Payment Backend

Page 22: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Payment BackendClients

Page 23: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Payment BackendClients

“What?”

next steps

Page 24: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Payment BackendClients

“How?” “What?”

next steps

send data

send data

send data

send data

Page 25: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Payment BackendClients

CheckoutAPI

“How?” “What?”

send data

send data

send data

send data

next steps

Page 26: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

CC Form

CC Form

Checkout API

Page 27: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Success

CC Form

Confirmation

Checkout API

CC Form

Page 28: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

SuccessCC Form

TaxInfo

CC Form

ConfirmationTax Info

Required in some

countries

Checkout API

Page 29: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

SuccessCC Form

TaxInfo

CC Form

ConfirmationTax Info

Required in some

countries

PaymentBackend

Checkout API

Clients

Page 30: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

SuccessBillingAddress

CC Form

TaxInfo

CC Form

ConfirmationTax Info

Required in some

countries

Billing Address

PaymentBackend

Checkout API

Clients

Page 31: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

SuccessBillingAddress

CC Form

TaxInfo

Offer Code

One Time Code

X3G6D8A7

CC Form

ConfirmationTax Info

Required in some

countries

Billing Address

PaymentBackend

Checkout API

Clients

Page 32: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

CheckoutAPI

SuccessBillingAddress

CC Form

TaxInfo

Offer Code

One Time Code

X3G6D8A7

CC Form

ConfirmationTax Info

Required in some

countries

Billing Address

PaymentBackend

Checkout API

Clients

Page 33: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Checkout API

Start purchase What is the first step?

Page 34: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Checkout API

Start purchase What is the first step?

Collect CC InformationDisplay CC Form

CC Form

Page 35: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Checkout API

Start purchase What is the first step?

Collect CC InformationDisplay CC Form

CC Form

CC Form

Send credit card data Send credit card data

Page 36: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Checkout API

Start purchase What is the first step?

Collect CC InformationDisplay CC Form

CC Form

CC Form

Confirmation

Show ConfirmationDisplay Confirmation

Send credit card data Send credit card data

Page 37: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Checkout API

Checkout API

Start purchase What is the first step?

Collect CC InformationDisplay CC Form

CC Form

Send credit card data Send credit card data

Confirmation

Show ConfirmationDisplay Confirmation

CC Form

One Time Code

X3G6D8A7

Page 38: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Advantages

Spotify Payments

● Change checkout experience without client release

● Clients can build native experiences

● Consolidated business logic

● Rapidly test, experiment and learn

● Mix & Match

Page 39: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Page 40: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Clients

Page 41: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Clients

CheckoutAPI

Page 42: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Payment BackendClients

CheckoutAPI

Page 43: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Payment BackendClients

CheckoutAPI

Adyen

PayPal

Klarna

Payment Providers

Page 44: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Payment BackendClients

CheckoutAPI

Adyen

PayPal

Klarna

BillingAPI

charge

success

Payment Providers

Page 45: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Payment BackendClients

CheckoutAPI

Adyen

PayPal

Klarna

BillingAPI

charge

success

Payment Providers

FinancialData

SettlementReconciliation Callbacks Monitoring

Page 46: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Billing API

Payment BackendClients

CheckoutAPI

Adyen

PayPal

Klarna

BillingAPI

charge

success

Payment Providers

FinancialData

SettlementReconciliation Callbacks Monitoring

Page 47: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Automatic Alerts

Page 48: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Monitoring

BillingAPI

{ "message": "payment_received", "provider": "adyen", "method": "cards", "amount: "9.99", "currency": "USD", "country": "US", "product_type": "premium", "duration:" 1, "duration_type": "month", "reference": "9107771201",}

{ "message": "payment_failed", "provider": "adyen", "method": "cards", "amount: "9.99", "currency": "USD", "country": "US", "product_type": "premium", "duration:" 1, "duration_type": "month", "reference": "9108771203", "failure_code": "399",}

Page 49: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Automatic Alerts

Payment transactions processed (initial payments)

Payment transactions failed (initial payments)

Page 50: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Automatic Alerts

Payment transactions processed (initial payments)

Payment transactions failed (initial payments)

Broke initial payments

Page 51: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Automatic Alerts

Payment transactions processed (initial payments)

Payment transactions failed (initial payments)

Broke initial payments

Provider had an issue

Page 52: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Automatic Alerts

Payment transactions processed (initial payments)

Payment transactions failed (initial payments)

Broke initial payments

Provider had an issue

Other providers continued working

Page 53: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Advantages

Spotify Payments

● Fairly low number of false positives

● Works very well for high volume providers (Adyen)

● Become more aware of local events

Page 54: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

API Design

Page 55: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Why we build APIs

Spotify Payments

● Many clients, many providers

● Integrate with other internal systems

● More complex products and business rules

● Customization

Page 56: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

My time @ Spotify

Spotify Payments

● APIs make it easier for multiple teams to collaborate

● APIs help you take a hard problem and divide it into more

manageable domains

● APIs require documentation

● APIs enable you to rapidly test, experiment and learn

Page 57: How Spotify Payments Creates APIs to Manage Complexity (Horia Jurcut)

Tack.

57Spotify Payments