Skip to content

Commit faa2919

Browse files
authored
Merge pull request #8 from genuineq/master
SDK upgraded to 10.js + write Cypress tests
2 parents 9b28e22 + a2c76c5 commit faa2919

34 files changed

+7820
-59
lines changed

.circleci/config.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# to use orbs, must use version >= 2.1
2+
version: 2.1
3+
orbs:
4+
# import Cypress orb by specifying an exact version x.y.z
5+
# or the latest version 1.x.x using "@1" syntax
6+
cypress: cypress-io/cypress@1
7+
workflows:
8+
oscommerce:
9+
jobs:
10+
# "cypress" is the name of the imported orb
11+
# "run" is the name of the job defined in Cypress orb
12+
- cypress/run:
13+
name: Run_QUICK_tests
14+
context:
15+
- paylike
16+
spec: cypress/integration/quick_test.js
17+
filters:
18+
branches:
19+
only:
20+
- master
21+
- cypress/run:
22+
name: Run_FULL_tests
23+
requires:
24+
- Run_QUICK_tests
25+
context:
26+
- paylike
27+
spec: cypress/integration/full_test.js
28+
filters:
29+
branches:
30+
only:
31+
- master
32+
# the following must run after all test passed
33+
# to show latest supported version in repository readme.md file
34+
- cypress/run:
35+
name: Run_LOG_VERSION_remotely
36+
requires:
37+
- Run_FULL_tests
38+
context:
39+
- paylike
40+
spec: cypress/integration/log_version.js
41+
filters:
42+
branches:
43+
only:
44+
- master
45+
#################################################################################
46+
# osCommerce Phoenix
47+
#################################################################################
48+
oscommerce_phoenix:
49+
jobs:
50+
# "cypress" is the name of the imported orb
51+
# "run" is the name of the job defined in Cypress orb
52+
- cypress/run:
53+
name: Run_phoenix_QUICK_tests
54+
context:
55+
- paylike
56+
spec: cypress/integration/phoenix_quick_test.js
57+
filters:
58+
branches:
59+
only:
60+
- master
61+
- cypress/run:
62+
name: Run_phoenix_FULL_tests
63+
requires:
64+
- Run_phoenix_QUICK_tests
65+
context:
66+
- paylike
67+
spec: cypress/integration/phoenix_full_test.js
68+
filters:
69+
branches:
70+
only:
71+
- master
72+
# the following must run after all test passed
73+
# to show latest supported version in repository readme.md file
74+
- cypress/run:
75+
name: Run_phoenix_LOG_VERSION_remotely
76+
requires:
77+
- Run_phoenix_FULL_tests
78+
context:
79+
- paylike
80+
spec: cypress/integration/phoenix_log_version.js
81+
filters:
82+
branches:
83+
only:
84+
- master

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea
2+
.DS_Store
3+
.env
4+
.env.production
5+
/vendor
6+
!/*/vendor
7+
logs
8+
git-hooks
9+
node_modules
10+
cypress.env.json

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ available by a user.
55

66
Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
77

8-
9-
## Supported osCommerce versions
10-
11-
*The plugin has been tested with osCommerce v.2.3.4.1
8+
## Supported osCommerce versions [![Last succesfull test](https://log.derikon.ro/api/v1/log/read?tag=oscommerce&view=svg&label=osCommerce&key=ecommerce&background=5C9CCC)](https://log.derikon.ro/api/v1/log/read?tag=oscommerce&view=html)
129

1310
## Installation
1411

@@ -17,18 +14,21 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
1714
2. Create a live account
1815
3. Create an app key for your osCommerce website
1916
4. Upload the files in the `upload` folder to root of your osCommerce store.
17+
18+
NOTE:
19+
20+
To skip steps 5 - 7, upload `oscautochange.php` file to your osCommerce store root.\
21+
Then access `YOUR_WEB_URL/oscautochange.php` in browser address bar.\
22+
Will show log/success messages based on script status and the file `oscautochange.php` will be deleted.\
23+
Then go to step 8.
24+
2025
5. In: `includes/template_top.php` add:
2126
```
22-
<?php
23-
if ( basename( $PHP_SELF ) == 'checkout_confirmation.php' ) {
24-
?>
25-
<script src="https://sdk.paylike.io/6.js"></script>
26-
<script src= "includes/javascript/paylike.js"></script>
27-
<?php
28-
}
29-
?>
30-
```
31-
Anywhere betwen the `head` tags.
27+
<?php if ( basename( $PHP_SELF ) == 'checkout_confirmation.php' ) : ?>
28+
<script src= "includes/javascript/paylike.js"></script>
29+
<?php endif ?>
30+
```
31+
Anywhere between the `head` tags.
3232
6. In: `includes/.htaccess` add:
3333
```
3434
<FilesMatch "paylike.php">
@@ -69,7 +69,7 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
6969
if(isset($errorHandler))$errorHandler->display();
7070
```
7171
After case 'edit': line.
72-
8. Install the Paylike module from modules -> payment in the admin
72+
8. Install the Paylike module from modules -> payment in the admin (click on `Install Module` botton in the right corner)
7373
9. Insert the app key and your public key in the settings and enable the plugin
7474
7575
## Updating settings

README_Phoenix.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ available by a user.
55

66
Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
77

8-
## Supported osCommerce versions
9-
10-
*The plugin has been tested with osCommerce CE Phoenix up to v1.0.7.10
8+
## Supported PhoenixCart versions [![Last succesfull test](https://log.derikon.ro/api/v1/log/read?tag=phoenixcart&view=svg&label=PhoenixCart&key=ecommerce&background=FC7F03)](https://log.derikon.ro/api/v1/log/read?tag=phoenixcart&view=html)
119

1210
## Installation
1311

@@ -16,18 +14,26 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
1614
2. Create a live account
1715
3. Create an app key for your osCommerce website
1816
4. Upload the files in the `upload` folder to root of your osCommerce store.
17+
18+
NOTE:
19+
20+
To skip steps 5 - 7, upload `phoenixautochange.php` file to your osCommerce store root.\
21+
Then access `YOUR_WEB_URL/phoenixautochange.php` in browser address bar.\
22+
Will show log/success messages based on script status and the file `phoenixautochange.php` will be deleted.\
23+
Then go to step 8.
24+
1925
5. In: `includes/application_top.php` add:
2026
```
2127
if ( basename( $PHP_SELF ) == 'checkout_confirmation.php' ) {
22-
echo '<script src="https://sdk.paylike.io/6.js"></script>';
28+
echo '<script src="https://sdk.paylike.io/10.js"></script>';
2329
echo '<script src= "includes/javascript/paylike.js"></script>';
2430
}
2531
```
2632
After the last line.
2733
6. In: `includes/.htaccess` add:
2834
```
2935
<FilesMatch "paylike.php">
30-
Allow from all
36+
Require all granted
3137
</FilesMatch>
3238
3339
```
@@ -64,8 +70,9 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
6470
```
6571
<?php if(isset($errorHandler))$errorHandler->display(); ?>
6672
```
67-
Before <div class="row no-gutters"> line.
68-
8. Install the Paylike module from modules -> payment in the admin
73+
Before ```<div class="row no-gutters">``` line.
74+
75+
8. Install the Paylike module from modules -> payment in the admin
6976
9. Insert the app key and your public key in the settings and enable the plugin
7077
7178
## Updating settings

Testing.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#Testing with Cypress
2+
3+
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.
4+
5+
***DO NOT USE IN PRODUCTION, THE TESTS MODIFY SETTINGS AND CREATE ORDERS***
6+
7+
## Requirements
8+
9+
* A framework/shop installation is required, in which you need to have the sample theme installed and products displayed on the homepage.
10+
* You need to have Paylike module installed and configured (**test keys** required)
11+
* 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)
12+
* You also need to have an account with previous purchases for which you set the credentials in the `cypress.env.json` file
13+
* *For testing purpose, product stock management and sending order emails need to be disabled (if applicable).*
14+
15+
## Getting started
16+
17+
1. Run following commands into plugin folder (as in this repo)
18+
19+
```bash
20+
npm install cypress --save-dev
21+
```
22+
23+
2. Copy and rename `cypress.env.json.example` file in the root folder and fill the data as explained bellow:
24+
```json
25+
{
26+
"ENV_HTTP_AUTH_ENABLED": false, // 'true' if you have HTTP auth when accessing website
27+
"ENV_HTTP_USER": "", // if you have HTTP auth when accessing website
28+
"ENV_HTTP_PASS": "",
29+
"ENV_ADMIN_URL": "", // like http(s)://baseUrl/administrator
30+
"ENV_PHOENIX_ADMIN_URL": "",
31+
"ENV_CLIENT_USER": "", // frontend user
32+
"ENV_CLIENT_PASS": "",
33+
"ENV_ADMIN_USER": "", // admin user
34+
"ENV_ADMIN_PASS": "",
35+
"REMOTE_LOG_URL": "", // if you want to send log information about framework/shop & paylike module versions
36+
"ENV_CURRENCY_TO_CHANGE_WITH": "USD",
37+
"ENV_CURRENCIES_TO_TEST": ["USD", "EUR"], // currencies used to make payments with in Full test
38+
"ENV_CARD_NUMBER": 4100000000000000,
39+
"ENV_CARD_EXPIRY": 1226,
40+
"ENV_CARD_CVV": 654
41+
}
42+
```
43+
44+
3. Start the Cypress testing server.
45+
```bash
46+
npx cypress open
47+
```
48+
4. In the interface, we can choose which test to run
49+
50+
## Getting Problems?
51+
52+
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.

cypress.env.json.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"ENV_HTTP_AUTH_ENABLED": false,
3+
"ENV_HTTP_USER": "",
4+
"ENV_HTTP_PASS": "",
5+
"ENV_ADMIN_URL": "",
6+
"ENV_CLIENT_USER": "",
7+
"ENV_CLIENT_PASS": "",
8+
"ENV_ADMIN_USER": "",
9+
"ENV_ADMIN_PASS": "",
10+
"REMOTE_LOG_URL": "",
11+
"ENV_CURRENCY_TO_CHANGE_WITH": "USD",
12+
"ENV_CURRENCIES_TO_TEST": ["USD", "EUR"],
13+
"ENV_CARD_NUMBER": 4100000000000000,
14+
"ENV_CARD_EXPIRY": 1226,
15+
"ENV_CARD_CVV": 654
16+
}

cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/integration/full_test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/// <reference types="cypress" />
2+
3+
'use strict';
4+
5+
import { TestMethods } from '../support/test_methods.js';
6+
7+
describe('paylike plugin full test', () => {
8+
/**
9+
* Login into admin and frontend to store cookies.
10+
*/
11+
before(() => {
12+
cy.goToPage(TestMethods.StoreUrl);
13+
TestMethods.loginIntoClientAccount();
14+
cy.goToPage(Cypress.env('ENV_ADMIN_URL'));
15+
TestMethods.loginIntoAdminBackend();
16+
});
17+
18+
/**
19+
* Run this on every test case bellow
20+
* - preserve cookies between tests
21+
*/
22+
beforeEach(() => {
23+
Cypress.Cookies.defaults({
24+
preserve: (cookie) => {
25+
return true;
26+
}
27+
});
28+
});
29+
30+
let captureModes = ['Instant', 'Delayed'];
31+
let currenciesToTest = Cypress.env('ENV_CURRENCIES_TO_TEST');
32+
33+
context(`make payments in "${captureModes[0]}" mode`, () => {
34+
/** Modify Paylike settings. */
35+
it(`change Paylike capture mode to "${captureModes[0]}"`, () => {
36+
TestMethods.changePaylikeCaptureMode(captureModes[0]);
37+
});
38+
39+
/** Make Instant payments */
40+
for (var currency of currenciesToTest) {
41+
TestMethods.payWithSelectedCurrency(currency);
42+
}
43+
});
44+
45+
context(`make payments in "${captureModes[1]}" mode`, () => {
46+
/** Modify Paylike settings. */
47+
it(`change Paylike capture mode to "${captureModes[1]}"`, () => {
48+
TestMethods.changePaylikeCaptureMode(captureModes[1]);
49+
});
50+
51+
for (var currency of currenciesToTest) {
52+
/**
53+
* HARDCODED currency
54+
*/
55+
if ('USD' == currency || 'RON' == currency) {
56+
TestMethods.payWithSelectedCurrency(currency);
57+
}
58+
}
59+
});
60+
}); // describe

cypress/integration/log_version.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="cypress" />
2+
3+
'use strict';
4+
5+
import { TestMethods } from '../support/test_methods.js';
6+
7+
describe('paylike plugin version log remotely', () => {
8+
/**
9+
* Go to backend site admin
10+
*/
11+
before(() => {
12+
cy.goToPage(Cypress.env('ENV_ADMIN_URL'));
13+
TestMethods.loginIntoAdminBackend();
14+
});
15+
16+
/** Send log after full test finished. */
17+
it('log shop & paylike versions remotely', () => {
18+
TestMethods.logVersions();
19+
});
20+
}); // describe

0 commit comments

Comments
 (0)