/**
  * Get vault payment token entity
  *
  * @param \Braintree\Transaction $transaction
  * @return PaymentTokenInterface|null
  */
 protected function getVaultPaymentToken(Transaction $transaction)
 {
     // Check token existing in gateway response
     $token = $transaction->creditCardDetails->token;
     if (empty($token)) {
         return null;
     }
     /** @var PaymentTokenInterface $paymentToken */
     $paymentToken = $this->paymentTokenFactory->create();
     $paymentToken->setGatewayToken($token);
     $paymentToken->setExpiresAt($this->getExpirationDate($transaction));
     $paymentToken->setTokenDetails($this->convertDetailsToJSON(['type' => $this->getCreditCardType($transaction->creditCardDetails->cardType), 'maskedCC' => $transaction->creditCardDetails->last4, 'expirationDate' => $transaction->creditCardDetails->expirationDate]));
     return $paymentToken;
 }
Exemple #2
0
 /**
  * @param Payment $payment
  * @param string $token
  * @throws LocalizedException
  * @return void
  */
 protected function createPaymentToken(Payment $payment, $token)
 {
     /** @var PaymentTokenInterface $paymentToken */
     $paymentToken = $this->paymentTokenFactory->create();
     $paymentToken->setGatewayToken($token);
     $paymentToken->setTokenDetails(json_encode($payment->getAdditionalInformation(Transparent::CC_DETAILS)));
     $this->getPaymentExtensionAttributes($payment)->setVaultPaymentToken($paymentToken);
 }