/** * 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)); }
/** * @see RequestEntity::setTransaction() * @dataProvider providerTransactionMockData */ public function testSetTransaction($type, $paymentMethod, $paymentCountry, $ipAddress, $cookie, $userAgent) { $transaction = new TransactionEntity(); $transaction->setType($type)->setPaymentMethod($paymentMethod)->setPaymentCountry($paymentCountry)->setIpAddress($ipAddress)->setCookie($cookie)->setUserAgent($userAgent); $rs = $this->object->setTransaction($transaction); $this->assertInstanceOf('\\PayU\\Entity\\RequestEntity', $rs); $rs = $this->object->getTransaction(); $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\TransactionEntity', $rs); $this->assertEquals($type, $rs->getType()); $this->assertEquals($paymentMethod, $rs->getPaymentMethod()); $this->assertEquals($paymentCountry, $rs->getPaymentCountry()); $this->assertEquals($ipAddress, $rs->getIpAddress()); $this->assertEquals($cookie, $rs->getCookie()); $this->assertEquals($userAgent, $rs->getUserAgent()); }
/** * @see TransactionEntity::toArray() */ public function testToArray() { $rs = $this->object->toArray(); $this->assertArrayHasKey('expiration', $rs); $this->assertArrayHasKey('type', $rs); $this->assertArrayHasKey('paymentMethod', $rs); $this->assertArrayHasKey('paymentCountry', $rs); $this->assertArrayHasKey('ipAddress', $rs); $this->assertArrayHasKey('cookie', $rs); $this->assertArrayHasKey('userAgent', $rs); $this->assertArrayHasKey('order', $rs); $this->assertArrayHasKey('creditCard', $rs); $this->assertArrayHasKey('payer', $rs); $this->assertArrayHasKey('extraParameters', $rs); }
/** * Make a cash collection request for payment order. * * @param TransactionEntity $transaction * @param int $expiration * * @return stdClass */ public function cashCollection(TransactionEntity $transaction, $expiration = 4) { $this->xmlRequest->addChild('isTest', 'false'); $transaction->setType(PaymentTypes::AUTHORIZATION_AND_CAPTURE)->setExpiration($expiration); return $this->authorizeRequest($transaction); }
/** * 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)); }
/** * Generate arry order. * @return array */ public function toArray() { return array('transaction' => $this->transaction->toArray()); }