/** @inheritdoc */ public function getBusCodeForPaymentMethod(\Magento\Sales\Api\Data\OrderPaymentInterface $payment) { $result = null; $mage = $payment->getMethod(); if ($mage == self::M_PAY_BRAINTREE) { $result = self::B_PAY_BRAINTREE; } elseif ($mage == self::M_PAY_CHECK_MONEY) { $result = self::B_PAY_CHECK_MONEY; } elseif ($mage == self::M_PAY_INTERNAL_MONEY) { $result = self::B_PAY_INTERNAL_MONEY; } return $result; }
/** * Get vault payment token entity * * @param \Braintree\Transaction $transaction * @param OrderPaymentInterface $payment * @return PaymentTokenInterface|null */ protected function getVaultPaymentToken(Transaction $transaction, OrderPaymentInterface $payment) { // Check token existing in gateway response $token = $transaction->creditCardDetails->token; if (empty($token)) { return null; } $order = $payment->getOrder(); /** @var PaymentTokenInterface $paymentToken */ $paymentToken = $this->paymentTokenFactory->create(); $paymentToken->setGatewayToken($token); $paymentToken->setCustomerId($order->getCustomerId()); $paymentToken->setPaymentMethodCode($payment->getMethod()); $paymentToken->setCreatedAt($order->getCreatedAt()); $paymentToken->setTokenDetails($this->convertDetailsToJSON(['type' => $this->getCreditCardType($transaction->creditCardDetails->cardType), 'maskedCC' => $transaction->creditCardDetails->last4, 'expirationDate' => $transaction->creditCardDetails->expirationDate])); return $paymentToken; }