Skip to content

Commit 9f2aa71

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 8a5a281 + 1489c20 commit 9f2aa71

48 files changed

Lines changed: 4138 additions & 1892 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.project
2+
.buildpath
3+
/.settings/

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ php:
99
- 7.1
1010

1111
script:
12-
- phpunit example/
13-
- phpunit lib/
14-
- phpunit config/
15-
- phpunit return/
12+
- phpunit example/
13+
- phpunit lib/
14+
- phpunit config/
15+
- phpunit return/

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.0.0, 2022-06-23:
2+
- New PHP sample code for Lyra payment gateway integration.

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contributing to Lyra PHP payment form examples
2+
3+
Anyone is welcome to contribute to Lyra PHP payment form examples. There are various ways you can contribute:
4+
5+
- Raise an issue on GitHub.
6+
- Send us a Pull Request on **develop** branch with your bug fixes.
7+
- Fork your own copy of the repository to add new features.
8+
- Provide feedback and suggestions on enhancements.

COPYING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright © 2022 Lyra Network.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this software except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

LICENSE renamed to LICENSE.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright [yyyy] [name of copyright owner]
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
@@ -198,5 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
202-
201+
limitations under the License.

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# PayZen VADS payment exemple - PHP
2-
3-
[![Build Status](https://travis-ci.org/lyra/vads-payment-php.svg?branch=master)](https://travis-ci.org/lyra/vads-payment-php)
1+
# Lyra PHP payment form example
42

53
## Introduction
6-
The code presented here is a demonstration of the implementation of the VADS PayZen payment system, aimed to ease its use and learning.
74

5+
The code presented here is an example of the implementation of the Lyra payment gateway form integration in PHP. It aims to ease its use and learning.
86

97
## Contents
10-
* payzenFormToolBox.php, the core file, defining an utility class encapsulating all the PayZen logics of this example
118

12-
## Example
13-
* `config/config.php`, a centralized configuration and initialisation file
14-
* `return/form-return.php`, the file for the return URL after payment
15-
* `return/ipn-return.php`, a minimal implementation of the IPN callback (notification must be turned on in the back-office with the correct URL)
9+
This project main contents are:
10+
* `lib/locale`: contains the different translation files for French, English, German and Spanish languages.
11+
* `lib/lyra-payment-form-sdk`: core files that contains the Lyra payment SDK logic.
12+
* `lib/tools`: the core file, defining an utilitary class encapsulating all the Lyra logics of the examples.
13+
* `config/Config.php`: a centralized configuration and initialization file.
14+
* `example/`: contains the logic implementation of the different payment examples.
15+
* `example/return-payment.php`: the file for the return URL at the end of the payment.
16+
* Some other resources for styling pages.
1617

1718
## The first use
18-
1. Place the files on the same directory, under the root of your web-server
19-
2. In `config/config.php`, replace the occurences of `[***CHANGE-ME***]` by the actual values of your PayZen account
20-
3. Access `index.html` from your browser.
21-
4. Follow the PayZen indications to perform the payment
2219

20+
1. Copy the content of this project to your PHP web server.
21+
2. In `config/Config.php`, replace the occurrence of the token `[***CHANGE-ME***]` by the actual return url and configure all settings with the actual values from your gateway Back Office.
22+
3. Access the `index.php` page from your browser.
23+
4. Follow the indications to perform a payment
2324

2425
## The next steps
2526

26-
You will also find here the instructions on how to plug the toolbox logging process to your own logging mechanism, how to override the IPN and RETURN URL defined for your PayZen account, and finally, you can change the `TEST` parameter to `PRODUCTION` to switch to _real_ payment mode, with *all* the caution this decision expects.
27-
28-
27+
You will also find here the instructions on how to plug the toolbox logging process to your own logging mechanism, how
28+
to override the IPN and RETURN URL defined for your gateway Back Office. And finally, you can change the `TEST` parameter
29+
to `PRODUCTION` to switch to real payment mode, with *all* the caution this decision expects.
2930

3031
## Note
31-
* The documentation used to write this code was [Guide d'implementation formulaire de paiement, v3.4](https://payzen.io)
32-
3332

33+
* The documentation used to write this code was [Guide d'implementation formulaire de paiement, v3.4](https://payzen.io)

assets/css/style.css

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
body {
2+
padding-top: 70px;
3+
/*
4+
* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top.
5+
* Change if height of navigation changes.
6+
*/
7+
padding-bottom: 8em;
8+
}
9+
10+
.navbar, .navbar-inverse {
11+
background-color: #293c7a;
12+
border-color : #293c7a;
13+
}
14+
15+
.navbar-inverse .navbar-nav > li > a, .navbar-inverse .navbar-brand {
16+
color: #fff;
17+
}
18+
19+
.form-control {
20+
min-width: 220px;
21+
}
22+
23+
/* Style the buttons that are used to open and close the accordion panel */
24+
.accordion {
25+
background-color: #eee;
26+
color: #444;
27+
cursor: pointer;
28+
padding: 18px;
29+
width: 100%;
30+
text-align: left;
31+
border: none;
32+
outline: none;
33+
transition: 0.4s;
34+
}
35+
36+
/*
37+
* Add a background color to the button if it is clicked on (add the .active class with JS),
38+
* and when you move the mouse over it (hover).
39+
*/
40+
.active, .accordion:hover {
41+
background-color: #ccc;
42+
}
43+
44+
/* Style the accordion panel. Note: hidden by default */
45+
.panel {
46+
padding: 0 18px;
47+
background-color: white;
48+
display: none;
49+
overflow: hidden;
50+
}
51+
52+
.forminput[type=text] {
53+
width: 20%;
54+
padding: 12px 20px;
55+
margin: 8px 0;
56+
display: inline-block;
57+
border: 1px solid #ccc;
58+
border-radius: 4px;
59+
box-sizing: border-box;
60+
}
61+
62+
.forminput[type=number] {
63+
width: 100%;
64+
padding: 12px 20px;
65+
margin: 8px 0;
66+
display: inline-block;
67+
border: 1px solid #ccc;
68+
border-radius: 4px;
69+
box-sizing: border-box;
70+
}
71+
72+
.forminput[type=submit] {
73+
width: 100%;
74+
background-color: #293c7a;
75+
color: white;
76+
padding: 14px 20px;
77+
margin: 8px 0;
78+
border: none;
79+
border-radius: 4px;
80+
cursor: pointer;
81+
}
82+
83+
.forminput[type=submit]:hover {
84+
background-color: #293c7a;
85+
}
86+
87+
.checkoutdiv {
88+
border-radius: 5px;
89+
background-color: #f2f2f2;
90+
padding: 20px;
91+
}
92+
93+
.close {
94+
float: right;
95+
font-size: 21px;
96+
font-weight: 700;
97+
line-height: 1;
98+
color: #000;
99+
text-shadow: 0 1px 0 #fff;
100+
filter: alpha(opacity=20);
101+
opacity: .2;
102+
}

assets/js/script.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright © Lyra Network.
3+
* This file is part of Lyra PHP payment form example. See COPYING.md for license details.
4+
*
5+
* @author Lyra Network <https://www.lyra.com>
6+
* @copyright Lyra Network
7+
* @license http://www.apache.org/licenses/
8+
*/
9+
10+
var acc = document.getElementsByClassName("accordion");
11+
var i;
12+
13+
for (i = 0; i < acc.length; i++) {
14+
acc[i].addEventListener("click", function () {
15+
// Toggle between adding and removing the "active" class
16+
// to highlight the button that controls the panel.
17+
this.classList.toggle("active");
18+
19+
// Toggle between hiding and showing the active panel.
20+
var panel = this.nextElementSibling;
21+
if (panel.style.display === "block") {
22+
panel.style.display = "none";
23+
} else {
24+
panel.style.display = "block";
25+
}
26+
});
27+
}

config/config.php

Lines changed: 88 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,110 @@
11
<?php
2-
/*
3-
* PayZen VADS payment example
4-
*
5-
* Bootstraping code, handles initialisation and configuration
6-
*
7-
* @version 0.7
2+
/**
3+
* Copyright © Lyra Network.
4+
* This file is part of Lyra PHP payment form example. See COPYING.md for license details.
85
*
6+
* @author Lyra Network <https://www.lyra.com>
7+
* @copyright Lyra Network
8+
* @license http://www.apache.org/licenses/
99
*/
1010

11-
12-
require "../lib/class-payment-form-toolbox.php";
13-
1411
/**
15-
* Toolbox initialisation, using PayZen account informations
12+
* Configuration initialisation, using Lyra account informations.
1613
*
17-
* Shop ID (shopID)
18-
* 8-digit shop ID provided in your Back Office (Menu: Settings > Shop > Certificates).
14+
* shop ID (site_id)
15+
* 8-digit shop ID provided in your Back Office (Menu: Settings > Shop > Keys).
1916
*
20-
* Certificate (certTest || certProd)
21-
* provided in your Back Office (Menu: Settings > Shop > Certificates).
17+
* Test key or Production key (key_test || key_prod)
18+
* provided in your Back Office (Menu: Settings > Shop > Keys).
2219
*
23-
* Mode (ctxMode)
20+
* Mode (ctx_mode)
2421
* Allows to indicate the operating mode of the module (TEST or PRODUCTION)
2522
*
26-
* Platform URL (platform)
23+
* Platform URL (platform_url)
2724
* the platform URL needs to be changed according to your needs (COUNTRY)
2825
* DEMO: https://demo.payzen.eu/vads-payment/
2926
* France: https://secure.payzen.eu/vads-payment/
3027
* Brazil: https://secure.payzen.com.br/vads-payment/
3128
* Germany: https://de.payzen.eu/vads-payment/
3229
* Chili: https://secure.payzen.cl/vads-payment/
33-
* India: https://secure.payzen.co.in/vads-payment/
3430
*
35-
* Ask support at payzen.io for your platform URL if you don't know it
31+
* Ask support at https://www.lyra.com/support/ for your platform URL if you don't know it.
3632
*
37-
* IPN (optional)
38-
* Instant Payment Notification URL
39-
* will override the IPN URL and popuplate the vads_url_check field
33+
* Signature algorithm (sign_algo)
34+
* The signature algorithm chosen in the shop configuration: 'SHA-256'/'SHA-1'
35+
*
36+
* Return Mode (return_mode)
37+
* This setting defines the return mode by which the settings will be sent back to the shop
38+
* (3 possible values GET / POST / NONE). If this field is not filled the gateway does not
39+
* send back any data to the shop when the customer returns to the shop.
40+
*
41+
* URL Return (url_return)
42+
* Shop return URL. When the customer clicks on "return to the shop" this URL allows to treat
43+
* the data in order to display the payment details. It is strongly recommended NOT to treat
44+
* the data in the database (order update, order record) after the payment analysis.
45+
* The server URL must allow you to update the database.
46+
*
47+
* Data acquisition mode (action_mode)
48+
* This setting is set to INTERACTIVE if the card details are entered on the payment gateway.
49+
*
50+
* Debug Mode (debug)
51+
* TRUE: Allows to display the fields which will be sent to the shop.
52+
* FALSE: Automatic redirection to the payment page.
4053
*/
54+
class Config
55+
{
56+
/**
57+
* @var array string[]
58+
*/
59+
private $config_params = array (
60+
'site_id' => '12345678',
61+
'key_test' => '1111111111111111',
62+
'key_prod' => '2222222222222222',
63+
'ctx_mode' => 'TEST', // 'TEST' / 'PRODUCTION'
64+
'platform_url' => 'https://secure.payzen.eu/vads-payment/',
65+
'sign_algo' => 'SHA-256', // 'SHA-256'/'SHA-1'
66+
'return_mode' => 'POST',// 'POST' / 'GET'
67+
'url_return' => '***CHANGE-ME***',
68+
'action_mode' => 'INTERACTIVE',//'INTERACTIVE'/ 'IFRAME'
69+
'debug' => true // TRUE / FALSE
70+
);
71+
72+
/**
73+
* @return string
74+
*/
75+
public function getAbsPath()
76+
{
77+
return realpath(implode(DIRECTORY_SEPARATOR, ['.', '..'])) . DIRECTORY_SEPARATOR;
78+
}
4179

42-
$args = array(
43-
'shopID' => '[***CHANGE-ME***]', // shopID
44-
'certTest' => '[***CHANGE-ME***]', // certificate, TEST-version
45-
'certProd' => '[***CHANGE-ME***]', // certificate, PRODUCTION-version
46-
'ctxMode' => 'TEST', // PRODUCTION || TEST
47-
'platform' => '[***CHANGE-ME***]', // Platform URL
48-
'algorithm' => 'sha256', // the signature algorithm chosen in the shop configuration
49-
'debug' => true
50-
);
80+
/**
81+
* @return array
82+
*/
83+
public function getConfigParams()
84+
{
85+
return $this->config_params;
86+
}
5187

52-
$toolbox = new paymentFormToolbox($args);
88+
/**
89+
* @param $name
90+
* @return mixed|void
91+
*/
92+
public function getConfigParam($name)
93+
{
94+
if (array_key_exists($name, $this->config_params)) {
95+
return $this->config_params[$name];
96+
}
97+
}
5398

54-
return $toolbox;
99+
/**
100+
* @param $name
101+
* @param $value
102+
* @return void
103+
*/
104+
public function setConfigParam($name, $value)
105+
{
106+
if (! empty($name)) {
107+
$this->config_params[$name] = $value;
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)