Skip to content

Commit de8949d

Browse files
committed
- Added in config.php new parameter (key)
- New method for convert correctly price.
2 parents cc669e3 + a26c9f5 commit de8949d

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Changelog
22

33
All Notable changes to `Redsys` will be documented in this file
4+
## 1.0.3 (2015-11-26)
5+
6+
### Added
7+
- In config.php new parameter (key)
8+
- New method for convert correctly price.
9+
10+
### Deprecated
11+
- Nothing
12+
13+
### Fixed
14+
- Nothing
15+
16+
### Removed
17+
- In Tpv.php removed injection by default the config.
18+
19+
### Security
20+
- Nothing
421

522
## 1.0.0 (2015-11-15)
623

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ class RedsysController extends Controller
6060
public function index()
6161
{
6262
try{
63-
$key = 'sq7HjrUOBfKmC576ILgskD5srU870gJ7';
64-
65-
63+
$key = config('redsys.key');
64+
6665
Redsys::setAmount(rand(10,600));
6766
Redsys::setOrder(time());
6867
Redsys::setMerchantcode('999008881'); //Reemplazar por el código que proporciona el banco
6968
Redsys::setCurrency('978');
7069
Redsys::setTransactiontype('0');
7170
Redsys::setTerminal('1');
71+
Redsys::setNotification(config('redsys.url_notification')); //Url de notificacion
72+
Redsys::setUrlOk(config('redsys.url_ok')); //Url OK
73+
Redsys::setUrlKo(config('redsys.url_ko')); //Url KO
7274
Redsys::setVersion('HMAC_SHA256_V1');
7375
Redsys::setTradeName('Tienda S.L');
7476
Redsys::setTitular('Pedro Risco');

src/Tpv.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct()
3535
$this->_setMethod='T';
3636
$this->_setSubmit = '';
3737

38-
$this->_setParameters = array('DS_MERCHANT_URLOK' => config('redsys.url_ok'), 'DS_MERCHANT_URLKO' => config('redsys.url_ko'), 'DS_MERCHANT_MERCHANTURL' => config('redsys.url_notification'));
38+
$this->_setParameters = array();
3939
$this->_setVersion = 'HMAC_SHA256_V1';
4040
$this->_setNameForm = 'redsys_form';
4141
$this->_setIdForm = 'redsys_form';
@@ -56,7 +56,7 @@ public function __construct()
5656
public function setAmount($amount)
5757
{
5858
if($amount > 0) {
59-
$amount = $this->priceToSQL($amount);
59+
$amount = $this->convertNumber($amount);
6060
$amount = intval(strval($amount*100));
6161

6262
$this->_setParameters['DS_MERCHANT_AMOUNT'] = $amount;
@@ -567,6 +567,13 @@ private function priceToSQL($price)
567567
return $price;
568568
}
569569

570+
private function convertNumber($price)
571+
{
572+
$number=number_format(str_replace(',', '.', $price), 2, '.', '');
573+
return $number;
574+
575+
}
576+
570577
/****** Base64 Functions *****
571578
* @param $input
572579
* @return string

src/config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
return [
3+
'key' => '',
34
'url_notification' => '',
45
'url_ok' => '',
56
'url_ko' => '',

0 commit comments

Comments
 (0)