コード例 #1
0
ファイル: BuyerEntity.php プロジェクト: leonardothibes/payu
 /**
  * Generate arry order.
  * @return array
  */
 public function toArray()
 {
     return array('fullName' => $this->fullName, 'emailAddress' => $this->emailAddress, 'dniNumber' => $this->dniNumber, 'shippingAddress' => $this->shippingAddress->toArray());
 }
コード例 #2
0
 public function testIsEmptyWithNotEmptyObjectShouldReturnFalse()
 {
     $this->object->setCity('Test');
     $this->assertFalse($this->object->isEmpty());
 }
コード例 #3
0
 /**
  * @see OrderEntity::setBuyer()
  */
 public function testSetBuyer()
 {
     $address = array('street1' => 'street1_' . rand(1, 1000), 'street2' => 'street2_' . rand(1, 1000), 'city' => 'city_' . rand(1, 1000), 'state' => 'state_' . rand(1, 1000), 'country' => 'country_' . rand(1, 1000), 'postalCode' => 'postalCode_' . rand(1, 1000), 'phone' => 'phone_' . rand(1, 1000));
     $shippingAddress = new ShippingAddressEntity();
     $shippingAddress->setStreet1($address['street1'])->setStreet2($address['street2'])->setCity($address['city'])->setState($address['state'])->setCountry($address['country'])->setPostalCode($address['postalCode'])->setPhone($address['phone']);
     $buyerEntity = new BuyerEntity();
     $buyerEntity->setShippingAddress($shippingAddress);
     $buyer = array('fullName' => 'person name ' . rand(1, 9) . rand(1, 9) . rand(1, 9), 'emailAddress' => 'email' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '@foo-bar.com', 'dniNumber' => Cpf::random(), 'shippingAddress' => $address);
     $buyerEntity->setFullName($buyer['fullName'])->setEmailAddress($buyer['emailAddress'])->setDniNumber($buyer['dniNumber']);
     $this->object->setBuyer($buyerEntity);
     $rs = $this->object->getBuyer();
     $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\Order\\BuyerEntity', $rs);
     $this->assertEquals($buyer['fullName'], $rs->getFullName());
     $this->assertEquals($buyer['emailAddress'], $rs->getEmailAddress());
     $this->assertEquals($buyer['dniNumber'], $rs->getDniNumber());
     $shippingAddress = $rs->getShippingAddress();
     $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\ShippingAddressEntity', $shippingAddress);
     $this->assertEquals($shippingAddress->getStreet1(), $address['street1']);
     $this->assertEquals($shippingAddress->getStreet2(), $address['street2']);
     $this->assertEquals($shippingAddress->getCity(), $address['city']);
     $this->assertEquals($shippingAddress->getState(), $address['state']);
     $this->assertEquals($shippingAddress->getCountry(), $address['country']);
     $this->assertEquals($shippingAddress->getPostalCode(), $address['postalCode']);
     $this->assertEquals($shippingAddress->getPhone(), $address['phone']);
 }
コード例 #4
0
 /**
  * @see BuyerEntity::toArray()
  */
 public function testToArray()
 {
     $address = array('street1' => 'street1_' . rand(1, 1000), 'street2' => 'street2_' . rand(1, 1000), 'city' => 'city_' . rand(1, 1000), 'state' => 'state_' . rand(1, 1000), 'country' => 'country_' . rand(1, 1000), 'postalCode' => 'postalCode_' . rand(1, 1000), 'phone' => 'phone_' . rand(1, 1000));
     $shippingAddress = new ShippingAddressEntity();
     $shippingAddress->setStreet1($address['street1'])->setStreet2($address['street2'])->setCity($address['city'])->setState($address['state'])->setCountry($address['country'])->setPostalCode($address['postalCode'])->setPhone($address['phone']);
     $this->object->setShippingAddress($shippingAddress);
     $buyer = array('fullName' => 'person name ' . rand(1, 9) . rand(1, 9) . rand(1, 9), 'emailAddress' => 'email' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '@foo-bar.com', 'dniNumber' => Cpf::random(), 'shippingAddress' => $address);
     $this->object->setFullName($buyer['fullName'])->setEmailAddress($buyer['emailAddress'])->setDniNumber($buyer['dniNumber']);
     $rs = $this->object->toArray();
     $this->assertSame($buyer, $rs);
 }
