Skip to content

Commit

Permalink
Merge pull request #19 from genuineq/master
Browse files Browse the repository at this point in the history
Fixes: Gift wrapping cost change in One Page Checkout mode & Decimals update
  • Loading branch information
ionutcalara authored Mar 16, 2022
2 parents aafcfae + 3388194 commit 9988094
Show file tree
Hide file tree
Showing 29 changed files with 5,009 additions and 74 deletions.
44 changes: 44 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# to use orbs, must use version >= 2.1
version: 2.1
orbs:
# import Cypress orb by specifying an exact version x.y.z
# or the latest version 1.x.x using "@1" syntax
cypress: cypress-io/cypress@1
workflows:
build:
jobs:
# "cypress" is the name of the imported orb
# "run" is the name of the job defined in Cypress orb
- cypress/run:
name: Run_QUICK_tests
context:
- paylike
spec: cypress/integration/quick_test.js
filters:
branches:
only:
- cypress_tests
- cypress/run:
name: Run_FULL_tests
requires:
- Run_QUICK_tests
context:
- paylike
spec: cypress/integration/full_test.js
filters:
branches:
only:
- cypress_tests
# the following must run after all test passed
# to show latest supported version in repository readme.md file
- cypress/run:
name: Run_LOG_VERSION_remotely
requires:
- Run_FULL_tests
context:
- paylike
spec: cypress/integration/log_version.js
filters:
branches:
only:
- cypress_tests
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
.DS_Store
.DS_Store
node_modules
cypress.env.json
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ You can also find information about the plugin here: https://paylike.io/plugins/

## Supported Prestashop versions

