예제 #1
0
 /**
  * Loads result object values from json object
  * @param string $string json
  * @return void
  */
 public function unserialize($string)
 {
     $data = json_decode($string);
     foreach ($data as $property => $value) {
         $method = $this->setterName($property);
         if (is_numeric($value) && strstr($value, '.')) {
             $value = floatval($value);
         } elseif (is_object($value)) {
             if ($property == 'authorization_information') {
                 $object = new AuthorizationInformation();
                 $object->unserialize(json_encode($value));
                 $value = $object;
             } elseif ($property == 'payment_instrument') {
                 if (!isset($data->payment_method)) {
                     throw new Exception\Runtime('Property "payment_method" is missing');
                 }
                 if ($data->payment_method == Payment\Create::CARD) {
                     $object = new PaymentInstrumentCard();
                 } elseif ($data->payment_method == Payment\Create::RECURRING) {
                     $object = new PaymentInstrumentRecurring();
                 }
                 $object->unserialize(json_encode($value));
                 $value = $object;
             }
         }
         $this->{$method}($value);
     }
 }
예제 #2
0
 function it_maps_authorization_information(Payment $payment)
 {
     $data = ['authorization_information' => ['url' => 'https://authorization.url/auth', 'data' => 'eJxdUl1vwj.......']];
     $info = new AuthorizationInformation();
     $info->setUrl('https://authorization.url/auth');
     $info->setData('eJxdUl1vwj.......');
     $payment->setAuthorizationInformation($info)->shouldBeCalled();
     $this->map($data, $payment);
 }
예제 #3
0
 function it_is_serializable()
 {
     $this->shouldImplement('\\Serializable');
     $this->setId('foo');
     $this->setAmount(20.0);
     $this->setType(null);
     $info = new AuthorizationInformation();
     $info->setUrl('http://...');
     $info->setData('some_data');
     $this->setAuthorizationInformation($info);
     $this->serialize()->shouldReturn('{"id":"foo","amount":"20.00","authorization_information":{"url":"http:\\/\\/...","data":"some_data"}}');
 }
 public function testBeginAuthorization()
 {
     $session = $this->client->getContainer()->get('session');
     $payment = new Payment();
     $payment->setId('payment_id');
     $auth = new AuthorizationInformation();
     $auth->setUrl('http://...');
     $auth->setData('auth_data');
     $payment->setAuthorizationInformation($auth);
     $session->set('cardinity_payment', $payment->serialize());
     $crawler = $this->client->request('GET', '/cardinity/authorization/begin');
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 }