diff --git a/test/Integration/Gateways/TransITConnector/CommercialCardTest.php b/test/Integration/Gateways/TransITConnector/CommercialCardTest.php index 9bac8fe0..f3cafac1 100644 --- a/test/Integration/Gateways/TransITConnector/CommercialCardTest.php +++ b/test/Integration/Gateways/TransITConnector/CommercialCardTest.php @@ -1,221 +1,221 @@ -getConfig()); - } - - protected function getConfig() { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322602'; - $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; - $config->developerId = '003226G001'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - $config->acceptorConfig = new AcceptorConfig(); - return $config; - } - - protected function getAddy() { - $addy = new Address(); - $addy->streetAddress1 = 'address line 1 contents'; - $addy->postalCode = '47130'; - return $addy; - } - - protected function getVisaManual() { - $visaManual = new CreditCardData(); - $visaManual->number = '4012000098765439'; - $visaManual->expMonth = 12; - $visaManual->expYear = TestCards::validCardExpYear(); - $visaManual->cvn = '999'; - return $visaManual; - } - - protected function getMasterCardManual() { - $masterCardManual = new CreditCardData(); - $masterCardManual->number = '5146315000000055'; - $masterCardManual->expMonth = 12; - $masterCardManual->expYear = TestCards::validCardExpYear(); - $masterCardManual->cvn = '998'; - return $masterCardManual; - } - - protected function getAmexManual() { - $amexManual = new CreditCardData(); - $amexManual->number = "371449635392376"; - $amexManual->expMonth = 12; - $amexManual->expYear = TestCards::validCardExpYear(); - $amexManual->cvn = "9997"; - return $amexManual; - } - - // These are all stolen from dotnet cert file - public function test01VisaManualLevelII() { - $commercialData = new CommercialData(TaxType::NOT_USED); - $commercialData->poNumber = '9876543210'; - $commercialData->taxAmount = 0; - - $response = $this->getVisaManual()->charge(52) - ->withCurrency("USD") - ->withCommercialData($commercialData) - ->withAddress($this->getAddy()) - ->withDescription("Test_001_Visa_Level_II_Sale") - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test02MasterCardManualLevelII() { - $commercialData = new CommercialData(TaxType::SALES_TAX); - $commercialData->poNumber = '9876543210'; - $commercialData->taxAmount = .02; - - $response = $this->getMasterCardManual()->charge(.52) - ->withCurrency("USD") - ->withCommercialData($commercialData) - ->withAddress($this->getAddy()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test03AmexManualLevelII() { - $commercialData = new CommercialData(TaxType::NOT_USED); - $commercialData->supplierReferenceNumber = "123456"; - $commercialData->customerReferenceId = "987654"; - $commercialData->destinationPostalCode = "85284"; - $commercialData->description = "AMEX LEVEL 2 TEST CASE"; - $commercialData->taxAmount = 0; - - $response = $this->getAmexManual()->charge(1.50) - ->withCurrency('USD') - ->withCommercialData($commercialData) - ->withAddress($this->getAddy()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test04VisaManualLevelIII() { - $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); - $commercialData->poNumber = 1784951399984509620; - $commercialData->taxAmount = .01; - $commercialData->destinationPostalCode = '85212'; - $commercialData->destinationCountryCode = "USA"; - $commercialData->originPostalCode = "22193"; - $commercialData->summaryCommodityCode = "SCC"; - $commercialData->customerVatNumber = "123456789"; - $commercialData->vatInvoiceNumber = "UVATREF162"; - $commercialData->orderDate = date('m/d/Y'); - $commercialData->freightAmount = 0.01; - $commercialData->dutyAmount = 0.01; - $commercialData->additionalTaxDetails = new AdditionalTaxDetails( - .01, - TaxCategory::VAT, - .04, - "VAT" - ); - - $lineItem1 = new CommercialLineItem; - $lineItem1->productCode = "PRDCD1"; - $lineItem1->name = "PRDCD1NAME"; - $lineItem1->unitCost = 0.01; - $lineItem1->quantity = 1; - $lineItem1->unitOfMeasure = "METER"; - $lineItem1->description = "PRODUCT 1 NOTES"; - $lineItem1->commodityCode = "12DIGIT ACCO"; - $lineItem1->alternateTaxId = "1234567890"; - $lineItem1->creditDebitIndicator = CreditDebitIndicator::CREDIT; - $lineItem1->discountDetails = new DiscountDetails( - .50, - "Indep Sale 1", - .1, - "SALE" - ); - - $lineItem2 = new CommercialLineItem; - $lineItem2->productCode = "PRDCD2"; - $lineItem2->name = "PRDCD2NAME"; - $lineItem2->unitCost = 0.01; - $lineItem2->quantity = 1; - $lineItem2->unitOfMeasure = "METER"; - $lineItem2->description = "PRODUCT 2 NOTES"; - $lineItem2->commodityCode = "12DIGIT ACCO"; - $lineItem2->alternateTaxId = "1234567890"; - $lineItem2->creditDebitIndicator = CreditDebitIndicator::DEBIT; - $lineItem2->discountDetails = new DiscountDetails( - .50, - "Indep Sale 1", - .1, - "SALE" - ); - - $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times - - $response = $this->getVisaManual()->charge(.53) - ->withCurrency('USD') - ->withCommercialData($commercialData) - ->withAddress($this->getAddy()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test05MasterCardManualLevelIII() { - $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); - $commercialData->poNumber = "9876543210"; - $commercialData->taxAmount = 0.01; - $commercialData->destinationPostalCode = "85212"; - $commercialData->destinationCountryCode = "USA"; - $commercialData->originPostalCode = "22193"; - $commercialData->summaryCommodityCode = "SCC"; - $commercialData->customerVatNumber = "123456789"; - $commercialData->vatInvoiceNumber = "UVATREF162"; - $commercialData->orderDate = date('m/d/Y'); - $commercialData->freightAmount = 0.01; - $commercialData->dutyAmount = 0.01; - $commercialData->additionalTaxDetails = new AdditionalTaxDetails(.01, TaxCategory::VAT, .04, "VAT"); - - $lineItem = new CommercialLineItem; - $lineItem->productCode = "PRDCD1"; - $lineItem->name = "PRDCD1NAME"; - $lineItem->unitCost = 0.01; - $lineItem->quantity = 1; - $lineItem->unitOfMeasure = "METER"; - $lineItem->description = "PRODUCT 1 NOTES"; - $lineItem->commodityCode = "12DIGIT ACCO"; - $lineItem->alternateTaxId = "1234567890"; - $lineItem->creditDebitIndicator = CreditDebitIndicator::CREDIT; - $commercialData->addLineItems($lineItem); - - $response = $this->getMasterCardManual()->charge(.53) - ->withCurrency('USD') - ->withCommercialData($commercialData) - ->withAddress($this->getAddy()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } -} +getConfig()); + } + + protected function getConfig() { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); + return $config; + } + + protected function getAddy() { + $addy = new Address(); + $addy->streetAddress1 = 'address line 1 contents'; + $addy->postalCode = '47130'; + return $addy; + } + + protected function getVisaManual() { + $visaManual = new CreditCardData(); + $visaManual->number = '4012000098765439'; + $visaManual->expMonth = 12; + $visaManual->expYear = TestCards::validCardExpYear(); + $visaManual->cvn = '999'; + return $visaManual; + } + + protected function getMasterCardManual() { + $masterCardManual = new CreditCardData(); + $masterCardManual->number = '5146315000000055'; + $masterCardManual->expMonth = 12; + $masterCardManual->expYear = TestCards::validCardExpYear(); + $masterCardManual->cvn = '998'; + return $masterCardManual; + } + + protected function getAmexManual() { + $amexManual = new CreditCardData(); + $amexManual->number = "371449635392376"; + $amexManual->expMonth = 12; + $amexManual->expYear = TestCards::validCardExpYear(); + $amexManual->cvn = "9997"; + return $amexManual; + } + + // These are all stolen from dotnet cert file + public function test01VisaManualLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = 0; + + $response = $this->getVisaManual()->charge(52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->withDescription("Test_001_Visa_Level_II_Sale") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test02MasterCardManualLevelII() { + $commercialData = new CommercialData(TaxType::SALES_TAX); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = .02; + + $response = $this->getMasterCardManual()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test03AmexManualLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->supplierReferenceNumber = "123456"; + $commercialData->customerReferenceId = "987654"; + $commercialData->destinationPostalCode = "85284"; + $commercialData->description = "AMEX LEVEL 2 TEST CASE"; + $commercialData->taxAmount = 0; + + $response = $this->getAmexManual()->charge(1.50) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test04VisaManualLevelIII() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = 1784951399984509620; + $commercialData->taxAmount = .01; + $commercialData->destinationPostalCode = '85212'; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails( + .01, + TaxCategory::VAT, + .04, + "VAT" + ); + + $lineItem1 = new CommercialLineItem; + $lineItem1->productCode = "PRDCD1"; + $lineItem1->name = "PRDCD1NAME"; + $lineItem1->unitCost = 0.01; + $lineItem1->quantity = 1; + $lineItem1->unitOfMeasure = "METER"; + $lineItem1->description = "PRODUCT 1 NOTES"; + $lineItem1->commodityCode = "12DIGIT ACCO"; + $lineItem1->alternateTaxId = "1234567890"; + $lineItem1->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $lineItem1->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + + $lineItem2 = new CommercialLineItem; + $lineItem2->productCode = "PRDCD2"; + $lineItem2->name = "PRDCD2NAME"; + $lineItem2->unitCost = 0.01; + $lineItem2->quantity = 1; + $lineItem2->unitOfMeasure = "METER"; + $lineItem2->description = "PRODUCT 2 NOTES"; + $lineItem2->commodityCode = "12DIGIT ACCO"; + $lineItem2->alternateTaxId = "1234567890"; + $lineItem2->creditDebitIndicator = CreditDebitIndicator::DEBIT; + $lineItem2->discountDetails = new DiscountDetails( + .50, + "Indep Sale 1", + .1, + "SALE" + ); + + $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times + + $response = $this->getVisaManual()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test05MasterCardManualLevelIII() { + $commercialData = new CommercialData(TaxType::NOT_USED, CommercialIndicator::LEVEL_III); + $commercialData->poNumber = "9876543210"; + $commercialData->taxAmount = 0.01; + $commercialData->destinationPostalCode = "85212"; + $commercialData->destinationCountryCode = "USA"; + $commercialData->originPostalCode = "22193"; + $commercialData->summaryCommodityCode = "SCC"; + $commercialData->customerVatNumber = "123456789"; + $commercialData->vatInvoiceNumber = "UVATREF162"; + $commercialData->orderDate = date('m/d/Y'); + $commercialData->freightAmount = 0.01; + $commercialData->dutyAmount = 0.01; + $commercialData->additionalTaxDetails = new AdditionalTaxDetails(.01, TaxCategory::VAT, .04, "VAT"); + + $lineItem = new CommercialLineItem; + $lineItem->productCode = "PRDCD1"; + $lineItem->name = "PRDCD1NAME"; + $lineItem->unitCost = 0.01; + $lineItem->quantity = 1; + $lineItem->unitOfMeasure = "METER"; + $lineItem->description = "PRODUCT 1 NOTES"; + $lineItem->commodityCode = "12DIGIT ACCO"; + $lineItem->alternateTaxId = "1234567890"; + $lineItem->creditDebitIndicator = CreditDebitIndicator::CREDIT; + $commercialData->addLineItems($lineItem); + + $response = $this->getMasterCardManual()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAddy()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/TransITConnector/TransITAdminTest.php b/test/Integration/Gateways/TransITConnector/TransITAdminTest.php index 9edf946b..0ffd187e 100644 --- a/test/Integration/Gateways/TransITConnector/TransITAdminTest.php +++ b/test/Integration/Gateways/TransITConnector/TransITAdminTest.php @@ -1,93 +1,97 @@ -card = TestCards::visaManual(); - - ServicesContainer::configure($this->getConfig()); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322602'; - $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; - $config->developerId = '003226G001'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - - return $config; - } - - public function testTokenizeCardKeyed() - { - $token = $this->card->tokenize()->execute(); - $this->assertNotNull($token); - $this->assertEquals('00', $token->responseCode); - $this->assertNotNull($token->token); - } - - public function testCreateManifest() - { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322602'; - $config->developerId = '003226G001'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - - ServicesContainer::configure($config); - $provider = ServicesContainer::instance()->getClient(); - - //create Transaction Key - $response = $provider->getTransactionKey(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->transactionKey); - - //create Manifest - $provider->transactionKey = $response->transactionKey; - $manifest = $provider->createManifest(); - - $this->assertNotNull($manifest); - } - - public function testDisableTransactionKey() - { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322602'; - $config->developerId = '003226G001'; - //TransactionKey needs to be disabled. Throw 'Invalid Transaction Key' when key is not in active state - $config->transactionKey = 'F508Z7TIGFORSTDYJQLMK9NGFFPBIXV0'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - - ServicesContainer::configure($config); - $provider = ServicesContainer::instance()->getClient(); - - //create new Transaction Key - $response = $provider->getTransactionKey(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->transactionKey); - } -} +card = TestCards::visaManual(); + + ServicesContainer::configureService($this->getConfig()); + } + + protected function getConfig() + { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); + + return $config; + } + + public function testTokenizeCardKeyed() + { + $token = $this->card->tokenize()->execute(); + $this->assertNotNull($token); + $this->assertEquals('00', $token->responseCode); + $this->assertNotNull($token->token); + } + + public function testCreateManifest() + { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); + + ServicesContainer::configureService($config); + $provider = ServicesContainer::instance()->getClient(); + + //create Transaction Key + $response = $provider->getTransactionKey(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->transactionKey); + + //create Manifest + $provider->transactionKey = $response->transactionKey; + $manifest = $provider->createManifest(); + + $this->assertNotNull($manifest); + } + + public function testDisableTransactionKey() + { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->developerId = '003226G001'; + //TransactionKey needs to be disabled. Throw 'Invalid Transaction Key' when key is not in active state + $config->transactionKey = 'F508Z7TIGFORSTDYJQLMK9NGFFPBIXV0'; + $config->acceptorConfig = new AcceptorConfig(); + $config->gatewayProvider = GatewayProvider::TRANSIT; + + ServicesContainer::configureService($config); + $provider = ServicesContainer::instance()->getClient(); + + //create new Transaction Key + $response = $provider->getTransactionKey(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->transactionKey); + } +} diff --git a/test/Integration/Gateways/TransITConnector/TransITDebitTest.php b/test/Integration/Gateways/TransITConnector/TransITDebitTest.php index f6d0fd6f..8251e6d7 100644 --- a/test/Integration/Gateways/TransITConnector/TransITDebitTest.php +++ b/test/Integration/Gateways/TransITConnector/TransITDebitTest.php @@ -1,54 +1,53 @@ -track = new DebitTrackData(); - - $encryptionData = new EncryptionData(); - $encryptionData->version = '01'; - $encryptionData->ksn = '000000000000000'; - - $this->track->encryptionData = $encryptionData; - $this->track->pinBlock = '0000'; - $this->track->setValue(';'); - - ServicesContainer::configure($this->getConfig()); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322602'; - $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; - $config->developerId = '003226G001'; - - $config->gatewayProvider = GatewayProvider::TRANSIT; - return $config; - } - - public function testDebitSale() - { - $response = $this->track->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } -} +track = new DebitTrackData(); + + $encryptionData = new EncryptionData(); + $encryptionData->version = '01'; + $encryptionData->ksn = '000000000000000'; + + $this->track->encryptionData = $encryptionData; + $this->track->pinBlock = '0000'; + $this->track->setValue(';'); + + ServicesContainer::configureService($this->getConfig()); + } + + protected function getConfig() + { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->acceptorConfig = new AcceptorConfig(); + return $config; + } + + public function testDebitSale() + { + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/TransITConnector/TransITTests.php b/test/Integration/Gateways/TransITConnector/TransITTests.php index e6814e59..c1b476d0 100644 --- a/test/Integration/Gateways/TransITConnector/TransITTests.php +++ b/test/Integration/Gateways/TransITConnector/TransITTests.php @@ -1,323 +1,325 @@ -getConfig()); - - $this->address = new Address(); - $this->address->streetAddress1 = '1 Federal Street'; - $this->address->postalCode = '02110'; - - $this->card = TestCards::masterCardManual(); - - $this->track = new CreditTrackData(); - $this->track->setValue(';'); - - $this->tokenizedCard = new CreditCardData(); - $this->tokenizedCard->token = '5RpF5t9Asb9U6527'; - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322602'; - $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; - $config->developerId = '003226G001'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - return $config; - } - - public function testAdjustTip() - { - $response = $this->card->charge(10) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $adjust = $response->edit() - ->withGratuity(1.05) - ->execute(); - - $this->assertNotNull($adjust); - $this->assertEquals('00', $response->responseCode); - } - - public function testAuthorizeKeyed() - { - $response = $this->card->authorize(10) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertFalse($response->avsResponseCode == '0'); // verify an AVS response of some sort - } - - public function testAuthorizeSwiped() - { - $response = $this->track->authorize(100) - ->withCurrency('USD') - ->withInvoiceNumber('1264') - ->withClientTransactionId('137149') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testAuthorizeToken() - { - $response = $this->tokenizedCard->authorize(10) - ->withCurrency('USD') - ->withInvoiceNumber('1558') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testTokenizedCardSale() - { - $token = $this->card->tokenize()->execute(); - $this->assertNotNull($token); - $this->assertEquals('00', $token->responseCode); - $this->assertNotNull($token->token); - - $tokenizedCard = new CreditCardData(); - $tokenizedCard->token = $token->token; - - $response = $tokenizedCard->charge(10) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testBalanceInquiry() - { - $response = $this->card->balanceInquiry() - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCapture() - { - $response = $this->card->authorize(10) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $captureResponse = $response->capture()->execute(); - - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testSaleKeyed() - { - - $response = $this->card->charge(100) - ->withCurrency('USD') - ->withAllowDuplicates(false) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testSaleSwiped() - { - $response = $this->track->charge(100) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testSaleToken() - { - $response = $this->tokenizedCard->charge(1.29) - ->withCurrency('USD') - ->withCashBack(0) - ->withConvenienceAmount(0) - ->withInvoiceNumber('1559') - ->withClientTransactionId('166909') - ->withAllowPartialAuth(false) - ->withAllowDuplicates(false) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Response not mapping correctly - public function testSettleBatch() - { - $response = BatchService::closeBatch(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->batchSummary); - $this->assertNotNull($response->batchSummary->totalAmount); - } - - public function testVoid() - { - $response = $this->card->charge(10) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $response->void() - ->withDescription('DEVICE_UNAVAILABLE') - ->execute(); - - $this->assertNotNull($voidResponse); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function testVerify() - { - $response = $this->card->verify() - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRequestMUTOnSale() { - $response = $this->card->charge(12.34) - ->withCurrency('USD') - ->withRequestMultiUseToken(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertNotNull($response->token); - } - - public function testRefund() - { - $response = $this->card->charge(10) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $refundResponse = $response->refund() - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($refundResponse); - $this->assertEquals('00', $refundResponse->responseCode); - } - - public function testRefundByCard() - { - $response = $this->card->refund(15.11) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRefundBySwipe() - { - $response = $this->track->refund(15.11) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testSaleSwipedTrack1Pattern() - { - $this->track = new CreditTrackData(); - $this->track->setValue('%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332'); - - $response = $this->track->charge(10) - ->withCurrency('USD') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type. - */ - public function testAuthorizeWithoutAmount() - { - $response = $this->card->authorize() - ->withCurrency('USD') - ->execute(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type. - */ - public function testSaleWithoutAmount() - { - $response = $this->card->charge() - ->withCurrency('USD') - ->execute(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type. - */ - public function testRefundWithoutAmount() - { - $response = $this->card->refund() - ->withCurrency('USD') - ->execute(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\ConfigurationException - * @expectedExceptionMessage deviceID is required for this configuration. - */ - public function testCredentialsError() - { - $config = new ServicesConfig(); - $config->gatewayProvider = GatewayProvider::TRANSIT; - - ServicesContainer::configure($config); - } -} +getConfig()); + + $this->address = new Address(); + $this->address->streetAddress1 = '1 Federal Street'; + $this->address->postalCode = '02110'; + + $this->card = TestCards::masterCardManual(); + + $this->track = new CreditTrackData(); + $this->track->setValue(';'); + + $this->tokenizedCard = new CreditCardData(); + $this->tokenizedCard->token = '5RpF5t9Asb9U6527'; + } + + protected function getConfig() + { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322602'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->acceptorConfig = new AcceptorConfig(); + return $config; + } + + public function testAdjustTip() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $adjust = $response->edit() + ->withGratuity(1.05) + ->execute(); + + $this->assertNotNull($adjust); + $this->assertEquals('00', $response->responseCode); + } + + public function testAuthorizeKeyed() + { + $response = $this->card->authorize(10) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertFalse($response->avsResponseCode == '0'); // verify an AVS response of some sort + } + + public function testAuthorizeSwiped() + { + $response = $this->track->authorize(100) + ->withCurrency('USD') + ->withInvoiceNumber('1264') + ->withClientTransactionId('137149') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testAuthorizeToken() + { + $response = $this->tokenizedCard->authorize(10) + ->withCurrency('USD') + ->withInvoiceNumber('1558') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testTokenizedCardSale() + { + $token = $this->card->tokenize()->execute(); + $this->assertNotNull($token); + $this->assertEquals('00', $token->responseCode); + $this->assertNotNull($token->token); + + $tokenizedCard = new CreditCardData(); + $tokenizedCard->token = $token->token; + + $response = $tokenizedCard->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testBalanceInquiry() + { + $response = $this->card->balanceInquiry() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCapture() + { + $response = $this->card->authorize(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $captureResponse = $response->capture()->execute(); + + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testSaleKeyed() + { + + $response = $this->card->charge(100) + ->withCurrency('USD') + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleSwiped() + { + $response = $this->track->charge(100) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleToken() + { + $response = $this->tokenizedCard->charge(1.29) + ->withCurrency('USD') + ->withCashBack(0) + ->withConvenienceAmount(0) + ->withInvoiceNumber('1559') + ->withClientTransactionId('166909') + ->withAllowPartialAuth(false) + ->withAllowDuplicates(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Response not mapping correctly + public function testSettleBatch() + { + $response = BatchService::closeBatch(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->batchSummary); + $this->assertNotNull($response->batchSummary->totalAmount); + } + + public function testVoid() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->withDescription('DEVICE_UNAVAILABLE') + ->execute(); + + $this->assertNotNull($voidResponse); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function testVerify() + { + $response = $this->card->verify() + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRequestMUTOnSale() { + $response = $this->card->charge(12.34) + ->withCurrency('USD') + ->withRequestMultiUseToken(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertNotNull($response->token); + } + + public function testRefund() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $refundResponse = $response->refund() + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($refundResponse); + $this->assertEquals('00', $refundResponse->responseCode); + } + + public function testRefundByCard() + { + $response = $this->card->refund(15.11) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRefundBySwipe() + { + $response = $this->track->refund(15.11) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testSaleSwipedTrack1Pattern() + { + $this->track = new CreditTrackData(); + $this->track->setValue('%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332'); + + $response = $this->track->charge(10) + ->withCurrency('USD') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type. + */ + public function testAuthorizeWithoutAmount() + { + $response = $this->card->authorize() + ->withCurrency('USD') + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type. + */ + public function testSaleWithoutAmount() + { + $response = $this->card->charge() + ->withCurrency('USD') + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type. + */ + public function testRefundWithoutAmount() + { + $response = $this->card->refund() + ->withCurrency('USD') + ->execute(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\ConfigurationException + * @expectedExceptionMessage deviceID is required for this configuration. + */ + public function testCredentialsError() + { + $config = new TransitConfig(); + $config->acceptorConfig = new AcceptorConfig(); + + ServicesContainer::configureService($config); + } +}