-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from magento-mpi/MPI-PR-bugfixes
Fixed Issues: - MAGETWO-58670 Unable to go to PayPal side from first attempt after applying discount on checkout - MAGETWO-58997 Copy past detector fails in Vault module - MAGETWO-59033 [Github] Authorize.net doesn't allow to use JCB and Diners Club credit cards - MAGETWO-59187 Magento\Checkout\Test\TestCase\OnePageCheckoutTest fails on variation OnePageCheckoutUspsTestVariation2
- Loading branch information
Showing
14 changed files
with
343 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Vault\Api; | ||
|
||
use Magento\Vault\Model\VaultPaymentInterface; | ||
|
||
/** | ||
* Contains methods to retrieve vault payment methods | ||
* This interface is consistent with \Magento\Payment\Api\PaymentMethodListInterface | ||
* @api | ||
*/ | ||
interface PaymentMethodListInterface | ||
{ | ||
/** | ||
* Get list of available vault payments | ||
* @param int $storeId | ||
* @return VaultPaymentInterface[] | ||
*/ | ||
public function getList($storeId); | ||
|
||
/** | ||
* Get list of enabled in the configuration vault payments | ||
* @param int $storeId | ||
* @return VaultPaymentInterface[] | ||
*/ | ||
public function getActiveList($storeId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Vault\Model; | ||
|
||
use Magento\Payment\Api\Data\PaymentMethodInterface; | ||
use Magento\Payment\Api\PaymentMethodListInterface; | ||
use Magento\Payment\Model\Method\InstanceFactory; | ||
use Magento\Payment\Model\MethodInterface; | ||
use Magento\Vault\Api\PaymentMethodListInterface as VaultPaymentMethodListInterface; | ||
|
||
/** | ||
* Contains methods to retrieve configured vault payments | ||
*/ | ||
class PaymentMethodList implements VaultPaymentMethodListInterface | ||
{ | ||
/** | ||
* @var InstanceFactory | ||
*/ | ||
private $instanceFactory; | ||
|
||
/** | ||
* @var PaymentMethodListInterface | ||
*/ | ||
private $paymentMethodList; | ||
|
||
/** | ||
* PaymentMethodList constructor. | ||
* @param PaymentMethodListInterface $paymentMethodList | ||
* @param InstanceFactory $instanceFactory | ||
*/ | ||
public function __construct(PaymentMethodListInterface $paymentMethodList, InstanceFactory $instanceFactory) | ||
{ | ||
$this->instanceFactory = $instanceFactory; | ||
$this->paymentMethodList = $paymentMethodList; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getList($storeId) | ||
{ | ||
return $this->filterList($this->paymentMethodList->getList($storeId)); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getActiveList($storeId) | ||
{ | ||
return $this->filterList($this->paymentMethodList->getActiveList($storeId)); | ||
} | ||
|
||
/** | ||
* Filter vault methods from payments | ||
* @param PaymentMethodInterface[] $list | ||
* @return VaultPaymentInterface[] | ||
*/ | ||
private function filterList(array $list) | ||
{ | ||
$paymentMethods = array_map( | ||
function (PaymentMethodInterface $paymentMethod) { | ||
return $this->instanceFactory->create($paymentMethod); | ||
}, | ||
$list | ||
); | ||
|
||
$availableMethods = array_filter( | ||
$paymentMethods, | ||
function (MethodInterface $methodInstance) { | ||
return $methodInstance instanceof VaultPaymentInterface; | ||
} | ||
); | ||
return array_values($availableMethods); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.