This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
GraphQl-644: [Checkout] Support of "Braintree" payment method #392
Merged
magento-engcom-team
merged 27 commits into
magento:2.3-develop
from
pmclain:feature/braintree-payment
Aug 5, 2019
Merged
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
93b08f6
Prototype BraintreeGraphQl Payments
pmclain 7f226f6
Merge remote-tracking branch 'origin/2.3-develop' into feature/braint…
naydav c7fd250
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain a59a919
Braintree CC and Vault Support and Tests
pmclain 411a559
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain a784526
Add braintree mock for testing
pmclain 5f25fdd
fix static test failures
pmclain 4527ea2
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain d57d076
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain 05632a8
Move Method Specific input into PaymentMethodInput
pmclain 3720ec0
Revert error reporting change committed by mistake
pmclain a6e32e8
Mutation for creating braintree client token
pmclain c4609cc
Generate nonce from public hash server-side
pmclain c1eee4f
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain 4939d9c
Validate additional input is present for associated payment method
pmclain ba459a1
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain fe23996
Add validation for additonal data input
pmclain 2448894
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain c552e35
Add parent-compatible typehint to constructor docblock
pmclain e49df5b
Merge remote-tracking branch 'upstream/2.3-develop' into feature/brai…
pmclain 169ac1b
Get storeId from resolver context
pmclain f69b080
Add composer deps to module sequence
pmclain ec719be
Update php reqs in BraintreeGraphQl composer.json
pmclain d757fb5
Update tests to use @magentoConfigFixture
pmclain 1132a47
Replace static with self
pmclain 6fc0322
Merge remote-tracking branch 'origin/2.3-develop' into feature/braint…
naydav 00002f4
magento/graphql-ce#644: [Checkout] Support of "Braintree" payment method
naydav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\BraintreeGraphQl\Model; | ||
|
||
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderInterface; | ||
use Magento\Framework\Stdlib\ArrayManager; | ||
|
||
class BraintreeDataProvider implements AdditionalDataProviderInterface | ||
{ | ||
private const PATH_ADDITIONAL_DATA = 'input/payment_method/additional_data/braintree'; | ||
|
||
/** | ||
* @var ArrayManager | ||
*/ | ||
private $arrayManager; | ||
|
||
public function __construct( | ||
ArrayManager $arrayManager | ||
) { | ||
$this->arrayManager = $arrayManager; | ||
} | ||
|
||
public function getData(array $args): array | ||
{ | ||
return $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $args) ?? []; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/code/Magento/BraintreeGraphQl/Model/BraintreeVaultDataProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\BraintreeGraphQl\Model; | ||
|
||
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderInterface; | ||
use Magento\Framework\Stdlib\ArrayManager; | ||
|
||
class BraintreeVaultDataProvider implements AdditionalDataProviderInterface | ||
{ | ||
private const PATH_ADDITIONAL_DATA = 'input/payment_method/additional_data/braintree_vault'; | ||
|
||
/** | ||
* @var ArrayManager | ||
*/ | ||
private $arrayManager; | ||
|
||
public function __construct( | ||
ArrayManager $arrayManager | ||
) { | ||
$this->arrayManager = $arrayManager; | ||
} | ||
|
||
public function getData(array $args): array | ||
{ | ||
return $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $args) ?? []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# BraintreeGraphQl | ||
|
||
**BraintreeGraphQl** provides type and resolver for method additional | ||
information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "magento/module-braintree-graph-ql", | ||
"description": "N/A", | ||
"type": "magento2-module", | ||
"require": { | ||
"php": "~7.1.3||~7.2.0", | ||
"magento/framework": "*" | ||
}, | ||
"suggest": { | ||
"magento/module-graph-ql": "*" | ||
}, | ||
"license": [ | ||
"OSL-3.0", | ||
"AFL-3.0" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Magento\\BraintreeGraphQl\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderPool"> | ||
<arguments> | ||
<argument name="dataProviders" xsi:type="array"> | ||
<item name="braintree" xsi:type="object">Magento\BraintreeGraphQl\Model\BraintreeDataProvider</item> | ||
<item name="braintree_vault" xsi:type="object">Magento\BraintreeGraphQl\Model\BraintreeVaultDataProvider</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Magento_BraintreeGraphQl"/> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright © Magento, Inc. All rights reserved. | ||
# See COPYING.txt for license details. | ||
|
||
input PaymentMethodAdditionalDataInput { | ||
braintree: BraintreeInput | ||
braintree_vault: BraintreeVaultInput | ||
} | ||
|
||
input BraintreeInput { | ||
lenaorobei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
payment_method_nonce: String! | ||
is_active_payment_token_enabler: Boolean! | ||
} | ||
|
||
input BraintreeVaultInput { | ||
payment_method_nonce: String! | ||
public_hash: String! | ||
is_active_payment_token_enabler: Boolean! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_BraintreeGraphQl', __DIR__); |
16 changes: 16 additions & 0 deletions
16
app/code/Magento/QuoteGraphQl/Model/Cart/Payment/AdditionalDataProviderInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\QuoteGraphQl\Model\Cart\Payment; | ||
|
||
/** | ||
* Interface for payment method additional data provider | ||
*/ | ||
interface AdditionalDataProviderInterface | ||
{ | ||
public function getData(array $args): array; | ||
} |
31 changes: 31 additions & 0 deletions
31
app/code/Magento/QuoteGraphQl/Model/Cart/Payment/AdditionalDataProviderPool.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\QuoteGraphQl\Model\Cart\Payment; | ||
|
||
class AdditionalDataProviderPool | ||
{ | ||
/** | ||
* @var AdditionalDataProviderInterface[] | ||
*/ | ||
private $dataProviders; | ||
|
||
public function __construct(array $dataProviders = []) | ||
{ | ||
$this->dataProviders = $dataProviders; | ||
} | ||
|
||
public function getData(string $methodCode, array $args): array | ||
{ | ||
$additionalData = []; | ||
if (isset($this->dataProviders[$methodCode])) { | ||
$additionalData = $this->dataProviders[$methodCode]->getData($args); | ||
} | ||
|
||
return $additionalData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add composer dependencies here in order to avoid installation sequence issues.