Successfully reported this slideshow.

SilverShop and Omnipay Slides

0

Share

Upcoming SlideShare
Payments On Rails
Payments On Rails
Loading in …3
×
1 of 44
1 of 44

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

SilverShop and Omnipay Slides

  1. 1. Hi @bummzack
  2. 2. SilverShop
  3. 3. What happened • Rebranded as “SilverShop” • 2.0 was released in July 2016 • Current version is 2.1 • Mark Guinn retired as a Maintainer
  4. 4. 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
  5. 5. Features added via modules • Stock-Management • Discounts and Coupons • Various Shipping-Methods • Product-Search • Colored-Variations • AJAX functionality
  6. 6. Why use SilverShop?
  7. 7. Seriously though…
  8. 8. An example
  9. 9. SilverStripe & Omnipay
  10. 10. 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
  11. 11. The Omnipay Architecture • Payment API via Gateways • Request/Response ≠ HTTP-Request/Response • Omnipay is stateless
  12. 12. A simple example 1/3 composer require omnipay/paypal
  13. 13. A simple example 1/3 composer require omnipay/paypal # purchase.php require_once 'vendor/autoload.php';
 use OmnipayOmnipay; …
  14. 14. A simple example 1/3 composer require omnipay/paypal # purchase.php require_once 'vendor/autoload.php';
 use OmnipayOmnipay;
 
 $gateway = Omnipay::create('PayPal_Express'); …
  15. 15. A simple example 1/3 composer require omnipay/paypal # purchase.php require_once 'vendor/autoload.php';
 use OmnipayOmnipay;
 
 $gateway = Omnipay::create('PayPal_Express');
 $gateway->initialize([
 'username' => 'username.example.com',
 'password' => '0123456789',
 'signature' => 'AbUnchOFRandOMChaActeRS.muCHSiGnaTURe11101',
 'testmode' => true
 ]); …
  16. 16. 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'
 ]); …
  17. 17. 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();
 }
  18. 18. 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();
 }
  19. 19. The silverstripe-omnipay module
  20. 20. 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.
  21. 21. 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
  22. 22. A simple example 1/3 composer require silverstripe/silverstripe-omnipay composer require omnipay/paypal
  23. 23. A simple example 1/3 composer 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
  24. 24. A simple example 2/3 private static $allowed_actions = [
 'purchase', 'completed', 'cancelled'];
  25. 25. A simple example 2/3 private 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'));
 …
  26. 26. A simple example 2/3 private 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);
 …
  27. 27. A simple example 2/3 private 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();
 }
  28. 28. A simple example 3/3 https://shop.example.com/paymentendpoint/<hash>/complete https://shop.example.com/mypaymentpage/completed
  29. 29. silverstripe-omnipay-ui module
  30. 30. Thanks!
  31. 31. Questions?

×