Slide 1

Slide 1 text

BUILDING STRIPE'S API AMBER FENG @amfeng

Slide 2

Slide 2 text

STRIPE: PAYMENTS FOR DEVELOPERS

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

WE CARE ABOUT API DESIGN

Slide 5

Slide 5 text

PAYMENTS API CREDIT CARD PAYMENTS TOKENIZED & STORED CARDS RECURRING BILLING > curl https://api.stripe.com/v1/charges \ -u sk_test_mkGsLqEW6SLnZa487HYfJVLf: \ -d amount=400 \ -d currency=usd \ -d "card[number]=4242424242424242" \ -d "card[exp_month]=12" \ -d "card[exp_year]=2014" \ -d "card[cvc]=123"

Slide 6

Slide 6 text

DESIGNING THE API

Slide 7

Slide 7 text

RPC ORIENTED ○ method=list_charges ○ All calls are POST, and return 200 POST /v0?method=list_charges &key=KEY v0 API (2010, beta)

Slide 8

Slide 8 text

DESIGN GOALS: CONSISTENCY, SIMPLICITY, POWER

Slide 9

Slide 9 text

HTTP ORIENTED ○ GET, POST, DELETE ○ HTTP status code to indicate result GET /v1/charges?count=60 -u KEY: v1 API

Slide 10

Slide 10 text

GET /v1/charges GET /v1/charges/CHARGE_ID POST /v1/charges POST /v1/charges/CHARGE_ID DELETE /v1/charges/CHARGE_ID v1 API

Slide 11

Slide 11 text

SUPPORTING THE API

Slide 12

Slide 12 text

MAKE IT EASY TO GET STARTED

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

LANGUAGE-SPECIFIC LIBRARIES & DOCS

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

FOCUSED API THAT ALLOWS FLEXIBILITY

Slide 19

Slide 19 text

LET USERS BUILD EXTENSIONS WEBHOOKS ○ Posted events to a webhook URL ○ charge.succeeded, charge.refunded, etc. CONNECT ○ OAuth2 API ○ Users can authorize access to their Stripe accounts ○ Full access to Stripe API

Slide 20

Slide 20 text

PROVIDE A TESTING ENVIRONMENT

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

HELP YOUR USERS DEBUG

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

{ "error": { "message": "You must provide an integer value for 'exp_year'.", "type": "card_error", "param": "exp_year" } }

Slide 26

Slide 26 text

>> Stripe::Customer.create Stripe::AuthenticationError: No API key provided. (HINT: set your API key using "Stripe.api_key = ". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email [email protected] if you have any questions.)

Slide 27

Slide 27 text

>> Stripe.api_key = TEST_KEY => ... >> Stripe::Charge.retrieve(LIVE_CHARGE_ID) Stripe::InvalidRequestError: (Status 404) No such charge: ch_17SOe5QQ2exd2S; a similar object exists in live mode, but a test mode key was used to make this request.

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

DEALING WITH CHANGE

Slide 31

Slide 31 text

BACKWARDS INCOMPATIBLE CHANGES ○ Per-user version, set on first API call ○ Allow upgrading versions and detailed changelog ○ Pass version override in headers FEATURE GATING ○ Experimental or one-off ○ shows_applications VERSIONING

Slide 32

Slide 32 text

MANY DEFINITIONS OF A "GOOD API"

Slide 33

Slide 33 text

THANKS! (: AMBER FENG @amfeng