コード例 #1
0
 /**
  * @see OrderEntity::toArray()
  */
 public function testToArray()
 {
     $accountId = 'accountId_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $this->object->setAccountId($accountId);
     $referenceCode = 'referenceCode_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $this->object->setReferenceCode($referenceCode);
     $description = 'description_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $this->object->setDescription($description);
     $language = 'language_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $this->object->setLanguage($language);
     $notifyUrl = 'http://notifyurl-' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '.com';
     $this->object->setNotifyUrl($notifyUrl);
     $signature = sha1('signature');
     $this->object->setSignature($signature);
     $shippingAddress = $this->object->getShippingAddress();
     $shippingAddress->setStreet1('street1_' . rand(1, 1000))->setStreet2('street2_' . rand(1, 1000))->setCity('city_' . rand(1, 1000))->setState('state_' . rand(1, 1000))->setCountry('country_' . rand(1, 1000))->setPostalCode('postalCode_' . rand(1, 1000))->setPhone('phone_' . rand(1, 1000));
     $buyer = $this->object->getBuyer();
     $buyer->setFullName('person name ' . rand(1, 9) . rand(1, 9) . rand(1, 9))->setEmailAddress('email' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '@foo-bar.com')->setDniNumber(Cpf::random())->setShippingAddress($shippingAddress);
     $additionalValues = $this->object->getAdditionalValues();
     $additionalValues->addTax(AdditionalValuesEntity::TX_VALUE, 'BRL', 'BRL', 1000);
     $additionalValues->addTax(AdditionalValuesEntity::TX_TAX, 'BRL', 'BRL', 1000);
     $additionalValues->addTax(AdditionalValuesEntity::TX_TAX_RETURN_BASE, 'BRL', 1000);
     $additionalValues->addTax(AdditionalValuesEntity::TX_ADDITIONAL_VALUE, 'BRL', 1000);
     $order = $this->object->toArray();
     $this->assertInternalType('array', $order);
     $this->assertEquals($accountId, $order['accountId']);
     $this->assertEquals($referenceCode, $order['referenceCode']);
     $this->assertEquals($description, $order['description']);
     $this->assertEquals($language, $order['language']);
     $this->assertEquals($notifyUrl, $order['notifyUrl']);
     $this->assertEquals($signature, $order['signature']);
     $this->assertEquals($shippingAddress->getStreet1(), $order['shippingAddress']['street1']);
     $this->assertEquals($shippingAddress->getStreet2(), $order['shippingAddress']['street2']);
     $this->assertEquals($shippingAddress->getCity(), $order['shippingAddress']['city']);
     $this->assertEquals($shippingAddress->getState(), $order['shippingAddress']['state']);
     $this->assertEquals($shippingAddress->getCountry(), $order['shippingAddress']['country']);
     $this->assertEquals($shippingAddress->getPostalCode(), $order['shippingAddress']['postalCode']);
     $this->assertEquals($shippingAddress->getPhone(), $order['shippingAddress']['phone']);
     $this->assertEquals($buyer->getFullName(), $order['buyer']['fullName']);
     $this->assertEquals($buyer->getEmailAddress(), $order['buyer']['emailAddress']);
     $this->assertEquals($buyer->getDniNumber(), $order['buyer']['dniNumber']);
     $this->assertEquals($shippingAddress->toArray(), $order['buyer']['shippingAddress']);
     $this->assertEquals($additionalValues->toArray(), $order['additionalValues']);
 }
コード例 #2
0
 /**
  * Generate arry order.
  * @return array
  */
 public function toArray()
 {
     return array('expiration' => $this->expiration, 'type' => $this->type, 'paymentMethod' => $this->paymentMethod, 'paymentCountry' => $this->paymentCountry, 'ipAddress' => $this->ipAddress, 'cookie' => $this->cookie, 'userAgent' => $this->userAgent, 'order' => $this->order->toArray(), 'creditCard' => $this->creditCard->toArray(), 'payer' => $this->payer->toArray(), 'extraParameters' => $this->extraParameters->toArray());
 }
コード例 #3
0
 /**
  * @see TransactionEntity::setOrder()
  */
 public function testSetOrder()
 {
     $orderEntity = new OrderEntity();
     $accountId = 'accountId_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $orderEntity->setAccountId($accountId);
     $referenceCode = 'referenceCode_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $orderEntity->setReferenceCode($referenceCode);
     $description = 'description_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $orderEntity->setDescription($description);
     $language = 'language_' . rand(1, 9) . rand(1, 9) . rand(1, 9);
     $orderEntity->setLanguage($language);
     $notifyUrl = 'http://notifyurl-' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '.com';
     $orderEntity->setNotifyUrl($notifyUrl);
     $signature = sha1('signature');
     $orderEntity->setSignature($signature);
     $rs = $this->object->setOrder($orderEntity);
     $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\TransactionEntity', $rs);
     $rs = $this->object->getOrder();
     $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\Order\\OrderEntity', $rs);
     $this->assertEquals($accountId, $rs->getAccountId());
     $this->assertEquals($referenceCode, $rs->getReferenceCode());
     $this->assertEquals($description, $rs->getDescription());
     $this->assertEquals($language, $rs->getLanguage());
     $this->assertEquals($notifyUrl, $rs->getNotifyUrl());
     $this->assertEquals($signature, $rs->getSignature());
 }