Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BillingAgreementConfigProvider.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Paypal\Model;
7 
9 use Magento\Paypal\Model\Billing\AgreementFactory;
12 
17 {
21  protected $currentCustomer;
22 
26  protected $agreementFactory;
27 
32  public function __construct(
34  AgreementFactory $agreementFactory
35  ) {
36  $this->currentCustomer = $currentCustomer;
37  $this->agreementFactory = $agreementFactory;
38  }
39 
43  public function getConfig()
44  {
45  $config = [
46  'payment' => [
47  'paypalBillingAgreement' => [
48  'agreements' => $this->getBillingAgreements(),
50  ]
51  ]
52  ];
53 
54  return $config;
55  }
56 
62  protected function getBillingAgreements()
63  {
64  $customerId = $this->currentCustomer->getCustomerId();
65  $data = [];
66  if (!$customerId) {
67  return $data;
68  }
69  $collection = $this->agreementFactory->create()->getAvailableCustomerBillingAgreements(
71  );
72  foreach ($collection as $item) {
73  $data[] = ['id' => $item->getId(), 'referenceId' => $item->getReferenceId()];
74  }
75  return $data;
76  }
77 }
$config
Definition: fraud_order.php:17
__construct(CurrentCustomer $currentCustomer, AgreementFactory $agreementFactory)