Hss.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Paypal\Helper;
  7. /**
  8. * Hosted Sole Solution helper
  9. */
  10. class Hss extends \Magento\Framework\App\Helper\AbstractHelper
  11. {
  12. /**
  13. * Hosted Sole Solution methods
  14. *
  15. * @var string[]
  16. */
  17. protected $_hssMethods = [
  18. \Magento\Paypal\Model\Config::METHOD_HOSTEDPRO,
  19. \Magento\Paypal\Model\Config::METHOD_PAYFLOWLINK,
  20. \Magento\Paypal\Model\Config::METHOD_PAYFLOWADVANCED,
  21. ];
  22. /**
  23. * @var \Magento\Checkout\Model\Session
  24. */
  25. protected $_checkoutSession;
  26. /**
  27. * Constructor
  28. *
  29. * @param \Magento\Framework\App\Helper\Context $context
  30. * @param \Magento\Checkout\Model\Session $checkoutSession
  31. */
  32. public function __construct(
  33. \Magento\Framework\App\Helper\Context $context,
  34. \Magento\Checkout\Model\Session $checkoutSession
  35. ) {
  36. $this->_checkoutSession = $checkoutSession;
  37. parent::__construct($context);
  38. }
  39. /**
  40. * Get template for button in order review page if HSS method was selected
  41. *
  42. * @param string $name template name
  43. * @return string
  44. */
  45. public function getReviewButtonTemplate($name)
  46. {
  47. $quote = $this->_checkoutSession->getQuote();
  48. if ($quote) {
  49. $payment = $quote->getPayment();
  50. if ($payment && in_array($payment->getMethod(), $this->_hssMethods)) {
  51. return $name;
  52. }
  53. }
  54. return '';
  55. }
  56. /**
  57. * Get methods
  58. *
  59. * @return string[]
  60. */
  61. public function getHssMethods()
  62. {
  63. return $this->_hssMethods;
  64. }
  65. }