diff --git a/src/Redsys/Tpv/Tpv.php b/src/Redsys/Tpv/Tpv.php index ce87fca..08454c5 100644 --- a/src/Redsys/Tpv/Tpv.php +++ b/src/Redsys/Tpv/Tpv.php @@ -133,14 +133,27 @@ public function setFormHiddens(array $options) } public function getFormHiddens() + { + $hiddens = ''; + + foreach ($this->getFormValues() as $key => $value) { + $hiddens .= $this->getInputHidden($key, $value); + } + + return $hiddens; + } + + public function getFormValues() { if (empty($this->values)) { throw new Exception('Form fields must be initialized previously'); } - return $this->getInputHidden('SignatureVersion', $this->options['SignatureVersion']) - .$this->getInputHidden('MerchantParameters', $this->getMerchantParametersEncoded()) - .$this->getInputHidden('Signature', $this->getValuesSignature()); + return array( + 'SignatureVersion' => $this->options['SignatureVersion'], + 'MerchantParameters' => $this->getMerchantParametersEncoded(), + 'Signature' => $this->getValuesSignature() + ); } public function getInputHidden($name, $value) diff --git a/tests/Redsys/Tpv/TpvTest.php b/tests/Redsys/Tpv/TpvTest.php index 5353230..7cbe8f3 100644 --- a/tests/Redsys/Tpv/TpvTest.php +++ b/tests/Redsys/Tpv/TpvTest.php @@ -100,6 +100,10 @@ public function testFormFields($tpv) 'MerchantURL' => 'http://example.com', ]); + $values = $tpv->getFormValues(); + + $this->assertTrue(count($values) === count(array_filter($values))); + $fields = $tpv->getFormHiddens(); $this->assertContains('