* The plugin has been tested with most versions of Prestashop at every iteration. We recommend using the latest version of Prestashop, but if that is not possible for some reason, test the plugin with your Prestashop version and it would probably function properly.
* Prestashop version last tested on: *1.6.1.22*
[![Last succesfull test](https://log.derikon.ro/api/v1/log/read?tag=prestashop16&view=svg&label=PrestaShop&key=ecommerce&background=A31208)](https://log.derikon.ro/api/v1/log/read?tag=prestashop16&view=html)

* The plugin has been tested with most versions of Prestashop at every iteration. We recommend using the latest version of Prestashop, but if that is not possible for some reason, test the plugin with your Prestashop version and it would probably function properly.

## Installation

Expand All @@ -23,9 +24,9 @@ Once you have installed Prestashop, follow these simple steps:
1. Signup at [paylike.io](https://paylike.io) (it’s free)
1. Create a live account
1. Create an app key for your CS-Cart website
1. Zip the paylikepayment folder.
1. Zip the paylikepayment folder (or use the zip provided).
2. Log in as administrator and upload the zip you just created under modules/add a new module (plus icon in the top right corner).
3. You will be redirected to a list that contains the Paylike plugin. Click the green button that says install, and then in the confirmation popup, click proceed with the installation.
3. You will be redirected to a list that contains the Paylike plugin. Click the green button that says install, and then in the confirmation popup, click proceed with the installation.
4. You will be redirected to the settings screen where you need to add the Public and App key that you can find in your Paylike account.

## Updating settings
Expand All @@ -34,10 +35,42 @@ Under the extension settings, you can:
* Update the payment method text in the payment gateways list
* Update the payment method description in the payment gateways list
* Update the credit card logos that you want to show (you can change which one you accept under the paylike account).
* Update the title that shows up in the payment popup
* Update the title that shows up in the payment popup
* Update the popup description, choose whether you want to show the popup (the cart contents will show up instead)
* Add test/live keys
* Set payment mode (test/live)
* Change the capture type (Instant/Manual via Paylike Tool)



## Limitations

* In order to use the Paylike module you'll need to set "Number of decimals" option to match the paylike supported decimals. Since this is a global setting that affects all currencies you cannot use at the same time currencies with different decimals.
Change this option from: Admin -> Preferences -> General

* Paylike doesn't provide support for customizable decimals display. In order to display the correct values durring the payment process you'll need to set "Decimals" option to value "True" for the "Edit" panel of the currencies used in your store.
Change this option from: Admin -> Localization -> Currencies

## How to capture / manage transactions
* Managing orders payment is possible by accessing Admin panel -> Orders section.
1. Click on order and find "PROCESS PAYLIKE PAYMENT" section.
2. Select proper action from dropdown field.
3. Click on `Process Action`. Done!

1. Capture
* In Instant mode, the orders are captured automatically
* In Delayed mode you can do this in "PROCESS PAYLIKE PAYMENT" section by selecting `Capture` from dropdown field.
2. Refund
* To Refund an order you can do this in "PROCESS PAYLIKE PAYMENT" section by selecting `Refund` from dropdown field.
3. Void
* To Void an order you can do this in "PROCESS PAYLIKE PAYMENT" section by selecting `Void` from dropdown field. The order must be captured prior to void action.

## Available features

1. Capture
* Opencart admin panel: full capture
* Paylike admin panel: full/partial capture
2. Refund
* Opencart admin panel: full/partial refund
* Paylike admin panel: full/partial refund
3. Void
* Opencart admin panel: full void
* Paylike admin panel: full/partial void
51 changes: 51 additions & 0 deletions Testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#Testing with Cypress

As you can see the plugin is bundled with Cypress testing on this repository. You can use the tests, if you have some experience with testing.

***DO NOT USE IN PRODUCTION, THE TESTS MODIFY SETTINGS AND CREATE ORDERS***

## Requirements

* A framework/shop installation is required, in which you need to have the sample theme installed and products displayed on the homepage.
* You need to have Paylike module installed and configured (**test keys** required)
* You need to have some other currencies configured in store, then set them in `cypress.env.json` file (these will be used to make payments with every currency specified)
* You also need to have an account with previous purchases for which you set the credentials in the `cypress.env.json` file
* *For testing purpose, product stock management and sending order emails need to be disabled (if applicable).*

## Getting started

1. Run following commands into plugin folder (as in this repo)

```bash
npm install cypress --save-dev
```

2. Copy and rename `cypress.env.json.example` file in the root folder and fill the data as explained bellow:
```json
{
"ENV_HTTP_AUTH_ENABLED": false, // 'true' if you have HTTP auth when accessing website
"ENV_HTTP_USER": "", // if you have HTTP auth when accessing website
"ENV_HTTP_PASS": "",
"ENV_ADMIN_URL": "", // like http(s)://baseUrl/administrator
"ENV_CLIENT_USER": "", // frontend user
"ENV_CLIENT_PASS": "",
"ENV_ADMIN_USER": "", // admin user
"ENV_ADMIN_PASS": "",
"REMOTE_LOG_URL": "", // if you want to send log information about framework/shop & paylike module versions
"ENV_CURRENCY_TO_CHANGE_WITH": "USD",
"ENV_CURRENCIES_TO_TEST": ["USD", "EUR"], // currencies used to make payments with in Full test
"ENV_CARD_NUMBER": 4100000000000000,
"ENV_CARD_EXPIRY": 1226,
"ENV_CARD_CVV": 654
}
```
3. Start the Cypress testing server.
```bash
npx cypress open
```
4. In the interface, we can choose which test to run
## Getting Problems?
Since this is a frontend test, its not always consistent, due to delays or some glitches regarding overlapping elements. If you can't get over an issue please open an issue and we'll take a look.
16 changes: 16 additions & 0 deletions cypress.env.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ENV_HTTP_AUTH_ENABLED": false,
"ENV_HTTP_USER": "",
"ENV_HTTP_PASS": "",
"ENV_ADMIN_URL": "",
"ENV_CLIENT_USER": "",
"ENV_CLIENT_PASS": "",
"ENV_ADMIN_USER": "",
"ENV_ADMIN_PASS": "",
"REMOTE_LOG_URL": "",
"ENV_CURRENCY_TO_CHANGE_WITH": "USD",
"ENV_CURRENCIES_TO_TEST": ["USD", "EUR"],
"ENV_CARD_NUMBER": 4100000000000000,
"ENV_CARD_EXPIRY": 1226,
"ENV_CARD_CVV": 654
}
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
60 changes: 60 additions & 0 deletions cypress/integration/full_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/// <reference types="cypress" />

'use strict';

import { TestMethods } from '../support/test_methods.js';

describe('paylike plugin full test', () => {
/**
* Login into admin and frontend to store cookies.
*/
before(() => {
TestMethods.loginIntoClientAccount();
TestMethods.loginIntoAdminBackend();
});

/**
* Run this on every test case bellow
* - preserve cookies between tests
*/
beforeEach(() => {
Cypress.Cookies.defaults({
preserve: (cookie) => {
return true;
}
});
});

let captureModes = ['Instant', 'Delayed'];
let currenciesToTest = Cypress.env('ENV_CURRENCIES_TO_TEST');

context(`make payments in "${captureModes[0]}" mode`, () => {
/** Modify Paylike settings. */
it(`change Paylike capture mode to "${captureModes[0]}"`, () => {
TestMethods.changePaylikeCaptureMode(captureModes[0]);
});

/** Make Instant payments */
for (var currency of currenciesToTest) {
TestMethods.payWithSelectedCurrency(currency, 'refund');
}
});

context(`make payments in "${captureModes[1]}" mode`, () => {
/** Modify Paylike settings. */
it(`change Paylike capture mode to "${captureModes[1]}"`, () => {
TestMethods.changePaylikeCaptureMode(captureModes[1]);
});

for (var currency of currenciesToTest) {
/**
* HARDCODED currency
*/
if ('USD' == currency || 'RON' == currency) {
TestMethods.payWithSelectedCurrency(currency, 'capture');
/** In "delayed" mode we check "void" action too. */
TestMethods.payWithSelectedCurrency(currency, 'void');
}
}
});
}); // describe
19 changes: 19 additions & 0 deletions cypress/integration/log_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="cypress" />

'use strict';

import { TestMethods } from '../support/test_methods.js';

describe('paylike plugin version log remotely', () => {
/**
* Go to backend site admin
*/
before(() => {
TestMethods.loginIntoAdminBackend();
});

/** Send log after full test finished. */
it('log shop & paylike versions remotely', () => {
TestMethods.logVersions();
});
}); // describe
58 changes: 58 additions & 0 deletions cypress/integration/quick_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/// <reference types="cypress" />

'use strict';

import { TestMethods } from '../support/test_methods.js';

describe('paylike plugin quick test', () => {
/**
* Login into admin and frontend to store cookies.
*/
before(() => {
TestMethods.loginIntoClientAccount();
TestMethods.loginIntoAdminBackend();
});

/**
* Run this on every test case bellow
* - preserve cookies between tests
*/
beforeEach(() => {
Cypress.Cookies.defaults({
preserve: (cookie) => {
return true;
}
});
});

let currency = Cypress.env('ENV_CURRENCY_TO_CHANGE_WITH');
let captureMode = 'Delayed';

/**
* Modify Paylike capture mode
*/
it('modify Paylike settings for capture mode', () => {
TestMethods.changePaylikeCaptureMode(captureMode);
});

/** Pay and process order. */
/** Capture */
TestMethods.payWithSelectedCurrency(currency, 'capture');

/** Refund last created order (previously captured). */
it('Process last order captured from admin panel to be refunded', () => {
TestMethods.processOrderFromAdmin('refund', currency);
});

/** Capture */
TestMethods.payWithSelectedCurrency(currency, 'capture');

/** Partial refund last created order (previously captured). */
it('Process last order captured from admin panel to be refunded', () => {
TestMethods.processOrderFromAdmin('refund', currency, /*partialAmount*/ true);
});

/** Void */
TestMethods.payWithSelectedCurrency(currency, 'void');

}); // describe
22 changes: 22 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
Loading

0 comments on commit 9988094

Please sign in to comment.