|
1 | 1 | <?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. |
8 | 5 | * |
| 6 | + * @author Lyra Network <https://www.lyra.com> |
| 7 | + * @copyright Lyra Network |
| 8 | + * @license http://www.apache.org/licenses/ |
9 | 9 | */ |
10 | 10 |
|
11 | | - |
12 | | -require "../lib/class-payment-form-toolbox.php"; |
13 | | - |
14 | 11 | /** |
15 | | - * Toolbox initialisation, using PayZen account informations |
| 12 | + * Configuration initialisation, using Lyra account informations. |
16 | 13 | * |
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). |
19 | 16 | * |
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). |
22 | 19 | * |
23 | | - * Mode (ctxMode) |
| 20 | + * Mode (ctx_mode) |
24 | 21 | * Allows to indicate the operating mode of the module (TEST or PRODUCTION) |
25 | 22 | * |
26 | | - * Platform URL (platform) |
| 23 | + * Platform URL (platform_url) |
27 | 24 | * the platform URL needs to be changed according to your needs (COUNTRY) |
28 | 25 | * DEMO: https://demo.payzen.eu/vads-payment/ |
29 | 26 | * France: https://secure.payzen.eu/vads-payment/ |
30 | 27 | * Brazil: https://secure.payzen.com.br/vads-payment/ |
31 | 28 | * Germany: https://de.payzen.eu/vads-payment/ |
32 | 29 | * Chili: https://secure.payzen.cl/vads-payment/ |
33 | | - * India: https://secure.payzen.co.in/vads-payment/ |
34 | 30 | * |
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. |
36 | 32 | * |
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. |
40 | 53 | */ |
| 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 | + } |
41 | 79 |
|
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 | + } |
51 | 87 |
|
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 | + } |
53 | 98 |
|
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