Ejemplo n.º 1
0
 public function testGettersSetters()
 {
     $customerInfo = new CustomerInfo();
     $payment = new Payment();
     $payment->setValue(1.23);
     $payment->setKey('secret');
     $payment->setMaxDate('2014-11-29');
     $payment->setCustomerInfo($customerInfo);
     $this->assertSame(1.23, $payment->getValue());
     $this->assertSame('secret', $payment->getKey());
     $this->assertSame('2014-11-29', $payment->getMaxDate());
     $this->assertSame($customerInfo, $payment->getCustomerInfo());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function handleRequest(Config $config)
 {
     $parameters = array('ep_cin' => $config->getCin(), 'ep_user' => $config->getUser(), 'ep_entity' => $config->getEntity(), 'ep_language' => $config->getLanguage(), 'ep_country' => $config->getCountry(), 'ep_ref_type' => 'auto', 't_value' => strval($this->payment->getValue()), 't_key' => $this->payment->getKey());
     if ($this->payment->getCustomerInfo() instanceof CustomerInfo) {
         $parameters = array_merge($parameters, $this->payment->getCustomerInfo()->toArray());
     }
     // Optional authentication code
     if ($config->getCode()) {
         $parameters['s_code'] = $config->getCode();
     }
     // Optional maximum date for payment acceptance
     if ($this->payment->getMaxDate()) {
         $parameters['o_max_date'] = $this->payment->getMaxDate();
         $parameters['ep_partner'] = $config->getUser();
     }
     switch ($this->payment->getType()) {
         case Payment::TYPE_BOLETO:
         case Payment::TYPE_MOTO:
             $parameters['ep_type'] = $this->payment->getType();
             break;
     }
     return $parameters;
 }
Ejemplo n.º 3
0
 /**
  * @group integration
  */
 public function testCreatePaymentWithKey()
 {
     $payment = new Payment();
     $payment->setValue(12);
     $payment->setKey('secret');
     $request = new CreatePayment($payment);
     $response = $this->getClient()->request($request);
     $this->assertTrue($response->isValid());
     $this->assertSame('ok0', $response->getStatus());
     $this->assertStringStartsWith('ep_country and ep_entity and ep_user and ep_cin ok', $response->getMessage());
     $this->assertSame($this->getConfig()->getCin(), $response->getCin());
     $this->assertSame($this->getConfig()->getUser(), $response->getUser());
     $this->assertSame($this->getConfig()->getEntity(), $response->getEntity());
     $this->assertTrue($response->getReference() != null);
     $this->assertSame($payment->getValue(), $response->getValue());
     $this->assertSame($payment->getKey(), $response->getKey());
     $this->assertRegExp('#https?://(test\\.|www\\.)?easypay.pt/_s/.*#', $response->getLink());
     $this->assertSame($payment->getKey(), $response->getKey());
 }