LiqPayWidget.php 882 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace reactlogic\liqpay;
  3. use Yii;
  4. /**
  5. * This is just an example.
  6. */
  7. class LiqPayWidget extends \yii\base\Widget
  8. {
  9. /**
  10. * LiqPay payment params
  11. * See doc: https://www.liqpay.ua/documentation/api/aquiring/checkout/doc
  12. * @var array $data
  13. */
  14. public $data = array();
  15. /**
  16. * paymentForm | paymentLink
  17. * @var string $type
  18. */
  19. public $type = 'paymentForm';
  20. public $label;
  21. public $css_class;
  22. public function run()
  23. {
  24. /** @var \reactlogic\liqpay\Module $liqPay */
  25. $liqPay = Yii::$app->getModule('liqpay');
  26. $model = $liqPay->buildForm($this->data);
  27. $model->validate();
  28. return $this->render($this->type, [
  29. 'model' => $model,
  30. 'type' => $this->type,
  31. '_label' => $this->label,
  32. '_class' => $this->css_class,
  33. ]);
  34. }
  35. }