Skip to content

Commit

Permalink
Merge pull request #36 from checkout/dev
Browse files Browse the repository at this point in the history
Frames 3D Secure fix
  • Loading branch information
nicolas-maalouf-cko authored Dec 7, 2017
2 parents 2cfbe9a + d22a7c1 commit 71cd3df
Show file tree
Hide file tree
Showing 17 changed files with 8,242 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/ export-ignore
circle.yml export-ignore
4 changes: 4 additions & 0 deletions Controller/Payment/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public function finalizeProcess($paymentToken) {
// Debug info
$this->watchdog->bark($response);

if (isset($response['responseCode']) && (int) $response['responseCode'] >= 40000) {
throw new LocalizedException(__('There has been an error processing your transaction.'));
}

// If it's an alternative payment
if (isset($response['chargeMode']) && (int) $response['chargeMode'] == 3) {
if (isset($response['responseCode']) && (int) $response['responseCode'] == 10000 || (int) $response['responseCode'] == 10100) {
Expand Down
24 changes: 19 additions & 5 deletions Observer/AddExtraDataToTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,34 @@
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Checkout\Model\Session;
use Magento\Sales\Api\Data\OrderInterface;

class AddExtraDataToTransport implements ObserverInterface {

public function __construct(ScopeConfigInterface $scopeConfig)
protected $scopeConfig;
protected $checkoutSession;
protected $orderInterface;

public function __construct(ScopeConfigInterface $scopeConfig, Session $checkoutSession, OrderInterface $orderInterface)
{
$this->scopeConfig = $scopeConfig;
$this->checkoutSession = $checkoutSession;
$this->orderInterface = $orderInterface;
}

public function execute(Observer $observer)
{
// Get the email content
$transport = $observer->getEvent()->getTransport();
// Get the current payment method used
$paymentMethod = $this->checkoutSession->getQuote()->getPayment()->getMethod();

if ($paymentMethod == 'checkout_com' || $paymentMethod == 'checkout_com_cc_vault') {

// Get the email content
$transport = $observer->getEvent()->getTransport();

// Override the payment information block
$transport['payment_html'] = $this->scopeConfig->getValue('payment/checkout_com/title');
// Override the payment information block
$transport['payment_html'] = $this->scopeConfig->getValue('payment/checkout_com/title');
}
}
}
58 changes: 58 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
general:
artifacts:
- "/home/ubuntu/checkout-magento2-plugin/tests/reports/screenshots"
machine:
node:
version: 6
timezone:
Europe/London

dependencies:
override:
- echo "Ignore CircleCI defaults"
pre:
- mysql -u ubuntu -e "create database magento"
- sudo add-apt-repository ppa:ondrej/php -y
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb
- npm install -g npm
- cd ~/checkout-magento2-plugin/tests && npm install
post:
- sudo rm /etc/apache2/mods-enabled/php5.load && sudo rm /etc/apache2/mods-enabled/php5.conf
- sudo cp ~/checkout-magento2-plugin/tests/config/000-default.conf /etc/apache2/sites-available
- sudo service apache2 restart
- sudo apt-get purge php5-common
- sudo apt-get update
- sudo apt-get install php7.0 php7.0-gd php7.0-curl php7.0-intl php7.0-zip php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml -y
- sudo a2ensite 000-default.conf
- sudo service apache2 restart
- sudo rm -rf /usr/local/bin/composer
- sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
- sudo php /usr/local/bin/composer init --no-interaction && sudo php /usr/local/bin/composer config -a http-basic.repo.magento.com ${MG2_USERNAME} ${MG2_PASSWORD}
- sudo mkdir /var/www/html/magento2
- sudo php /usr/local/bin/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.1.7 /var/www/html/magento2
- sudo chmod -R 777 /var/www/html/magento2
- sudo php /var/www/html/magento2/bin/magento setup:install --admin-email "[email protected]" --admin-firstname "checkout" --admin-lastname "plugin" --admin-password "Checkout17" --admin-user "admin" --backend-frontname admin --base-url "http://127.0.0.1/magento2" --db-host 127.0.0.1 --db-name magento --db-user ubuntu --session-save files --use-rewrites 1 --use-secure 0 -vvv
- sudo php /var/www/html/magento2/bin/magento setup:upgrade
- sudo php /var/www/html/magento2/bin/magento setup:di:compile
- cd /var/www/html/magento2/app && sudo mkdir code && cd code && sudo mkdir CheckoutCom && cd CheckoutCom && sudo mkdir Magento2 && sudo cp -R ~/checkout-magento2-plugin/* Magento2/
- sudo chmod -R 777 /var/www/html/magento2
- sudo php /var/www/html/magento2/bin/magento setup:upgrade
- sudo php /var/www/html/magento2/bin/magento setup:static-content:deploy
- sudo php /var/www/html/magento2/bin/magento indexer:reindex
- cd /var/www/html/magento2 && sudo php /usr/local/bin/composer config -a http-basic.repo.magento.com ${MG2_USERNAME} ${MG2_PASSWORD}
- sudo php /var/www/html/magento2/bin/magento sampledata:deploy
- sudo php /var/www/html/magento2/bin/magento setup:upgrade
- sudo php /var/www/html/magento2/bin/magento setup:di:compile
- sudo php /var/www/html/magento2/bin/magento cache:clean
- sudo a2enmod rewrite
- mysql -u ubuntu -e "use magento; insert core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0);"
- sudo php /var/www/html/magento2/bin/magento cache:clean
- sudo chmod -R 777 /var/www/html/magento2
- sudo service apache2 restart

test:
override:
- npm test --prefix tests/


2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"magento/module-vault": "100.2.*"
},
"type": "magento2-module",
"version": "1.0.14",
"version": "1.0.15",
"autoload": {
"files": [
"registration.php"
Expand Down
14 changes: 14 additions & 0 deletions tests/config/000-default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html

<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
20 changes: 20 additions & 0 deletions tests/config/chimp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

module.exports = {
path: './features',
screenshotsPath: './reports/screenshots',
screenshotsOnError: true,
saveScreenshotsToDisk: true,
saveScreenshotsToReport: true,
timeout: 120000,
webdriverio: {
logLevel: 'silent',
screenshotPath: './reports/screenshots',
desiredCapabilities: {
chromeOptions: {
args: ['headless', 'disable-gpu'],
},
isHeadless: true,
},
debug: true,
},
};
12 changes: 12 additions & 0 deletions tests/features/_beforeall.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Setup Magento
Keys, Url's

Scenario: I should be able to disable magento's URL incription and set the plugin keys
Given I set the viewport and timeout
Given I disable the url secret key encryption
Given I update the stock for my test item
Given I go to the backend of Checkout's plugin
Given I set the sandbox keys
Given I save the backend settings
Given I create an account
Given I logout from the registered customer account
52 changes: 52 additions & 0 deletions tests/features/guest.customer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Feature: Guest Customer Test Suite
MAGENTO 2.1

Scenario: I should be able to complete a 3D transaction using Frames integration
Given I go to the backend of Checkout's plugin
Given I enable 3D Secure
Given I set the integration type to frames
Given I save the backend settings
Then I clear magento's cache
Then I complete the order flow as a unregistered customer until the payment stage
Then I choose Checkout as a payment option
Then I complete Checkout Frames with a mastercard card
Then I submit the order for the frames integration
Then I complete the THREE D details
Then I should see the success page

Scenario: I should be able to complete a non-3D transaction using Frames integration
Given I go to the backend of Checkout's plugin
Given I disable 3D Secure
Given I set the integration type to frames
Given I save the backend settings
Then I clear magento's cache
Then I complete the order flow as a unregistered customer until the payment stage
Then I choose Checkout as a payment option
Then I complete Checkout Frames with a mastercard card
Then I submit the order for the frames integration
Then I should see the success page

Scenario: I should be able to complete a 3D transaction using Hosted integration
Given I go to the backend of Checkout's plugin
Given I enable 3D Secure
Given I set the integration type to hosted
Given I save the backend settings
Then I clear magento's cache
Then I complete the order flow as a unregistered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I complete Checkout Hosted with a mastercard card
Then I complete the THREE D details
Then I should see the success page

Scenario: I should be able to complete a non-3D transaction using Hosted integration
Given I go to the backend of Checkout's plugin
Given I disable 3D Secure
Given I set the integration type to hosted
Given I save the backend settings
Then I clear magento's cache
Then I complete the order flow as a unregistered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I complete Checkout Hosted with a mastercard card
Then I should see the success page
111 changes: 111 additions & 0 deletions tests/features/registered.customer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Feature: Registered Customer Test Suite
MAGENTO 2.1

Scenario: I should be able to complete a 3D transaction using Frames integration
Given I go to the backend of Checkout's plugin
Given I enable 3D Secure
Given I set the integration type to frames
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I complete Checkout Frames with a mastercard card
Then I submit the order for the frames integration
Then I complete the THREE D details
Then I should see the success page
Given I logout from the registered customer account

Scenario: I should be able to complete a non-3D transaction using Frames integration
Given I go to the backend of Checkout's plugin
Given I disable 3D Secure
Given I set the integration type to frames
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I complete Checkout Frames with a mastercard card
Then I submit the order for the frames integration
Then I should see the success page
Given I logout from the registered customer account

Scenario: I should be able to complete a 3D transaction using Hosted integration
Given I go to the backend of Checkout's plugin
Given I set the integration type to hosted
Given I enable 3D Secure
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I complete Checkout Hosted with a mastercard card
Then I complete the THREE D details
Then I should see the success page
Given I logout from the registered customer account

Scenario: I should be able to complete a non-3D transaction using Hosted integration
Given I go to the backend of Checkout's plugin
Given I disable 3D Secure
Given I set the integration type to hosted
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I complete Checkout Hosted with a mastercard card
Then I should see the success page
Given I logout from the registered customer account

Scenario: I should be able to customise Hosted integration
Given I go to the backend of Checkout's plugin
Given I set the integration type to hosted
Given I set the theme color
Given I set the button label
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I should see a customised hosted page


Scenario: I should be able to set the Checkout plugin paymet option title as the first payment option
Given I go to the backend of Checkout's plugin
Given I set the payment option title
Given I set the payment option order
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I should see the plugin title

Scenario: In Checkout Hosted I should be able see alternaive payments for the mixed payment mode
Given I go to the backend of Checkout's plugin
Given I set the integration type to hosted
Given I disable 3D Secure
Given I set the payment mode to mixed
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I should see the card tab
Then I should see the alternative payments tab

Scenario: In Checkout Hosted I should be able see only alternaive payments for the coresponding payment mode
Given I go to the backend of Checkout's plugin
Given I set the integration type to hosted
Given I disable 3D Secure
Given I set the payment mode to cards
Given I save the backend settings
Then I clear magento's cache
Given I login the registered customer account
Then I complete the order flow as a registered customer until the payment stage
Then I choose Checkout as a payment option
Then I submit the order for the hosted integration
Then I should see the just the card options
Loading

0 comments on commit 71cd3df

Please sign in to comment.