| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Omnipay\Redsys; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Omnipay\Common\AbstractGateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Omnipay\Redsys\Message\CompletePurchaseRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Omnipay\Redsys\Message\PurchaseRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * Redsys Redirect Gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @link http://www.redsys.es/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | class RedirectGateway extends AbstractGateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 | 1 |  |     public function getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 | 1 |  |         return 'Redsys Redirect'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 | 60 |  |     public function getDefaultParameters() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 60 |  |             'merchantId'      => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 60 |  |             'merchantName'    => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 60 |  |             'terminalId'      => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 60 |  |             'hmacKey'         => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 60 |  |             'protocolVersion' => '2.1.0', // default in case not set in the gateway config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 60 |  |             'testMode'        => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     public function getMerchantId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         return $this->getParameter('merchantId'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 6 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public function setMerchantId($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 6 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         return $this->setParameter('merchantId', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     public function getMerchantName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         return $this->getParameter('merchantName'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 6 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function setMerchantName($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 6 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         return $this->setParameter('merchantName', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function getTerminalId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         return $this->getParameter('terminalId'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 6 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     public function setTerminalId($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 6 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         return $this->setParameter('terminalId', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 | 2 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     public function getHmacKey() | 
            
                                                                        
                            
            
                                    
            
            
                | 64 | 2 |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         return $this->getParameter('hmacKey'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 6 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     public function setHmacKey($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 6 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         return $this->setParameter('hmacKey', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     public function getProtocolVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 3 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         return $this->getParameter('protocolVersion'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 7 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function setProtocolVersion($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 7 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         return $this->setParameter('protocolVersion', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     public function purchase(array $parameters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         return $this->createRequest('\Omnipay\Redsys\Message\PurchaseRequest', $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function completePurchase(array $parameters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         return $this->createRequest('\Omnipay\Redsys\Message\CompletePurchaseRequest', $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 92 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 93 |  |  |  |