orderPaymentRepository = $orderPaymentRepository; $this->objectCopyService = $objectCopyService; $this->dataObjectHelper = $dataObjectHelper; } /** * @param Payment $object * @param array $data * @return OrderPaymentInterface */ public function convert(Payment $object, $data = []) { $paymentData = $this->objectCopyService->getDataFromFieldset( 'quote_convert_payment', 'to_order_payment', $object ); $orderPayment = $this->orderPaymentRepository->create(); $this->dataObjectHelper->populateWithArray( $orderPayment, array_merge($paymentData, $data), \Magento\Sales\Api\Data\OrderPaymentInterface::class ); $orderPayment->setAdditionalInformation( array_merge( $object->getAdditionalInformation(), [Substitution::INFO_KEY_TITLE => $object->getMethodInstance()->getTitle()] ) ); // set directly on the model $orderPayment->setCcNumber($object->getCcNumber()); $orderPayment->setCcCid($object->getCcCid()); return $orderPayment; } }