Skip to content

Commit 8a6a7b3

Browse files
committed
Small improvements from Scrutinizer, add more badges to the README
1 parent 88e7934 commit 8a6a7b3

File tree

3 files changed

+44
-72
lines changed

3 files changed

+44
-72
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ php:
1010
before_script:
1111
- composer install -n --dev --prefer-source
1212

13-
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
13+
script:
14+
- vendor/bin/phpcs --standard=PSR2 src
15+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" == "hhvm" ]; then vendor/bin/phpunit --verbose; fi;'
16+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then vendor/bin/phpunit --verbose --coverage-clover coverage.clover; fi;'
17+
18+
after_success:
19+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;'
20+
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;'

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
**Redsys driver for the Omnipay PHP payment processing library**
44

55
[![Build Status](https://travis-ci.org/PatronBase/omnipay-redsys.png?branch=master)](https://travis-ci.org/PatronBase/omnipay-redsys)
6+
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/PatronBase/omnipay-redsys.svg?style=flat)](https://scrutinizer-ci.com/g/PatronBase/omnipay-redsys/code-structure)
7+
[![Code Quality](https://img.shields.io/scrutinizer/g/PatronBase/omnipay-redsys.svg?style=flat)](https://scrutinizer-ci.com/g/PatronBase/omnipay-redsys/?branch=master)
8+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md)
69
[![Latest Stable Version](https://poser.pugx.org/PatronBase/omnipay-redsys/version.png)](https://packagist.org/packages/patronbase/omnipay-redsys)
710
[![Total Downloads](https://poser.pugx.org/patronbase/omnipay-redsys/d/total.png)](https://packagist.org/packages/patronbase/omnipay-redsys)
811

src/Message/PurchaseRequest.php

Lines changed: 33 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ class PurchaseRequest extends AbstractRequest
1111
{
1212
protected $liveEndpoint = 'https://sis.redsys.es/sis/realizarPago';
1313
protected $testEndpoint = 'https://sis-t.redsys.es:25443/sis/realizarPago';
14+
protected static $consumerLanguages = array(
15+
'es' => '001', // Spanish
16+
'en' => '002', // English
17+
'ca' => '003', // Catalan - same as Valencian (010)
18+
'fr' => '004', // French
19+
'de' => '005', // German
20+
'nl' => '006', // Dutch
21+
'it' => '007', // Italian
22+
'sv' => '008', // Swedish
23+
'pt' => '009', // Portuguese
24+
'pl' => '011', // Polish
25+
'gl' => '012', // Galician
26+
'eu' => '013', // Basque
27+
);
1428

1529
public function getCardholder()
1630
{
@@ -40,57 +54,7 @@ public function setConsumerLanguage($value)
4054
}
4155
$value = str_pad($value, 3, '0', STR_PAD_LEFT);
4256
} elseif (!is_numeric($value)) {
43-
switch ($value) {
44-
default:
45-
// Spanish
46-
case 'es':
47-
$value = '001';
48-
break;
49-
// English
50-
case 'en':
51-
$value = '002';
52-
break;
53-
// Catalan - same as Valencian (010)
54-
case 'ca':
55-
$value = '003';
56-
break;
57-
// French
58-
case 'fr':
59-
$value = '004';
60-
break;
61-
// German
62-
case 'de':
63-
$value = '005';
64-
break;
65-
// Dutch
66-
case 'nl':
67-
$value = '006';
68-
break;
69-
// Italian
70-
case 'it':
71-
$value = '007';
72-
break;
73-
// Swedish
74-
case 'sv':
75-
$value = '008';
76-
break;
77-
// Portuguese
78-
case 'pt':
79-
$value = '009';
80-
break;
81-
// Polish
82-
case 'pl':
83-
$value = '011';
84-
break;
85-
// Galician
86-
case 'gl':
87-
$value = '012';
88-
break;
89-
// Basque
90-
case 'eu':
91-
$value = '013';
92-
break;
93-
}
57+
$value = isset(self::$consumerLanguages[$value]) ? self::$consumerLanguages[$value] : '001';
9458
}
9559

9660
return $this->setParameter('consumerLanguage', $value);
@@ -171,26 +135,24 @@ public function getData()
171135
{
172136
$this->validate('merchantId', 'terminalId', 'amount', 'currency');
173137

174-
$data = array();
175-
176-
// mandatory fields
177-
$data['Ds_Merchant_MerchantCode'] = $this->getMerchantId();
178-
$data['Ds_Merchant_Terminal'] = $this->getTerminalId();
179-
$data['Ds_Merchant_TransactionType'] = '0'; // Authorisation
180-
$data['Ds_Merchant_Amount'] = $this->getAmountInteger();
181-
$data['Ds_Merchant_Currency'] = $this->getCurrencyNumeric(); // uses ISO-4217 codes
182-
$data['Ds_Merchant_Order'] = $this->getTransactionId();
183-
$data['Ds_Merchant_MerchantUrl'] = $this->getNotifyUrl();
184-
// optional fields
185-
$data['Ds_Merchant_ProductDescription'] = $this->getDescription();
186-
$data['Ds_Merchant_Cardholder'] = $this->getCardholder();
187-
$data['Ds_Merchant_UrlOK'] = $this->getReturnUrl();
188-
$data['Ds_Merchant_UrlKO'] = $this->getReturnUrl();
189-
$data['Ds_Merchant_MerchantName'] = $this->getMerchantName();
190-
$data['Ds_Merchant_ConsumerLanguage'] = $this->getConsumerLanguage();
191-
$data['Ds_Merchant_MerchantData'] = $this->getMerchantData();
192-
193-
return $data;
138+
return array(
139+
// mandatory fields
140+
'Ds_Merchant_MerchantCode' => $this->getMerchantId(),
141+
'Ds_Merchant_Terminal' => $this->getTerminalId(),
142+
'Ds_Merchant_TransactionType' => '0', // Authorisation
143+
'Ds_Merchant_Amount' => $this->getAmountInteger(),
144+
'Ds_Merchant_Currency' => $this->getCurrencyNumeric(), // uses ISO-4217 codes
145+
'Ds_Merchant_Order' => $this->getTransactionId(),
146+
'Ds_Merchant_MerchantUrl' => $this->getNotifyUrl(),
147+
// optional fields
148+
'Ds_Merchant_ProductDescription' => $this->getDescription(),
149+
'Ds_Merchant_Cardholder' => $this->getCardholder(),
150+
'Ds_Merchant_UrlOK' => $this->getReturnUrl(),
151+
'Ds_Merchant_UrlKO' => $this->getReturnUrl(),
152+
'Ds_Merchant_MerchantName' => $this->getMerchantName(),
153+
'Ds_Merchant_ConsumerLanguage' => $this->getConsumerLanguage(),
154+
'Ds_Merchant_MerchantData' => $this->getMerchantData(),
155+
);
194156
}
195157

196158
public function sendData($data)

0 commit comments

Comments
 (0)