Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #36 from pmclain/3d-secure
Browse files Browse the repository at this point in the history
3D Secure Support
  • Loading branch information
pmclain authored Apr 5, 2018
2 parents 9122028 + f0308c0 commit 3ca5ef2
Show file tree
Hide file tree
Showing 107 changed files with 6,620 additions and 4,061 deletions.
49 changes: 45 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,57 @@ addons:
hosts:
- magento2.travis
language: php
php:
- 7.1
matrix:
include:
- php: 7.1
env:
- MAGENTO_VERSION=2.3-develop
- TEST_SUITE=unit
- php: 7.1
env:
- MAGENTO_VERSION=2.2-develop
- TEST_SUITE=unit
- php: 7.1
env:
- MAGENTO_VERSION=2.2-develop
- TEST_SUITE=integration
- php: 7.1
env:
- MAGENTO_VERSION=2.2.2
- TEST_SUITE=unit
- php: 7.1
env:
- MAGENTO_VERSION=2.2.2
- TEST_SUITE=integration
- php: 7.0
env:
- MAGENTO_VERSION=2.3-develop
- TEST_SUITE=unit
- php: 7.0
env:
- MAGENTO_VERSION=2.2-develop
- TEST_SUITE=unit
- php: 7.0
env:
- MAGENTO_VERSION=2.2-develop
- TEST_SUITE=integration
- php: 7.0
env:
- MAGENTO_VERSION=2.2.2
- TEST_SUITE=unit
- php: 7.0
env:
- MAGENTO_VERSION=2.2.2
- TEST_SUITE=integration
env:
global:
- COMPOSER_BIN_DIR=~/bin
matrix:
- TEST_SUITE=unit
- STRIPE_MOCK_VERSION=0.5.0
- COMPOSER_PACKAGE_NAME=pmclain/module-stripe
cache:
apt: true
directories:
- $HOME/.composer/cache
- stripe-mock
before_script: ./.travis/before_script.sh
script: phpunit -c magento2/dev/tests/$TEST_SUITE
21 changes: 16 additions & 5 deletions .travis/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
set -e
trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR

# download stripe mock
if [ ! -d "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" ]; then
mkdir -p stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/
curl -L "https://github.com/stripe/stripe-mock/releases/download/v${STRIPE_MOCK_VERSION}/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -o "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz"
tar -zxf "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -C "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/"
fi

# start stripe mock
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock > /dev/null &
STRIPE_MOCK_PID=$!

# mock mail
sudo service postfix stop
echo # print a newline
Expand All @@ -17,20 +28,20 @@ phpenv rehash;
composer selfupdate

# clone main magento github repository
git clone --branch 2.2.2 --depth=1 https://github.com/magento/magento2
git clone --branch $MAGENTO_VERSION --depth=1 https://github.com/magento/magento2

# install Magento
cd magento2

# add composer package under test, composer require will trigger update/install
composer config minimum-stability dev
composer config repositories.travis_to_test git https://github.com/pmclain/module-stripe.git
composer require pmclain/module-stripe:dev-master#$TRAVIS_COMMIT
composer config repositories.travis_to_test git https://github.com/$TRAVIS_REPO_SLUG.git
composer require $COMPOSER_PACKAGE_NAME:dev-$TRAVIS_BRANCH#$TRAVIS_COMMIT

# prepare for test suite
case $TEST_SUITE in
integration)
cp vendor/pmclain/module-stripe/Test/Integration/phpunit.xml.dist dev/tests/integration/phpunit.xml
cp vendor/$COMPOSER_PACKAGE_NAME/Test/Integration/phpunit.xml.dist dev/tests/integration/phpunit.xml

cd dev/tests/integration

Expand Down Expand Up @@ -58,6 +69,6 @@ case $TEST_SUITE in
cd ../../..
;;
unit)
cp vendor/pmclain/module-stripe/Test/Unit/phpunit.xml.dist dev/tests/unit/phpunit.xml
cp vendor/$COMPOSER_PACKAGE_NAME/Test/Unit/phpunit.xml.dist dev/tests/unit/phpunit.xml
;;
esac
91 changes: 46 additions & 45 deletions Block/Customer/CardRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @copyright Copyright (c) 2017-2018
* @license Open Software License (OSL 3.0)
*/

namespace Pmclain\Stripe\Block\Customer;

use Pmclain\Stripe\Model\Ui\ConfigProvider;
Expand All @@ -21,54 +22,54 @@

