protected function setUp() { $this->paymentToken = $this->getMock(PaymentTokenInterface::class); $this->paymentTokenFactory = $this->getMockBuilder(PaymentTokenInterfaceFactory::class)->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->paymentTokenFactory->expects(self::once())->method('create')->willReturn($this->paymentToken); $this->paymentExtension = $this->getMockBuilder(OrderPaymentExtensionInterface::class)->setMethods(['setVaultPaymentToken', 'getVaultPaymentToken'])->disableOriginalConstructor()->getMock(); $this->paymentExtensionFactory = $this->getMockBuilder(OrderPaymentExtensionInterfaceFactory::class)->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->paymentExtensionFactory->expects(self::once())->method('create')->willReturn($this->paymentExtension); $this->payment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock(); $this->subjectReader = $this->getMockBuilder(SubjectReader::class)->disableOriginalConstructor()->getMock(); $mapperArray = ["american-express" => "AE", "discover" => "DI", "jcb" => "JCB", "mastercard" => "MC", "master-card" => "MC", "visa" => "VI", "maestro" => "MI", "diners-club" => "DN", "unionpay" => "CUP"]; $this->config = $this->getMockBuilder(Config::class)->setMethods(['getCctypesMapper'])->disableOriginalConstructor()->getMock(); $this->config->expects(self::once())->method('getCctypesMapper')->willReturn($mapperArray); $this->paymentHandler = new VaultDetailsHandler($this->paymentTokenFactory, $this->paymentExtensionFactory, $this->config, $this->subjectReader); }
/** * @param Payment $payment * @return \Magento\Sales\Api\Data\OrderPaymentExtensionInterface */ private function getPaymentExtensionAttributes(Payment $payment) { $extensionAttributes = $payment->getExtensionAttributes(); if ($extensionAttributes === null) { $extensionAttributes = $this->paymentExtensionFactory->create(); $payment->setExtensionAttributes($extensionAttributes); } return $extensionAttributes; }
/** * Get payment extension attributes * @param InfoInterface $payment * @return OrderPaymentExtensionInterface */ private function getExtensionAttributes(InfoInterface $payment) { $extensionAttributes = $payment->getExtensionAttributes(); if (null === $extensionAttributes) { $extensionAttributes = $this->paymentExtensionFactory->create(); $payment->setExtensionAttributes($extensionAttributes); } return $extensionAttributes; }