This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lunar/hosted-checkout
Hosted checkout
- Loading branch information
Showing
31 changed files
with
5,718 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
- payment_plugin_tests | ||
spec: cypress/integration/quick_test.js | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
- cypress/run: | ||
name: Run_FULL_tests | ||
requires: | ||
- Run_QUICK_tests | ||
context: | ||
- payment_plugin_tests | ||
spec: cypress/integration/full_test.js | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
# 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: | ||
- payment_plugin_tests | ||
spec: cypress/integration/log_version.js | ||
filters: | ||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,50 @@ | ||
# payments-plugin-drupal-commerce-8.x | ||
# Lunar Online Payments for Drupal 8.x | ||
|
||
Lunar Online Payments plugin for the e-commerce platform Drupal Commerce | ||
## Supported Drupal Commerce versions | ||
*The plugin has been tested with most versions of Drupal Commerce at every iteration. We recommend using the latest version of Drupal Commerce, but if that is not possible for some reason, test the plugin with your Drupal Commerce version and it would probably function properly.* | ||
|
||
Scaffolded from [backstage-template-empty-repository](https://github.com/lunarway/backstage-template-empty-repository) | ||
|
||
## Installation | ||
|
||
Once you have installed Drupal Commerce on your Drupal setup, follow these simple steps: | ||
1. Signup at [lunar.app](https://lunar.app) (it’s free) | ||
1. Create an account | ||
1. Create an keys for your Drupal website | ||
1. Upload the contents of the `zip` file from latest release (https://github.com/lunar/payments-plugin-drupal-commerce-8.x/releases) to the modules directory and enable it on the `admin/modules` page OR run `composer require drupal/commerce_lunar` | ||
1. If the zip file is used, it is required to run `compose require lunar/payments-api-sdk` before installing the plugin | ||
1. Add the payment gateway from `admin/commerce/config/payment-gateways` and select one of the Lunar methods displayed under the `Plugin` section | ||
1. Set capture mode to either Delayed or Instant under `Capture mode` section. | ||
` | ||
|
||
|
||
## Updating settings | ||
|
||
Under the Lunar payment method 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 title that shows up in the checkout flow | ||
* Add app & public keys and other required data | ||
* Change the capture mode (Instant/Delayed) | ||
|
||
|
||
## How to | ||
|
||
1. Capture | ||
* In "Instant" mode, the orders are captured automatically | ||
* In "Delayed" mode you can capture an order by using the Payments tab from an order. If available the capture operation will show up. | ||
2. Refund | ||
* You can refund an order by using the Payment tab from an order. If available the refund operation will show up. | ||
3. Void | ||
* You can void an order by using the Payment operations from an order. If available the void operation will show up. | ||
|
||
## Available features | ||
|
||
1. Capture | ||
* Drupal admin panel: full/partial capture | ||
* Lunar admin panel: full/partial capture | ||
2. Refund | ||
* Drupal admin panel: full/partial refund | ||
* Lunar admin panel: full/partial refund | ||
3. Void | ||
* Drupal admin panel: full void | ||
* Lunar admin panel: full/partial void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#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 this payment 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 changing currency in frontend you need to have installed commerce-multicurrency module, available at [drupal.org](https://www.drupal.org/project/commerce_multicurrency/releases) | ||
* *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 & 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
## 8.x-1.0: | ||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "lunar/payments-plugin-drupal-commerce-8.x", | ||
"description": "Lunar Online Payments for Drupal 8.x", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Lunar", | ||
"email": "[email protected]" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/// <reference types="cypress" /> | ||
|
||
'use strict'; | ||
|
||
import { TestMethods } from '../support/test_methods.js'; | ||
|
||
describe('plugin full test', () => { | ||
/** | ||
* Login into admin and frontend to store cookies. | ||
*/ | ||
before(() => { | ||
cy.goToPage(TestMethods.StoreUrl + '/user/login'); | ||
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'); | ||
|
||
/** | ||
* TEMPORARY ADDED | ||
*/ | ||
it('enable module (disable other)', () => { | ||
TestMethods.enableThisModuleDisableOther(); | ||
}); | ||
|
||
context(`make payments in "${captureModes[0]}" mode`, () => { | ||
/** Modify plugin settings. */ | ||
it(`change capture mode to "${captureModes[0]}"`, () => { | ||
TestMethods.changeCaptureMode(captureModes[0]); | ||
}); | ||
|
||
/** Make Instant payments */ | ||
for (var currency of currenciesToTest) { | ||
TestMethods.changeProductCurrency(currency); | ||
TestMethods.payWithSelectedCurrency(currency, 'refund'); | ||
} | ||
}); | ||
|
||
context(`make payments in "${captureModes[1]}" mode`, () => { | ||
/** Modify plugin settings. */ | ||
it(`change capture mode to "${captureModes[1]}"`, () => { | ||
TestMethods.changeCaptureMode(captureModes[1]); | ||
}); | ||
|
||
for (var currency of currenciesToTest) { | ||
/** | ||
* HARDCODED currency | ||
*/ | ||
if ('USD' == currency || 'RON' == currency) { | ||
TestMethods.changeProductCurrency(currency); | ||
TestMethods.payWithSelectedCurrency(currency, 'capture'); | ||
/** In "delayed" mode we check "void" action too. */ | ||
TestMethods.payWithSelectedCurrency(currency, 'void'); | ||
} | ||
} | ||
}); | ||
|
||
/** | ||
* TEMPORARY ADDED | ||
*/ | ||
it('disable module (enable other)', () => { | ||
TestMethods.disableThisModuleEnableOther(); | ||
}); | ||
}); // describe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference types="cypress" /> | ||
|
||
'use strict'; | ||
|
||
import { TestMethods } from '../support/test_methods.js'; | ||
|
||
describe('log versions remotely', () => { | ||
/** | ||
* Go to backend site admin | ||
*/ | ||
before(() => { | ||
cy.goToPage(TestMethods.StoreUrl + '/user/login'); | ||
TestMethods.loginIntoAdminBackend(); | ||
}); | ||
|
||
/** Send log after full test finished. */ | ||
it('log shop & plugin versions remotely', () => { | ||
TestMethods.logVersions(); | ||
}); | ||
}); // describe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/// <reference types="cypress" /> | ||
|
||
'use strict'; | ||
|
||
import { TestMethods } from '../support/test_methods.js'; | ||
|
||
describe('plugin quick test', () => { | ||
/** | ||
* Login into admin and frontend to store cookies. | ||
*/ | ||
before(() => { | ||
cy.goToPage(TestMethods.StoreUrl + '/user/login'); | ||
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'; | ||
|
||
/** | ||
* TEMPORARY ADDED | ||
*/ | ||
it('enable module (disable other)', () => { | ||
TestMethods.enableThisModuleDisableOther(); | ||
}); | ||
|
||
/** | ||
* Modify capture mode | ||
*/ | ||
it('modify settings for capture mode', () => { | ||
TestMethods.changeCaptureMode(captureMode); | ||
}); | ||
|
||
/** | ||
* Change product currency | ||
*/ | ||
TestMethods.changeProductCurrency(currency); | ||
|
||
/** 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'); | ||
}); | ||
|
||
/** Partial Capture */ | ||
TestMethods.payWithSelectedCurrency(currency, 'capture', /*partialAmount*/ true); | ||
|
||
/** Refund last created order (previously captured). */ | ||
it('Process last order captured from admin panel to be refunded', () => { | ||
TestMethods.processOrderFromAdmin('refund', /*partialAmount*/ true); | ||
}); | ||
|
||
/** Void */ | ||
TestMethods.payWithSelectedCurrency(currency, 'void'); | ||
|
||
/** | ||
* TEMPORARY ADDED | ||
*/ | ||
it('disable module (enable other)', () => { | ||
TestMethods.disableThisModuleEnableOther(); | ||
}); | ||
}); // describe |
Oops, something went wrong.