class CardRenderer extends AbstractCardRenderer
{
/**
* Can render specified token
*
* @param PaymentTokenInterface $token
* @return boolean
*/
public function canRender(PaymentTokenInterface $token)
{
return $token->getPaymentMethodCode() === ConfigProvider::CODE;
}
/**
* Can render specified token
*
* @param PaymentTokenInterface $token
* @return boolean
*/
public function canRender(PaymentTokenInterface $token)
{
return $token->getPaymentMethodCode() === ConfigProvider::CODE;
}

/**
* @return string
*/
public function getNumberLast4Digits()
{
return $this->getTokenDetails()['maskedCC'];
}
/**
* @return string
*/
public function getNumberLast4Digits()
{
return $this->getTokenDetails()['maskedCC'];
}

/**
* @return string
*/
public function getExpDate()
{
return $this->getTokenDetails()['expirationDate'];
}
/**
* @return string
*/
public function getExpDate()
{
return $this->getTokenDetails()['expirationDate'];
}

/**
* @return string
*/
public function getIconUrl()
{
return $this->getIconForType($this->getTokenDetails()['type'])['url'];
}
/**
* @return string
*/
public function getIconUrl()
{
return $this->getIconForType($this->getTokenDetails()['type'])['url'];
}

/**
* @return int
*/
public function getIconHeight()
{
return $this->getIconForType($this->getTokenDetails()['type'])['height'];
}
/**
* @return int
*/
public function getIconHeight()
{
return $this->getIconForType($this->getTokenDetails()['type'])['height'];
}

/**
* @return int
*/
public function getIconWidth()
{
return $this->getIconForType($this->getTokenDetails()['type'])['width'];
}
/**
* @return int
*/
public function getIconWidth()
{
return $this->getIconForType($this->getTokenDetails()['type'])['width'];
}
}
87 changes: 50 additions & 37 deletions Block/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @copyright Copyright (c) 2017-2018
* @license Open Software License (OSL 3.0)
*/

namespace Pmclain\Stripe\Block;

use Pmclain\Stripe\Gateway\Config\Config as GatewayConfig;
Expand All @@ -21,48 +22,60 @@
use Magento\Payment\Model\Config;
use Magento\Payment\Helper\Data as Helper;
use Pmclain\Stripe\Model\Ui\ConfigProvider;
use Magento\Vault\Model\VaultPaymentInterface;

class Form extends Cc
{
/** @var GatewayConfig $gatewayConfig */
protected $gatewayConfig;
/** @var GatewayConfig $gatewayConfig */
protected $gatewayConfig;

/** @var Helper $paymentDataHelper */
private $paymentDataHelper;
/** @var Helper $paymentDataHelper */
private $paymentDataHelper;

public function __construct(
Context $context,
Config $paymentConfig,
GatewayConfig $gatewayConfig,
Helper $helper,
array $data = []
) {
parent::__construct($context, $paymentConfig, $data);
$this->gatewayConfig = $gatewayConfig;
$this->paymentDataHelper = $helper;
}
/**
* Form constructor.
* @param Context $context
* @param Config $paymentConfig
* @param GatewayConfig $gatewayConfig
* @param Helper $helper
* @param array $data
*/
public function __construct(
Context $context,
Config $paymentConfig,
GatewayConfig $gatewayConfig,
Helper $helper,
array $data = []
) {
parent::__construct($context, $paymentConfig, $data);
$this->gatewayConfig = $gatewayConfig;
$this->paymentDataHelper = $helper;
}

public function useCcv() {
return $this->gatewayConfig->isCcvEnabled();
}
/**
* @return bool
*/
public function useCcv()
{
return $this->gatewayConfig->isCcvEnabled();
}

/**
* Check if vault enabled
* @return bool
*/
public function isVaultEnabled()
{
$storeId = $this->_storeManager->getStore()->getId();
$vaultPayment = $this->getVaultPayment();
return $vaultPayment->isActive($storeId);
}
/**
* Check if vault enabled
* @return bool
*/
public function isVaultEnabled()
{
$storeId = $this->_storeManager->getStore()->getId();
$vaultPayment = $this->getVaultPayment();
return $vaultPayment->isActive($storeId);
}

/**
* Get configured vault payment for Braintree
* @return VaultPaymentInterface
*/
private function getVaultPayment()
{
return $this->paymentDataHelper->getMethodInstance(ConfigProvider::CC_VAULT_CODE);
}
}
/**
* @return VaultPaymentInterface
*/
private function getVaultPayment()
{
return $this->paymentDataHelper->getMethodInstance(ConfigProvider::CC_VAULT_CODE);
}
}
23 changes: 12 additions & 11 deletions Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
* @copyright Copyright (c) 2017-2018
* @license Open Software License (OSL 3.0)
*/

namespace Pmclain\Stripe\Block;

use Magento\Framework\Phrase;
use Magento\Payment\Block\ConfigurableInfo;

class Info extends ConfigurableInfo
{
/**
* Returns label
*
* @param string $field
* @return Phrase
*/
protected function getLabel($field)
{
return __($field);
}
}
/**
* Returns label
*
* @param string $field
* @return Phrase
*/
protected function getLabel($field)
{
return __($field);
}
}
Loading

0 comments on commit 3ca5ef2

Please sign in to comment.