diff --git a/app/code/Magento/Braintree/Model/Ui/Adminhtml/PayPal/TokenUiComponentProvider.php b/app/code/Magento/Braintree/Model/Ui/Adminhtml/PayPal/TokenUiComponentProvider.php
new file mode 100644
index 0000000000000..fd94e18e2cd94
--- /dev/null
+++ b/app/code/Magento/Braintree/Model/Ui/Adminhtml/PayPal/TokenUiComponentProvider.php
@@ -0,0 +1,84 @@
+componentFactory = $componentFactory;
+ $this->urlBuilder = $urlBuilder;
+ $this->config = $config;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getComponentForToken(PaymentTokenInterface $paymentToken)
+ {
+ $data = json_decode($paymentToken->getTokenDetails() ?: '{}', true);
+ $data['icon'] = $this->config->getPayPalIcon();
+ $component = $this->componentFactory->create(
+ [
+ 'config' => [
+ 'code' => PayPalConfigProvider::PAYPAL_VAULT_CODE,
+ 'nonceUrl' => $this->getNonceRetrieveUrl(),
+ TokenUiComponentProviderInterface::COMPONENT_DETAILS => $data,
+ TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
+ 'template' => 'Magento_Braintree::form/paypal/vault.phtml'
+ ],
+ 'name' => Template::class
+ ]
+ );
+
+ return $component;
+ }
+
+ /**
+ * Get url to retrieve payment method nonce
+ * @return string
+ */
+ private function getNonceRetrieveUrl()
+ {
+ return $this->urlBuilder->getUrl(ConfigProvider::CODE . '/payment/getnonce', ['_secure' => true]);
+ }
+}
diff --git a/app/code/Magento/Braintree/Model/Ui/Adminhtml/TokenUiComponentProvider.php b/app/code/Magento/Braintree/Model/Ui/Adminhtml/TokenUiComponentProvider.php
index 6cfc96ea23d0d..420b8365b3ea4 100644
--- a/app/code/Magento/Braintree/Model/Ui/Adminhtml/TokenUiComponentProvider.php
+++ b/app/code/Magento/Braintree/Model/Ui/Adminhtml/TokenUiComponentProvider.php
@@ -49,6 +49,7 @@ public function getComponentForToken(PaymentTokenInterface $paymentToken)
$component = $this->componentFactory->create(
[
'config' => [
+ 'code' => ConfigProvider::CC_VAULT_CODE,
'nonceUrl' => $this->getNonceRetrieveUrl(),
TokenUiComponentProviderInterface::COMPONENT_DETAILS => $data,
TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash(),
diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php
new file mode 100644
index 0000000000000..bdc39cbc5b868
--- /dev/null
+++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php
@@ -0,0 +1,114 @@
+componentFactory = $this->getMockBuilder(TokenUiComponentInterfaceFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->urlBuilder = $this->getMock(UrlInterface::class);
+
+ $this->config = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getPayPalIcon'])
+ ->getMock();
+
+ $this->tokenUiComponentProvider = new TokenUiComponentProvider(
+ $this->componentFactory,
+ $this->urlBuilder,
+ $this->config
+ );
+ }
+
+ /**
+ * @covers \Magento\Braintree\Model\Ui\Adminhtml\PayPal\TokenUiComponentProvider::getComponentForToken
+ */
+ public function testGetComponentForToken()
+ {
+ $nonceUrl = 'https://payment/adminhtml/nonce/url';
+ $payerEmail = 'john.doe@test.com';
+ $icon = [
+ 'url' => 'https://payment/adminhtml/icon.png',
+ 'width' => 48,
+ 'height' => 32
+ ];
+
+ $expected = [
+ 'code' => 'vault',
+ 'nonceUrl' => $nonceUrl,
+ 'details' => [
+ 'payerEmail' => $payerEmail,
+ 'icon' => $icon
+ ],
+ 'template' => 'vault.phtml'
+ ];
+
+ $this->config->expects(static::once())
+ ->method('getPayPalIcon')
+ ->willReturn($icon);
+
+ $paymentToken = $this->getMock(PaymentTokenInterface::class);
+ $paymentToken->expects(static::once())
+ ->method('getTokenDetails')
+ ->willReturn('{"payerEmail":" ' . $payerEmail . '"}');
+ $paymentToken->expects(static::once())
+ ->method('getPublicHash')
+ ->willReturn('cmk32dl21l');
+
+ $this->urlBuilder->expects(static::once())
+ ->method('getUrl')
+ ->willReturn($nonceUrl);
+
+ $tokenComponent = $this->getMock(TokenUiComponentInterface::class);
+ $tokenComponent->expects(static::once())
+ ->method('getConfig')
+ ->willReturn($expected);
+
+ $this->componentFactory->expects(static::once())
+ ->method('create')
+ ->willReturn($tokenComponent);
+
+ $component = $this->tokenUiComponentProvider->getComponentForToken($paymentToken);
+ static::assertEquals($tokenComponent, $component);
+ static::assertEquals($expected, $component->getConfig());
+ }
+}
diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php
index d1665c71804cf..f159136cf4c46 100644
--- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php
+++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php
@@ -7,10 +7,10 @@
use Magento\Braintree\Model\Ui\Adminhtml\TokenUiComponentProvider;
use Magento\Framework\UrlInterface;
-use Magento\Framework\View\Element\Template;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Model\Ui\TokenUiComponentInterface;
use Magento\Vault\Model\Ui\TokenUiComponentInterfaceFactory;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Class TokenUiComponentProviderTest
@@ -19,12 +19,12 @@ class TokenUiComponentProviderTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var TokenUiComponentInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var TokenUiComponentInterfaceFactory|MockObject
*/
private $componentFactory;
/**
- * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var UrlInterface|MockObject
*/
private $urlBuilder;
@@ -59,6 +59,7 @@ public function testGetComponentForToken()
$expirationDate = '12/2015';
$expected = [
+ 'code' => 'vault',
'nonceUrl' => $nonceUrl,
'details' => [
'type' => $type,
diff --git a/app/code/Magento/Braintree/etc/adminhtml/di.xml b/app/code/Magento/Braintree/etc/adminhtml/di.xml
index f252b977f20bd..d154aabbb01b5 100644
--- a/app/code/Magento/Braintree/etc/adminhtml/di.xml
+++ b/app/code/Magento/Braintree/etc/adminhtml/di.xml
@@ -47,6 +47,7 @@
- Magento\Braintree\Model\Ui\Adminhtml\TokenUiComponentProvider
+ - Magento\Braintree\Model\Ui\Adminhtml\PayPal\TokenUiComponentProvider
diff --git a/app/code/Magento/Braintree/etc/config.xml b/app/code/Magento/Braintree/etc/config.xml
index 095a8419c8529..bf19324ae7a02 100644
--- a/app/code/Magento/Braintree/etc/config.xml
+++ b/app/code/Magento/Braintree/etc/config.xml
@@ -71,7 +71,8 @@
BraintreePayPalVaultFacade
- Vault Token (Braintree PayPal)
+ Stored Accounts (Braintree PayPal)
+ 1
diff --git a/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml
index 571c5ededeb99..5e4f36e1c1fb4 100644
--- a/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml
+++ b/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml
@@ -18,6 +18,10 @@
braintree_cc_vault
Magento_Vault::form/vault.phtml
+
+ braintree_paypal_vault
+ Magento_Vault::form/vault.phtml
+
braintree_cc_vault
Magento_Vault::form/vault.phtml
+
+ braintree_paypal_vault
+ Magento_Vault::form/vault.phtml
+