コード例 #5
0
 /**
  * Provides a OK data to test authorization and capture.
  * @return array
  */
 public function providerMockTransaction()
 {
     $transaction = new TransactionEntity();
     //Transaction.
     $ipAddress = rand(1, 254) . '.' . rand(1, 254) . '.' . rand(1, 254) . '.' . rand(1, 254);
     $cookie = 'cookie_' . md5(rand(1000, 2000));
     $browsers = array('Safari', 'Chrome', 'Firefox', 'Opera', 'IE');
     $userAgent = $browsers[rand(0, count($browsers) - 1)];
     $transaction->setPaymentMethod(PaymentMethods::VISA)->setPaymentCountry(PaymentCountries::PANAMA)->setIpAddress($ipAddress)->setCookie($cookie)->setUserAgent($userAgent);
     //Transaction.
     //Shipping address.
     $shippingAddress = new ShippingAddressEntity();
     $shippingAddress->setStreet1('street1_' . rand(1, 1000))->setStreet2('street2_' . rand(1, 1000))->setCity('city_' . rand(1, 1000))->setState('state_' . rand(1, 1000))->setCountry(PaymentCountries::PANAMA)->setPostalCode('postalCode_' . rand(1, 1000))->setPhone('phone_' . rand(1, 1000));
     //Shipping address.
     //Order.
     $order = $transaction->getOrder();
     $order->setAccountId('accountId_' . rand(1, 9) . rand(1, 9) . rand(1, 9))->setReferenceCode('referenceCode_' . rand(1, 9) . rand(1, 9) . rand(1, 9))->setDescription('description_' . rand(1, 9) . rand(1, 9) . rand(1, 9))->setLanguage('en')->setNotifyUrl('http://notifyurl-' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '.com')->setSignature(sha1('signature'))->setShippingAddress($shippingAddress);
     //Order.
     //Buyer.
     $buyer = $order->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);
     //Buyer.
     //Additional values.
     $additionalValues = $order->getAdditionalValues();
     $additionalValues->addTax('TX_VALUE', 'USD', 100);
     //Additional values.
     //Credit card.
     $creditCard = $transaction->getCreditCard();
     $creditCard->setNumber('4111111111111111')->setSecurityCode(rand(1, 9) . rand(1, 9) . rand(1, 9))->setExpirationDate(rand(2015, 2020) . '/' . rand(10, 12))->setName('person name ' . rand(1, 9) . rand(1, 9) . rand(1, 9));
     //Credit card.
     //Payer.
     $billingAddress = new BillingAddressEntity();
     $billingAddress->setStreet1('street1_' . rand(1, 1000))->setStreet2('street2_' . rand(1, 1000))->setCity('city_' . rand(1, 1000))->setState('state_' . rand(1, 1000))->setCountry(PaymentCountries::PANAMA)->setPostalCode('postalCode_' . rand(1, 1000))->setPhone('phone_' . rand(1, 1000));
     $payer = $transaction->getPayer();
     $payer->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')->setContactPhone(rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9))->setDniNumber(Cpf::random())->setBillingAddress($billingAddress);
     //Payer.
     return array(array($transaction));
 }
コード例 #6
0
ファイル: OrderEntity.php プロジェクト: leonardothibes/payu
 /**
  * Generate array order.
  * @return array
  */
 public function toArray()
 {
     $return = array('accountId' => $this->accountId, 'referenceCode' => $this->referenceCode, 'description' => $this->description, 'language' => $this->language, 'notifyUrl' => $this->notifyUrl, 'signature' => $this->signature, 'buyer' => $this->buyer->toArray(), 'additionalValues' => $this->additionalValues->toArray());
     if (!$this->getShippingAddress()->isEmpty()) {
         $return = array_merge($return, array('shippingAddress' => $this->shippingAddress->toArray()));
     }
     return $return;
 }