Purchaseorder.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\OfflinePayments\Model;
  7. use Magento\Framework\Exception\LocalizedException;
  8. /**
  9. * Class Purchaseorder
  10. *
  11. * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes()
  12. *
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod
  17. {
  18. const PAYMENT_METHOD_PURCHASEORDER_CODE = 'purchaseorder';
  19. /**
  20. * Payment method code
  21. *
  22. * @var string
  23. */
  24. protected $_code = self::PAYMENT_METHOD_PURCHASEORDER_CODE;
  25. /**
  26. * @var string
  27. */
  28. protected $_formBlockType = \Magento\OfflinePayments\Block\Form\Purchaseorder::class;
  29. /**
  30. * @var string
  31. */
  32. protected $_infoBlockType = \Magento\OfflinePayments\Block\Info\Purchaseorder::class;
  33. /**
  34. * Availability option
  35. *
  36. * @var bool
  37. */
  38. protected $_isOffline = true;
  39. /**
  40. * Assign data to info model instance
  41. *
  42. * @param \Magento\Framework\DataObject|mixed $data
  43. * @return $this
  44. * @throws LocalizedException
  45. */
  46. public function assignData(\Magento\Framework\DataObject $data)
  47. {
  48. $this->getInfoInstance()->setPoNumber($data->getPoNumber());
  49. return $this;
  50. }
  51. /**
  52. * Validate payment method information object
  53. *
  54. * @return $this
  55. * @throws LocalizedException
  56. * @api
  57. * @since 100.2.3
  58. */
  59. public function validate()
  60. {
  61. parent::validate();
  62. if (empty($this->getInfoInstance()->getPoNumber())) {
  63. throw new LocalizedException(__('Purchase order number is a required field.'));
  64. }
  65. return $this;
  66. }
  67. }