/**
  * Provides a OK data to test cash collection.
  * @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)];
     $paymentMethods = array(PaymentMethods::BAPRO, PaymentMethods::COBRO_EXPRESS, PaymentMethods::PAGOFACIL, PaymentMethods::RAPIPAGO, PaymentMethods::RIPSA);
     $paymentMethod = $paymentMethods[rand(0, count($paymentMethods) - 1)];
     $transaction->setPaymentMethod($paymentMethod)->setPaymentCountry(PaymentCountries::ARGENTINA)->setIpAddress($ipAddress)->setCookie($cookie)->setUserAgent($userAgent);
     //Transaction.
     //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'));
     //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());
     //Buyer.
     //Additional values.
     $additionalValues = $order->getAdditionalValues();
     $additionalValues->addTax('TX_VALUE', PaymentCurrency::ARGENTINA, 100);
     //Additional values.
     //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));
 }
示例#2
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']);
 }
示例#3
0
 /**
  * @see \Tbs\Helper\Cpf::random()
  */
 public function testRandom()
 {
     for ($i = 1; $i <= 5; $i++) {
         $rs = cpf::random();
         $this->assertEquals(11, strlen($rs));
         $this->assertTrue(is_numeric($rs));
         $this->assertTrue(cpf::isValid($rs));
         $rs = cpf::random(true);
         $this->assertRegExp('/^[0-9]{3}\\.[0-9]{3}\\.[0-9]{3}\\-[0-9]{2}$/', $rs);
         $this->assertTrue(cpf::isValid($rs));
     }
 }
示例#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));
 }