Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IframeConfigProvider.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Paypal\Model;
7 
10 use Magento\Payment\Helper\Data as PaymentHelper;
11 
13 {
17  protected $methodCodes = [
21  ];
22 
26  protected $methods = [];
27 
31  protected $paymentHelper;
32 
36  protected $urlBuilder;
37 
42  public function __construct(
43  PaymentHelper $paymentHelper,
45  ) {
46  $this->paymentHelper = $paymentHelper;
47  $this->urlBuilder = $urlBuilder;
48 
49  foreach ($this->methodCodes as $code) {
50  $this->methods[$code] = $this->paymentHelper->getMethodInstance($code);
51  }
52  }
53 
57  public function getConfig()
58  {
59  $config = [
60  'payment' => [
61  'paypalIframe' => [],
62  ],
63  ];
64  foreach ($this->methodCodes as $code) {
65  if ($this->methods[$code]->isAvailable()) {
66  $config['payment']['paypalIframe']['actionUrl'][$code] = $this->getFrameActionUrl($code);
67  }
68  }
69 
70  return $config;
71  }
72 
79  protected function getFrameActionUrl($code)
80  {
81  $url = '';
82  switch ($code) {
84  $url = $this->urlBuilder->getUrl('paypal/payflowadvanced/form', ['_secure' => true]);
85  break;
87  $url = $this->urlBuilder->getUrl('paypal/payflow/form', ['_secure' => true]);
88  break;
90  $url = $this->urlBuilder->getUrl('paypal/hostedpro/redirect', ['_secure' => true]);
91  break;
92  }
93 
94  return $url;
95  }
96 }
$config
Definition: fraud_order.php:17
$code
Definition: info.phtml:12
__construct(PaymentHelper $paymentHelper, UrlInterface $urlBuilder)