8 use Braintree\Transaction;
15 use Magento\Sales\Api\Data\OrderPaymentExtensionInterface;
16 use Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory;
66 Json $serializer =
null 80 $paymentDO = $this->subjectReader->readPayment($handlingSubject);
112 'type' => $this->getCreditCardType(
$transaction->creditCardDetails->cardType),
114 'expirationDate' =>
$transaction->creditCardDetails->expirationDate
124 private function getExpirationDate(Transaction
$transaction)
126 $expDate = new \DateTime(
134 new \DateTimeZone(
'UTC')
136 $expDate->add(
new \DateInterval(
'P1M'));
137 return $expDate->format(
'Y-m-d 00:00:00');
145 private function convertDetailsToJSON(
$details)
147 $json = $this->serializer->serialize(
$details);
148 return $json ? $json :
'{}';
157 private function getCreditCardType(
$type)
159 $replaced = str_replace(
' ',
'-', strtolower(
$type));
160 $mapper = $this->config->getCcTypesMapper();
162 return $mapper[$replaced];
170 private function getExtensionAttributes(InfoInterface
$payment)
__construct(PaymentTokenFactoryInterface $paymentTokenFactory, OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory, Config $config, SubjectReader $subjectReader, Json $serializer=null)
handle(array $handlingSubject, array $response)
const TOKEN_TYPE_CREDIT_CARD