Skip to content

Convert MageBraintree to use the serializer rather than Zend_Json #8393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,33 @@ class VaultDetailsHandler implements HandlerInterface
*/
protected $config;

/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;

/**
* Constructor
*
* @param PaymentTokenInterfaceFactory $paymentTokenFactory
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
* @param Config $config
* @param SubjectReader $subjectReader
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
PaymentTokenInterfaceFactory $paymentTokenFactory,
OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
Config $config,
SubjectReader $subjectReader
SubjectReader $subjectReader,
\Magento\Framework\Serialize\SerializerInterface $serializer = null
) {
$this->paymentTokenFactory = $paymentTokenFactory;
$this->paymentExtensionFactory = $paymentExtensionFactory;
$this->config = $config;
$this->subjectReader = $subjectReader;
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Serialize\SerializerInterface::class);
}

/**
Expand Down Expand Up @@ -133,7 +142,7 @@ private function getExpirationDate(Transaction $transaction)
*/
private function convertDetailsToJSON($details)
{
$json = \Zend_Json::encode($details);
$json = $this->serializer->serialize($details);
return $json ? $json : '{}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,20 @@ protected function setUp()
->method('getCctypesMapper')
->willReturn($mapperArray);

$this->serializer = $this->getMock(
\Magento\Framework\Serialize\SerializerInterface::class,
[],
[],
'',
false
);

$this->paymentHandler = new VaultDetailsHandler(
$this->paymentTokenFactory,
$this->paymentExtensionFactory,
$this->config,
$this->subjectReader
$this->subjectReader,
$this->serializer
);
}

Expand Down