コード例 #1
0
 /**
  * Generate vault payment public hash
  *
  * @param PaymentTokenInterface $paymentToken
  * @return string
  */
 protected function generatePublicHash(PaymentTokenInterface $paymentToken)
 {
     $hashKey = $paymentToken->getGatewayToken();
     if ($paymentToken->getCustomerId()) {
         $hashKey = $paymentToken->getCustomerId();
     }
     $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails();
     return $this->encryptor->getHash($hashKey);
 }
コード例 #2
0
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Response\VaultDetailsHandler::handle
  */
 public function testHandle()
 {
     $this->paymentExtension->expects(self::once())->method('setVaultPaymentToken')->with($this->paymentToken);
     $this->paymentExtension->expects(self::once())->method('getVaultPaymentToken')->willReturn($this->paymentToken);
     $paymentData = $this->getPaymentDataObjectMock();
     $transaction = $this->getBraintreeTransaction();
     $subject = ['payment' => $paymentData];
     $response = ['object' => $transaction];
     $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction);
     $this->paymentToken->expects(static::once())->method('setGatewayToken')->with('rh3gd4');
     $this->paymentToken->expects(static::once())->method('setExpiresAt')->with('2022-01-01 00:00:00');
     $this->paymentHandler->handle($subject, $response);
     $this->assertSame($this->paymentToken, $this->payment->getExtensionAttributes()->getVaultPaymentToken());
 }
コード例 #3
0
 /**
  * Get UI component for token
  * @param PaymentTokenInterface $paymentToken
  * @return TokenUiComponentInterface
  */
 public function getComponentForToken(PaymentTokenInterface $paymentToken)
 {
     $jsonDetails = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
     $component = $this->componentFactory->create(['config' => ['code' => ConfigProvider::CC_VAULT_CODE, 'nonceUrl' => $this->getNonceRetrieveUrl(), TokenUiComponentProviderInterface::COMPONENT_DETAILS => $jsonDetails, TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash()], 'name' => 'Magento_Braintree/js/view/payment/method-renderer/vault']);
     return $component;
 }
コード例 #4
0
 /**
  * @inheritdoc
  */
 public function getComponentForToken(PaymentTokenInterface $paymentToken)
 {
     $data = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
     $component = $this->componentFactory->create(['config' => [TokenUiComponentProviderInterface::COMPONENT_DETAILS => $data, TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(), 'template' => 'Magento_Paypal::payflowpro/vault.phtml'], 'name' => Template::class]);
     return $component;
 }
コード例 #5
0
 /**
  * Deletes a specified payment token.
  *
  * @param \Magento\Vault\Api\Data\PaymentTokenInterface $paymentToken The invoice.
  * @return bool
  */
 public function delete(Data\PaymentTokenInterface $paymentToken)
 {
     /** @var PaymentToken $tokenModel */
     $tokenModel = $this->getById($paymentToken->getEntityId());
     if (empty($tokenModel->getPublicHash())) {
         return false;
     }
     $tokenModel->setIsActive(false);
     $tokenModel->save();
     return true;
 }
コード例 #6
0
 /**
  * @param PaymentTokenInterface $token
  * @param OrderPaymentInterface $payment
  * @return bool
  */
 public function saveTokenWithPaymentLink(PaymentTokenInterface $token, OrderPaymentInterface $payment)
 {
     $tokenDuplicate = $this->getByPublicHash($token->getPublicHash(), $token->getCustomerId());
     if (!empty($tokenDuplicate)) {
         if ($token->getIsVisible() || $tokenDuplicate->getIsVisible()) {
             $token->setEntityId($tokenDuplicate->getEntityId());
             $token->setIsVisible(true);
         } elseif ($token->getIsVisible() === $tokenDuplicate->getIsVisible()) {
             $token->setEntityId($tokenDuplicate->getEntityId());
         } else {
             $token->setPublicHash($this->encryptor->getHash($token->getPublicHash() . $token->getGatewayToken()));
         }
     }
     $this->paymentTokenRepository->save($token);
     $result = $this->addLinkToOrderPayment($token->getEntityId(), $payment->getEntityId());
     return $result;
 }
コード例 #7
0
 /**
  * Can render specified token
  *
  * @param PaymentTokenInterface $token
  * @return boolean
  */
 public function canRender(PaymentTokenInterface $token)
 {
     return $token->getPaymentMethodCode() === Config::METHOD_PAYFLOWPRO;
 }
コード例 #8
0
 /**
  * Can render specified token
  *
  * @param PaymentTokenInterface $token
  * @return boolean
  */
 public function canRender(PaymentTokenInterface $token)
 {
     return $token->getPaymentMethodCode() === ConfigProvider::CODE;
 }
コード例 #9
0
 /**
  * @inheritdoc
  */
 public function getComponentForToken(PaymentTokenInterface $paymentToken)
 {
     $data = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
     $component = $this->componentFactory->create(['config' => ['nonceUrl' => $this->getNonceRetrieveUrl(), TokenUiComponentProviderInterface::COMPONENT_DETAILS => $data, TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(), 'template' => 'Magento_BraintreeTwo::form/vault.phtml'], 'name' => Template::class]);
     return $component;
 }
コード例 #10
0
 /**
  * @param PaymentTokenInterface $token
  * @param OrderPaymentInterface $payment
  * @return bool
  */
 public function saveTokenWithPaymentLink(PaymentTokenInterface $token, OrderPaymentInterface $payment)
 {
     $tokenDuplicate = $this->getByPublicHash($token->getPublicHash(), $token->getCustomerId());
     if (!empty($tokenDuplicate)) {
         $token->setEntityId($tokenDuplicate->getEntityId());
         $token->setIsVisible($token->getIsActive());
     }
     $this->paymentTokenRepository->save($token);
     $result = $this->addLinkToOrderPayment($token->getEntityId(), $payment->getEntityId());
     return $result;
 }
コード例 #11
0
 /**
  * Get UI component for token
  * @param PaymentTokenInterface $paymentToken
  * @return TokenUiComponentInterface
  */
 public function getComponentForToken(PaymentTokenInterface $paymentToken)
 {
     $jsonDetails = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
     $component = $this->componentFactory->create(['config' => [TokenUiComponentProviderInterface::COMPONENT_DETAILS => $jsonDetails, TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash()], 'name' => 'Magento_Paypal/js/view/payment/method-renderer/payflowpro/vault']);
     return $component;
 }