Modern PerlCommerce Stefan Hornburg (Racke) racke@linuxia.de - - PowerPoint PPT Presentation

modern perlcommerce
SMART_READER_LITE
LIVE PREVIEW

Modern PerlCommerce Stefan Hornburg (Racke) racke@linuxia.de - - PowerPoint PPT Presentation

Modern PerlCommerce Past and Future API Development & Deployment Modern PerlCommerce Stefan Hornburg (Racke) racke@linuxia.de Pittsburgh Perl Workshop, 8th October 2011 racke Modern PerlCommerce Modern PerlCommerce Perl Buzzwords


slide-1
SLIDE 1

Modern PerlCommerce Past and Future API Development & Deployment

Modern PerlCommerce

Stefan Hornburg (Racke)

racke@linuxia.de

Pittsburgh Perl Workshop, 8th October 2011

racke Modern PerlCommerce

slide-2
SLIDE 2

Modern PerlCommerce Past and Future API Development & Deployment Perl Buzzwords Modern Perl PerlCommerce Choices

Nitesi

racke Modern PerlCommerce

slide-3
SLIDE 3

Modern PerlCommerce Past and Future API Development & Deployment Perl Buzzwords Modern Perl PerlCommerce Choices

Perl Buzzwords

◮ Marketing Perl ◮ Modern Perl ◮ Postmodern Perl

racke Modern PerlCommerce

slide-4
SLIDE 4

Modern PerlCommerce Past and Future API Development & Deployment Perl Buzzwords Modern Perl PerlCommerce Choices

Modern Perl

◮ CPAN ◮ Best Practices ◮ Tests ◮ Separation (Modules, Plugins, Hooks, Templates) ◮ PSGI/Plack

racke Modern PerlCommerce

slide-5
SLIDE 5

Modern PerlCommerce Past and Future API Development & Deployment Perl Buzzwords Modern Perl PerlCommerce Choices

PerlCommerce Choices

◮ Interchange ◮ Handel ◮ Agora ◮ Business::Cart::Generic

racke Modern PerlCommerce

slide-6
SLIDE 6

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Past

◮ 1995 CGI ◮ 1995 MiniVend ◮ 1998 http://www.materialboerse.de/ ◮ 2001 Interchange

racke Modern PerlCommerce

slide-7
SLIDE 7

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Interchange Development

◮ Lot of things ◮ Small community ◮ Same codebase

racke Modern PerlCommerce

slide-8
SLIDE 8

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Status quo

racke Modern PerlCommerce

slide-9
SLIDE 9

Modern PerlCommerce Past and Future API Development & Deployment Past Future

References

◮ Backcountry http://www.backcountry.com/ ◮ FragnanceNet http://www.fragrancenet.com/

racke Modern PerlCommerce

slide-10
SLIDE 10

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Future

racke Modern PerlCommerce

slide-11
SLIDE 11

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Principles

◮ KISS ◮ Components ◮ Agnostic ◮ Expressive

racke Modern PerlCommerce

slide-12
SLIDE 12

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Agnostic

Cart

◮ Session ◮ DBI ◮ Webservice *

racke Modern PerlCommerce

slide-13
SLIDE 13

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Agnostic

Account Manager

◮ DBI ◮ LDAP * ◮ OpenID *

racke Modern PerlCommerce

slide-14
SLIDE 14

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Agnostic

Templating Engine

◮ Template::Toolkit ◮ Template::Flute

racke Modern PerlCommerce

slide-15
SLIDE 15

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Agnostic

Web framework

◮ Catalyst ◮ Mojo ◮ Dancer

racke Modern PerlCommerce

slide-16
SLIDE 16

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Preferences

◮ Dancer ◮ Template::Flute ◮ DBI

racke Modern PerlCommerce

slide-17
SLIDE 17

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Framework

◮ Dispatching requests ◮ Parameter parsing ◮ Session handling ◮ Template engine ◮ I18N

racke Modern PerlCommerce

slide-18
SLIDE 18

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Extensions

◮ Bundles ◮ Plugins ◮ Hooks

racke Modern PerlCommerce

slide-19
SLIDE 19

Modern PerlCommerce Past and Future API Development & Deployment Past Future

Features

◮ Navigation ◮ Cart ◮ Checkout ◮ Accounts

racke Modern PerlCommerce

slide-20
SLIDE 20

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Cart

◮ SKU, Name, Quantity, Price ◮ Price > 0 ◮ Combines automatically ◮ Multiple carts ◮ Storage everywhere ◮ Price caching

racke Modern PerlCommerce

slide-21
SLIDE 21

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Nitesi::Cart Methods

use Dancer : : Plugin : : N i t e s i ; cart −>add ( sku => ’POM253 ’ , name => ’ Pomelo ’ , price => 3.00 , quantity => 10); cart −>remove ( sku => ’POM253 ’ ) ; cart −>count ( ) ; cart −>clear ( ) ; cart −>t o t a l ( ) ; cart −>subtotal ( ) ;

racke Modern PerlCommerce

slide-22
SLIDE 22

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Everything is a Cart

◮ Saved Carts ◮ Wishlists ◮ Collections

racke Modern PerlCommerce

slide-23
SLIDE 23

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Multiple Carts

