Spryker-eco/braintree 2.0.0 does not work


#1

Hi,

i would like to use for the paypal payment the Braintree method. I followed the documentation for the configuration. When i try to make a payment i got the following error:

TypeError - Argument 1 passed to Spryker\Zed\Payment\Dependency\Plugin\Checkout\CheckoutPluginCollection::add() must be an instance of Spryker\Zed\Payment\Dependency\Plugin\Checkout\CheckoutPluginInterface, instance of SprykerEco\Zed\Braintree\Communication\Plugin\Checkout\BraintreePreCheckPlugin given, called in /var/www/spryker/releases/current/src/Pyz/Zed/Payment/PaymentDependencyProvider.php on line 31 in "/var/www/spryker/releases/current/vendor/spryker/payment/src/Spryker/Zed/Payment/Dependency/Plugin/Checkout/CheckoutPluginCollection.php::26" {"exception":"[object] (TypeError(code: 0): Argument 1 passed to Spryker\\Zed\\Payment\\Dependency\\Plugin\\Checkout\\CheckoutPluginCollection::add() must be an instance of Spryker\\Zed\\Payment\\Dependency\\Plugin\\Checkout\\CheckoutPluginInterface, instance of SprykerEco\\Zed\\Braintree\\Communication\\Plugin\\Checkout\\BraintreePreCheckPlugin given, called in /var/www/spryker/releases/current/src/Pyz/Zed/Payment/PaymentDependencyProvider.php on line 31 at /var/www/spryker/releases/current/vendor/spryker/payment/src/Spryker/Zed/Payment/Dependency/Plugin/Checkout/CheckoutPluginCollection.php:26)

In SprykerEco\Zed\Braintree\Communication\Plugin\Checkout\ we add

$pluginCollection
     ->add(new BraintreePreCheckPlugin(), BraintreeConfig::PROVIDER_NAME, PaymentDependencyProvider::CHECKOUT_PRE_CHECK_PLUGINS)
......

$pluginCollection->add requires as first attribute a CheckoutPluginInterface :

public function add(CheckoutPluginInterface $plugin, $provider, $pluginType)

The Braintree Plugins does not match with the required Object Type, example:

class BraintreePreCheckPlugin extends BaseAbstractPlugin implements CheckoutPreConditionInterface

I am using “spryker/payment” : 4.3.2

Best Regards,
Jozsef


#2

Hi Jozsef,

It seems like a documentation issue that wasn’t updated properly yet.
The developer, who was working on the module, provided this answer to me:

To configure payment you need to do this in Pyz/Zed/Checkout/CheckoutDependencyProvider.php:

protected function getCheckoutPreConditions(Container $container)
{
    return [
        ...
        new BraintreePreCheckPlugin(),
    ];
}

protected function getCheckoutOrderSavers(Container $container)
{
    $plugins = [
        ...
        new BraintreeSaveOrderPlugin(),
    ];

    return $plugins;
}

protected function getCheckoutPostHooks(Container $container)
{
    return [
        ...
        new BraintreePostSavePlugin(),
    ];
}

Hope this will help you.

Best regards,
Valerii


#3

Hallo Valerii,

Thank you.
That was the Problem, i managed to rezolv it a little later after analysing the code :slight_smile:

Best Regards,
Jozsef


#4

…also, documentation mentions nothing about integration with frontend design — should it work out of the box?
IMHO, https://github.com/spryker-shop/suite/blob/master/frontend/settings.js#L24 does not provide any paths for webpack to spryker-eco modules, resulting in the following console output:

logger.ts:45 [yves_default@error] application error -> Error: pay-pal failed to mount

— Darius


#5

Hi Darius,

thank you for the feedback! Appropriate team has been notified about this.

Best regards,
Valerii