Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Spree Commerce hub - technical summary
Search
Brian Quinn
September 17, 2013
1
190
Spree Commerce hub - technical summary
Brian Quinn
September 17, 2013
Tweet
Share
More Decks by Brian Quinn
See All by Brian Quinn
Backend Integrations & the Spree Commerce Hub
bdq
3
460
SpreeConf DC 2013: Introducing the Spree Integrator
bdq
2
530
E-commerce Ireland: Introduction to Spree Commerce
bdq
1
270
SpreeConf Europe: Backbone.js & Spree
bdq
4
960
SpreeConf 2012: Spree themes with Deface
bdq
9
5.4k
SpreeConf 2012: Spree's Hidden Gems
bdq
3
770
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Facilitating Awesome Meetings
lara
50
6.1k
Building Applications with DynamoDB
mza
90
6.1k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Automating Front-end Workflow
addyosmani
1366
200k
Designing the Hi-DPI Web
ddemaree
280
34k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
A Philosophy of Restraint
colly
203
16k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Transcript
Spree Commerce hub
Spree Commerce hub Overview
Spree Commerce store front Spree Commerce hub Overview
Spree Commerce store front Spree Commerce hub Overview
Spree Commerce store front Spree Commerce hub Mandrill NetSuite Shipwire
Custom Overview
Spree Commerce store front Spree Commerce hub Mandrill NetSuite Shipwire
Custom SendGrid Xero Amazon Custom So Ne E Cu Overview
Store front hub Mandrill Endpoint Overview
Store front hub orders updated since (timestamp) updated orders Mandrill
Endpoint Overview
Store front hub orders updated since (timestamp) updated orders Mandrill
Endpoint detect new orders Overview
Store front hub orders updated since (timestamp) updated orders Mandrill
Endpoint send order confirmation email detect new orders confirmation Overview
Store front hub orders updated since (timestamp) updated orders confirmation
Overview
Store front hub orders updated since (timestamp) updated orders send
shipment to fulfillment detect ready shipments confirmation Shipwire Endpoint Overview
Store front hub Shipwire Endpoint Overview
Store front hub poll for shipments (bookmark) dispatched shipments Shipwire
Endpoint Overview
Store front hub poll for shipments (bookmark) dispatched shipments Shipwire
Endpoint update shipment state + tracking confirmation Overview
Store front hub poll for shipments (bookmark) dispatched shipments Shipwire
Endpoint update shipment state + tracking confirmation Overview
hub poll for shipments (bookmark) dispatched shipments Shipwire Endpoint +
tracking Mandrill Endpoint Overview
hub poll for shipments (bookmark) dispatched shipments Shipwire Endpoint +
tracking Mandrill Endpoint Overview
hub poll for shipments (bookmark) dispatched shipments Shipwire Endpoint +
tracking Mandrill Endpoint send shipment notification email Overview
hub poll for shipments (bookmark) dispatched shipments Shipwire Endpoint +
tracking Mandrill Endpoint send shipment notification email confirmation Overview
Message Basics
JSON
Message: Overview 1 { 2 "message": "payment:ready", 3 "payload": {
4 "payment": { 5 "id": 15913, 6 "amount": "129.57", 7 "state": "pending", 8 "payment_method": { 9 "id": 931422127, 10 "name": "Credit Card", 11 "environment": "production" 12 } 13 } 14 } 15 }
Message: Overview 1 { 2 "message": "payment:ready", 3 "payload": {
4 "payment": { 5 "id": 15913, 6 "amount": "129.57", 7 "state": "pending", 8 "payment_method": { 9 "id": 931422127, 10 "name": "Credit Card", 11 "environment": "production" 12 } 13 } 14 } 15 }
Message: Overview 1 { 2 "message": "payment:ready", 3 "payload": {
4 "payment": { 5 "id": 15913, 6 "amount": "129.57", 7 "state": "pending", 8 "payment_method": { 9 "id": 931422127, 10 "name": "Credit Card", 11 "environment": "production" 12 } 13 } 14 } 15 }
message:
Order New order:new Order Updated order:updated Order Cancelled order:cancelled
Order New order:new Order Updated order:updated Order Cancelled order:cancelled Shipment
Confirmation shipment:confirm Shipment Ready shipment:ready
Order New order:new Order Updated order:updated Order Cancelled order:cancelled Payment
Ready payment:ready Shipment Confirmation shipment:confirm Shipment Ready shipment:ready Payment Captured payment:captured Payment Declined payment:declined
1 { 2 "message_id": "518783ac7575e46507000001", 3 "message": "payment:ready", 4 "payload":
{ ... }, 5 "parameters": [ 6 { 7 "name": "quickbooks.user_name", 8 "value": "iQ55k..." 9 }, 10 { 11 "name": "quickbooks.password", 12 "value": "YQoQS..." 13 } 14 ] 15 } Message: Parameters
1 { 2 "message_id": "518783ac7575e46507000001", 3 "message": "payment:ready", 4 "payload":
{ ... }, 5 "parameters": [ 6 { 7 "name": "quickbooks.user_name", 8 "value": "iQ55k..." 9 }, 10 { 11 "name": "quickbooks.password", 12 "value": "YQoQS..." 13 } 14 ] 15 } Message: Parameters
Message Flow
MSG Message Flow
MSG Incoming Queue Message Flow
MSG Incoming Queue Router Message Flow
MSG Incoming Queue Router Message Flow
MSG Incoming Queue Router Consumer Registry Message Flow
MSG Incoming Queue Router Consumer Registry Accepted Queue Message Flow
order:new MSG Incoming Queue Router Consumer Registry Accepted Queue Message
Flow
order:new 1 x order:new MSG Incoming Queue Router Consumer Registry
Accepted Queue Message Flow
order:new 1 x order:new order:new - Mandrill - NetSuite -
MixPanel MSG Incoming Queue Router Consumer Registry Accepted Queue Message Flow
order:new 1 x order:new order:new - Mandrill - NetSuite -
MixPanel 3 x order:new - Mandrill - NetSuite - MixPanel MSG Incoming Queue Router Consumer Registry Accepted Queue Message Flow
Accepted Queue 3 x order:new - Mandrill - NetSuite -
MixPanel Message Flow
Accepted Queue Dispatcher 3 x order:new - Mandrill - NetSuite
- MixPanel Message Flow
Accepted Queue Dispatcher 3 x order:new - Mandrill - NetSuite
- MixPanel Message Flow
Accepted Queue Dispatcher Mandrill order:new 1 MixPanel order:new 3 NetSuite
order:new 2 3 x order:new - Mandrill - NetSuite - MixPanel Message Flow
Accepted Queue Dispatcher Mandrill order:new 1 MixPanel order:new 3 NetSuite
order:new 2 200: success 200: success 3 x order:new - Mandrill - NetSuite - MixPanel Message Flow
Accepted Queue Dispatcher Mandrill order:new 1 MixPanel order:new 3 NetSuite
order:new 2 200: success 200: success 3 x order:new - Mandrill - NetSuite - MixPanel Message Flow
Accepted Queue Dispatcher Mandrill order:new 1 MixPanel order:new 3 NetSuite
order:new 2 200: success 200: success 500: fail! 3 x order:new - Mandrill - NetSuite - MixPanel Message Flow
Accepted Queue Dispatcher NetSuite 1 x order:new - NetSuite Message
Flow
Accepted Queue Dispatcher NetSuite order:new 2 500: fail! 1 x
order:new - NetSuite order:new 2 500: fail! order:new 2 500: fail! order:new 2 200: success Message Flow
Accepted Queue Dispatcher NetSuite order:new 2 500: fail! 1 x
order:new - NetSuite order:new 2 500: fail! order:new 2 500: fail! order:new 2 200: success Message Flow
Benefits
Versioned
Order V1 parent: null new Versioning
Order V1 parent: null new send order confirmation email Versioning
Order V1 parent: null Order V2 parent: V1 update new
send order confirmation email Versioning
Order V1 parent: null Order V2 parent: V1 update new
send order confirmation email capture payment Versioning
Order V1 parent: null Order V2 parent: V1 update new
Order V3 parent: V2 update send order confirmation email capture payment Versioning
Order V1 parent: null Order V2 parent: V1 update new
Order V3 parent: V2 update send order confirmation email capture payment send shipment to fulfillment Versioning
Order V1 parent: null Order V2 parent: V1 update new
Order V3 parent: V2 update update Order V4 parent: V3 send order confirmation email capture payment send shipment to fulfillment Versioning
Order V1 parent: null Order V2 parent: V1 update new
Order V3 parent: V2 update update Order V4 parent: V3 send order confirmation email capture payment send shipment to fulfillment send shipment confirmation Versioning
Versioning Implying events
Order V1 state: complete Versioning
Order V1 state: complete update Order V2 state: canceled Versioning
Order V1 state: complete update Order V2 state: canceled push
message order:update Versioning
Order V1 state: complete update Order V2 state: canceled order:canceled
push message order:update Versioning
Logged
Messages (8)
Messages (10)
Managed
Custom Endpoints
HTTP
Message: message_id 1 { 2 "message_id": "518783ac7575e46507000001", 3 "message": "payment:ready",
4 "payload": { 5 "payment": { 6 "id": 15913, 7 "amount": "129.57", 8 "state": "pending", 9 "payment_method": { 10 "id": 931422127, 11 "name": "Credit Card", 12 "environment": "production" 13 } 14 } 15 } 16 }
Message: message_id 1 { 2 "message_id": "518783ac7575e46507000001", 3 "message": "payment:ready",
4 "payload": { 5 "payment": { 6 "id": 15913, 7 "amount": "129.57", 8 "state": "pending", 9 "payment_method": { 10 "id": 931422127, 11 "name": "Credit Card", 12 "environment": "production" 13 } 14 } 15 } 16 }
Dispatcher Endpoint order:new
Dispatcher Endpoint POST JSON { ... } order:new
Dispatcher Endpoint {message_id: x} HTTP: 200 POST JSON { ...
} order:new
Dispatcher Endpoint {message_id: x} HTTP: 200 POST JSON { ...
} order:new --------------- ✓
Response: Basic 1 { 2 "message_id": "518783ac7575e46507000001" 3 }
Endpoint: Sinatra 1 require 'sinatra' 2 require 'sinatra/json' 3 4
class SimpleEndpoint < Sinatra::Base 5 helpers Sinatra::JSON 6 7 post '/' do 8 message = JSON.parse(request.body.read) 9 10 json 'message_id' => message['message_id'] 11 end 12 end
Endpoint: Sinatra 1 require 'sinatra' 2 require 'sinatra/json' 3 4
class SimpleEndpoint < Sinatra::Base 5 helpers Sinatra::JSON 6 7 post '/' do 8 message = JSON.parse(request.body.read) 9 10 json 'message_id' => message['message_id'] 11 end 12 end
Endpoint: Sinatra 1 require 'sinatra' 2 require 'sinatra/json' 3 4
class SimpleEndpoint < Sinatra::Base 5 helpers Sinatra::JSON 6 7 post '/' do 8 message = JSON.parse(request.body.read) 9 10 json 'message_id' => message['message_id'] 11 end 12 end <- DO INTERESTING THINGS HERE
Endpoint Base https://github.com/spree/endpoint_base
Example: Endpoint Base 1 class SimpleEndpoint < EndpointBase 2 post
'/' do 3 process_result 200, {'message_id' => @message['message_id'] } 4 end 5 end
1 { 2 "message_id": "518783ac7575e46507000001", 3 "notifications": [ 4 {
"level": "info", 5 "subject": "Shipment accepted", 6 "description": "Shipment H123456 was accepted by 3PL" 7 } 8 ], 9 } Response: Notifications
1 { 2 "message_id": "518783ac7575e46507000001", 3 "notifications": [ 4 {
"level": "info", 5 "subject": "Shipment accepted", 6 "description": "Shipment H123456 was accepted by 3PL" 7 } 8 ], 9 } Response: Notifications
None
1 { 2 "message_id": "518783ac7575e46507000001", 3 "notifications": [{"level": "info", "subject":
"it happened"}], 4 "messages": [ 5 { 6 "message": "payment:captured", 7 "payload": { 8 “amount": 129.99, 9 } 10 } 11 ] 12 } Response: Messages
1 { 2 "message_id": "518783ac7575e46507000001", 3 "notifications": [{"level": "info", "subject":
"it happened"}], 4 "messages": [ 5 { 6 "message": "payment:captured", 7 "payload": { 8 “amount": 129.99, 9 } 10 } 11 ] 12 } Response: Messages
None