cart ( ’ w i s h l i s t ’)−>add ( sku => ’ORA322 ’ , name => ’ Orange ’ , price => 2.00 , quantity => 5 ) ;

racke Modern PerlCommerce

slide-24
SLIDE 24

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Cart Backends

◮ Session ◮ DBI

racke Modern PerlCommerce

slide-25
SLIDE 25

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Inventory Check

MinQuantityField min_quantity MaxQuantityField inventory : quantity

racke Modern PerlCommerce

slide-26
SLIDE 26

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Inventory Check Hook

hook ’ before_cart_add ’ => sub { my ( $cart , $item ) = @_; my ( $inventory ) ; $inventory = query−>s e l e c t _ f i e l d ( table => ’ products ’ , f i e l d => ’ inventory ’ , where => { sku => $item−>{sku } } ) ; i f ( $item−>{quantity } > $inventory ) { $item−>{ error } = ’ Out of stock ’ ; } } ;

racke Modern PerlCommerce

slide-27
SLIDE 27

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Cart Hooks

◮ before_cart_add ◮ after_cart_add

racke Modern PerlCommerce

slide-28
SLIDE 28

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Cart Hooks

◮ before_cart_remove ◮ after_cart_remove

racke Modern PerlCommerce

slide-29
SLIDE 29

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Checkout

◮ Taxes ◮ Shipping ◮ Payment ◮ Invoice

racke Modern PerlCommerce

slide-30
SLIDE 30

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Payment

◮ Business::OnlinePayment

racke Modern PerlCommerce

slide-31
SLIDE 31

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Tax Modules on CPAN

◮ Business::Tax::Canada ◮ Business::CA::GST ◮ Business::Tax::VAT ◮ Business::Tax::VAT::Validation

racke Modern PerlCommerce

slide-32
SLIDE 32

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Shipping

◮ Simple Shipping ◮ Crazy Shipping ◮ Shipping API

racke Modern PerlCommerce

slide-33
SLIDE 33

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Costs

$cart−>apply_cost ( amount => 5 ) ; $cart−>apply_cost ( amount => 0.19 , r e l a t i v e => 1 ) ;

racke Modern PerlCommerce

slide-34
SLIDE 34

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

PDF Invoices

◮ HTML template ◮ Template::Flute::PDF

racke Modern PerlCommerce

slide-35
SLIDE 35

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Accounts

post ’ / login ’ => sub { i f ( account−>login ( username => params ( ’ body ’ )−>{username } , password => params ( ’ body ’ )−>{password } ) ) { r e d i r e c t ’ / customerservice ’ ; } else { r e d i r e c t ’ / login ’ ; } } ;

racke Modern PerlCommerce

slide-36
SLIDE 36

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Accounts

get ’ / checkout ’ => sub { i f ( account−>acl ( check => ’ submit_orders ’ ) ) { return template ’ checkout ’ ; } r e d i r e c t ’ / access_denied ’ ; } ;

racke Modern PerlCommerce

slide-37
SLIDE 37

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Account manager

◮ Account Providers ◮ Login/Logout ◮ Account Information ◮ Login status ◮ Forgot password ◮ Registration

racke Modern PerlCommerce

slide-38
SLIDE 38

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Account Provider

◮ DBI ◮ LDAP * ◮ Htpasswd * ◮ OpenID * ◮ OAuth *

racke Modern PerlCommerce

slide-39
SLIDE 39

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Access Control

◮ User ◮ Roles ◮ Permissions

racke Modern PerlCommerce

slide-40
SLIDE 40

Modern PerlCommerce Past and Future API Development & Deployment Cart Checkout Accounts and Access Control Forms

Forms

◮ Display ◮ Validation ◮ Storage

racke Modern PerlCommerce

slide-41
SLIDE 41

Modern PerlCommerce Past and Future API Development & Deployment Dancer Contribution The End

Routes

◮ Categories ◮ Products ◮ Cart ◮ Checkout ◮ Login/Logout ◮ Customer Service

racke Modern PerlCommerce

slide-42
SLIDE 42

Modern PerlCommerce Past and Future API Development & Deployment Dancer Contribution The End

Default Route

get qr { / ( . ∗ ) } => sub { my ( $sku ) = splat ; my $product ; # check f o r e x i s t i n g product i f ( $product = database−>quick_select ( ’ products ’ , { sku => $sku } ) ) # display flypage template ’ flypage ’ , $product ; } else { # display not found page status ’ not_found ’ ; forward ’ 404 ’ ; } } ;

racke Modern PerlCommerce

slide-43
SLIDE 43

Modern PerlCommerce Past and Future API Development & Deployment Dancer Contribution The End

CPAN/GitHub

◮ http://search.cpan.org/dist/Nitesi/ ◮ http://search.cpan.org/dist/Nitesi-DBI/ ◮ http://search.cpan.org/dist/

Dancer-Plugin-Nitesi/

◮ https://github.com/racke/Nitesi ◮ https://github.com/racke/Nitesi-DBI ◮ https:

//github.com/racke/Dancer-Plugin-Nitesi

racke Modern PerlCommerce

slide-44
SLIDE 44

Modern PerlCommerce Past and Future API Development & Deployment Dancer Contribution The End

The End

Slides: http://www.linuxia.de/talks/perlcommerce/

perlcommerce-beamer.pdf

Project: https://vsc.state.gov/

racke Modern PerlCommerce