Top Banner
Hi @bummzack
44

SilverShop and Omnipay Slides

Feb 13, 2017

Download

Software

Roman Schmid
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SilverShop and Omnipay Slides

Hi@bummzack

Page 2: SilverShop and Omnipay Slides

SilverShop

Page 3: SilverShop and Omnipay Slides

What happened• Rebranded as “SilverShop” • 2.0 was released in July 2016 • Current version is 2.1 • Mark Guinn retired as a Maintainer

Page 4: SilverShop and Omnipay Slides

Core-features• Shopping-Cart • Categories, Products, Variations • Checkout, either Single- or Multi-Step • Guest-Checkout • User-Accounts and Address-Book • Supports a wide range of payment service providers via Omnipay

Page 5: SilverShop and Omnipay Slides

Features added via modules• Stock-Management • Discounts and Coupons • Various Shipping-Methods • Product-Search • Colored-Variations • AJAX functionality

Page 6: SilverShop and Omnipay Slides

Why use SilverShop?

Page 7: SilverShop and Omnipay Slides
Page 8: SilverShop and Omnipay Slides

Seriously though…

Page 9: SilverShop and Omnipay Slides

An example

Page 10: SilverShop and Omnipay Slides
Page 11: SilverShop and Omnipay Slides
Page 12: SilverShop and Omnipay Slides
Page 13: SilverShop and Omnipay Slides
Page 14: SilverShop and Omnipay Slides
Page 15: SilverShop and Omnipay Slides
Page 16: SilverShop and Omnipay Slides
Page 17: SilverShop and Omnipay Slides
Page 18: SilverShop and Omnipay Slides
Page 19: SilverShop and Omnipay Slides
Page 20: SilverShop and Omnipay Slides

SilverStripe & Omnipay

Page 21: SilverShop and Omnipay Slides

The Omnipay Library• Framework agnostic payment library • Provides a single API for many different payment service providers • authorize, capture, purchase, refund, void • 100% unit-tested

Page 22: SilverShop and Omnipay Slides

The Omnipay Architecture• Payment API via Gateways • Request/Response ≠ HTTP-Request/Response • Omnipay is stateless

Page 23: SilverShop and Omnipay Slides

A simple example 1/3composer require omnipay/paypal

Page 24: SilverShop and Omnipay Slides

A simple example 1/3composer require omnipay/paypal

# purchase.php require_once 'vendor/autoload.php'; use Omnipay\Omnipay; …

Page 25: SilverShop and Omnipay Slides

A simple example 1/3composer require omnipay/paypal

# purchase.php require_once 'vendor/autoload.php'; use Omnipay\Omnipay; $gateway = Omnipay::create('PayPal_Express'); …

Page 26: SilverShop and Omnipay Slides

A simple example 1/3composer require omnipay/paypal

# purchase.php require_once 'vendor/autoload.php'; use Omnipay\Omnipay; $gateway = Omnipay::create('PayPal_Express'); $gateway->initialize([ 'username' => 'username.example.com', 'password' => '0123456789', 'signature' => 'AbUnchOFRandOMChaActeRS.muCHSiGnaTURe11101', 'testmode' => true]); …

Page 27: SilverShop and Omnipay Slides

A simple example 2/3# … continued $purchaseRequest = $gateway->purchase([ 'amount' => '10.00', 'currency' => 'USD', 'returnUrl' => 'https://shop.example.com/completePurchase.php', 'cancelUrl' => 'https://shop.example.com/cancelPurchase.php']); …

Page 28: SilverShop and Omnipay Slides

A simple example 2/3# … continued $purchaseRequest = $gateway->purchase([ 'amount' => '10.00', 'currency' => 'USD', 'returnUrl' => 'https://shop.example.com/completePurchase.php', 'cancelUrl' => 'https://shop.example.com/cancelPurchase.php']);

$purchaseResponse = $purchaseRequest->send(); if ($purchaseResponse->isRedirect()) { $purchaseResponse->redirect(); } else { echo $purchaseResponse->getMessage(); }

Page 29: SilverShop and Omnipay Slides
Page 30: SilverShop and Omnipay Slides

A simple example 3/3# completePurchase.php $completePurchaseRequest = $gateway->completePurchase([ 'amount' => '10.00', 'currency' => 'USD', 'returnUrl' => 'https://shop.example.com/completePurchase.php', 'cancelUrl' => 'https://shop.example.com/cancelPurchase.php']);

$completePurchaseResponse = $completePurchaseRequest->send(); if ($completePurchaseResponse->isSuccessful()) { echo 'Payment complete!'; } else { echo $completePurchaseResponse->getMessage(); }

Page 31: SilverShop and Omnipay Slides

The silverstripe-omnipay module

Page 32: SilverShop and Omnipay Slides

Features• Provides a SilverStripe specific wrapper for omnipay • Adds a persistence-layer (Payment DataObject) • Provides URL endpoints for off-site payments • Can be configured using the config API.

Page 33: SilverShop and Omnipay Slides

The architecture• You create instances of Payment and use PaymentServices

that operate on these Payments. • Services are commonly created through a ServiceFactory • Payment Services map to the Omnipay API:

authorize, capture, purchase, refund, void

Page 34: SilverShop and Omnipay Slides

A simple example 1/3composer require silverstripe/silverstripe-omnipay composer require omnipay/paypal

Page 35: SilverShop and Omnipay Slides

A simple example 1/3composer require silverstripe/silverstripe-omnipay composer require omnipay/paypal

# mysite/_config/payment.yml ---Name: payment-config---GatewayInfo: PayPal_Express: parameters: username: 'username.example.com' password: '0123456789' signature: 'AbUnchOFRandOMChaActeRS.muCHSiGnaTURe11101' testMode: true

Page 36: SilverShop and Omnipay Slides

A simple example 2/3private static $allowed_actions = [ 'purchase', 'completed', 'cancelled'];

Page 37: SilverShop and Omnipay Slides

A simple example 2/3private static $allowed_actions = [ 'purchase', 'completed', 'cancelled']; public function purchase(){ $payment = Payment::create() ->init('PayPal_Express', 10, 'USD') ->setSuccessUrl($this->Link('completed')) ->setFailureUrl($this->Link('cancelled')); …

Page 38: SilverShop and Omnipay Slides

A simple example 2/3private static $allowed_actions = [ 'purchase', 'completed', 'cancelled']; public function purchase(){ $payment = Payment::create() ->init('PayPal_Express', 10, 'USD') ->setSuccessUrl($this->Link('completed')) ->setFailureUrl($this->Link('cancelled')); $service = ServiceFactory::create()->getService( $payment, ServiceFactory::INTENT_PURCHASE); …

Page 39: SilverShop and Omnipay Slides

A simple example 2/3private static $allowed_actions = [ 'purchase', 'completed', 'cancelled']; public function purchase(){ $payment = Payment::create() ->init('PayPal_Express', 10, 'USD') ->setSuccessUrl($this->Link('completed')) ->setFailureUrl($this->Link('cancelled')); $service = ServiceFactory::create()->getService( $payment, ServiceFactory::INTENT_PURCHASE); $serviceResponse = $service->initiate(); return $serviceResponse->redirectOrRespond(); }

Page 40: SilverShop and Omnipay Slides

A simple example 3/3

https://shop.example.com/paymentendpoint/<hash>/complete

https://shop.example.com/mypaymentpage/completed

Page 41: SilverShop and Omnipay Slides

silverstripe-omnipay-ui module

Page 42: SilverShop and Omnipay Slides
Page 43: SilverShop and Omnipay Slides

Thanks!

Page 44: SilverShop and Omnipay Slides

Questions?