diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1993192d..4607ddf2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,48 +1,48 @@ - - - - - - - - - - - - ./test/ - - - ./test/Unit/ - - - ./test/Integration/ - - - ./test/Integration/Gateways/PorticoConnector/Certifications/ - ./test/Integration/Gateways/RealexConnector/Certifications/ - - - ./test/Integration/Gateways/PorticoConnector/ - - - ./test/Integration/Gateways/RealexConnector/ - - - - - - - ./src/ - - ./test/ - - - - - + + + + + + + + + + + + ./test/ + + + ./test/Unit/ + + + ./test/Integration/ + + + ./test/Integration/Gateways/PorticoConnector/Certifications/ + ./test/Integration/Gateways/RealexConnector/Certifications/ + + + ./test/Integration/Gateways/PorticoConnector/ + + + ./test/Integration/Gateways/RealexConnector/ + + + + + + + ./src/ + + ./test/ + + + + + diff --git a/sami.phar b/sami.phar deleted file mode 100644 index c341b043..00000000 Binary files a/sami.phar and /dev/null differ diff --git a/src/Entities/RecurringEntity.php b/src/Entities/RecurringEntity.php index 3f546dd6..c88cc9ba 100644 --- a/src/Entities/RecurringEntity.php +++ b/src/Entities/RecurringEntity.php @@ -1,110 +1,111 @@ - - */ -abstract class RecurringEntity implements IRecurringEntity -{ - /** - * All resource should be supplied a merchant-/application-defined ID. - * - * @var string - */ - public $id; - - /** - * All resources should be supplied a gateway-defined ID. - * - * @var string - */ - public $key; - - /** - * {@inheritDoc} - */ - public function create() - { - return RecurringService::create($this); - } - - /** - * {@inheritDoc} - */ - public function delete($force = false) - { - try { - return RecurringService::delete($this, $force); - } catch (ApiException $exc) { - throw new ApiException('Failed to delete record, see inner exception for more details', $exc); - } - } - - /** - * {@inheritDoc} - */ - public static function find($id, $configName = 'default') - { - $client = ServicesContainer::instance()->getRecurringClient($configName); - if (!$client->supportsRetrieval) { - throw new UnsupportedTransactionException(); - } - - $identifier = static::getIdentifierName(); - $response = RecurringService::search(static::class) - ->addSearchCriteria($identifier, $id) - ->execute(); - $entity = isset($response[0]) ? $response[0] : null; - - if ($entity !== null) { - return RecurringService::get($entity); - } - - return null; - } - - /** - * {@inheritDoc} - */ - public static function findAll($configName = 'default') - { - $client = ServicesContainer::instance()->getRecurringClient($configName); - if (!$client->supportsRetrieval) { - throw new UnsupportedTransactionException(); - } - - return RecurringService::search(static::class)->execute(); - } - - /** - * {@inheritDoc} - */ - public function saveChanges($configName = 'default') - { - try { - return RecurringService::edit($this); - } catch (ApiException $exc) { - throw new ApiException('Update failed, see inner exception for more details', $exc); - } - } - - protected static function getIdentifierName() - { - if (static::class === Customer::class) { - return 'customerIdentifier'; - } elseif (static::class === RecurringPaymentMethod::class) { - return 'paymentMethodIdentifier'; - } elseif (static::class === Schedule::class) { - return 'scheduleIdentifier'; - } - return ''; - } -} + + */ +abstract class RecurringEntity implements IRecurringEntity +{ + /** + * All resource should be supplied a merchant-/application-defined ID. + * + * @var string + */ + public $id; + + /** + * All resources should be supplied a gateway-defined ID. + * + * @var string + */ + public $key; + + /** + * {@inheritDoc} + */ + public function create() + { + return RecurringService::create($this); + } + + /** + * {@inheritDoc} + */ + public function delete($force = false) + { + try { + return RecurringService::delete($this, $force); + } catch (ApiException $exc) { + throw new ApiException('Failed to delete record, see inner exception for more details', $exc); + } + } + + /** + * {@inheritDoc} + */ + public static function find($id, $configName = 'default') + { + $client = ServicesContainer::instance()->getRecurringClient($configName); + if (!$client->supportsRetrieval) { + throw new UnsupportedTransactionException(); + } + + $identifier = static::getIdentifierName(); + $response = RecurringService::search(static::class) + ->addSearchCriteria($identifier, $id) + ->execute(); + + foreach ($response as $entity) { + if ($entity->id === $id) { + return RecurringService::get($entity); + } + } + + return null; + } + + /** + * {@inheritDoc} + */ + public static function findAll($configName = 'default') + { + $client = ServicesContainer::instance()->getRecurringClient($configName); + if (!$client->supportsRetrieval) { + throw new UnsupportedTransactionException(); + } + + return RecurringService::search(static::class)->execute(); + } + + /** + * {@inheritDoc} + */ + public function saveChanges($configName = 'default') + { + try { + return RecurringService::edit($this); + } catch (ApiException $exc) { + throw new ApiException('Update failed, see inner exception for more details', $exc); + } + } + + protected static function getIdentifierName() + { + if (static::class === Customer::class) { + return 'customerIdentifier'; + } elseif (static::class === RecurringPaymentMethod::class) { + return 'paymentMethodIdentifier'; + } elseif (static::class === Schedule::class) { + return 'scheduleIdentifier'; + } + return ''; + } +} diff --git a/src/ServiceConfigs/Gateways/TransitConfig.php b/src/ServiceConfigs/Gateways/TransitConfig.php index 23961027..ac853fe0 100644 --- a/src/ServiceConfigs/Gateways/TransitConfig.php +++ b/src/ServiceConfigs/Gateways/TransitConfig.php @@ -1,63 +1,66 @@ -gatewayProvider = GatewayProvider::TRANSIT; - } - - public function configureContainer($services) { - - $gateway = new TransITConnector(); - $gateway->deviceId = $this->deviceId; - $gateway->developerId = $this->developerId; - $gateway->timeout = $this->timeout; - $gateway->serviceUrl = $this->serviceUrl; - $gateway->requestLogger = $this->requestLogger; - $gateway->acceptorConfig = $this->acceptorConfig; - $gateway->merchantId = $this->merchantId; - $gateway->transactionKey = $this->transactionKey; - - if (empty($this->serviceUrl)) { - $gateway->serviceUrl = $this->environment == Environment::TEST ? ServiceEndpoints::TRANSIT_TEST : ServiceEndpoints::TRANSIT_PRODUCTION; - } - - $services->gatewayConnector = $gateway; - } - - public function validate() - { - parent::validate(); - - if ($this->acceptorConfig == null) { - throw new ConfigurationException("You must provide a valid AcceptorConfig."); - } else { - $this->acceptorConfig->validate(); - } - - if (empty($this->deviceId)) { - throw new ConfigurationException("DeviceId cannot be null."); - } - - if (empty($this->merchantId)) { - throw new ConfigurationException("MerchantId cannot be null."); - } - } -} +gatewayProvider = GatewayProvider::TRANSIT; + } + + public function configureContainer($services) { + + $gateway = new TransITConnector(); + $gateway->deviceId = $this->deviceId; + $gateway->developerId = $this->developerId; + $gateway->timeout = $this->timeout; + $gateway->serviceUrl = $this->serviceUrl; + $gateway->requestLogger = $this->requestLogger; + $gateway->acceptorConfig = $this->acceptorConfig; + $gateway->merchantId = $this->merchantId; + $gateway->transactionKey = $this->transactionKey; + $gateway->userId = $this->username; + $gateway->password = $this->password; + + if (empty($this->serviceUrl)) { + $gateway->serviceUrl = $this->environment == Environment::TEST ? ServiceEndpoints::TRANSIT_TEST : ServiceEndpoints::TRANSIT_PRODUCTION; + } + + $services->gatewayConnector = $gateway; + } + + public function validate() + { + parent::validate(); + + if ($this->acceptorConfig == null) { + throw new ConfigurationException("You must provide a valid AcceptorConfig."); + } else { + $this->acceptorConfig->validate(); + } + + if (empty($this->deviceId)) { + throw new ConfigurationException("DeviceId cannot be null."); + } + + if (empty($this->merchantId)) { + throw new ConfigurationException("MerchantId cannot be null."); + } + } +} diff --git a/src/ServicesConfig.php b/src/ServicesConfig.php new file mode 100644 index 00000000..8ed69065 --- /dev/null +++ b/src/ServicesConfig.php @@ -0,0 +1,43 @@ +gatewayConfig)) { + $this->gatewayConfig->validate(); + } + + if (!empty($this->deviceConnectionConfig)) { + $this->deviceConnectionConfig->validate(); + } + + if (!empty($this->tableServiceConfig)) { + $this->tableServiceConfig->validate(); + } + + if (!empty($this->payrollConfig)) { + $this->payrollConfig->validate(); + } + } +} diff --git a/test/Data/TestChecks.php b/test/Data/TestChecks.php index 70eadaee..22cb4b05 100644 --- a/test/Data/TestChecks.php +++ b/test/Data/TestChecks.php @@ -1,37 +1,37 @@ -accountNumber = '24413815'; - $check->routingNumber = '490000018'; - $check->checkType = $checkType; - $check->accountType = $accountType; - $check->secCode = $secCode; - $check->entryMode = EntryMethod::MANUAL; - $check->checkHolderName = 'John Doe'; - $check->driversLicenseNumber = '09876543210'; - $check->driversLicenseState = 'TX'; - $check->phoneNumber = '8003214567'; - $check->birthYear = '1997'; - $check->ssnLast4 = '4321'; - if (!empty($checkHolderName)) { - $check->checkHolderName = $checkHolderName; - } - return $check; - } -} +accountNumber = '1357902468'; + $check->routingNumber = '122000030'; + $check->checkType = $checkType; + $check->accountType = $accountType; + $check->secCode = $secCode; + $check->entryMode = EntryMethod::MANUAL; + $check->checkHolderName = 'John Doe'; + $check->driversLicenseNumber = '09876543210'; + $check->driversLicenseState = 'TX'; + $check->phoneNumber = '8003214567'; + $check->birthYear = '1997'; + $check->ssnLast4 = '4321'; + if (!empty($checkHolderName)) { + $check->checkHolderName = $checkHolderName; + } + return $check; + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.php index 3077c4ef..4a32f6d2 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.php @@ -1,481 +1,378 @@ -secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - protected function setup() - { - ServicesContainer::configure($this->config()); - - $this->address = new Address(); - $this->address->streetAddress1 = '123 Main St.'; - $this->address->city = 'Downtown'; - $this->address->province = 'NJ'; - $this->address->postalCode = '12345'; - } - - /// ACH Debit - Consumer - - public function test001ConsumerPersonalChecking() - { - $check = TestChecks::certification( - SecCode::PPD, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(11.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 25 - $voidResponse = $response->void()->execute(); - $this->assertNotNull($voidResponse); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test002ConsumerBusinessChecking() - { - $check = TestChecks::certification( - SecCode::PPD, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(12.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test003ConsumerPersonalSavings() - { - $check = TestChecks::certification( - SecCode::PPD, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(13.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test004ConsumerBusinessSavings() - { - $check = TestChecks::certification( - SecCode::PPD, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(14.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test005CorporatePersonalChecking() - { - $check = TestChecks::certification( - SecCode::CCD, - CheckType::PERSONAL, - AccountType::CHECKING, - "Heartland Pays" - ); - - $response = $check->charge(15.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 26 - $voidResponse = $response->void()->execute(); - $this->assertNotNull($voidResponse); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test006CorporateBusinessChecking() - { - $check = TestChecks::certification( - SecCode::CCD, - CheckType::BUSINESS, - AccountType::CHECKING, - "Heartland Pays" - ); - - $response = $check->charge(16.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test007CorporatePersonalSavings() - { - $check = TestChecks::certification( - SecCode::CCD, - CheckType::PERSONAL, - AccountType::SAVINGS, - "Heartland Pays" - ); - - $response = $check->charge(17.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test008CorporateBusinessSavings() - { - $check = TestChecks::certification( - SecCode::CCD, - CheckType::BUSINESS, - AccountType::SAVINGS, - "Heartland Pays" - ); - - $response = $check->charge(18.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test009EgoldPersonalChecking() - { - $check = TestChecks::certification( - SecCode::POP, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(11.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test010EgoldBusinessChecking() - { - $check = TestChecks::certification( - SecCode::CCD, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(12.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test011EgoldPersonalSavings() - { - $check = TestChecks::certification( - SecCode::POP, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(13.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test012EgoldBusinessSavings() - { - $check = TestChecks::certification( - SecCode::POP, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(14.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test013EsilverPersonalChecking() - { - $check = TestChecks::certification( - SecCode::POP, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(15.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test014EsilverBusinessChecking() - { - $check = TestChecks::certification( - SecCode::CCD, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(16.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test015EsilverPersonalSavings() - { - $check = TestChecks::certification( - SecCode::POP, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(17.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test016EsilverBusinessSavings() - { - $check = TestChecks::certification( - SecCode::POP, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(18.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage Processor Configuration error - */ - public function test017EbronzePersonalChecking() - { - $check = TestChecks::certification( - SecCode::EBRONZE, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(19.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage Processor Configuration error - */ - public function test018EbronzeBusinessChecking() - { - $check = TestChecks::certification( - SecCode::EBRONZE, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(20.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage Processor Configuration error - */ - public function test019EbronzePersonalSavings() - { - $check = TestChecks::certification( - SecCode::EBRONZE, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(21.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage Processor Configuration error - */ - public function test020EbronzeBusinessSavings() - { - $check = TestChecks::certification( - SecCode::EBRONZE, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(22.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test021WebPersonalChecking() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(23.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test022WebBusinessChecking() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(24.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test023WebPersonalSavings() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(25.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test024WebBusinessSavings() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(5.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } -} +secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + protected function setup() + { + ServicesContainer::configureService($this->config()); + + $this->address = new Address(); + $this->address->streetAddress1 = '123 Main St.'; + $this->address->city = 'Downtown'; + $this->address->province = 'NJ'; + $this->address->postalCode = '12345'; + } + + /// ACH Debit - Consumer + + public function test001ConsumerPersonalChecking() + { + $check = TestChecks::certification( + SecCode::PPD, + CheckType::PERSONAL, + AccountType::CHECKING + ); + + $response = $check->charge(11.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 25 + $voidResponse = $response->void()->execute(); + $this->assertNotNull($voidResponse); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test002ConsumerBusinessChecking() + { + $check = TestChecks::certification( + SecCode::PPD, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(12.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test003ConsumerPersonalSavings() + { + $check = TestChecks::certification( + SecCode::PPD, + CheckType::PERSONAL, + AccountType::SAVINGS + ); + + $response = $check->charge(13.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test004ConsumerBusinessSavings() + { + $check = TestChecks::certification( + SecCode::PPD, + CheckType::BUSINESS, + AccountType::SAVINGS + ); + + $response = $check->charge(14.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test005CorporatePersonalChecking() + { + $check = TestChecks::certification( + SecCode::CCD, + CheckType::PERSONAL, + AccountType::CHECKING, + "Heartland Pays" + ); + + $response = $check->charge(15.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 26 + $voidResponse = $response->void()->execute(); + $this->assertNotNull($voidResponse); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test006CorporateBusinessChecking() + { + $check = TestChecks::certification( + SecCode::CCD, + CheckType::BUSINESS, + AccountType::CHECKING, + "Heartland Pays" + ); + + $response = $check->charge(16.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test007CorporatePersonalSavings() + { + $check = TestChecks::certification( + SecCode::CCD, + CheckType::PERSONAL, + AccountType::SAVINGS, + "Heartland Pays" + ); + + $response = $check->charge(17.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test008CorporateBusinessSavings() + { + $check = TestChecks::certification( + SecCode::CCD, + CheckType::BUSINESS, + AccountType::SAVINGS, + "Heartland Pays" + ); + + $response = $check->charge(18.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test010EgoldBusinessChecking() + { + $check = TestChecks::certification( + SecCode::CCD, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(12.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test014EsilverBusinessChecking() + { + $check = TestChecks::certification( + SecCode::CCD, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(16.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage Processor Configuration error + */ + public function test017EbronzePersonalChecking() + { + $check = TestChecks::certification( + SecCode::EBRONZE, + CheckType::PERSONAL, + AccountType::CHECKING + ); + + $response = $check->charge(19.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage Processor Configuration error + */ + public function test018EbronzeBusinessChecking() + { + $check = TestChecks::certification( + SecCode::EBRONZE, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(20.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage Processor Configuration error + */ + public function test019EbronzePersonalSavings() + { + $check = TestChecks::certification( + SecCode::EBRONZE, + CheckType::PERSONAL, + AccountType::SAVINGS + ); + + $response = $check->charge(21.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage Processor Configuration error + */ + public function test020EbronzeBusinessSavings() + { + $check = TestChecks::certification( + SecCode::EBRONZE, + CheckType::BUSINESS, + AccountType::SAVINGS + ); + + $response = $check->charge(22.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test021WebPersonalChecking() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::PERSONAL, + AccountType::CHECKING + ); + + $response = $check->charge(23.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test022WebBusinessChecking() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(24.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test023WebPersonalSavings() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::PERSONAL, + AccountType::SAVINGS + ); + + $response = $check->charge(25.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test024WebBusinessSavings() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::BUSINESS, + AccountType::SAVINGS + ); + + $response = $check->charge(5.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.php index 19e5d5a6..3beccb37 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.php @@ -1,108 +1,108 @@ -secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - protected function setup() - { - ServicesContainer::configure($this->config()); - - $this->address = new Address(); - $this->address->streetAddress1 = '123 Main St.'; - $this->address->city = 'Downtown'; - $this->address->province = 'NJ'; - $this->address->postalCode = '12345'; - } - - public function test001ConsumerPersonalChecking() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(19.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test002ConsumerBusinessChecking() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(20.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test003ConsumerPersonalSavings() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(21.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test004ConsumerBusinessSavings() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(22.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } -} +secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + protected function setup() + { + ServicesContainer::configureService($this->config()); + + $this->address = new Address(); + $this->address->streetAddress1 = '123 Main St.'; + $this->address->city = 'Downtown'; + $this->address->province = 'NJ'; + $this->address->postalCode = '12345'; + } + + public function test001ConsumerPersonalChecking() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::PERSONAL, + AccountType::CHECKING + ); + + $response = $check->charge(19.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test002ConsumerBusinessChecking() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(20.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test003ConsumerPersonalSavings() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::PERSONAL, + AccountType::SAVINGS + ); + + $response = $check->charge(21.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test004ConsumerBusinessSavings() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::BUSINESS, + AccountType::SAVINGS + ); + + $response = $check->charge(22.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php index 304a4166..62320006 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php @@ -1,1972 +1,1986 @@ -value = $card->value; - $data->encryptionData = $card->encryptionData; - $data->pinBlock = $pinBlock; - return $data; - } - - public static function asEBTTrack($card, $pinBlock) - { - $data = new EBTTrackData(); - $data->value = $card->value; - $data->entryMethod = $card->entryMethod; - $data->encryptionData = $card->encryptionData; - $data->pinBlock = $pinBlock; - return $data; - } - - public static function asEBTManual($card, $pinBlock) - { - $data = new EBTCardData(); - $data->number = $card->number; - $data->expMonth = $card->expMonth; - $data->expYear = $card->expYear; - $data->pinBlock = $pinBlock; - return $data; - } - - public static function visaManual($cardPresent = false, $readerPresent = false) - { - $data = new CreditCardData(); - $data->number = '4012002000060016'; - $data->expMonth = 12; - $data->expYear = self::validCardExpYear(); - $data->cvn = '123'; - $data->cardPresent = $cardPresent; - $data->readerPresent = $readerPresent; - return $data; - } - - public static function visaSwipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function visaSwipeEncrypted($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $encryptionData = new EncryptionData(); - $encryptionData->version = '01'; - - $data = new CreditTrackData(); - $data->value = ';'; - $data->entryMethod = $entryMethod; - $data->encryptionData = $encryptionData; - return $data; - } - - public static function masterCardManual($cardPresent = false, $readerPresent = false) - { - $data = new CreditCardData(); - $data->number = '5473500000000014'; - $data->expMonth = 12; - $data->expYear = self::validCardExpYear(); - $data->cvn = '123'; - $data->cardPresent = $cardPresent; - $data->readerPresent = $readerPresent; - return $data; - } - - public static function masterCardSeries2Manual($cardPresent = false, $readerPresent = false) - { - $data = new CreditCardData(); - $data->number = '2223000010005780'; - $data->expMonth = 12; - $data->expYear = self::validCardExpYear(); - $data->cvn = '123'; - $data->cardPresent = $cardPresent; - $data->readerPresent = $readerPresent; - return $data; - } - - public static function masterCardSwipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332?;5473500000000014=25121019999888877776?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function masterCard24Swipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B2223000010005780^TEST CARD/EMV BIN-2^19121010000000009210?;2223000010005780=19121010000000009210?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function masterCard25Swipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B2223000010005798^TEST CARD/EMV BIN-2^19121010000000003840?;2223000010005798=19121010000000003840?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function masterCardSwipeEncrypted($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $encryptionData = new EncryptionData(); - $encryptionData->version = '01'; - - $data = new CreditTrackData(); - $data->value = ''; - $data->entryMethod = $entryMethod; - $data->encryptionData = $encryptionData; - return $data; - } - - public static function discoverManual($cardPresent = false, $readerPresent = false) - { - $data = new CreditCardData(); - $data->number = '6011000990156527'; - $data->expMonth = 12; - $data->expYear = self::validCardExpYear(); - $data->cvn = '123'; - $data->cardPresent = $cardPresent; - $data->readerPresent = $readerPresent; - return $data; - } - - public static function discoverSwipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B6011000990156527^DIS TEST CARD^25121011000062111401?;6011000990156527=25121011000062111401?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function discoverSwipeEncrypted($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $encryptionData = new EncryptionData(); - $encryptionData->version = '01'; - - $data = new CreditTrackData(); - $data->value = ''; - $data->entryMethod = $entryMethod; - $data->encryptionData = $encryptionData; - return $data; - } - - public static function amexManual($cardPresent = false, $readerPresent = false) - { - $data = new CreditCardData(); - $data->number = '372700699251018'; - $data->expMonth = 12; - $data->expYear = self::validCardExpYear(); - $data->cvn = '1234'; - $data->cardPresent = $cardPresent; - $data->readerPresent = $readerPresent; - return $data; - } - - public static function amexSwipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function jcbManual($cardPresent = false, $readerPresent = false) - { - $data = new CreditCardData(); - $data->number = '3566007770007321'; - $data->expMonth = 12; - $data->expYear = self::validCardExpYear(); - $data->cvn = '123'; - $data->cardPresent = $cardPresent; - $data->readerPresent = $readerPresent; - return $data; - } - - public static function jcbSwipe($entryMethod = null) - { - if ($entryMethod === null) { - $entryMethod = EntryMethod::SWIPE; - } - - $data = new CreditTrackData(); - $data->value = '%B3566007770007321^JCB TEST CARD^2512101100000000000000000064300000?;3566007770007321=25121011000000076435?'; - $data->entryMethod = $entryMethod; - return $data; - } - - public static function giftCard1Swipe() - { - $data = new GiftCard(); - $data->trackData = '%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?'; - return $data; - } - - public static function giftCard2Manual() - { - $data = new GiftCard(); - $data->number = '5022440000000000007'; - return $data; - } - - public static function gsbManual() - { - $data = new CreditCardData(); - $data->number = '6277220572999800'; - $data->expMonth = '12'; - $data->expYear = self::validCardExpYear(); - return $data; - } -} - - - -class EcommerceTest extends TestCase -{ - const NO_TRANS_IN_BATCH = 'Batch close was rejected because no transactions are associated with the currently open batch.'; - const BATCH_NOT_OPEN = 'Transaction was rejected because it requires a batch to be open.'; - - /** @var bool */ - private $useTokens = true; - - /** @var bool */ - private $usePrepaid = false; - - /** @var string */ - private $publicKey = ''; - - /** @var EcommerceInfo */ - private $ecommerceInfo = null; - - /** @var string|null */ - public static $visaToken = null; - - /** @var string|null */ - public static $mastercardToken = null; - - /** @var string|null */ - public static $discoverToken = null; - - /** @var string|null */ - public static $amexToken = null; - - private $enableCryptoUrl = true; - - private function config() - { - $config = new PorticoConfig(); - $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - protected function setup() : void - { - ServicesContainer::configureService($this->config()); - $this->publicKey = 'pkapi_cert_jKc1FtuyAydZhZfbB3'; - - $this->ecommerceInfo = new EcommerceInfo(); - $this->ecommerceInfo->channel = EcommerceChannel::ECOM; - } - - public function test000CloseBatch() - { - try { - $response = BatchService::closeBatch(); - $this->assertNotNull($response); - } catch (ApiException $e) { - if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) - && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) - ) { - $this->fail($e->getMessage()); - } - } - } - - /// CARD VERIFY - - /// Account Verification - - public function test001VerifyVisa() - { - $card = TestCards::visaManual(); - - $response = $card->verify() - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test002VerifyMasterCard() - { - $card = TestCards::masterCardManual(); - $response = $card->verify() - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test003VerifyDiscover() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::discoverManual(); - - $response = $card->verify() - ->withAddress($address) - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// Address Verification - - public function test004VerifyAmex() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->verify() - ->withAddress($address) - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// Balance Inquiry (for Prepaid Card) - - public function test005BalanceInquiryVisa() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $card = TestCards::visaManual(); - - $response = $card->balanceInquiry() - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// CREDIT SALE (For Multi-Use Token Only) - - public function test006ChargeVisaToken() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(13.01) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals(true, $response->token != null); - self::$visaToken = $response->token; - } - - public function test007ChargeMasterCardToken() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(13.02) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals(true, $response->token != null); - self::$mastercardToken = $response->token; - } - - public function test008ChargeDiscoverToken() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = TestCards::discoverManual(); - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(13.03) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals(true, $response->token != null); - self::$discoverToken = $response->token; - } - - public function test009ChargeAmexToken() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(13.04) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals(true, $response->token != null); - self::$amexToken = $response->token; - } - - /// CREDIT SALE - - public function test010ChargeVisa() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = self::$visaToken; - } - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(17.01) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $response->void() - ->execute(); - $this->assertEquals(true, $voidResponse != null); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test011ChargeMastercard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = self::$mastercardToken; - } - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(17.02) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test012ChargeDiscover() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = TestCards::discoverManual(); - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = self::$discoverToken; - } - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(17.03) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test013ChargeAmex() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = self::$amexToken; - } - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(17.04) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test014ChargeJcb() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = TestCards::jcbManual(); - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(17.04) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test011bChargeMasterCard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardSeries2Manual(); - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(17.02) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// AUTHORIZATION - - public function test015AuthorizationVisa() - { - # Test 015a Authorization - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - - $card = TestCards::visaManual(); - - $response = $card->authorize(17.06) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - # test 015b Capture/AddToBatch - $capture = $response->capture() - ->execute(); - $this->assertEquals(true, $capture != null); - $this->assertEquals('00', $capture->responseCode); - } - - public function test016AuthorizationMastercard() - { - # Test 016a Authorization - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '750241234'; - - $card = TestCards::masterCardManual(); - - $response = $card->authorize(17.07) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - # test 016b Capture/AddToBatch - $capture = $response->capture() - ->execute(); - $this->assertEquals(true, $capture != null); - $this->assertEquals('00', $capture->responseCode); - } - - public function test017AuthorizationDiscover() - { - # Test 017a Authorization - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::discoverManual(); - - $response = $card->authorize(17.08) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - # test 017b Capture/AddToBatch - # do not capture - } - - /// PARTIALLY - APPROVED SALE - - public function test018PartialApprovalVisa() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(130) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowPartialAuth(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(true, $response->authorizedAmount != null); - $this->assertEquals('110.00', $response->authorizedAmount); - } - - public function test019PartialApprovalDiscover() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::discoverManual(); - - $response = $card->charge(145) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowPartialAuth(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(true, $response->authorizedAmount != null); - $this->assertEquals('65.00', $response->authorizedAmount); - } - - public function test020PartialApprovalMastercard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::discoverManual(); - - $response = $card->charge(155) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowPartialAuth(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(true, $response->authorizedAmount != null); - $this->assertEquals('100.00', $response->authorizedAmount); - - $voidResponse = $response->void() - ->execute(); - $this->assertEquals(true, $voidResponse != null); - $this->assertEquals('00', $voidResponse->responseCode); - } - - /// LEVEL II CORPORATE PURCHASE CARD - - public function test021LevelIIResponseB() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '750241234'; - - $card = TestCards::visaManual(); - - $response = $card->charge(112.34) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('B', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test022LevelIIResponseB() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = TestCards::visaManual(); - - $response = $card->charge(112.34) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('B', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test023LevelIIResponseR() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(123.45) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('R', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test024LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(134.56) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test025LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.06) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test026LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.07) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test027LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.08) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test028LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.09) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test029LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.10) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test030LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.11) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test031LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.12) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test032LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.13) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - /// PRIOR / VOICE AUTHORIZATION - - public function test033OfflineSale() - { - $card = TestCards::visaManual(); - - $response = $card->charge(17.10) - ->withCurrency('USD') - ->withModifier(TransactionModifier::OFFLINE) - ->withOfflineAuthCode('654321') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test033OfflineAuthorization() - { - $card = TestCards::visaManual(); - - $response = $card->authorize(17.10) - ->withCurrency('USD') - ->withModifier(TransactionModifier::OFFLINE) - ->withOfflineAuthCode('654321') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// RETURN - - public function test034OfflineCreditReturn() - { - $card = TestCards::masterCardManual(); - - $response = $card->refund(15.15) - ->withCurrency('USD') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test034bOfflineCreditReturn() - { - $card = TestCards::masterCardManual(); - - $response = $card->refund(15.16) - ->withCurrency('USD') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ONLINE VOID / REVERSAL - - public function test035VoidTest10() - { - // see test 010 - } - - public function test036VoidTest20() - { - // see test 020 - } - - /// Time Out Reversal - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException - */ - public function test036bTimeoutReversal() - { - $sale = TestCards::visaManual()->charge(911) - ->withCurrency('USD') - ->withClientTransactionId('987321654') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $sale != null); - $this->assertEquals('91', $sale->responseCode); - - $response = Transaction::fromId(null, PaymentMethodType::CREDIT); - $response->clientTransactionId = '987321654'; - - $response->reverse(911)->execute(); - } - - /// One time bill payment - - public function test010ChargeVisaOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$visaToken; - } else { - $card = TestCards::visaManual(); - } - - $response = $card->charge(13.11) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $void = $response->void()->execute(); - - $this->assertEquals(true, $void != null); - $this->assertEquals('00', $void->responseCode); - } - - public function test011ChargeMasterCardOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$mastercardToken; - } else { - $card = TestCards::masterCardManual(); - } - - $response = $card->charge(13.12) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test012ChargeDiscoverOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$discoverToken; - } else { - $card = TestCards::discoverManual(); - } - - $response = $card->charge(13.13) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test013ChargeAmexOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$amexToken; - } else { - $card = TestCards::amexManual(); - } - - $response = $card->charge(13.14) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test014ChargeJcbOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '3566007770007321'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - - $response = $card->charge(13.15) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ADVANCED FRAUD SCREENING - - /** - * TODO: Change code assertions when AFS is enabled on account - */ - public function test037FraudPreventionSale() - { - $card = TestCards::visaManual(); - - $response = $card->charge(15000) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - // $this->assertEquals('FR', $response->responseCode); - } - - /** - * TODO: Change code assertions when AFS is enabled on account - */ - public function test038FraudPreventionReturn() - { - $card = TestCards::visaManual(); - - $response = $card->refund(15000) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - // $this->assertEquals('41', $response->responseCode); - } - - /// ONE CARD - GSB CARD FUNCTIONS - - /// BALANCE INQUIRY - - public function test037BalanceInquiryGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::gsbManual(); - - $response = $card->balanceInquiry() - ->withAddress($address) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ADD VALUE - - public function test038AddValueGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $card = new CreditTrackData(); - $card->value = '%B6277220572999800^ / ^49121010557010000016000000?F;6277220572999800=49121010557010000016?'; - - $response = $card->addValue(15.00) - ->withCurrency('USD') - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// SALE - - public function test039ChargeGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::gsbManual(); - - $response = $card->charge(2.05) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $response->void() - ->execute(); - $this->assertEquals(true, $voidResponse != null); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test040ChargeGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::gsbManual(); - - $response = $card->charge(2.10) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ONLINE VOID / REVERSAL - - public function test041VoidGsb() - { - // see test 039 - } - - /// HMS GIFT - REWARDS - - /// ACTIVATE - - public function test042ActivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->activate(6.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test043ActivateGift2() - { - - $card = TestCards::giftCard2Manual(); - - $response = $card->activate(7.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// LOAD / ADD VALUE - - public function test044AddValueGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->addValue(8.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test045AddValueGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->addValue(9.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// BALANCE INQUIRY - - public function test046BalanceInquiryGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - public function test047BalanceInquiryGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - /// REPLACE / TRANSFER - - public function test048ReplaceGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->replaceWith(TestCards::giftCard2Manual()) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - public function test049ReplaceGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->replaceWith(TestCards::giftCard1Swipe()) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - /// SALE / REDEEM - - public function test050SaleGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(1.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test051SaleGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(2.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test052SaleGift1Void() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(3.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $response->void() - ->execute(); - $this->assertEquals(true, $voidResponse != null); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test053SaleGift2Reversal() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(4.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $reversalResponse = $response->reverse(4.00) - ->execute(); - $this->assertEquals(true, $reversalResponse != null); - $this->assertEquals('00', $reversalResponse->responseCode); - } - - /// VOID - - public function test054VoidGift() - { - // see test 052 - } - - /// REVERSAL - - public function test055ReversalGift() - { - // see test 053 - } - - public function test056ReversalGift2() - { - $card = TestCards::giftCard2Manual(); - - $reversalResponse = $card->reverse(2.00) - ->execute(); - $this->assertEquals(true, $reversalResponse != null); - $this->assertEquals('00', $reversalResponse->responseCode); - } - - /// DEACTIVATE - - public function test057DeactivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->deactivate() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// RECEIPTS MESSAGING - - public function test058ReceiptsMessaging() - { - return; # print and scan receipt for test 51 - } - - /// REWARD - - /// BALANCE INQUIRY - - public function test059BalanceInquiryRewards1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->pointsBalanceAmount); - } - - public function test060BalanceInquiryRewards2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->pointsBalanceAmount); - } - - /// ALIAS - - public function test061CreateAliasGift1() - { - $response = GiftCard::create('9725550100'); - - $this->assertEquals(true, $response != null); - } - - public function test062CreateAliasGift2() - { - $response = GiftCard::create('9725550100'); - - $this->assertEquals(true, $response != null); - } - - public function test063AddAliasGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->addAlias('2145550199') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test064AddAliasGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->addAlias('2145550199') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test065DeleteAliasGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->removeAlias('2145550199') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// SALE / REDEEM - - public function test066RedeemPointsGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(100) - ->withCurrency('POINTS') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test067RedeemPointsGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(200) - ->withCurrency('POINTS') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test068RedeemPointsGift2() - { - $card = new GiftCard(); - $card->alias = '9725550100'; - - $response = $card->charge(300) - ->withCurrency('POINTS') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// REWARDS - - public function test069RewardsGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->rewards(10) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test070RewardsGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->rewards(11) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// REPLACE / TRANSFER - - public function test071ReplaceGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->replaceWith(TestCards::giftCard2Manual()) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test072ReplaceGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->replaceWith(TestCards::giftCard1Swipe()) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// DEACTIVATE - - public function test073DeactivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->deactivate() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test074DeactivateGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->deactivate() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// RECEIPTS MESSAGING - - public function test075ReceiptsMessaging() - { - return; # print and scan receipt for test 51 - } - - /// CLOSE BATCH - - public function test999CloseBatch() - { - try { - $response = BatchService::closeBatch(); - $this->assertNotNull($response); - // printf('batch id: %s', $response->id); - // printf('sequence number: %s', $response->sequenceNumber); - } catch (ApiException $e) { - if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) - && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) - ) { - $this->fail($e->getMessage()); - } - } - } - - public function test100ChargeVisaEcommerceInfo() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $secureEcom = new ThreeDSecure(); - $secureEcom->cavv = 'AAACBllleHchZTBWIGV4AAAAAAA='; - $secureEcom->xid = 'crqAeMwkEL9r4POdxpByWJ1/wYg='; - $secureEcom->eci = '5'; - $secureEcom->paymentDataSource = Secure3dPaymentDataSource::VISA_3DSECURE; - $secureEcom->paymentDataType = '3DSecure'; - - $card = TestCards::visaManual(); - $card->threeDSecure = $secureEcom; - - $response = $card->charge() - ->withCurrency('USD') - ->withAmount(13.01) - ->withAddress($address) - // ->withEcommerceInfo($this->ecommerceInfo) - ->withInvoiceNumber('12345') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } -} +value = $card->value; + $data->encryptionData = $card->encryptionData; + $data->pinBlock = $pinBlock; + return $data; + } + + public static function asEBTTrack($card, $pinBlock) + { + $data = new EBTTrackData(); + $data->value = $card->value; + $data->entryMethod = $card->entryMethod; + $data->encryptionData = $card->encryptionData; + $data->pinBlock = $pinBlock; + return $data; + } + + public static function asEBTManual($card, $pinBlock) + { + $data = new EBTCardData(); + $data->number = $card->number; + $data->expMonth = $card->expMonth; + $data->expYear = $card->expYear; + $data->pinBlock = $pinBlock; + return $data; + } + + public static function visaManual($cardPresent = false, $readerPresent = false) + { + $data = new CreditCardData(); + $data->number = '4012002000060016'; + $data->expMonth = 12; + $data->expYear = self::validCardExpYear(); + $data->cvn = '123'; + $data->cardPresent = $cardPresent; + $data->readerPresent = $readerPresent; + return $data; + } + + public static function visaSwipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function visaSwipeEncrypted($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $encryptionData = new EncryptionData(); + $encryptionData->version = '01'; + + $data = new CreditTrackData(); + $data->value = ';'; + $data->entryMethod = $entryMethod; + $data->encryptionData = $encryptionData; + return $data; + } + + public static function masterCardManual($cardPresent = false, $readerPresent = false) + { + $data = new CreditCardData(); + $data->number = '5473500000000014'; + $data->expMonth = 12; + $data->expYear = self::validCardExpYear(); + $data->cvn = '123'; + $data->cardPresent = $cardPresent; + $data->readerPresent = $readerPresent; + return $data; + } + + public static function masterCardSeries2Manual($cardPresent = false, $readerPresent = false) + { + $data = new CreditCardData(); + $data->number = '2223000010005780'; + $data->expMonth = 12; + $data->expYear = self::validCardExpYear(); + $data->cvn = '123'; + $data->cardPresent = $cardPresent; + $data->readerPresent = $readerPresent; + return $data; + } + + public static function masterCardSwipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332?;5473500000000014=25121019999888877776?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function masterCard24Swipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B2223000010005780^TEST CARD/EMV BIN-2^19121010000000009210?;2223000010005780=19121010000000009210?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function masterCard25Swipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B2223000010005798^TEST CARD/EMV BIN-2^19121010000000003840?;2223000010005798=19121010000000003840?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function masterCardSwipeEncrypted($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $encryptionData = new EncryptionData(); + $encryptionData->version = '01'; + + $data = new CreditTrackData(); + $data->value = ''; + $data->entryMethod = $entryMethod; + $data->encryptionData = $encryptionData; + return $data; + } + + public static function discoverManual($cardPresent = false, $readerPresent = false) + { + $data = new CreditCardData(); + $data->number = '6011000990156527'; + $data->expMonth = 12; + $data->expYear = self::validCardExpYear(); + $data->cvn = '123'; + $data->cardPresent = $cardPresent; + $data->readerPresent = $readerPresent; + return $data; + } + + public static function discoverSwipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B6011000990156527^DIS TEST CARD^25121011000062111401?;6011000990156527=25121011000062111401?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function discoverSwipeEncrypted($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $encryptionData = new EncryptionData(); + $encryptionData->version = '01'; + + $data = new CreditTrackData(); + $data->value = ''; + $data->entryMethod = $entryMethod; + $data->encryptionData = $encryptionData; + return $data; + } + + public static function amexManual($cardPresent = false, $readerPresent = false) + { + $data = new CreditCardData(); + $data->number = '372700699251018'; + $data->expMonth = 12; + $data->expYear = self::validCardExpYear(); + $data->cvn = '1234'; + $data->cardPresent = $cardPresent; + $data->readerPresent = $readerPresent; + return $data; + } + + public static function amexSwipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function jcbManual($cardPresent = false, $readerPresent = false) + { + $data = new CreditCardData(); + $data->number = '3566007770007321'; + $data->expMonth = 12; + $data->expYear = self::validCardExpYear(); + $data->cvn = '123'; + $data->cardPresent = $cardPresent; + $data->readerPresent = $readerPresent; + return $data; + } + + public static function jcbSwipe($entryMethod = null) + { + if ($entryMethod === null) { + $entryMethod = EntryMethod::SWIPE; + } + + $data = new CreditTrackData(); + $data->value = '%B3566007770007321^JCB TEST CARD^2512101100000000000000000064300000?;3566007770007321=25121011000000076435?'; + $data->entryMethod = $entryMethod; + return $data; + } + + public static function giftCard1Swipe() + { + $data = new GiftCard(); + $data->trackData = '%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?'; + return $data; + } + + public static function giftCard2Manual() + { + $data = new GiftCard(); + $data->number = '5022440000000000007'; + return $data; + } + + public static function gsbManual() + { + $data = new CreditCardData(); + $data->number = '6277220572999800'; + $data->expMonth = '12'; + $data->expYear = self::validCardExpYear(); + return $data; + } +} + + + +class EcommerceTest extends TestCase +{ + const NO_TRANS_IN_BATCH = 'Batch close was rejected because no transactions are associated with the currently open batch.'; + const BATCH_NOT_OPEN = 'Transaction was rejected because it requires a batch to be open.'; + + /** @var bool */ + private $useTokens = true; + + /** @var bool */ + private $usePrepaid = false; + + /** @var string */ + private $publicKey = ''; + + /** @var EcommerceInfo */ + private $ecommerceInfo = null; + + /** @var string|null */ + public static $visaToken = null; + + /** @var string|null */ + public static $mastercardToken = null; + + /** @var string|null */ + public static $discoverToken = null; + + /** @var string|null */ + public static $amexToken = null; + + private $enableCryptoUrl = true; + + private function config() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + protected function setup() : void + { + ServicesContainer::configureService($this->config()); + $this->publicKey = 'pkapi_cert_jKc1FtuyAydZhZfbB3'; + + $this->ecommerceInfo = new EcommerceInfo(); + $this->ecommerceInfo->channel = EcommerceChannel::ECOM; + } + + public function test000CloseBatch() + { + try { + $response = BatchService::closeBatch(); + $this->assertNotNull($response); + } catch (ApiException $e) { + if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) + && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) + ) { + $this->fail($e->getMessage()); + } + } + } + + /// CARD VERIFY + + /// Account Verification + + public function test001VerifyVisa() + { + $card = TestCards::visaManual(); + + $response = $card->verify() + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test002VerifyMasterCard() + { + $card = TestCards::masterCardManual(); + $response = $card->verify() + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test003VerifyDiscover() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::discoverManual(); + + $response = $card->verify() + ->withAddress($address) + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// Address Verification + + public function test004VerifyAmex() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->verify() + ->withAddress($address) + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// Balance Inquiry (for Prepaid Card) + + public function test005BalanceInquiryVisa() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $card = TestCards::visaManual(); + + $response = $card->balanceInquiry() + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// CREDIT SALE (For Multi-Use Token Only) + + public function test006ChargeVisaToken() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(13.01) + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals(true, $response->token != null); + self::$visaToken = $response->token; + } + + public function test007ChargeMasterCardToken() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(13.02) + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals(true, $response->token != null); + self::$mastercardToken = $response->token; + } + + public function test008ChargeDiscoverToken() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = TestCards::discoverManual(); + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(13.03) + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals(true, $response->token != null); + self::$discoverToken = $response->token; + } + + public function test009ChargeAmexToken() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(13.04) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withRequestMultiUseToken(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals(true, $response->token != null); + self::$amexToken = $response->token; + } + + /// CREDIT SALE + + public function test010ChargeVisa() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = self::$visaToken; + } + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(17.01) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->execute(); + $this->assertEquals(true, $voidResponse != null); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test011ChargeMastercard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = self::$mastercardToken; + } + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(17.02) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test012ChargeDiscover() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = TestCards::discoverManual(); + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = self::$discoverToken; + } + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(17.03) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test013ChargeAmex() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = self::$amexToken; + } + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(17.04) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test014ChargeJcb() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = TestCards::jcbManual(); + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(17.04) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test011bChargeMasterCard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardSeries2Manual(); + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(17.02) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// AUTHORIZATION + + public function test015AuthorizationVisa() + { + # Test 015a Authorization + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + + $card = TestCards::visaManual(); + + $response = $card->authorize(17.06) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + # test 015b Capture/AddToBatch + $capture = $response->capture() + ->execute(); + $this->assertEquals(true, $capture != null); + $this->assertEquals('00', $capture->responseCode); + } + + public function test016AuthorizationMastercard() + { + # Test 016a Authorization + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '750241234'; + + $card = TestCards::masterCardManual(); + + $response = $card->authorize(17.07) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + # test 016b Capture/AddToBatch + $capture = $response->capture() + ->execute(); + $this->assertEquals(true, $capture != null); + $this->assertEquals('00', $capture->responseCode); + } + + public function test017AuthorizationDiscover() + { + # Test 017a Authorization + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::discoverManual(); + + $response = $card->authorize(17.08) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + # test 017b Capture/AddToBatch + # do not capture + } + + /// PARTIALLY - APPROVED SALE + + public function test018PartialApprovalVisa() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(130) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowPartialAuth(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(true, $response->authorizedAmount != null); + $this->assertEquals('110.00', $response->authorizedAmount); + } + + public function test019PartialApprovalDiscover() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::discoverManual(); + + $response = $card->charge(145) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowPartialAuth(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(true, $response->authorizedAmount != null); + $this->assertEquals('65.00', $response->authorizedAmount); + } + + public function test020PartialApprovalMastercard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::discoverManual(); + + $response = $card->charge(155) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowPartialAuth(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(true, $response->authorizedAmount != null); + $this->assertEquals('100.00', $response->authorizedAmount); + + $voidResponse = $response->void() + ->execute(); + $this->assertEquals(true, $voidResponse != null); + $this->assertEquals('00', $voidResponse->responseCode); + } + + /// LEVEL II CORPORATE PURCHASE CARD + + public function test021LevelIIResponseB() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '750241234'; + + $card = TestCards::visaManual(); + + $response = $card->charge(112.34) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('B', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test022LevelIIResponseB() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = TestCards::visaManual(); + + $response = $card->charge(112.34) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('B', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test023LevelIIResponseR() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(123.45) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('R', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test024LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(134.56) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test025LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.06) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test026LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.07) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test027LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.08) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test028LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.09) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test029LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.10) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test030LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.11) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test031LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.12) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test032LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.13) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + /// PRIOR / VOICE AUTHORIZATION + + public function test033OfflineSale() + { + $card = TestCards::visaManual(); + + $response = $card->charge(17.10) + ->withCurrency('USD') + ->withModifier(TransactionModifier::OFFLINE) + ->withOfflineAuthCode('654321') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test033OfflineAuthorization() + { + $card = TestCards::visaManual(); + + $response = $card->authorize(17.10) + ->withCurrency('USD') + ->withModifier(TransactionModifier::OFFLINE) + ->withOfflineAuthCode('654321') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// RETURN + + public function test034OfflineCreditReturn() + { + $card = TestCards::masterCardManual(); + + $response = $card->refund(15.15) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test034bOfflineCreditReturn() + { + $card = TestCards::masterCardManual(); + + $response = $card->refund(15.16) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ONLINE VOID / REVERSAL + + public function test035VoidTest10() + { + // see test 010 + } + + public function test036VoidTest20() + { + // see test 020 + } + + /// Time Out Reversal + public function test036bTimeoutReversal() + { + $sale = TestCards::visaManual()->charge(911) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withClientTransactionId('987321654') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $sale != null); + $this->assertEquals('91', $sale->responseCode); + + $response = Transaction::fromId(null, PaymentMethodType::CREDIT); + $response->clientTransactionId = '987321654'; + + $this->expectException(GatewayException::class); + $response->reverse(911)->execute(); + } + + /// One time bill payment + + public function test010ChargeVisaOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$visaToken; + } else { + $card = TestCards::visaManual(); + } + + $response = $card->charge(13.11) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $void = $response->void()->execute(); + + $this->assertEquals(true, $void != null); + $this->assertEquals('00', $void->responseCode); + } + + public function test011ChargeMasterCardOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$mastercardToken; + } else { + $card = TestCards::masterCardManual(); + } + + $response = $card->charge(13.12) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test012ChargeDiscoverOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$discoverToken; + } else { + $card = TestCards::discoverManual(); + } + + $response = $card->charge(13.13) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test013ChargeAmexOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$amexToken; + } else { + $card = TestCards::amexManual(); + } + + $response = $card->charge(13.14) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test014ChargeJcbOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '3566007770007321'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + + $response = $card->charge(13.15) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ADVANCED FRAUD SCREENING + + /** + * TODO: Change code assertions when AFS is enabled on account + */ + public function test037FraudPreventionSale() + { + $card = TestCards::visaManual(); + + $response = $card->charge(15000) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals('FR', $response->responseCode); + } + + /** + * TODO: Change code assertions when AFS is enabled on account + */ + public function test038FraudPreventionReturn() + { + $card = TestCards::visaManual(); + + $response = $card->refund(15000) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals('41', $response->responseCode); + } + + /// ONE CARD - GSB CARD FUNCTIONS + + /// BALANCE INQUIRY + + public function test037BalanceInquiryGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::gsbManual(); + + $response = $card->balanceInquiry() + ->withAddress($address) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ADD VALUE + + public function test038AddValueGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $card = new CreditTrackData(); + $card->value = '%B6277220572999800^ / ^49121010557010000016000000?F;6277220572999800=49121010557010000016?'; + + $response = $card->addValue(15.00) + ->withCurrency('USD') + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// SALE + + public function test039ChargeGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::gsbManual(); + + $response = $card->charge(2.05) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->execute(); + $this->assertEquals(true, $voidResponse != null); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test040ChargeGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::gsbManual(); + + $response = $card->charge(2.10) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ONLINE VOID / REVERSAL + + public function test041VoidGsb() + { + // see test 039 + } + + /// HMS GIFT - REWARDS + + /// ACTIVATE + + public function test042ActivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->activate(6.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test043ActivateGift2() + { + + $card = TestCards::giftCard2Manual(); + + $response = $card->activate(7.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// LOAD / ADD VALUE + + public function test044AddValueGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->addValue(8.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test045AddValueGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->addValue(9.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// BALANCE INQUIRY + + public function test046BalanceInquiryGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + public function test047BalanceInquiryGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + /// REPLACE / TRANSFER + + public function test048ReplaceGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->replaceWith(TestCards::giftCard2Manual()) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + public function test049ReplaceGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->replaceWith(TestCards::giftCard1Swipe()) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + /// SALE / REDEEM + + public function test050SaleGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(1.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test051SaleGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(2.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test052SaleGift1Void() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(3.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->execute(); + $this->assertEquals(true, $voidResponse != null); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test053SaleGift2Reversal() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(4.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $reversalResponse = $response->reverse(4.00) + ->execute(); + $this->assertEquals(true, $reversalResponse != null); + $this->assertEquals('00', $reversalResponse->responseCode); + } + + /// VOID + + public function test054VoidGift() + { + // see test 052 + } + + /// REVERSAL + + public function test055ReversalGift() + { + // see test 053 + } + + public function test056ReversalGift2() + { + $card = TestCards::giftCard2Manual(); + + $reversalResponse = $card->reverse(2.00) + ->execute(); + $this->assertEquals(true, $reversalResponse != null); + $this->assertEquals('00', $reversalResponse->responseCode); + } + + /// DEACTIVATE + + public function test057DeactivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->deactivate() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// RECEIPTS MESSAGING + + public function test058ReceiptsMessaging() + { + return; # print and scan receipt for test 51 + } + + /// REWARD + + /// BALANCE INQUIRY + + public function test059BalanceInquiryRewards1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertTrue($response->pointsBalanceAmount > 0); + } + + public function test060BalanceInquiryRewards2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertTrue($response->pointsBalanceAmount > 0); + } + + /// ALIAS + + public function test061CreateAliasGift1() + { + $response = GiftCard::create('9725550100'); + + $this->assertEquals(true, $response != null); + } + + public function test062CreateAliasGift2() + { + $response = GiftCard::create('9725550100'); + + $this->assertEquals(true, $response != null); + } + + public function test063AddAliasGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->addAlias('2145550199') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test064AddAliasGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->addAlias('2145550199') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test065DeleteAliasGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->removeAlias('2145550199') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// SALE / REDEEM + + public function test066RedeemPointsGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(100) + ->withCurrency('POINTS') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test067RedeemPointsGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(200) + ->withCurrency('POINTS') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test068RedeemPointsGift2() + { + $card = new GiftCard(); + $card->alias = '9725550100'; + + $response = $card->charge(300) + ->withCurrency('POINTS') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// REWARDS + + public function test069RewardsGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->rewards(10) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test070RewardsGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->rewards(11) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// REPLACE / TRANSFER + + public function test071ReplaceGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->replaceWith(TestCards::giftCard2Manual()) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test072ReplaceGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->replaceWith(TestCards::giftCard1Swipe()) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// DEACTIVATE + + public function test073DeactivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->deactivate() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test074DeactivateGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->deactivate() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// RECEIPTS MESSAGING + + public function test075ReceiptsMessaging() + { + return; # print and scan receipt for test 51 + } + + /// CLOSE BATCH + + public function test999CloseBatch() + { + try { + $response = BatchService::closeBatch(); + $this->assertNotNull($response); + // printf('batch id: %s', $response->id); + // printf('sequence number: %s', $response->sequenceNumber); + } catch (ApiException $e) { + if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) + && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) + ) { + $this->fail($e->getMessage()); + } + } + } + + public function test100ChargeVisaEcommerceInfo() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $secureEcom = new ThreeDSecure(); + $secureEcom->cavv = 'AAACBllleHchZTBWIGV4AAAAAAA='; + $secureEcom->xid = 'crqAeMwkEL9r4POdxpByWJ1/wYg='; + $secureEcom->eci = '5'; + $secureEcom->paymentDataSource = Secure3dPaymentDataSource::VISA_3DSECURE; + $secureEcom->paymentDataType = '3DSecure'; + + $card = TestCards::visaManual(); + $card->threeDSecure = $secureEcom; + + $response = $card->charge() + ->withCurrency('USD') + ->withAmount(13.01) + ->withAddress($address) + // ->withEcommerceInfo($this->ecommerceInfo) + ->withInvoiceNumber('12345') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.php index 6400b5c8..72afddf3 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.php @@ -1,108 +1,108 @@ -secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - protected function setup() - { - ServicesContainer::configure($this->config()); - - $this->address = new Address(); - $this->address->streetAddress1 = '123 Main St.'; - $this->address->city = 'Downtown'; - $this->address->province = 'NJ'; - $this->address->postalCode = '12345'; - } - - public function test001ConsumerPersonalChecking() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::PERSONAL, - AccountType::CHECKING - ); - - $response = $check->charge(19.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test002ConsumerBusinessChecking() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::BUSINESS, - AccountType::CHECKING - ); - - $response = $check->charge(20.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test003ConsumerPersonalSavings() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::PERSONAL, - AccountType::SAVINGS - ); - - $response = $check->charge(21.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test004ConsumerBusinessSavings() - { - $check = TestChecks::certification( - SecCode::WEB, - CheckType::BUSINESS, - AccountType::SAVINGS - ); - - $response = $check->charge(22.00) - ->withCurrency('USD') - ->withAddress($this->address) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } -} +secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + protected function setup() + { + ServicesContainer::configureService($this->config()); + + $this->address = new Address(); + $this->address->streetAddress1 = '123 Main St.'; + $this->address->city = 'Downtown'; + $this->address->province = 'NJ'; + $this->address->postalCode = '12345'; + } + + public function test001ConsumerPersonalChecking() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::PERSONAL, + AccountType::CHECKING + ); + + $response = $check->charge(19.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test002ConsumerBusinessChecking() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::BUSINESS, + AccountType::CHECKING + ); + + $response = $check->charge(20.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test003ConsumerPersonalSavings() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::PERSONAL, + AccountType::SAVINGS + ); + + $response = $check->charge(21.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test004ConsumerBusinessSavings() + { + $check = TestChecks::certification( + SecCode::WEB, + CheckType::BUSINESS, + AccountType::SAVINGS + ); + + $response = $check->charge(22.00) + ->withCurrency('USD') + ->withAddress($this->address) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.php index fa3efa6d..e73330a9 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.php @@ -1,1697 +1,1713 @@ -secretApiKey = 'skapi_cert_MRCQAQBC_VQACBE0rFaZlbDDPieMGP06JDAtjyS7NQ'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - protected function setup() - { - ServicesContainer::configure($this->config()); - - $this->ecommerceInfo = new EcommerceInfo(); - $this->ecommerceInfo->channel = EcommerceChannel::MOTO; - } - - public function test000CloseBatch() - { - try { - $response = BatchService::closeBatch(); - $this->assertNotNull($response); - // print 'batch id: ' . $response->id . "\n"; - // print 'sequence number: ' . $response->sequenceNumber . "\n"; - } catch (ApiException $e) { - if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) - && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) - ) { - $this->fail($e->getMessage()); - } - } - } - - public function test001VerifyVisa() - { - $card = new CreditCardData(); - $card->number = '4484958240202792'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $response = $card->verify() - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test002VerifyMasterCard() - { - $card = new CreditCardData(); - $card->number = '5356083898949891'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $response = $card->verify() - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test003VerifyDiscover() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '6223971100014620'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $response = $card->verify() - ->withAddress($address) - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // StreetAddress verification - - public function test004VerifyAmex() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '345039962663847'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $response = $card->verify() - ->withAddress($address) - ->withRequestMultiUseToken($this->useTokens) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Balance Inquiry (for prepaid card) - - public function test005BalanceInquiryVisa() - { - $card = new CreditCardData(); - $card->number = '4664383951958601'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $response = $card->balanceInquiry()->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode, $response->responseMessage); - } - - // CREDIT SALE (for multi-use token only) - - public function test006ChargeVisaToken() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '4012002000060016'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $response = $card->charge(13.01) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - static::$visaToken = $response->token; - } - - public function test007ChargeMasterCardToken() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '5473500000000014'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - - $response = $card->charge(13.02) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - static::$mastercardToken = $response->token; - } - - public function test008ChargeDiscoverToken() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = new CreditCardData(); - $card->number = '6011000990156527'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - - $response = $card->charge(13.03) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - static::$discoverToken = $response->token; - } - - public function test009ChargeAmexToken() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '372700699251018'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '1234'; - - $response = $card->charge(13.04) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - static::$amexToken = $response->token; - } - - // CREDIT SALE - - public function test010ChargeVisa() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$visaToken; - } else { - $card = TestCards::visaManual(); - } - - $response = $card->charge(17.01) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 35 - $void = $response->void()->execute(); - - $this->assertNotNull($void); - $this->assertEquals('00', $void->responseCode); - } - - public function test011ChargeMasterCard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$mastercardToken; - } else { - $card = TestCards::masterCardManual(); - } - - $response = $card->charge(17.02) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test012ChargeDiscover() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$discoverToken; - } else { - $card = TestCards::discoverManual(); - } - - $response = $card->charge(17.03) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test013ChargeAmex() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$amexToken; - } else { - $card = TestCards::amexManual(); - } - - $response = $card->charge(17.04) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test014ChargeJcb() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '750241234'; - - $card = new CreditCardData(); - $card->number = '3566007770007321'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - - $response = $card->charge(17.05) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test011bChargeMasterCard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardSeries2Manual(); - - $response = $card->charge(17.02) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // AUTHORIZATION - - - public function test015AuthorizationVisa() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->authorize(17.06) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 15b - $capture = $response->capture()->execute(); - - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function test016AuthorizationMasterCard() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '750241234'; - - $card = TestCards::masterCardManual(); - - $response = $card->authorize(17.07) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 16b - $capture = $response->capture()->execute(); - - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function test017AuthorizationDiscover() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::discoverManual(); - - $response = $card->authorize(17.08) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test016bAuthorizationMasterCard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardSeries2Manual(); - - $response = $card->authorize(17.02) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // PARTIALLY APPROVED SALE - - public function test018PartialApprovalVisa() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(130) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowPartialAuth(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals('110.00', $response->authorizedAmount); - } - - public function test019PartialApprovalDiscover() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::discoverManual(); - - $response = $card->charge(145) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowPartialAuth(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals('65.00', $response->authorizedAmount); - } - - public function test020PartialApprovalMasterCard() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(155) - ->withCurrency('USD') - ->withEcommerceInfo($this->ecommerceInfo) - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowPartialAuth(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals('100.00', $response->authorizedAmount); - - // test case 36 - $void = $response->void()->execute(); - - $this->assertNotNull($void); - $this->assertEquals('00', $void->responseCode); - } - /// LEVEL II CORPORATE PURCHASE CARD - - public function test021LevelIIResponseB() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '750241234'; - - $card = TestCards::visaManual(); - - $response = $card->charge(112.34) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('B', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test022LevelIIResponseB() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = TestCards::visaManual(); - - $response = $card->charge(112.34) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('B', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test023LevelIIResponseR() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(123.45) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('R', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test024LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::visaManual(); - - $response = $card->charge(134.56) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test025LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.06) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test026LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.07) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test027LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.08) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test028LevelIIResponseS() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(); - - $response = $card->charge(111.09) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test029LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.10) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test030LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.11) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test031LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.12) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1.00) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function test032LevelIINoResponse() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::amexManual(); - - $response = $card->charge(111.13) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withPoNumber('9876543210') - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - - $this->assertEquals(true, $cpcResponse != null); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - /// PRIOR / VOICE AUTHORIZATION - - public function test033OfflineSale() - { - $card = TestCards::visaManual(); - - $response = $card->charge(17.10) - ->withCurrency('USD') - ->withModifier(TransactionModifier::OFFLINE) - ->withOfflineAuthCode('654321') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test033OfflineAuthorization() - { - $card = TestCards::visaManual(); - - $response = $card->authorize(17.10) - ->withCurrency('USD') - ->withModifier(TransactionModifier::OFFLINE) - ->withOfflineAuthCode('654321') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// RETURN - - public function test034OfflineCreditReturn() - { - $card = TestCards::masterCardManual(); - - $response = $card->refund(15.15) - ->withCurrency('USD') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test034bOfflineCreditReturn() - { - $card = TestCards::masterCardManual(); - - $response = $card->refund(15.16) - ->withCurrency('USD') - ->withInvoiceNumber('123456') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ONLINE VOID / REVERSAL - - public function test035VoidTest10() - { - // see test 010 - } - - public function test036VoidTest20() - { - // see test 020 - } - - /// Time Out Reversal - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException - */ - public function test036bTimeoutReversal() - { - $sale = TestCards::visaManual()->charge(911) - ->withCurrency('USD') - ->withClientTransactionId('987321654') - ->withEcommerceInfo($this->ecommerceInfo) - ->execute(); - - $this->assertEquals(true, $sale != null); - $this->assertEquals('91', $sale->responseCode); - - $response = Transaction::fromId(null, PaymentMethodType::CREDIT); - $response->clientTransactionId = '987321654'; - - $response->reverse(911)->execute(); - } - - /// One time bill payment - - public function test010ChargeVisaOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860 Dallas Pkwy'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$visaToken; - } else { - $card = TestCards::visaManual(); - } - - $response = $card->charge(13.11) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $void = $response->void()->execute(); - - $this->assertEquals(true, $void != null); - $this->assertEquals('00', $void->responseCode); - } - - public function test011ChargeMasterCardOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '750241234'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$mastercardToken; - } else { - $card = TestCards::masterCardManual(); - } - - $response = $card->charge(13.12) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test012ChargeDiscoverOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$discoverToken; - } else { - $card = TestCards::discoverManual(); - } - - $response = $card->charge(13.13) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test013ChargeAmexOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = null; - if ($this->useTokens) { - $card = new CreditCardData(); - $card->token = static::$amexToken; - } else { - $card = TestCards::amexManual(); - } - - $response = $card->charge(13.14) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test014ChargeJcbOneTime() - { - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = new CreditCardData(); - $card->number = '3566007770007321'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - - $response = $card->charge(13.15) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withOneTimePayment(true) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ADVANCED FRAUD SCREENING - - /** - * TODO: Change code assertions when AFS is enabled on account - */ - public function test037FraudPreventionSale() - { - $card = TestCards::visaManual(); - - $response = $card->charge(15000) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - // $this->assertEquals('FR', $response->responseCode); - } - - /** - * TODO: Change code assertions when AFS is enabled on account - */ - public function test038FraudPreventionReturn() - { - $card = TestCards::visaManual(); - - $response = $card->refund(15000) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - // $this->assertEquals('41', $response->responseCode); - } - - /// ONE CARD - GSB CARD FUNCTIONS - - /// BALANCE INQUIRY - - public function test037BalanceInquiryGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::gsbManual(); - - $response = $card->balanceInquiry() - ->withAddress($address) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ADD VALUE - - public function test038AddValueGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $card = new CreditTrackData(); - $card->value = '%B6277220572999800^ / ^49121010557010000016000000?F;6277220572999800=49121010557010000016?'; - - $response = $card->addValue(15.00) - ->withCurrency('USD') - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// SALE - - public function test039ChargeGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::gsbManual(); - - $response = $card->charge(2.05) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $response->void() - ->execute(); - $this->assertEquals(true, $voidResponse != null); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test040ChargeGsb() - { - if (false === $this->usePrepaid) { - $this->markTestSkipped('GSB not configured'); - } - - $address = new Address(); - $address->streetAddress1 = '6860'; - $address->postalCode = '75024'; - - $card = TestCards::gsbManual(); - - $response = $card->charge(2.10) - ->withCurrency('USD') - ->withAddress($address) - ->withInvoiceNumber('123456') - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// ONLINE VOID / REVERSAL - - public function test041VoidGsb() - { - // see test 039 - } - - /// HMS GIFT - REWARDS - - /// ACTIVATE - - public function test042ActivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->activate(6.00) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test043ActivateGift2() - { - - $card = TestCards::giftCard2Manual(); - - $response = $card->activate(7.00) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// LOAD / ADD VALUE - - public function test044AddValueGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->addValue(8.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test045AddValueGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->addValue(9.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// BALANCE INQUIRY - - public function test046BalanceInquiryGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - public function test047BalanceInquiryGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - /// REPLACE / TRANSFER - - public function test048ReplaceGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->replaceWith(TestCards::giftCard2Manual()) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - public function test049ReplaceGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->replaceWith(TestCards::giftCard1Swipe()) - ->execute(); - - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('10.00', $response->balanceAmount); - } - - /// SALE / REDEEM - - public function test050SaleGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(1.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test051SaleGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(2.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test052SaleGift1Void() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(3.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $voidResponse = $response->void() - ->execute(); - $this->assertEquals(true, $voidResponse != null); - $this->assertEquals('00', $voidResponse->responseCode); - } - - public function test053SaleGift2Reversal() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(4.00) - ->withCurrency('USD') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - - $reversalResponse = $response->reverse(4.00) - ->execute(); - $this->assertEquals(true, $reversalResponse != null); - $this->assertEquals('00', $reversalResponse->responseCode); - } - - /// VOID - - public function test054VoidGift() - { - // see test 052 - } - - /// REVERSAL - - public function test055ReversalGift() - { - // see test 053 - } - - public function test056ReversalGift2() - { - $card = TestCards::giftCard2Manual(); - - $reversalResponse = $card->reverse(2.00) - ->execute(); - $this->assertEquals(true, $reversalResponse != null); - $this->assertEquals('00', $reversalResponse->responseCode); - } - - /// DEACTIVATE - - public function test057DeactivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->deactivate() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// RECEIPTS MESSAGING - - public function test058ReceiptsMessaging() - { - return; # print and scan receipt for test 51 - } - - /// REWARD - - /// BALANCE INQUIRY - - public function test059BalanceInquiryRewards1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->pointsBalanceAmount); - } - - public function test060BalanceInquiryRewards2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->balanceInquiry() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->pointsBalanceAmount); - } - - /// ALIAS - - public function test061CreateAliasGift1() - { - $response = GiftCard::create('9725550100'); - - $this->assertEquals(true, $response != null); - } - - public function test062CreateAliasGift2() - { - $response = GiftCard::create('9725550100'); - - $this->assertEquals(true, $response != null); - } - - public function test063AddAliasGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->addAlias('2145550199') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test064AddAliasGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->addAlias('2145550199') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test065DeleteAliasGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->removeAlias('2145550199') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// SALE / REDEEM - - public function test066RedeemPointsGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(100) - ->withCurrency('POINTS') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test067RedeemPointsGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(200) - ->withCurrency('POINTS') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test068RedeemPointsGift2() - { - $card = new GiftCard(); - $card->alias = '9725550100'; - - $response = $card->charge(300) - ->withCurrency('POINTS') - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// REWARDS - - public function test069RewardsGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->rewards(10) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test070RewardsGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->rewards(11) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// REPLACE / TRANSFER - - public function test071ReplaceGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->replaceWith(TestCards::giftCard2Manual()) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test072ReplaceGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->replaceWith(TestCards::giftCard1Swipe()) - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// DEACTIVATE - - public function test073DeactivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->deactivate() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - public function test074DeactivateGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->deactivate() - ->execute(); - $this->assertEquals(true, $response != null); - $this->assertEquals('00', $response->responseCode); - } - - /// RECEIPTS MESSAGING - - public function test075ReceiptsMessaging() - { - return; # print and scan receipt for test 51 - } - - /// CLOSE BATCH - - public function test999CloseBatch() - { - try { - $response = BatchService::closeBatch(); - $this->assertNotNull($response); - // printf('batch id: %s', $response->id); - // printf('sequence number: %s', $response->sequenceNumber); - } catch (ApiException $e) { - if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) - || false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) - ) { - $this->fail($e->getMessage()); - } - } - } -} +secretApiKey = 'skapi_cert_MRCQAQBC_VQACBE0rFaZlbDDPieMGP06JDAtjyS7NQ'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + protected function setup() + { + ServicesContainer::configureService($this->config()); + + $this->ecommerceInfo = new EcommerceInfo(); + $this->ecommerceInfo->channel = EcommerceChannel::MOTO; + } + + public function test000CloseBatch() + { + try { + $response = BatchService::closeBatch(); + $this->assertNotNull($response); + // print 'batch id: ' . $response->id . "\n"; + // print 'sequence number: ' . $response->sequenceNumber . "\n"; + } catch (ApiException $e) { + if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) + && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) + ) { + $this->fail($e->getMessage()); + } + } + } + + public function test001VerifyVisa() + { + $card = new CreditCardData(); + $card->number = '4484958240202792'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $response = $card->verify() + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test002VerifyMasterCard() + { + $card = new CreditCardData(); + $card->number = '5356083898949891'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $response = $card->verify() + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test003VerifyDiscover() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '6223971100014620'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $response = $card->verify() + ->withAddress($address) + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // StreetAddress verification + + public function test004VerifyAmex() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '345039962663847'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $response = $card->verify() + ->withAddress($address) + ->withRequestMultiUseToken($this->useTokens) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Balance Inquiry (for prepaid card) + + public function test005BalanceInquiryVisa() + { + $card = new CreditCardData(); + $card->number = '4664383951958601'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $response = $card->balanceInquiry()->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode, $response->responseMessage); + } + + // CREDIT SALE (for multi-use token only) + + public function test006ChargeVisaToken() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '4012002000060016'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $response = $card->charge(13.01) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + static::$visaToken = $response->token; + } + + public function test007ChargeMasterCardToken() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '5473500000000014'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + + $response = $card->charge(13.02) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + static::$mastercardToken = $response->token; + } + + public function test008ChargeDiscoverToken() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = new CreditCardData(); + $card->number = '6011000990156527'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + + $response = $card->charge(13.03) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + static::$discoverToken = $response->token; + } + + public function test009ChargeAmexToken() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '372700699251018'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '1234'; + + $response = $card->charge(13.04) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + static::$amexToken = $response->token; + } + + // CREDIT SALE + + public function test010ChargeVisa() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$visaToken; + } else { + $card = TestCards::visaManual(); + } + + $response = $card->charge(17.01) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 35 + $void = $response->void()->execute(); + + $this->assertNotNull($void); + $this->assertEquals('00', $void->responseCode); + } + + public function test011ChargeMasterCard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$mastercardToken; + } else { + $card = TestCards::masterCardManual(); + } + + $response = $card->charge(17.02) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test012ChargeDiscover() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$discoverToken; + } else { + $card = TestCards::discoverManual(); + } + + $response = $card->charge(17.03) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test013ChargeAmex() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$amexToken; + } else { + $card = TestCards::amexManual(); + } + + $response = $card->charge(17.04) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test014ChargeJcb() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '750241234'; + + $card = new CreditCardData(); + $card->number = '3566007770007321'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + + $response = $card->charge(17.05) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test011bChargeMasterCard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardSeries2Manual(); + + $response = $card->charge(17.02) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // AUTHORIZATION + + + public function test015AuthorizationVisa() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->authorize(17.06) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 15b + $capture = $response->capture()->execute(); + + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function test016AuthorizationMasterCard() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '750241234'; + + $card = TestCards::masterCardManual(); + + $response = $card->authorize(17.07) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 16b + $capture = $response->capture()->execute(); + + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function test017AuthorizationDiscover() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::discoverManual(); + + $response = $card->authorize(17.08) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test016bAuthorizationMasterCard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardSeries2Manual(); + + $response = $card->authorize(17.02) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // PARTIALLY APPROVED SALE + + public function test018PartialApprovalVisa() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(130) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowPartialAuth(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals('110.00', $response->authorizedAmount); + } + + public function test019PartialApprovalDiscover() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::discoverManual(); + + $response = $card->charge(145) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowPartialAuth(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals('65.00', $response->authorizedAmount); + } + + public function test020PartialApprovalMasterCard() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(155) + ->withCurrency('USD') + ->withEcommerceInfo($this->ecommerceInfo) + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowPartialAuth(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals('100.00', $response->authorizedAmount); + + // test case 36 + $void = $response->void()->execute(); + + $this->assertNotNull($void); + $this->assertEquals('00', $void->responseCode); + } + /// LEVEL II CORPORATE PURCHASE CARD + + public function test021LevelIIResponseB() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '750241234'; + + $card = TestCards::visaManual(); + + $response = $card->charge(112.34) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('B', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test022LevelIIResponseB() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = TestCards::visaManual(); + + $response = $card->charge(112.34) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('B', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test023LevelIIResponseR() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(123.45) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('R', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test024LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::visaManual(); + + $response = $card->charge(134.56) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test025LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.06) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test026LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.07) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test027LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.08) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test028LevelIIResponseS() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(); + + $response = $card->charge(111.09) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test029LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.10) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test030LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.11) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test031LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.12) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1.00) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function test032LevelIINoResponse() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::amexManual(); + + $response = $card->charge(111.13) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withAddress($address) + ->withCommercialRequest(true) + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withPoNumber('9876543210') + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + + $this->assertEquals(true, $cpcResponse != null); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + /// PRIOR / VOICE AUTHORIZATION + + public function test033OfflineSale() + { + $card = TestCards::visaManual(); + + $response = $card->charge(17.10) + ->withCurrency('USD') + ->withModifier(TransactionModifier::OFFLINE) + ->withOfflineAuthCode('654321') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test033OfflineAuthorization() + { + $card = TestCards::visaManual(); + + $response = $card->authorize(17.10) + ->withCurrency('USD') + ->withModifier(TransactionModifier::OFFLINE) + ->withOfflineAuthCode('654321') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// RETURN + + public function test034OfflineCreditReturn() + { + $card = TestCards::masterCardManual(); + + $response = $card->refund(15.15) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test034bOfflineCreditReturn() + { + $card = TestCards::masterCardManual(); + + $response = $card->refund(15.16) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ONLINE VOID / REVERSAL + + public function test035VoidTest10() + { + // see test 010 + } + + public function test036VoidTest20() + { + // see test 020 + } + + /// Time Out Reversal + public function test036bTimeoutReversal() + { + $sale = TestCards::visaManual()->charge(911) + ->withCurrency('USD') + ->withInvoiceNumber('123456') + ->withClientTransactionId('987321654') + ->withEcommerceInfo($this->ecommerceInfo) + ->execute(); + + $this->assertEquals(true, $sale != null); + $this->assertEquals('91', $sale->responseCode); + + $response = Transaction::fromId(null, PaymentMethodType::CREDIT); + $response->clientTransactionId = '987321654'; + + $this->expectException(GatewayException::class); + $response->reverse(911)->execute(); + } + + /// One time bill payment + + public function test010ChargeVisaOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860 Dallas Pkwy'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$visaToken; + } else { + $card = TestCards::visaManual(); + } + + $response = $card->charge(13.11) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $void = $response->void()->execute(); + + $this->assertEquals(true, $void != null); + $this->assertEquals('00', $void->responseCode); + } + + public function test011ChargeMasterCardOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '750241234'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$mastercardToken; + } else { + $card = TestCards::masterCardManual(); + } + + $response = $card->charge(13.12) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test012ChargeDiscoverOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$discoverToken; + } else { + $card = TestCards::discoverManual(); + } + + $response = $card->charge(13.13) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test013ChargeAmexOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = null; + if ($this->useTokens) { + $card = new CreditCardData(); + $card->token = static::$amexToken; + } else { + $card = TestCards::amexManual(); + } + + $response = $card->charge(13.14) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test014ChargeJcbOneTime() + { + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = new CreditCardData(); + $card->number = '3566007770007321'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + + $response = $card->charge(13.15) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withOneTimePayment(true) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ADVANCED FRAUD SCREENING + + /** + * TODO: Change code assertions when AFS is enabled on account + */ + public function test037FraudPreventionSale() + { + $card = TestCards::visaManual(); + + $response = $card->charge(15000) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals('FR', $response->responseCode); + } + + /** + * TODO: Change code assertions when AFS is enabled on account + */ + public function test038FraudPreventionReturn() + { + $card = TestCards::visaManual(); + + $response = $card->refund(15000) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals('41', $response->responseCode); + } + + /// ONE CARD - GSB CARD FUNCTIONS + + /// BALANCE INQUIRY + + public function test037BalanceInquiryGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::gsbManual(); + + $response = $card->balanceInquiry() + ->withAddress($address) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ADD VALUE + + public function test038AddValueGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $card = new CreditTrackData(); + $card->value = '%B6277220572999800^ / ^49121010557010000016000000?F;6277220572999800=49121010557010000016?'; + + $response = $card->addValue(15.00) + ->withCurrency('USD') + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// SALE + + public function test039ChargeGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::gsbManual(); + + $response = $card->charge(2.05) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->execute(); + $this->assertEquals(true, $voidResponse != null); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test040ChargeGsb() + { + if (false === $this->usePrepaid) { + $this->markTestSkipped('GSB not configured'); + } + + $address = new Address(); + $address->streetAddress1 = '6860'; + $address->postalCode = '75024'; + + $card = TestCards::gsbManual(); + + $response = $card->charge(2.10) + ->withCurrency('USD') + ->withAddress($address) + ->withInvoiceNumber('123456') + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// ONLINE VOID / REVERSAL + + public function test041VoidGsb() + { + // see test 039 + } + + /// HMS GIFT - REWARDS + + /// ACTIVATE + + public function test042ActivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->activate(6.00) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test043ActivateGift2() + { + + $card = TestCards::giftCard2Manual(); + + $response = $card->activate(7.00) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// LOAD / ADD VALUE + + public function test044AddValueGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->addValue(8.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test045AddValueGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->addValue(9.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// BALANCE INQUIRY + + public function test046BalanceInquiryGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + public function test047BalanceInquiryGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + /// REPLACE / TRANSFER + + public function test048ReplaceGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->replaceWith(TestCards::giftCard2Manual()) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + public function test049ReplaceGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->replaceWith(TestCards::giftCard1Swipe()) + ->execute(); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('10.00', $response->balanceAmount); + } + + /// SALE / REDEEM + + public function test050SaleGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(1.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test051SaleGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(2.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test052SaleGift1Void() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(3.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $voidResponse = $response->void() + ->execute(); + $this->assertEquals(true, $voidResponse != null); + $this->assertEquals('00', $voidResponse->responseCode); + } + + public function test053SaleGift2Reversal() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(4.00) + ->withCurrency('USD') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + + $reversalResponse = $response->reverse(4.00) + ->execute(); + $this->assertEquals(true, $reversalResponse != null); + $this->assertEquals('00', $reversalResponse->responseCode); + } + + /// VOID + + public function test054VoidGift() + { + // see test 052 + } + + /// REVERSAL + + public function test055ReversalGift() + { + // see test 053 + } + + public function test056ReversalGift2() + { + $card = TestCards::giftCard2Manual(); + + $reversalResponse = $card->reverse(2.00) + ->execute(); + $this->assertEquals(true, $reversalResponse != null); + $this->assertEquals('00', $reversalResponse->responseCode); + } + + /// DEACTIVATE + + public function test057DeactivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->deactivate() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// RECEIPTS MESSAGING + + public function test058ReceiptsMessaging() + { + return; # print and scan receipt for test 51 + } + + /// REWARD + + /// BALANCE INQUIRY + + public function test059BalanceInquiryRewards1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertTrue($response->pointsBalanceAmount > 0); + } + + public function test060BalanceInquiryRewards2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->balanceInquiry() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + $this->assertTrue($response->pointsBalanceAmount > 0); + } + + /// ALIAS + + public function test061CreateAliasGift1() + { + $response = GiftCard::create('9725550100'); + + $this->assertEquals(true, $response != null); + } + + public function test062CreateAliasGift2() + { + $response = GiftCard::create('9725550100'); + + $this->assertEquals(true, $response != null); + } + + public function test063AddAliasGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->addAlias('2145550199') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test064AddAliasGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->addAlias('2145550199') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test065DeleteAliasGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->removeAlias('2145550199') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// SALE / REDEEM + + public function test066RedeemPointsGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(100) + ->withCurrency('POINTS') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test067RedeemPointsGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(200) + ->withCurrency('POINTS') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test068RedeemPointsGift2() + { + $card = new GiftCard(); + $card->alias = '9725550100'; + + $response = $card->charge(300) + ->withCurrency('POINTS') + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// REWARDS + + public function test069RewardsGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->rewards(10) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test070RewardsGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->rewards(11) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// REPLACE / TRANSFER + + public function test071ReplaceGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->replaceWith(TestCards::giftCard2Manual()) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test072ReplaceGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->replaceWith(TestCards::giftCard1Swipe()) + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// DEACTIVATE + + public function test073DeactivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->deactivate() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function test074DeactivateGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->deactivate() + ->execute(); + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /// RECEIPTS MESSAGING + + public function test075ReceiptsMessaging() + { + return; # print and scan receipt for test 51 + } + + /// CLOSE BATCH + + public function test999CloseBatch() + { + try { + $response = BatchService::closeBatch(); + $this->assertNotNull($response); + // printf('batch id: %s', $response->id); + // printf('sequence number: %s', $response->sequenceNumber); + } catch (ApiException $e) { + if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) + || false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) + ) { + $this->fail($e->getMessage()); + } + } + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.php index e615271b..a190fc4b 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.php @@ -1,630 +1,626 @@ -identifierBase, $this->todayDate, $identifier); - } - - /** - * @return PorticoConfig - */ - private function config() - { - $config = new PorticoConfig(); - $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - public function setup() : void - { - ServicesContainer::configureService($this->config()); - - $this->todayDate = date('Ymd'); - $this->identifierBase = substr( - sprintf('%s-%%s', GenerationUtils::getGuid()), - 0, - 10 - ); - } - - public function test000CleanUp() - { - try { - $results = Schedule::findAll(); - foreach ($results as $schedule) { - $schedule->delete(true); - } - } catch (\Exception $e) { - } - - try { - $results = RecurringPaymentMethod::findAll(); - foreach ($results as $paymentMethod) { - $paymentMethod->delete(true); - } - } catch (\Exception $e) { - } - - try { - $results = Customer::findAll(); - foreach ($results as $customer) { - $customer->delete(true); - } - } catch (\Exception $e) { - } - } - - // CUSTOMER SETUP - - public function test001AddCustomerPerson() - { - $customer = new Customer(); - $customer->id = $this->getIdentifier('Person'); - $customer->firstName = 'John'; - $customer->lastName = 'Doe'; - $customer->status = 'Active'; - $customer->email = 'john.doe@example.com'; - $customer->address = new Address(); - $customer->address->streetAddress1 = '123 Main St.'; - $customer->address->city = 'Dallas'; - $customer->address->province = 'TX'; - $customer->address->postalCode = '75024'; - $customer->address->country = 'USA'; - $customer->workPhone = '5551112222'; - - $customer = $customer->create(); - - $this->assertNotNull($customer); - $this->assertNotNull($customer->key); - static::$customerPerson = $customer; - - $found = Customer::find($customer->id); - $this->assertNotNull($found); - } - - public function test002AddCustomerBusiness() - { - $customer = new Customer(); - $customer->id = $this->getIdentifier('Business'); - $customer->company = 'AcmeCo'; - $customer->status = 'Active'; - $customer->email = 'john.doe@example.com'; - $customer->address = new Address(); - $customer->address->streetAddress1 = '987 Elm St.'; - $customer->address->city = 'Princeton'; - $customer->address->province = 'NJ'; - $customer->address->postalCode = '12345'; - $customer->address->country = 'USA'; - $customer->workPhone = '5551112222'; - - $customer = $customer->create(); - - $this->assertNotNull($customer); - $this->assertNotNull($customer->key); - static::$customerBusiness = $customer; - } - - // PAYMENT METHOD SETUP - - public function test003AddPaymentCreditVisa() - { - if (static::$customerPerson === null) { - $this->markTestIncomplete(); - } - - $card = new CreditCardData(); - $card->number = '4012002000060016'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $paymentMethod = static::$customerPerson->addPaymentMethod( - $this->getIdentifier('CreditV'), - $card - )->create(); - - $this->assertNotNull($paymentMethod); - $this->assertNotNull($paymentMethod->key); - static::$paymentMethodVisa = $paymentMethod; - } - - public function test004AddPaymentCreditMasterCard() - { - if (static::$customerPerson === null) { - $this->markTestIncomplete(); - } - - $card = new CreditCardData(); - $card->number = '5473500000000014'; - $card->expMonth = '12'; - $card->expYear = TestCards::validCardExpYear(); - - $paymentMethod = static::$customerPerson->addPaymentMethod( - $this->getIdentifier('CreditMC'), - $card - )->create(); - - $this->assertNotNull($paymentMethod); - $this->assertNotNull($paymentMethod->key); - static::$paymentMethodMasterCard = $paymentMethod; - } - - public function test005AddPaymentCheckPpd() - { - if (static::$customerPerson === null) { - $this->markTestIncomplete(); - } - - $check = new ECheck(); - $check->accountType = AccountType::CHECKING; - $check->checkType = CheckType::PERSONAL; - $check->secCode = SecCode::PPD; - $check->routingNumber = '122000030'; - $check->driversLicenseNumber = '7418529630'; - $check->driversLicenseState = 'TX'; - $check->accountNumber = '1357902468'; - $check->birthYear = 1989; - - $paymentMethod = static::$customerPerson->addPaymentMethod( - $this->getIdentifier('CheckPpd'), - $check - )->create(); - - $this->assertNotNull($paymentMethod); - $this->assertNotNull($paymentMethod->key); - static::$paymentMethodCheckPpd = $paymentMethod; - } - - public function test006AddPaymentCheckCcd() - { - if (static::$customerBusiness === null) { - $this->markTestIncomplete(); - } - - $check = new eCheck(); - $check->accountType = AccountType::CHECKING; - $check->checkType = CheckType::BUSINESS; - $check->secCode = SecCode::CCD; - $check->routingNumber = '122000030'; - $check->driversLicenseNumber = '7418529630'; - $check->driversLicenseState = 'TX'; - $check->accountNumber = '1357902468'; - $check->birthYear = 1989; - - $paymentMethod = static::$customerBusiness->addPaymentMethod( - $this->getIdentifier('CheckCcd'), - $check - )->create(); - - $this->assertNotNull($paymentMethod); - $this->assertNotNull($paymentMethod->key); - static::$paymentMethodCheckCcd = $paymentMethod; - } - - // PAYMENT SETUP - DECLINED - - /** - * expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - */ - public function test007AddPaymentCheckPpd() - { - if (static::$customerPerson === null) { - $this->markTestIncomplete(); - } - - $check = new eCheck(); - $check->accountType = AccountType::CHECKING; - $check->checkType = CheckType::PERSONAL; - $check->secCode = SecCode::PPD; - $check->routingNumber = '122000030'; - $check->driversLicenseNumber = '7418529630'; - $check->driversLicenseState = 'TX'; - $check->accountNumber = '1357902468'; - $check->birthYear = 1989; - - static::$customerPerson->addPaymentMethod( - $this->getIdentifier('CheckPpd'), - $check - )->create(); - } - - // Recurring Billing using PayPlan - Managed Schedule - - public function test008AddScheduleCreditVisa() - { - if (static::$paymentMethodVisa === null) { - $this->markTestIncomplete(); - } - - static::$scheduleVisaID = $this->getIdentifier('CreditV'); - - $schedule = static::$paymentMethodVisa->addSchedule( - static::$scheduleVisaID - ) - ->withStatus('Active') - ->withAmount(30.02) - ->withCurrency('USD') - ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) - ->withFrequency(ScheduleFrequency::WEEKLY) - ->withEndDate(\DateTime::createFromFormat('Y-m-d', '2027-04-01')) - ->withReprocessingCount(2) - ->create(); - - $this->assertNotNull($schedule); - $this->assertNotNull($schedule->key); - static::$scheduleVisa = $schedule; - } - - public function test009AddScheduleCreditMasterCard() - { - if (static::$paymentMethodMasterCard == null) { - $this->markTestIncomplete(); - } - - $schedule = static::$paymentMethodMasterCard->addSchedule( - $this->getIdentifier('CreditMC') - ) - ->withStatus('Active') - ->withAmount(30.02) - ->withCurrency('USD') - ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) - ->withFrequency(ScheduleFrequency::WEEKLY) - ->withEndDate(\DateTime::createFromFormat('Y-m-d', '2027-04-01')) - ->withReprocessingCount(2) - ->create(); - $this->assertNotNull($schedule); - $this->assertNotNull($schedule->key); - static::$scheduleMasterCard = $schedule; - } - - public function test010AddScheduleCheckPPD() - { - if (static::$paymentMethodCheckPpd == null) { - $this->markTestIncomplete(); - } - - $schedule = static::$paymentMethodCheckPpd->addSchedule( - $this->getIdentifier('CheckPPD') - ) - ->withStatus('Active') - ->withAmount(30.03) - ->withCurrency('USD') - ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) - ->withFrequency(ScheduleFrequency::MONTHLY) - ->withReprocessingCount(1) - ->withnumberOfPaymentsRemaining(2) - ->create(); - $this->assertNotNull($schedule); - $this->assertNotNull($schedule->key); - static::$scheduleCheckPpd = $schedule; - } - - public function test011AddScheduleCheckCCD() - { - if (static::$paymentMethodCheckCcd == null) { - $this->markTestIncomplete(); - } - - $schedule = static::$paymentMethodCheckCcd->addSchedule( - $this->getIdentifier('CheckCCD') - ) - ->withStatus('Active') - ->withAmount(30.04) - ->withCurrency('USD') - ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) - ->withFrequency(ScheduleFrequency::BI_WEEKLY) - ->withReprocessingCount(1) - ->create(); - $this->assertNotNull($schedule); - $this->assertNotNull($schedule->key); - static::$scheduleCheckCcd = $schedule; - } - - /** - * expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - */ - public function test012AddScheduleCreditVisa() - { - if (static::$paymentMethodVisa == null) { - $this->markTestIncomplete(); - } - - $schedule = static::$paymentMethodVisa->addSchedule( - $this->getIdentifier('CreditV') - ) - ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) - ->withAmount(30.01) - ->withCurrency('USD') - ->withFrequency(ScheduleFrequency::WEEKLY) - ->withReprocessingCount(1) - ->withStatus('Active') - ->create(); - } - - /** - * expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - */ - public function test013AddScheduleCCheckPPD() - { - if (static::$paymentMethodCheckPpd == null) { - $this->markTestIncomplete(); - } - - $schedule = static::$paymentMethodCheckPpd->addSchedule( - $this->getIdentifier('CheckPPD') - ) - ->withStatus('Active') - ->withAmount(30.03) - ->withCurrency('USD') - ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) - ->withFrequency(ScheduleFrequency::MONTHLY) - ->withReprocessingCount(1) - ->withnumberOfPaymentsRemaining(2) - ->create(); - } - - // Recurring Billing using PayPlan - Managed Schedule - - public function test014RecurringBillingVisa() - { - if (static::$paymentMethodVisa == null || static::$scheduleVisa == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodVisa->charge(20.01) - ->withCurrency('USD') - ->withScheduleId(static::$scheduleVisa->key) - ->withOneTimePayment(false) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test015RecurringBillingMasterCard() - { - if (true || static::$paymentMethodMasterCard == null || static::$scheduleMasterCard == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodMasterCard->charge(20.02) - ->withCurrency('USD') - ->withScheduleId(static::$scheduleVisa->key) - ->withOneTimePayment(false) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test016RecurringBillingCheckPPD() - { - if (static::$paymentMethodCheckPpd == null || static::$scheduleCheckPpd == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodCheckPpd->charge(20.03) - ->withCurrency('USD') - ->withScheduleId(static::$scheduleVisa->key) - ->withOneTimePayment(false) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test017RecurringBillingCheckCCD() - { - if (static::$paymentMethodCheckCcd == null || static::$scheduleCheckCcd == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodCheckCcd->charge(20.04) - ->withCurrency('USD') - ->withScheduleId(static::$scheduleVisa->key) - ->withOneTimePayment(false) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // One time bill payment - - public function test018RecurringBillingVisa() - { - if (static::$paymentMethodVisa == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodVisa->charge(20.06) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test019RecurringBillingMasterCard() - { - if (static::$paymentMethodMasterCard == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodMasterCard->charge(20.07) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test020RecurringBillingCheckPPD() - { - if (static::$paymentMethodCheckPpd == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodCheckPpd->charge(20.08) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function test021RecurringBillingCheckCCD() - { - if (static::$paymentMethodCheckCcd == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodCheckCcd->charge(20.09) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Onetime bill payment - declined - - public function test022RecurringBillingVisa_Decline() - { - if (static::$paymentMethodVisa == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodVisa->charge(10.08) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('51', $response->responseCode); - } - - public function test023RecurringBillingCheckPPD_Decline() - { - if (true || static::$paymentMethodCheckPpd == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodCheckPpd->charge(25.02) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('1', $response->responseCode); - } - - public function test024RecurringBillingVisaWithCOF() - { - if (static::$paymentMethodVisa == null || static::$scheduleVisa == null) { - $this->markTestIncomplete(); - } - - $response = static::$paymentMethodVisa->charge(20.01) - ->withCurrency('USD') - ->withScheduleId(static::$scheduleVisa->key) - ->withOneTimePayment(false) - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->cardBrandTransactionId); - - $nextResponse = static::$paymentMethodVisa->charge(20.01) - ->withCurrency('USD') - ->withScheduleId(static::$scheduleVisa->key) - ->withOneTimePayment(false) - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) - ->execute(); - - $this->assertNotNull($nextResponse); - $this->assertEquals('00', $nextResponse->responseCode); - } - - public function test025EditStartDateUsingString() - { - $schedule = Schedule::find(static::$scheduleVisaID); - $schedule->startDate = '01022026'; - $schedule->saveChanges(); - } - - public function test026EditStartDateUsingDateTimeObj() - { - $updateTimeValueAsObj = new DateTime(); - $updateTimeValueAsObj->add(new DateInterval('P1Y')); - - $schedule = Schedule::find(static::$scheduleVisaID); - $schedule->startDate = $updateTimeValueAsObj; - $schedule->saveChanges(); - } -} +identifierBase, $this->todayDate, $identifier); + } + + /** + * @return PorticoConfig + */ + private function config() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + public function setup() : void + { + ServicesContainer::configureService($this->config()); + + $this->todayDate = date('Ymd'); + $this->identifierBase = substr( + sprintf('%s-%%s', GenerationUtils::getGuid()), + 0, + 10 + ); + } + + public function test000CleanUp() + { + try { + $results = Schedule::findAll(); + foreach ($results as $schedule) { + $schedule->delete(true); + } + } catch (\Exception $e) { + } + + try { + $results = RecurringPaymentMethod::findAll(); + foreach ($results as $paymentMethod) { + $paymentMethod->delete(true); + } + } catch (\Exception $e) { + } + + try { + $results = Customer::findAll(); + foreach ($results as $customer) { + $customer->delete(true); + } + } catch (\Exception $e) { + } + } + + // CUSTOMER SETUP + + public function test001AddCustomerPerson() + { + $customer = new Customer(); + $customer->id = $this->getIdentifier('Person'); + $customer->firstName = 'John'; + $customer->lastName = 'Doe'; + $customer->status = 'Active'; + $customer->email = 'john.doe@example.com'; + $customer->address = new Address(); + $customer->address->streetAddress1 = '123 Main St.'; + $customer->address->city = 'Dallas'; + $customer->address->province = 'TX'; + $customer->address->postalCode = '75024'; + $customer->address->country = 'USA'; + $customer->workPhone = '5551112222'; + + $customer = $customer->create(); + + $this->assertNotNull($customer); + $this->assertNotNull($customer->key); + static::$customerPerson = $customer; + + $found = Customer::find($customer->id); + $this->assertNotNull($found); + } + + public function test002AddCustomerBusiness() + { + $customer = new Customer(); + $customer->id = $this->getIdentifier('Business'); + $customer->company = 'AcmeCo'; + $customer->status = 'Active'; + $customer->email = 'john.doe@example.com'; + $customer->address = new Address(); + $customer->address->streetAddress1 = '987 Elm St.'; + $customer->address->city = 'Princeton'; + $customer->address->province = 'NJ'; + $customer->address->postalCode = '12345'; + $customer->address->country = 'USA'; + $customer->workPhone = '5551112222'; + + $customer = $customer->create(); + + $this->assertNotNull($customer); + $this->assertNotNull($customer->key); + static::$customerBusiness = $customer; + } + + // PAYMENT METHOD SETUP + + public function test003AddPaymentCreditVisa() + { + if (static::$customerPerson === null) { + $this->markTestIncomplete(); + } + + $card = new CreditCardData(); + $card->number = '4012002000060016'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $paymentMethod = static::$customerPerson->addPaymentMethod( + $this->getIdentifier('CreditV'), + $card + )->create(); + + $this->assertNotNull($paymentMethod); + $this->assertNotNull($paymentMethod->key); + static::$paymentMethodVisa = $paymentMethod; + } + + public function test004AddPaymentCreditMasterCard() + { + if (static::$customerPerson === null) { + $this->markTestIncomplete(); + } + + $card = new CreditCardData(); + $card->number = '5473500000000014'; + $card->expMonth = '12'; + $card->expYear = TestCards::validCardExpYear(); + + $paymentMethod = static::$customerPerson->addPaymentMethod( + $this->getIdentifier('CreditMC'), + $card + )->create(); + + $this->assertNotNull($paymentMethod); + $this->assertNotNull($paymentMethod->key); + static::$paymentMethodMasterCard = $paymentMethod; + } + + public function test005AddPaymentCheckPpd() + { + if (static::$customerPerson === null) { + $this->markTestIncomplete(); + } + + $check = new ECheck(); + $check->accountType = AccountType::CHECKING; + $check->checkType = CheckType::PERSONAL; + $check->secCode = SecCode::PPD; + $check->routingNumber = '122000030'; + $check->driversLicenseNumber = '7418529630'; + $check->driversLicenseState = 'TX'; + $check->accountNumber = '1357902468'; + $check->birthYear = 1989; + + $paymentMethod = static::$customerPerson->addPaymentMethod( + $this->getIdentifier('CheckPpd'), + $check + )->create(); + + $this->assertNotNull($paymentMethod); + $this->assertNotNull($paymentMethod->key); + static::$paymentMethodCheckPpd = $paymentMethod; + } + + public function test006AddPaymentCheckCcd() + { + if (static::$customerBusiness === null) { + $this->markTestIncomplete(); + } + + $check = new eCheck(); + $check->accountType = AccountType::CHECKING; + $check->checkType = CheckType::BUSINESS; + $check->secCode = SecCode::CCD; + $check->routingNumber = '122000030'; + $check->driversLicenseNumber = '7418529630'; + $check->driversLicenseState = 'TX'; + $check->accountNumber = '1357902468'; + $check->birthYear = 1989; + + $paymentMethod = static::$customerBusiness->addPaymentMethod( + $this->getIdentifier('CheckCcd'), + $check + )->create(); + + $this->assertNotNull($paymentMethod); + $this->assertNotNull($paymentMethod->key); + static::$paymentMethodCheckCcd = $paymentMethod; + } + + // PAYMENT SETUP - DECLINED + + /** + * expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + */ + public function test007AddPaymentCheckPpd() + { + if (static::$customerPerson === null) { + $this->markTestIncomplete(); + } + + $check = new eCheck(); + $check->accountType = AccountType::CHECKING; + $check->checkType = CheckType::PERSONAL; + $check->secCode = SecCode::PPD; + $check->routingNumber = '122000030'; + $check->driversLicenseNumber = '7418529630'; + $check->driversLicenseState = 'TX'; + $check->accountNumber = '1357902468'; + $check->birthYear = 1989; + + static::$customerPerson->addPaymentMethod( + $this->getIdentifier('CheckPpd'), + $check + )->create(); + } + + // Recurring Billing using PayPlan - Managed Schedule + + public function test008AddScheduleCreditVisa() + { + if (static::$paymentMethodVisa === null) { + $this->markTestIncomplete(); + } + + static::$scheduleVisaID = $this->getIdentifier('CreditV'); + + $schedule = static::$paymentMethodVisa->addSchedule( + static::$scheduleVisaID + ) + ->withStatus('Active') + ->withAmount(30.02) + ->withCurrency('USD') + ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) + ->withFrequency(ScheduleFrequency::WEEKLY) + ->withEndDate(\DateTime::createFromFormat('Y-m-d', '2027-04-01')) + ->withReprocessingCount(2) + ->create(); + + $this->assertNotNull($schedule); + $this->assertNotNull($schedule->key); + static::$scheduleVisa = $schedule; + } + + public function test009AddScheduleCreditMasterCard() + { + if (static::$paymentMethodMasterCard == null) { + $this->markTestIncomplete(); + } + + $schedule = static::$paymentMethodMasterCard->addSchedule( + $this->getIdentifier('CreditMC') + ) + ->withStatus('Active') + ->withAmount(30.02) + ->withCurrency('USD') + ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) + ->withFrequency(ScheduleFrequency::WEEKLY) + ->withEndDate(\DateTime::createFromFormat('Y-m-d', '2027-04-01')) + ->withReprocessingCount(2) + ->create(); + $this->assertNotNull($schedule); + $this->assertNotNull($schedule->key); + static::$scheduleMasterCard = $schedule; + } + + public function test010AddScheduleCheckPPD() + { + if (static::$paymentMethodCheckPpd == null) { + $this->markTestIncomplete(); + } + + $schedule = static::$paymentMethodCheckPpd->addSchedule( + $this->getIdentifier('CheckPPD') + ) + ->withStatus('Active') + ->withAmount(30.03) + ->withCurrency('USD') + ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) + ->withFrequency(ScheduleFrequency::MONTHLY) + ->withReprocessingCount(1) + ->withnumberOfPaymentsRemaining(2) + ->create(); + $this->assertNotNull($schedule); + $this->assertNotNull($schedule->key); + static::$scheduleCheckPpd = $schedule; + } + + public function test011AddScheduleCheckCCD() + { + if (static::$paymentMethodCheckCcd == null) { + $this->markTestIncomplete(); + } + + $schedule = static::$paymentMethodCheckCcd->addSchedule( + $this->getIdentifier('CheckCCD') + ) + ->withStatus('Active') + ->withAmount(30.04) + ->withCurrency('USD') + ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) + ->withFrequency(ScheduleFrequency::BI_WEEKLY) + ->withReprocessingCount(1) + ->create(); + $this->assertNotNull($schedule); + $this->assertNotNull($schedule->key); + static::$scheduleCheckCcd = $schedule; + } + + /** + * expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + */ + public function test012AddScheduleCreditVisa() + { + if (static::$paymentMethodVisa == null) { + $this->markTestIncomplete(); + } + + $schedule = static::$paymentMethodVisa->addSchedule( + $this->getIdentifier('CreditV') + ) + ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) + ->withAmount(30.01) + ->withCurrency('USD') + ->withFrequency(ScheduleFrequency::WEEKLY) + ->withReprocessingCount(1) + ->withStatus('Active') + ->create(); + } + + /** + * expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + */ + public function test013AddScheduleCCheckPPD() + { + if (static::$paymentMethodCheckPpd == null) { + $this->markTestIncomplete(); + } + + $schedule = static::$paymentMethodCheckPpd->addSchedule( + $this->getIdentifier('CheckPPD') + ) + ->withStatus('Active') + ->withAmount(30.03) + ->withCurrency('USD') + ->withStartDate(\DateTime::createFromFormat('Y-m-d', '2027-02-01')) + ->withFrequency(ScheduleFrequency::MONTHLY) + ->withReprocessingCount(1) + ->withnumberOfPaymentsRemaining(2) + ->create(); + } + + // Recurring Billing using PayPlan - Managed Schedule + + public function test014RecurringBillingVisa() + { + if (static::$paymentMethodVisa == null || static::$scheduleVisa == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodVisa->charge(20.01) + ->withCurrency('USD') + ->withScheduleId(static::$scheduleVisa->key) + ->withOneTimePayment(false) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test015RecurringBillingMasterCard() + { + if (true || static::$paymentMethodMasterCard == null || static::$scheduleMasterCard == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodMasterCard->charge(20.02) + ->withCurrency('USD') + ->withScheduleId(static::$scheduleVisa->key) + ->withOneTimePayment(false) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test016RecurringBillingCheckPPD() + { + if (static::$paymentMethodCheckPpd == null || static::$scheduleCheckPpd == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodCheckPpd->charge(20.03) + ->withCurrency('USD') + ->withScheduleId(static::$scheduleVisa->key) + ->withOneTimePayment(false) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test017RecurringBillingCheckCCD() + { + if (static::$paymentMethodCheckCcd == null || static::$scheduleCheckCcd == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodCheckCcd->charge(20.04) + ->withCurrency('USD') + ->withScheduleId(static::$scheduleVisa->key) + ->withOneTimePayment(false) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // One time bill payment + + public function test018RecurringBillingVisa() + { + if (static::$paymentMethodVisa == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodVisa->charge(20.06) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test019RecurringBillingMasterCard() + { + if (static::$paymentMethodMasterCard == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodMasterCard->charge(20.07) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test020RecurringBillingCheckPPD() + { + if (static::$paymentMethodCheckPpd == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodCheckPpd->charge(20.08) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function test021RecurringBillingCheckCCD() + { + if (static::$paymentMethodCheckCcd == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodCheckCcd->charge(20.09) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Onetime bill payment - declined + + public function test022RecurringBillingVisaDecline() + { + if (static::$paymentMethodVisa == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodVisa->charge(10.08) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('51', $response->responseCode); + } + + public function test023RecurringBillingCheckPPDDecline() + { + if (true || static::$paymentMethodCheckPpd == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodCheckPpd->charge(25.02) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('1', $response->responseCode); + } + + public function test024RecurringBillingVisaWithCOF() + { + if (static::$paymentMethodVisa == null || static::$scheduleVisa == null) { + $this->markTestIncomplete(); + } + + $response = static::$paymentMethodVisa->charge(20.01) + ->withCurrency('USD') + ->withScheduleId(static::$scheduleVisa->key) + ->withOneTimePayment(false) + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->cardBrandTransactionId); + + $nextResponse = static::$paymentMethodVisa->charge(20.01) + ->withCurrency('USD') + ->withScheduleId(static::$scheduleVisa->key) + ->withOneTimePayment(false) + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) + ->execute(); + + $this->assertNotNull($nextResponse); + $this->assertEquals('00', $nextResponse->responseCode); + } + + public function test025EditStartDateUsingString() + { + $schedule = Schedule::find(static::$scheduleVisaID); + $schedule->startDate = '01022026'; + $schedule->saveChanges(); + } + + public function test026EditStartDateUsingDateTimeObj() + { + $updateTimeValueAsObj = new DateTime(); + $updateTimeValueAsObj->add(new DateInterval('P1Y')); + + $schedule = Schedule::find(static::$scheduleVisaID); + $schedule->startDate = $updateTimeValueAsObj; + $schedule->saveChanges(); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.php index bf526119..273bb3e8 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.php @@ -1,1982 +1,1982 @@ -secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - ServicesContainer::Configure($config); - } - - public function testRetail000CloseBatch() - { - try { - $response = BatchService::closeBatch(); - $this->assertNotNull($response); - // error_log(sprintf('Batch ID: %s', $response->Id)); - // error_log(sprintf('Sequence Number: %s', $response->sequenceNumber)); - } catch (ApiException $e) { - if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) - && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) - ) { - $this->fail($e->getMessage()); - } - } - } - - /* - CREDIT CARD FUNCTIONS - CARD VERIFY - ACCOUNT VERIFICATION - */ - - public function testRetail001CardVerifyVisa() - { - $visaenc = TestCards::visaSwipeEncrypted(); - - $response = $visaenc->verify() - ->withAllowDuplicates(true) - ->withRequestMultiUseToken(static::$useTokens) - ->execute(); - $this->assertNotNull($response, '$response is null'); - $this->assertEquals('00', $response->responseCode, $response->responseMessage); - - if (static::$useTokens) { - $this->assertNotNull($response->token, 'token is null'); - - $token = new CreditCardData(); - $token->token = $response->token; - - $saleResponse = $token->charge(15.01) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($saleResponse); - $this->assertEquals('00', $saleResponse->responseCode); - } - } - - public function testRetail002CardVerifyMastercardSwipe() - { - $cardenc = TestCards::masterCardSwipeEncrypted(); - - $response = $cardenc->verify() - ->withAllowDuplicates(true) - ->withRequestMultiUseToken(static::$useTokens) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - if (static::$useTokens) { - $this->assertNotNull($response->token); - - $token = new CreditCardData(); - $token->token = $response->token; - - $saleResponse = $token->charge(15.02) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($saleResponse); - $this->assertEquals('00', $saleResponse->responseCode); - } - } - - public function testRetail003CardVerifyDiscover() - { - $discoverenc = TestCards::discoverSwipeEncrypted(); - - $response = $discoverenc->verify() - ->withAllowDuplicates(true) - ->withRequestMultiUseToken(static::$useTokens) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - if (static::$useTokens) { - $this->assertNotNull($response->token); - - $token = new CreditCardData(); - $token->token = $response->token; - - $saleResponse = $token->charge(15.03) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($saleResponse); - $this->assertEquals('00', $saleResponse->responseCode); - } - } - - // Address Verification - - public function testRetail004CardVerifyAmex() - { - $address = new Address(); - $address->postalCode = '75024'; - - $manualamex = TestCards::amexManual(false, true); - - $response = $manualamex->verify() - ->withAllowDuplicates(true) - ->withAddress($address) - ->withRequestMultiUseToken(static::$useTokens) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - if (static::$useTokens) { - $this->assertNotNull($response->token); - - $token = new CreditCardData(); - $token->token = $response->token; - - $saleResponse = $token->charge(15.04) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($saleResponse); - $this->assertEquals('00', $saleResponse->responseCode); - } - } - - // Balance Inquiry (for Prepaid) - - public function testRetail005BalanceInquiryVisa() - { - $visaenc = TestCards::visaSwipeEncrypted(); - - $response = $visaenc->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // CREDIT SALE (For multi-use token only) - - public function testRetail006ChargeVisaSwipeToken() - { - $card = TestCards::visaSwipe(); - $response = $card->charge(15.01) - ->withCurrency('USD') - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - static::$visatoken = $response->token; - } - - public function testRetail007ChargeMastercardSwipeToken() - { - $card = TestCards::masterCardSwipe(); - $response = $card->charge(15.02) - ->withCurrency('USD') - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - static::$mastercardtoken = $response->token; - } - - public function testRetail008ChargeDiscoverSwipeToken() - { - $card = TestCards::discoverSwipe(); - $response = $card->charge(15.03) - ->withCurrency('USD') - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - static::$discovertoken = $response->token; - } - - public function testRetail009ChargeAmexSwipeToken() - { - $card = TestCards::amexSwipe(); - $response = $card->charge(15.04) - ->withCurrency('USD') - ->withRequestMultiUseToken(true) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - static::$amextoken = $response->token; - } - - /* - CREDIT SALE - SWIPED - */ - - public function testRetail010ChargeVisaSwipe() - { - $card = TestCards::visaSwipe(); - $response = $card->charge(15.01) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test 59 - $reverse = $response->reverse(15.01) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reverse); - $this->assertEquals('00', $reverse->responseCode); - } - - public function testRetail011ChargeMastercardSwipe() - { - $card = TestCards::masterCardSwipe(); - $response = $card->charge(15.02) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail012ChargeDiscoverSwipe() - { - $card = TestCards::discoverSwipe(); - $response = $card->charge(15.03) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail013ChargeAmexSwipe() - { - $card = TestCards::amexSwipe(); - $response = $card->charge(15.04) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail014ChargeJcbSwipe() - { - $card = TestCards::JcbSwipe(); - $response = $card->charge(15.05) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 58 - $refund = $response->refund(15.05) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($refund); - $this->assertEquals('00', $refund->responseCode); - } - - public function testRetail014aChargeRetailMastercard24() - { - $card = TestCards::masterCard24Swipe(); - $response = $card->charge(15.34) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail014bChargeRetailMastercard25() - { - $card = TestCards::masterCard25Swipe(); - $response = $card->charge(15.34) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail015ChargeVisaSwipe() - { - $card = TestCards::visaSwipe(); - $response = $card->charge(15.06) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 63 - $reversal = $response->reverse(15.06) - ->withAllowDuplicates(true) - ->withAuthAmount(5.06) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Manually Entered - Card Present - - public function testRetail016ChargeVisaManualCardPresent() - { - $address = new Address(); - $address->postalCode = '750241234'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $manualcard = TestCards::visaManual(true, true); - $response = $manualcard->charge(16.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail017ChargeMasterCardManualCardPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $manualcard = TestCards::masterCardManual(true, true); - $response = $manualcard->charge(16.02) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 60 - $reverse = $response->reverse(16.02) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reverse); - $this->assertEquals('00', $reverse->responseCode); - } - - public function testRetail018ChargeDiscoverManualCardPresent() - { - $address = new Address(); - $address->postalCode = '750241234'; - - $manualcard = TestCards::discoverManual(true, true); - $response = $manualcard->charge(16.03) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail019ChargeAmexManualCardPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860'; - - $manualcard = TestCards::amexManual(true, true); - $response = $manualcard->charge(16.04) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail020ChargeJcbManualCardPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - - $manualcard = TestCards::JcbManual(true, true); - $response = $manualcard->charge(16.05) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail021ChargeDiscoverManualCardPresent() - { - $address = new Address(); - $address->postalCode = '750241234'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $manualcard = TestCards::discoverManual(true, true); - $response = $manualcard->charge(16.07) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 64 - $reversal = $response->reverse(16.07) - ->withAllowDuplicates(true) - ->withAuthAmount(6.07) - ->execute(); - $this->assertNotNull($reversal); - $this->assertEquals('00', $reversal->responseCode); - } - - // Manually Entered - Card Not Present - - public function testRetail022ChargeVisaManualCardNotPresent() - { - $address = new Address(); - $address->postalCode = '750241234'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $manualcard = null; - if (static::$useTokens) { - $manualcard = new CreditCardData(); - $manualcard->token = static::$visatoken; - } else { - $manualcard = TestCards::visaManual(false, true); - } - - $response = $manualcard->charge(17.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail023ChargeMasterCardManualCardNotPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $manualcard = null; - if (static::$useTokens) { - $manualcard = new CreditCardData(); - $manualcard->token = static::$mastercardtoken; - } else { - $manualcard = TestCards::masterCardManual(false, true); - } - - $response = $manualcard->charge(17.02) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 61 - $reversal = $response->reverse(17.02) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reversal); - $this->assertEquals('00', $reversal->responseCode); - } - - public function testRetail024ChargeDiscoverManualCardNotPresent() - { - $address = new Address(); - $address->postalCode = '750241234'; - - $manualcard = null; - if (static::$useTokens) { - $manualcard = new CreditCardData(); - $manualcard->token = static::$discovertoken; - } else { - $manualcard = TestCards::discoverManual(false, true); - } - - $response = $manualcard->charge(17.03) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail025ChargeAmexManualCardNotPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860'; - - $manualcard = null; - if (static::$useTokens) { - $manualcard = new CreditCardData(); - $manualcard->token = static::$amextoken; - } else { - $manualcard = TestCards::amexManual(false, true); - } - - $response = $manualcard->charge(17.04) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail026ChargeJcbManualCardNotPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - - $manualcard = TestCards::JcbManual(false, true); - $response = $manualcard->charge(17.05) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Contactless - - public function testRetail027ChargeVisaContactless() - { - $card = TestCards::visaSwipe(EntryMethod::PROXIMITY); - $response = $card->charge(18.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail028ChargeMastercardContactless() - { - $card = TestCards::masterCardSwipe(EntryMethod::PROXIMITY); - - $response = $card->charge(18.02) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail029ChargeDiscoverContactless() - { - $card = TestCards::discoverSwipe(EntryMethod::PROXIMITY); - - $response = $card->charge(18.03) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail030ChargeAmexContactless() - { - $card = TestCards::amexSwipe(EntryMethod::PROXIMITY); - - $response = $card->charge(18.04) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // AUTHORIZATION - - public function testRetail031AuthorizeVisaSwipe() - { - $card = TestCards::visaSwipe(); - - // 031a authorize - $response = $card->authorize(15.08) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 031b capture - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail032AuthorizeVisaSwipeAdditionalAuth() - { - $card = TestCards::visaSwipe(); - - // 032a authorize - $response = $card->authorize(15.09) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 032b Additional Auth (restaurant only) - - // 032c Add to batch - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail033AuthorizeMasterCardSwipe() - { - $card = TestCards::masterCardSwipe(); - - // 033a authorize - $response = $card->authorize(15.10) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 033b capture - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail033aAuthorizeDiscoverSwipe() - { - $card = TestCards::discoverSwipe(); - - $response = $card->authorize(15.10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // AUTHORIZATION - Manually Entered, Card Present - - public function testRetail034AuthorizeVisaManualCardPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $card = TestCards::visaManual(true, true); - - // 034a authorize - $response = $card->authorize(16.08) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 034b capture - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail035AuthorizeVisaManualCardPresentAdditionalAuth() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $card = TestCards::visaManual(true, true); - - // 035a authorize - $response = $card->authorize(16.09) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 035b Additional Auth (restaurant only) - - // 035c Add to batch - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail036AuthorizeMasterCardManualCardPresent() - { - $address = new Address(); - $address->postalCode = '75024'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $card = TestCards::masterCardManual(true, true); - - // 036a authorize - $response = $card->authorize(16.10) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 036b capture - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail036aAuthorizeDiscoverManualCardPresent() - { - $address = new Address(); - $address->postalCode = '750241234'; - - $card = TestCards::discoverManual(true, true); - $response = $card->authorize(16.10) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // AUTHORIZATION - Manually Entered, Card Not Present - - public function testRetail037AuthorizeVisaManual() - { - $address = new Address(); - $address->postalCode = '750241234'; - $address->streetAddress1 = '6860 Dallas Pkwy'; - - $card = TestCards::visaManual(false, true); - - // 034a authorize - $response = $card->authorize(17.08) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 034b capture - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail038AuthorizeMasterCardManual() - { - $address = new Address(); - $address->postalCode = '750241234'; - $address->streetAddress1 = '6860'; - - $card = TestCards::masterCardManual(false, true); - - // 036a authorize - $response = $card->authorize(17.09) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // 036b capture - $captureResponse = $response->capture()->execute(); - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testRetail038aAuthorizeDiscoverManual() - { - $address = new Address(); - $address->postalCode = '750241234'; - - $card = TestCards::discoverManual(false, true); - - $response = $card->authorize(17.10) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // PARTIALLY APPROVED SALE (Required) - - public function testRetail039ChargeDiscoverSwipePartialApproval() - { - $card = TestCards::discoverSwipe(); - - $response = $card->charge(40.00) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAllowPartialAuth(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(40.00, $response->authorizedAmount); - } - - public function testRetail040ChargeVisaSwipePartialApproval() - { - $card = TestCards::visaSwipe(); - $response = $card->charge(130.00) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAllowPartialAuth(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(110.00, $response->authorizedAmount); - } - - public function testRetail041ChargeDiscoverManualPartialApproval() - { - $address = new Address(); - $address->postalCode = '75024'; - $card = TestCards::discoverManual(true, true); - - $response = $card->charge(145.00) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAllowPartialAuth(true) - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(65.00, $response->authorizedAmount); - } - - public function testRetail042ChargeMasterCardSwipePartialApproval() - { - $card = TestCards::masterCardSwipe(); - $response = $card->charge(155.00) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAllowPartialAuth(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(100.00, $response->authorizedAmount); - - // test case 62 - $reversal = $response->reverse(100.00) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reversal); - $this->assertEquals('00', $reversal->responseCode); - } - - /* - SALE WITH GRATUITY - Tip Edit (Tip at Settlement) - */ - - public function testRetail043ChargeVisaSwipeEditGratuity() - { - $card = TestCards::visaSwipe(); - $response = $card->charge(15.12) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $editResponse = $response->edit() - ->withAllowDuplicates(true) - ->withAmount(18.12) - ->withGratuity(3.00) - ->execute(); - $this->assertNotNull($editResponse); - $this->assertEquals('00', $editResponse->responseCode); - } - - public function testRetail044ChargeMasterCardManualEditGratuity() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(true, true); - $response = $card->charge(15.13) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $editResponse = $response->edit() - ->withAllowDuplicates(true) - ->withAmount(18.13) - ->withGratuity(3.00) - ->execute(); - $this->assertNotNull($editResponse); - $this->assertEquals('00', $editResponse->responseCode); - } - - // Tip on Purchase - - public function testRetail045ChargeVisaManualGratuity() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::visaManual(true, true); - - $response = $card->charge(18.61) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withGratuity(3.50) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail046ChargeMasterCardSwipeGratuity() - { - $card = TestCards::masterCardSwipe(); - - $response = $card->charge(18.62) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withGratuity(3.50) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $editResponse = $response->edit() - ->withAllowDuplicates(true) - ->withAmount(18.12) - ->withGratuity(3.00) - ->execute(); - $this->assertNotNull($editResponse); - $this->assertEquals('00', $editResponse->responseCode); - } - - // LEVEL II CORPORATE PURCHASE CARD - - public function testRetail047LevelIIVisaSwipeResponseB() - { - $card = TestCards::visaSwipe(); - - $response = $card->charge(112.34) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('B', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail047aLevelIIVisaSwipeResponseB() - { - $card = TestCards::visaSwipe(); - - $response = $card->charge(112.34) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('B', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withTaxType(TaxType::NOT_USED) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail048LevelIIVisaSwipeResponseR() - { - $card = TestCards::visaSwipe(); - - $response = $card->charge(123.45) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('R', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail049LevelIIVisaManualResponseS() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::visaManual(true, true); - - $response = $card->charge(134.56) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail050LevelIIMasterCardSwipeResponseS() - { - $card = TestCards::masterCardSwipe(); - - $response = $card->charge(111.06) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail051LevelIIMasterCardManualResponseS() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(true, true); - - $response = $card->charge(111.07) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail051aLevelIIMasterCardManualResponseS() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(true, true); - $response = $card->charge(111.08) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail052LevelIIMasterCardManualResponseS() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::masterCardManual(true, true); - $response = $card->charge(111.09) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('S', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail053LevelIIAmexSwipeNoResponse() - { - $card = TestCards::amexSwipe(); - $response = $card->charge(111.10) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withTaxType(TaxType::SALES_TAX) - ->withTaxAmount(1) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail054LevelIIAmexManualNoResponse() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::amexManual(true, true); - - $response = $card->charge(111.11) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail055LevelIIAmexManualNoResponse() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::amexManual(true, true); - $response = $card->charge(111.12) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::NOT_USED) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - public function testRetail055aLevelIIAmexManualNoResponse() - { - $address = new Address(); - $address->postalCode = '75024'; - - $card = TestCards::amexManual(true, true); - $response = $card->charge(111.13) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAddress($address) - ->withCommercialRequest(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals('0', $response->commercialIndicator); - - $cpcResponse = $response->edit() - ->withAllowDuplicates(true) - ->withPoNumber('9876543210') - ->withTaxType(TaxType::TAX_EXEMPT) - ->execute(); - $this->assertNotNull($cpcResponse); - $this->assertEquals('00', $cpcResponse->responseCode); - } - - // OFFLINE SALE / AUTHORIZATION - - public function testRetail056OfflineChargeVisaManual() - { - $card = TestCards::visaManual(false, true); - - $response = $card->charge(15.12) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withOfflineAuthCode('654321') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail056OfflineAuthVisaManual() - { - $card = TestCards::visaManual(false, true); - - $response = $card->authorize(15.11) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withOfflineAuthCode('654321') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // RETURN - - public function testRetail057ReturnMasterCard() - { - $card = TestCards::masterCardManual(false, true); - - $response = $card->refund(15.11) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail057aReturnMasterCardSwipe() - { - $card = TestCards::masterCardSwipe(); - $response = $card->refund(15.15) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail058ReturnJcbTransactionId() - { - // See test 14 - } - - // ONLINE VOID / REVERSAL (Required) - - public function testRetail059ReversalVisa() - { - // see test 10 - } - - public function testRetail060ReversalMasterCard() - { - // see test case 17 - } - - public function testRetail061ReversalMasterCard() - { - // see test case 23 - } - - public function testRetail062ReversalMasterCard() - { - // see test case 42 - } - - public function testRetail063ReversalVisaPartial() - { - // see test case 15 - } - - public function testRetail064ReversalDiscoverPartial() - { - // see test 21 - } - - // PIN DEBIT CARD FUNCTIONS - - public function testRetail065DebitSaleVisaSwipe() - { - $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(14.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail066DebitSaleMasterCardSwipe() - { - $card = TestCards::asDebit(TestCards::masterCardSwipe(), 'F505AD81659AA42A3D123412324000AB'); - - $response = $card->charge(14.02) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - // test case 71 - $reversal = $response->reverse(14.02) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reversal); - $this->assertEquals('00', $reversal->responseCode); - } - - public function testRetail067DebitSaleVisaSwipeCashBack() - { - $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(14.03) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCashBack(5.00) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail067aDebitSaleMasterCard() - { - $card = TestCards::asDebit(TestCards::masterCardSwipe(), 'F505AD81659AA42A3D123412324000AB'); - - $response = $card->charge(14.04) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // PARTIALLY APPROVED PURCHASE - - public function testRetail068DebitSaleMasterCardPartialApproval() - { - $card = TestCards::asDebit(TestCards::masterCardSwipe(), 'F505AD81659AA42A3D123412324000AB'); - - $response = $card->charge(33.00) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAllowPartialAuth(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('10', $response->responseCode); - $this->assertEquals(22.00, $response->authorizedAmount); - } - - public function testRetail069DebitSaleVisaPartialApproval() - { - $this->markTestSkipped(); - - $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(44.00) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withAllowPartialAuth(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals(33.00, $response->authorizedAmount); - - // test case 72 - $reversal = $response->reverse(33.00) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reversal); - $this->assertEquals('00', $reversal->responseCode); - } - - // RETURN - - public function testRetail070DebitReturnVisaSwipe() - { - $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->refund(14.07) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail070aDebitReturnVisaSwipe() - { - $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->refund(14.08) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $reversalResponse = $response->reverse(14.08) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($reversalResponse); - $this->assertEquals('00', $reversalResponse->responseCode); - } - - // REVERSAL - - public function testRetail071DebitReversalMasterCard() - { - // see test case 66 - } - - public function testRetail072DebitReversalVisa() - { - // see test case 96 - } - - /* - EBT FUNCTIONS - Food Stamp Purchase - */ - - public function testRetail080EbtfsPurchaseVisaSwipe() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(101.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail081EbtfsPurchaseVisaManual() - { - $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(102.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Food Stamp Electronic Voucher (Manual Entry Only) - - public function testRetail082EbtVoucherPurchaseVisa() - { - $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); - $card->SerialNumber = '123456789012345'; - $card->approvalCode = '123456'; - - $response = $card->charge(103.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Food Stamp Balance Inquiry - - public function testRetail083EbtfsReturnVisaSwipe() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->refund(104.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail084EbtfsReturnVisaManual() - { - $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->refund(105.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Food Stamp Balance Inquiry - - public function testRetail085EbtBalanceInquiryVisaSwipe() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail086EbtBalanceInquiryVisaManual() - { - $card = TestCards::asEBTManual(TestCards::visaManual(true, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /* - $this->assertEquals('00', $response->responseCode); - EBT CASH BENEFITS - Cash Back Purchase - */ - - public function testRetail087EbtCashBackPurchaseVisaSwipe() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(106.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCashBack(5.00) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail088EbtCashBackPurchaseVisaManual() - { - $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(107.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCashBack(5.00) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // No Cash Back Purchase - - public function testRetail089EbtCashBackPurchaseVisaSwipeNoCashBack() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(108.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCashBack(0) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail090EbtCashBackPurchaseVisaManualNoCashBack() - { - $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(109.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCashBack(0) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Cash Back Balance Inquiry - - public function testRetail091EbtBalanceInquiryVisaSwipeCash() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->balanceInquiry(InquiryType::CASH)->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail092EbtBalanceInquiryVisaManualCash() - { - $card = TestCards::asEBTManual(TestCards::visaManual(true, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->balanceInquiry(InquiryType::CASH)->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - // Cash Benefits Withdrawal - - public function testRetail093EbtBenefitWithDrawalVisaSwipe() - { - $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(110.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testRetail094EbtBenefitWithDrawalVisaManual() - { - $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); - - $response = $card->charge(111.01) - ->withAllowDuplicates(true) - ->withCurrency('USD') - ->withCashBack(0) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /* - HMS GIFT - REWARDS - GIFT - ACTIVATE - */ - - public function testRetail095ActivateGift1Swipe() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->activate(6.00)->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail096ActivateGift2Manual() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->activate(7.00)->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - // ADD VALUE - - public function testRetail097AddValueGift1Swipe() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->addValue(8.00) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail098AddValueGift2Manual() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->activate(9.00)->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - // BALANCE INQUIRY - - public function testRetail099BalanceInquiryGift1Swipe() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertEquals(10.00, $response->balanceAmount); - } - - public function testRetail100BalanceInquiryGift2Manual() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - $this->assertEquals(10.00, $response->balanceAmount); - } - - // REPLACE / TRANSFER - - public function testRetail101ReplaceGift1Swipe() - { - $oldCard = TestCards::giftCard1Swipe(); - $newCard = TestCards::giftCard2Manual(); - - $response = $oldCard->replaceWith($newCard)->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail102ReplaceGift2Manual() - { - $newCard = TestCards::giftCard1Swipe(); - $oldCard = TestCards::giftCard2Manual(); - - $response = $oldCard->replaceWith($newCard)->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - // SALE / REDEEM - - public function testRetail103SaleGift1Swipe() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(1.00) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail104SaleGift2Manual() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(2.00) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail105SaleGift1VoidSwipe() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->charge(3.00) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - - // test case 107 - $voidResponse = $response->void()->execute(); - $this->assertNotNull($voidResponse); - $this->assertEquals('0', $voidResponse->responseCode); - } - - public function testRetail106SaleGift2ReversalManual() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->charge(4.00) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - - //test case 108 - $voidResponse = $response->reverse(4.00)->execute(); - $this->assertNotNull($voidResponse); - $this->assertEquals('0', $voidResponse->responseCode); - } - - // VOID - - public function testRetail107VoidGift() - { - // see test case 105 - } - - // REVERSAL - - public function testRetail108ReversalGift() - { - // see test case 106 - } - - // DEACTIVATE - - public function testRetail109DeactivateGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->deactivate()->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - // RECEIPTS MESSAGING - - public function testRetail110ReceiptsMessaging() - { - // PRINT AND SCAN RECEIPT FOR TEST 107 - } - - /* - REWARDS - BALANCE INQUIRY - */ - - public function testRetail111BalanceInquiryRewards1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - $this->assertEquals(0, $response->pointsBalanceAmount); - } - - public function testRetail112BalanceInquiryRewards2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->balanceInquiry()->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - $this->assertEquals(0, $response->pointsBalanceAmount); - } - - // ALIAS - - public function testRetail113CreateAliasGift1() - { - $card = GiftCard::create('9725550100'); - $this->assertNotNull($card); - } - - public function testRetail114CreateAliasGift2() - { - $card = GiftCard::create('9725550100'); - $this->assertNotNull($card); - } - - public function testRetail115AddAliasGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->addAlias('2145550199')->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail116AddAliasGift2() - { - $card = TestCards::giftCard2Manual(); - - $response = $card->addAlias('2145550199')->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail117DeleteAliasGift1() - { - $card = TestCards::giftCard1Swipe(); - - $response = $card->removeAlias('2145550199')->execute(); - $this->assertNotNull($response); - $this->assertEquals('0', $response->responseCode); - } - - public function testRetail999CloseBatch() - { - try { - $response = BatchService::closeBatch(); - $this->assertNotNull($response); - // error_log(sprintf('Batch ID: %s', $response->Id)); - // error_log(sprintf('Sequence Number: %s', $response->SequenceNumber)); - } catch (Exception $exec) { - if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) - && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) - ) { - $this->fail($e->getMessage()); - } - } - } -} +secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + ServicesContainer::configureService($config); + } + + public function testRetail000CloseBatch() + { + try { + $response = BatchService::closeBatch(); + $this->assertNotNull($response); + // error_log(sprintf('Batch ID: %s', $response->Id)); + // error_log(sprintf('Sequence Number: %s', $response->sequenceNumber)); + } catch (ApiException $e) { + if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) + && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) + ) { + $this->fail($e->getMessage()); + } + } + } + + /* + CREDIT CARD FUNCTIONS + CARD VERIFY + ACCOUNT VERIFICATION + */ + + public function testRetail001CardVerifyVisa() + { + $visaenc = TestCards::visaSwipeEncrypted(); + + $response = $visaenc->verify() + ->withAllowDuplicates(true) + ->withRequestMultiUseToken(static::$useTokens) + ->execute(); + $this->assertNotNull($response, '$response is null'); + $this->assertEquals('00', $response->responseCode, $response->responseMessage); + + if (static::$useTokens) { + $this->assertNotNull($response->token, 'token is null'); + + $token = new CreditCardData(); + $token->token = $response->token; + + $saleResponse = $token->charge(15.01) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($saleResponse); + $this->assertEquals('00', $saleResponse->responseCode); + } + } + + public function testRetail002CardVerifyMastercardSwipe() + { + $cardenc = TestCards::masterCardSwipeEncrypted(); + + $response = $cardenc->verify() + ->withAllowDuplicates(true) + ->withRequestMultiUseToken(static::$useTokens) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + if (static::$useTokens) { + $this->assertNotNull($response->token); + + $token = new CreditCardData(); + $token->token = $response->token; + + $saleResponse = $token->charge(15.02) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($saleResponse); + $this->assertEquals('00', $saleResponse->responseCode); + } + } + + public function testRetail003CardVerifyDiscover() + { + $discoverenc = TestCards::discoverSwipeEncrypted(); + + $response = $discoverenc->verify() + ->withAllowDuplicates(true) + ->withRequestMultiUseToken(static::$useTokens) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + if (static::$useTokens) { + $this->assertNotNull($response->token); + + $token = new CreditCardData(); + $token->token = $response->token; + + $saleResponse = $token->charge(15.03) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($saleResponse); + $this->assertEquals('00', $saleResponse->responseCode); + } + } + + // Address Verification + + public function testRetail004CardVerifyAmex() + { + $address = new Address(); + $address->postalCode = '75024'; + + $manualamex = TestCards::amexManual(false, true); + + $response = $manualamex->verify() + ->withAllowDuplicates(true) + ->withAddress($address) + ->withRequestMultiUseToken(static::$useTokens) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + if (static::$useTokens) { + $this->assertNotNull($response->token); + + $token = new CreditCardData(); + $token->token = $response->token; + + $saleResponse = $token->charge(15.04) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($saleResponse); + $this->assertEquals('00', $saleResponse->responseCode); + } + } + + // Balance Inquiry (for Prepaid) + + public function testRetail005BalanceInquiryVisa() + { + $visaenc = TestCards::visaSwipeEncrypted(); + + $response = $visaenc->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // CREDIT SALE (For multi-use token only) + + public function testRetail006ChargeVisaSwipeToken() + { + $card = TestCards::visaSwipe(); + $response = $card->charge(15.01) + ->withCurrency('USD') + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + static::$visatoken = $response->token; + } + + public function testRetail007ChargeMastercardSwipeToken() + { + $card = TestCards::masterCardSwipe(); + $response = $card->charge(15.02) + ->withCurrency('USD') + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + static::$mastercardtoken = $response->token; + } + + public function testRetail008ChargeDiscoverSwipeToken() + { + $card = TestCards::discoverSwipe(); + $response = $card->charge(15.03) + ->withCurrency('USD') + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + static::$discovertoken = $response->token; + } + + public function testRetail009ChargeAmexSwipeToken() + { + $card = TestCards::amexSwipe(); + $response = $card->charge(15.04) + ->withCurrency('USD') + ->withRequestMultiUseToken(true) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + static::$amextoken = $response->token; + } + + /* + CREDIT SALE + SWIPED + */ + + public function testRetail010ChargeVisaSwipe() + { + $card = TestCards::visaSwipe(); + $response = $card->charge(15.01) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test 59 + $reverse = $response->reverse(15.01) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reverse); + $this->assertEquals('00', $reverse->responseCode); + } + + public function testRetail011ChargeMastercardSwipe() + { + $card = TestCards::masterCardSwipe(); + $response = $card->charge(15.02) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail012ChargeDiscoverSwipe() + { + $card = TestCards::discoverSwipe(); + $response = $card->charge(15.03) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail013ChargeAmexSwipe() + { + $card = TestCards::amexSwipe(); + $response = $card->charge(15.04) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail014ChargeJcbSwipe() + { + $card = TestCards::JcbSwipe(); + $response = $card->charge(15.05) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 58 + $refund = $response->refund(15.05) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($refund); + $this->assertEquals('00', $refund->responseCode); + } + + public function testRetail014aChargeRetailMastercard24() + { + $card = TestCards::masterCard24Swipe(); + $response = $card->charge(15.34) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail014bChargeRetailMastercard25() + { + $card = TestCards::masterCard25Swipe(); + $response = $card->charge(15.34) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail015ChargeVisaSwipe() + { + $card = TestCards::visaSwipe(); + $response = $card->charge(15.06) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 63 + $reversal = $response->reverse(15.06) + ->withAllowDuplicates(true) + ->withAuthAmount(5.06) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Manually Entered - Card Present + + public function testRetail016ChargeVisaManualCardPresent() + { + $address = new Address(); + $address->postalCode = '750241234'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $manualcard = TestCards::visaManual(true, true); + $response = $manualcard->charge(16.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail017ChargeMasterCardManualCardPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $manualcard = TestCards::masterCardManual(true, true); + $response = $manualcard->charge(16.02) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 60 + $reverse = $response->reverse(16.02) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reverse); + $this->assertEquals('00', $reverse->responseCode); + } + + public function testRetail018ChargeDiscoverManualCardPresent() + { + $address = new Address(); + $address->postalCode = '750241234'; + + $manualcard = TestCards::discoverManual(true, true); + $response = $manualcard->charge(16.03) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail019ChargeAmexManualCardPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860'; + + $manualcard = TestCards::amexManual(true, true); + $response = $manualcard->charge(16.04) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail020ChargeJcbManualCardPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + + $manualcard = TestCards::JcbManual(true, true); + $response = $manualcard->charge(16.05) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail021ChargeDiscoverManualCardPresent() + { + $address = new Address(); + $address->postalCode = '750241234'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $manualcard = TestCards::discoverManual(true, true); + $response = $manualcard->charge(16.07) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 64 + $reversal = $response->reverse(16.07) + ->withAllowDuplicates(true) + ->withAuthAmount(6.07) + ->execute(); + $this->assertNotNull($reversal); + $this->assertEquals('00', $reversal->responseCode); + } + + // Manually Entered - Card Not Present + + public function testRetail022ChargeVisaManualCardNotPresent() + { + $address = new Address(); + $address->postalCode = '750241234'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $manualcard = null; + if (static::$useTokens) { + $manualcard = new CreditCardData(); + $manualcard->token = static::$visatoken; + } else { + $manualcard = TestCards::visaManual(false, true); + } + + $response = $manualcard->charge(17.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail023ChargeMasterCardManualCardNotPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $manualcard = null; + if (static::$useTokens) { + $manualcard = new CreditCardData(); + $manualcard->token = static::$mastercardtoken; + } else { + $manualcard = TestCards::masterCardManual(false, true); + } + + $response = $manualcard->charge(17.02) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 61 + $reversal = $response->reverse(17.02) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reversal); + $this->assertEquals('00', $reversal->responseCode); + } + + public function testRetail024ChargeDiscoverManualCardNotPresent() + { + $address = new Address(); + $address->postalCode = '750241234'; + + $manualcard = null; + if (static::$useTokens) { + $manualcard = new CreditCardData(); + $manualcard->token = static::$discovertoken; + } else { + $manualcard = TestCards::discoverManual(false, true); + } + + $response = $manualcard->charge(17.03) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail025ChargeAmexManualCardNotPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860'; + + $manualcard = null; + if (static::$useTokens) { + $manualcard = new CreditCardData(); + $manualcard->token = static::$amextoken; + } else { + $manualcard = TestCards::amexManual(false, true); + } + + $response = $manualcard->charge(17.04) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail026ChargeJcbManualCardNotPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + + $manualcard = TestCards::JcbManual(false, true); + $response = $manualcard->charge(17.05) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Contactless + + public function testRetail027ChargeVisaContactless() + { + $card = TestCards::visaSwipe(EntryMethod::PROXIMITY); + $response = $card->charge(18.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail028ChargeMastercardContactless() + { + $card = TestCards::masterCardSwipe(EntryMethod::PROXIMITY); + + $response = $card->charge(18.02) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail029ChargeDiscoverContactless() + { + $card = TestCards::discoverSwipe(EntryMethod::PROXIMITY); + + $response = $card->charge(18.03) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail030ChargeAmexContactless() + { + $card = TestCards::amexSwipe(EntryMethod::PROXIMITY); + + $response = $card->charge(18.04) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // AUTHORIZATION + + public function testRetail031AuthorizeVisaSwipe() + { + $card = TestCards::visaSwipe(); + + // 031a authorize + $response = $card->authorize(15.08) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 031b capture + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail032AuthorizeVisaSwipeAdditionalAuth() + { + $card = TestCards::visaSwipe(); + + // 032a authorize + $response = $card->authorize(15.09) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 032b Additional Auth (restaurant only) + + // 032c Add to batch + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail033AuthorizeMasterCardSwipe() + { + $card = TestCards::masterCardSwipe(); + + // 033a authorize + $response = $card->authorize(15.10) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 033b capture + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail033aAuthorizeDiscoverSwipe() + { + $card = TestCards::discoverSwipe(); + + $response = $card->authorize(15.10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // AUTHORIZATION - Manually Entered, Card Present + + public function testRetail034AuthorizeVisaManualCardPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $card = TestCards::visaManual(true, true); + + // 034a authorize + $response = $card->authorize(16.08) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 034b capture + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail035AuthorizeVisaManualCardPresentAdditionalAuth() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $card = TestCards::visaManual(true, true); + + // 035a authorize + $response = $card->authorize(16.09) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 035b Additional Auth (restaurant only) + + // 035c Add to batch + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail036AuthorizeMasterCardManualCardPresent() + { + $address = new Address(); + $address->postalCode = '75024'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $card = TestCards::masterCardManual(true, true); + + // 036a authorize + $response = $card->authorize(16.10) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 036b capture + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail036aAuthorizeDiscoverManualCardPresent() + { + $address = new Address(); + $address->postalCode = '750241234'; + + $card = TestCards::discoverManual(true, true); + $response = $card->authorize(16.10) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // AUTHORIZATION - Manually Entered, Card Not Present + + public function testRetail037AuthorizeVisaManual() + { + $address = new Address(); + $address->postalCode = '750241234'; + $address->streetAddress1 = '6860 Dallas Pkwy'; + + $card = TestCards::visaManual(false, true); + + // 034a authorize + $response = $card->authorize(17.08) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 034b capture + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail038AuthorizeMasterCardManual() + { + $address = new Address(); + $address->postalCode = '750241234'; + $address->streetAddress1 = '6860'; + + $card = TestCards::masterCardManual(false, true); + + // 036a authorize + $response = $card->authorize(17.09) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // 036b capture + $captureResponse = $response->capture()->execute(); + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testRetail038aAuthorizeDiscoverManual() + { + $address = new Address(); + $address->postalCode = '750241234'; + + $card = TestCards::discoverManual(false, true); + + $response = $card->authorize(17.10) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // PARTIALLY APPROVED SALE (Required) + + public function testRetail039ChargeDiscoverSwipePartialApproval() + { + $card = TestCards::discoverSwipe(); + + $response = $card->charge(40.00) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAllowPartialAuth(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(40.00, $response->authorizedAmount); + } + + public function testRetail040ChargeVisaSwipePartialApproval() + { + $card = TestCards::visaSwipe(); + $response = $card->charge(130.00) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAllowPartialAuth(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(110.00, $response->authorizedAmount); + } + + public function testRetail041ChargeDiscoverManualPartialApproval() + { + $address = new Address(); + $address->postalCode = '75024'; + $card = TestCards::discoverManual(true, true); + + $response = $card->charge(145.00) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAllowPartialAuth(true) + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(65.00, $response->authorizedAmount); + } + + public function testRetail042ChargeMasterCardSwipePartialApproval() + { + $card = TestCards::masterCardSwipe(); + $response = $card->charge(155.00) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAllowPartialAuth(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(100.00, $response->authorizedAmount); + + // test case 62 + $reversal = $response->reverse(100.00) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reversal); + $this->assertEquals('00', $reversal->responseCode); + } + + /* + SALE WITH GRATUITY + Tip Edit (Tip at Settlement) + */ + + public function testRetail043ChargeVisaSwipeEditGratuity() + { + $card = TestCards::visaSwipe(); + $response = $card->charge(15.12) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $editResponse = $response->edit() + ->withAllowDuplicates(true) + ->withAmount(18.12) + ->withGratuity(3.00) + ->execute(); + $this->assertNotNull($editResponse); + $this->assertEquals('00', $editResponse->responseCode); + } + + public function testRetail044ChargeMasterCardManualEditGratuity() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(true, true); + $response = $card->charge(15.13) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $editResponse = $response->edit() + ->withAllowDuplicates(true) + ->withAmount(18.13) + ->withGratuity(3.00) + ->execute(); + $this->assertNotNull($editResponse); + $this->assertEquals('00', $editResponse->responseCode); + } + + // Tip on Purchase + + public function testRetail045ChargeVisaManualGratuity() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::visaManual(true, true); + + $response = $card->charge(18.61) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withGratuity(3.50) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail046ChargeMasterCardSwipeGratuity() + { + $card = TestCards::masterCardSwipe(); + + $response = $card->charge(18.62) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withGratuity(3.50) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $editResponse = $response->edit() + ->withAllowDuplicates(true) + ->withAmount(18.12) + ->withGratuity(3.00) + ->execute(); + $this->assertNotNull($editResponse); + $this->assertEquals('00', $editResponse->responseCode); + } + + // LEVEL II CORPORATE PURCHASE CARD + + public function testRetail047LevelIIVisaSwipeResponseB() + { + $card = TestCards::visaSwipe(); + + $response = $card->charge(112.34) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('B', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail047aLevelIIVisaSwipeResponseB() + { + $card = TestCards::visaSwipe(); + + $response = $card->charge(112.34) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('B', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withTaxType(TaxType::NOT_USED) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail048LevelIIVisaSwipeResponseR() + { + $card = TestCards::visaSwipe(); + + $response = $card->charge(123.45) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('R', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail049LevelIIVisaManualResponseS() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::visaManual(true, true); + + $response = $card->charge(134.56) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail050LevelIIMasterCardSwipeResponseS() + { + $card = TestCards::masterCardSwipe(); + + $response = $card->charge(111.06) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail051LevelIIMasterCardManualResponseS() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(true, true); + + $response = $card->charge(111.07) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail051aLevelIIMasterCardManualResponseS() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(true, true); + $response = $card->charge(111.08) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail052LevelIIMasterCardManualResponseS() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::masterCardManual(true, true); + $response = $card->charge(111.09) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('S', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail053LevelIIAmexSwipeNoResponse() + { + $card = TestCards::amexSwipe(); + $response = $card->charge(111.10) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withTaxType(TaxType::SALES_TAX) + ->withTaxAmount(1) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail054LevelIIAmexManualNoResponse() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::amexManual(true, true); + + $response = $card->charge(111.11) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail055LevelIIAmexManualNoResponse() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::amexManual(true, true); + $response = $card->charge(111.12) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::NOT_USED) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + public function testRetail055aLevelIIAmexManualNoResponse() + { + $address = new Address(); + $address->postalCode = '75024'; + + $card = TestCards::amexManual(true, true); + $response = $card->charge(111.13) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAddress($address) + ->withCommercialRequest(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals('0', $response->commercialIndicator); + + $cpcResponse = $response->edit() + ->withAllowDuplicates(true) + ->withPoNumber('9876543210') + ->withTaxType(TaxType::TAX_EXEMPT) + ->execute(); + $this->assertNotNull($cpcResponse); + $this->assertEquals('00', $cpcResponse->responseCode); + } + + // OFFLINE SALE / AUTHORIZATION + + public function testRetail056OfflineChargeVisaManual() + { + $card = TestCards::visaManual(false, true); + + $response = $card->charge(15.12) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withOfflineAuthCode('654321') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail056OfflineAuthVisaManual() + { + $card = TestCards::visaManual(false, true); + + $response = $card->authorize(15.11) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withOfflineAuthCode('654321') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // RETURN + + public function testRetail057ReturnMasterCard() + { + $card = TestCards::masterCardManual(false, true); + + $response = $card->refund(15.11) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail057aReturnMasterCardSwipe() + { + $card = TestCards::masterCardSwipe(); + $response = $card->refund(15.15) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail058ReturnJcbTransactionId() + { + // See test 14 + } + + // ONLINE VOID / REVERSAL (Required) + + public function testRetail059ReversalVisa() + { + // see test 10 + } + + public function testRetail060ReversalMasterCard() + { + // see test case 17 + } + + public function testRetail061ReversalMasterCard() + { + // see test case 23 + } + + public function testRetail062ReversalMasterCard() + { + // see test case 42 + } + + public function testRetail063ReversalVisaPartial() + { + // see test case 15 + } + + public function testRetail064ReversalDiscoverPartial() + { + // see test 21 + } + + // PIN DEBIT CARD FUNCTIONS + + public function testRetail065DebitSaleVisaSwipe() + { + $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(14.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail066DebitSaleMasterCardSwipe() + { + $card = TestCards::asDebit(TestCards::masterCardSwipe(), 'F505AD81659AA42A3D123412324000AB'); + + $response = $card->charge(14.02) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + // test case 71 + $reversal = $response->reverse(14.02) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reversal); + $this->assertEquals('00', $reversal->responseCode); + } + + public function testRetail067DebitSaleVisaSwipeCashBack() + { + $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(14.03) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCashBack(5.00) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail067aDebitSaleMasterCard() + { + $card = TestCards::asDebit(TestCards::masterCardSwipe(), 'F505AD81659AA42A3D123412324000AB'); + + $response = $card->charge(14.04) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // PARTIALLY APPROVED PURCHASE + + public function testRetail068DebitSaleMasterCardPartialApproval() + { + $card = TestCards::asDebit(TestCards::masterCardSwipe(), 'F505AD81659AA42A3D123412324000AB'); + + $response = $card->charge(33.00) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAllowPartialAuth(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('10', $response->responseCode); + $this->assertEquals(22.00, $response->authorizedAmount); + } + + public function testRetail069DebitSaleVisaPartialApproval() + { + $this->markTestSkipped(); + + $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(44.00) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withAllowPartialAuth(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals(33.00, $response->authorizedAmount); + + // test case 72 + $reversal = $response->reverse(33.00) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reversal); + $this->assertEquals('00', $reversal->responseCode); + } + + // RETURN + + public function testRetail070DebitReturnVisaSwipe() + { + $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->refund(14.07) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail070aDebitReturnVisaSwipe() + { + $card = TestCards::asDebit(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->refund(14.08) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $reversalResponse = $response->reverse(14.08) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($reversalResponse); + $this->assertEquals('00', $reversalResponse->responseCode); + } + + // REVERSAL + + public function testRetail071DebitReversalMasterCard() + { + // see test case 66 + } + + public function testRetail072DebitReversalVisa() + { + // see test case 96 + } + + /* + EBT FUNCTIONS + Food Stamp Purchase + */ + + public function testRetail080EbtfsPurchaseVisaSwipe() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipe(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(101.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail081EbtfsPurchaseVisaManual() + { + $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(102.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Food Stamp Electronic Voucher (Manual Entry Only) + + public function testRetail082EbtVoucherPurchaseVisa() + { + $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); + $card->SerialNumber = '123456789012345'; + $card->approvalCode = '123456'; + + $response = $card->charge(103.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Food Stamp Balance Inquiry + + public function testRetail083EbtfsReturnVisaSwipe() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->refund(104.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail084EbtfsReturnVisaManual() + { + $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->refund(105.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Food Stamp Balance Inquiry + + public function testRetail085EbtBalanceInquiryVisaSwipe() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail086EbtBalanceInquiryVisaManual() + { + $card = TestCards::asEBTManual(TestCards::visaManual(true, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /* + $this->assertEquals('00', $response->responseCode); + EBT CASH BENEFITS + Cash Back Purchase + */ + + public function testRetail087EbtCashBackPurchaseVisaSwipe() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(106.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCashBack(5.00) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail088EbtCashBackPurchaseVisaManual() + { + $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(107.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCashBack(5.00) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // No Cash Back Purchase + + public function testRetail089EbtCashBackPurchaseVisaSwipeNoCashBack() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(108.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCashBack(0) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail090EbtCashBackPurchaseVisaManualNoCashBack() + { + $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(109.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCashBack(0) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Cash Back Balance Inquiry + + public function testRetail091EbtBalanceInquiryVisaSwipeCash() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->balanceInquiry(InquiryType::CASH)->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail092EbtBalanceInquiryVisaManualCash() + { + $card = TestCards::asEBTManual(TestCards::visaManual(true, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->balanceInquiry(InquiryType::CASH)->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + // Cash Benefits Withdrawal + + public function testRetail093EbtBenefitWithDrawalVisaSwipe() + { + $card = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(110.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testRetail094EbtBenefitWithDrawalVisaManual() + { + $card = TestCards::asEBTManual(TestCards::visaManual(false, true), '32539F50C245A6A93D123412324000AA'); + + $response = $card->charge(111.01) + ->withAllowDuplicates(true) + ->withCurrency('USD') + ->withCashBack(0) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /* + HMS GIFT - REWARDS + GIFT + ACTIVATE + */ + + public function testRetail095ActivateGift1Swipe() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->activate(6.00)->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail096ActivateGift2Manual() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->activate(7.00)->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + // ADD VALUE + + public function testRetail097AddValueGift1Swipe() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->addValue(8.00) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail098AddValueGift2Manual() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->activate(9.00)->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + // BALANCE INQUIRY + + public function testRetail099BalanceInquiryGift1Swipe() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertEquals(10.00, $response->balanceAmount); + } + + public function testRetail100BalanceInquiryGift2Manual() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + $this->assertEquals(10.00, $response->balanceAmount); + } + + // REPLACE / TRANSFER + + public function testRetail101ReplaceGift1Swipe() + { + $oldCard = TestCards::giftCard1Swipe(); + $newCard = TestCards::giftCard2Manual(); + + $response = $oldCard->replaceWith($newCard)->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail102ReplaceGift2Manual() + { + $newCard = TestCards::giftCard1Swipe(); + $oldCard = TestCards::giftCard2Manual(); + + $response = $oldCard->replaceWith($newCard)->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + // SALE / REDEEM + + public function testRetail103SaleGift1Swipe() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(1.00) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail104SaleGift2Manual() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(2.00) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail105SaleGift1VoidSwipe() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->charge(3.00) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + + // test case 107 + $voidResponse = $response->void()->execute(); + $this->assertNotNull($voidResponse); + $this->assertEquals('0', $voidResponse->responseCode); + } + + public function testRetail106SaleGift2ReversalManual() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->charge(4.00) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + + //test case 108 + $voidResponse = $response->reverse(4.00)->execute(); + $this->assertNotNull($voidResponse); + $this->assertEquals('0', $voidResponse->responseCode); + } + + // VOID + + public function testRetail107VoidGift() + { + // see test case 105 + } + + // REVERSAL + + public function testRetail108ReversalGift() + { + // see test case 106 + } + + // DEACTIVATE + + public function testRetail109DeactivateGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->deactivate()->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + // RECEIPTS MESSAGING + + public function testRetail110ReceiptsMessaging() + { + // PRINT AND SCAN RECEIPT FOR TEST 107 + } + + /* + REWARDS + BALANCE INQUIRY + */ + + public function testRetail111BalanceInquiryRewards1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + $this->assertTrue($response->pointsBalanceAmount > 0); + } + + public function testRetail112BalanceInquiryRewards2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->balanceInquiry()->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + $this->assertTrue($response->pointsBalanceAmount > 0); + } + + // ALIAS + + public function testRetail113CreateAliasGift1() + { + $card = GiftCard::create('9725550100'); + $this->assertNotNull($card); + } + + public function testRetail114CreateAliasGift2() + { + $card = GiftCard::create('9725550100'); + $this->assertNotNull($card); + } + + public function testRetail115AddAliasGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->addAlias('2145550199')->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail116AddAliasGift2() + { + $card = TestCards::giftCard2Manual(); + + $response = $card->addAlias('2145550199')->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail117DeleteAliasGift1() + { + $card = TestCards::giftCard1Swipe(); + + $response = $card->removeAlias('2145550199')->execute(); + $this->assertNotNull($response); + $this->assertEquals('0', $response->responseCode); + } + + public function testRetail999CloseBatch() + { + try { + $response = BatchService::closeBatch(); + $this->assertNotNull($response); + // error_log(sprintf('Batch ID: %s', $response->Id)); + // error_log(sprintf('Sequence Number: %s', $response->SequenceNumber)); + } catch (Exception $e) { + if (false === strpos($e->getMessage(), static::BATCH_NOT_OPEN) + && false === strpos($e->getMessage(), static::NO_TRANS_IN_BATCH) + ) { + $this->fail($e->getMessage()); + } + } + } +} diff --git a/test/Integration/Gateways/PorticoConnector/CreditTest.php b/test/Integration/Gateways/PorticoConnector/CreditTest.php index 7a4f4550..2a9316bf 100644 --- a/test/Integration/Gateways/PorticoConnector/CreditTest.php +++ b/test/Integration/Gateways/PorticoConnector/CreditTest.php @@ -1,365 +1,365 @@ -card = new CreditCardData(); - $this->card->number = '4111111111111111'; - $this->card->expMonth = 12; - $this->card->expYear = TestCards::validCardExpYear(); - $this->card->cvn = '123'; - $this->card->cardHolderName = 'Joe Smith'; - - - $this->track = new CreditTrackData(); - $this->track->value = ';'; - $this->track->encryptionData = new EncryptionData(); - $this->track->encryptionData->version = '01'; - - ServicesContainer::configure($this->getConfig()); - } - - public function testCreditAuthorization() - { - $authorization = $this->card->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $capture = $authorization->capture(16) - ->withGratuity(2) - ->execute(); - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function testCreditServiceAuth() - { - $service = new CreditService( - $this->getConfig() - ); - - $authorization = $service->authorize(15) - ->withCurrency('USD') - ->withPaymentMethod($this->card) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $capture = $service->capture($authorization->transactionReference->transactionId) - ->withAmount(17) - ->withGratuity(2) - ->execute(); - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function testCreditSale() - { - $response = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditOfflineAuth() - { - $response = $this->card->authorize(16) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditOfflineSale() - { - $response = $this->card->charge(16) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditRefund() - { - $response = $this->card->refund(16) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditReverse() - { - $response = $this->card->reverse(15) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditVerify() - { - $response = $this->card->verify() - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeAuthorization() - { - $authorization = $this->track->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $capture = $authorization->capture(16) - ->withGratuity(2) - ->execute(); - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function testCreditServiceSwipeAuth() - { - $service = new CreditService( - $this->getConfig() - ); - - $authorization = $service->authorize(15) - ->withCurrency('USD') - ->withPaymentMethod($this->track) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $capture = $service->capture($authorization->transactionReference->transactionId) - ->withAmount(17) - ->withGratuity(2) - ->execute(); - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function testCreditSwipeSale() - { - $response = $this->track->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeOfflineAuth() - { - $response = $this->track->authorize(16) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeOfflineSale() - { - $response = $this->track->charge(16) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeAddValue() - { - $this->markTestSkipped('GSB not configured'); - - $response = $this->track->addValue(16) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeBalanceInquiry() - { - $response = $this->track->balanceInquiry() - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeRefund() - { - $response = $this->track->refund(16) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeReverse() - { - $response = $this->track->reverse(15) - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditSwipeVerify() - { - $response = $this->track->verify() - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->secretApiKey = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - public function testCreditSaleWithCOF() - { - $response = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->cardBrandTransactionId); - - $nextResponse = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) - ->execute(); - - $this->assertNotNull($nextResponse); - $this->assertEquals('00', $nextResponse->responseCode); - } - - public function testCreditVerifyWithCOF() - { - $response = $this->card->verify() - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->cardBrandTransactionId); - - $nextResponse = $this->card->verify() - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) - ->execute(); - - $this->assertNotNull($nextResponse); - $this->assertEquals('00', $nextResponse->responseCode); - } - - public function testCreditAuthorizationWithCOF() - { - $response = $this->card->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->cardBrandTransactionId); - - $nextResponse = $this->card->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) - ->execute(); - - $this->assertNotNull($nextResponse); - $this->assertEquals('00', $nextResponse->responseCode); - - $captureResponse = $nextResponse->capture(16) - ->withGratuity(2) - ->execute(); - - $this->assertNotNull($captureResponse); - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function testCreditReverseViaClientTxnId() - { - $clientTxnId = time(); - - $authorization = $this->card->charge(420.69) - ->withClientTransactionId($clientTxnId) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $reverse = Transaction::fromClientTransactionId($clientTxnId) - ->reverse(420.69) - ->execute(); - - $this->assertNotNull($reverse); - $this->assertEquals('00', $reverse->responseCode); - } -} +card = new CreditCardData(); + $this->card->number = '4111111111111111'; + $this->card->expMonth = 12; + $this->card->expYear = TestCards::validCardExpYear(); + $this->card->cvn = '123'; + $this->card->cardHolderName = 'Joe Smith'; + + + $this->track = new CreditTrackData(); + $this->track->value = ';'; + $this->track->encryptionData = new EncryptionData(); + $this->track->encryptionData->version = '01'; + + ServicesContainer::configureService($this->getConfig()); + } + + public function testCreditAuthorization() + { + $authorization = $this->card->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $capture = $authorization->capture(16) + ->withGratuity(2) + ->execute(); + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function testCreditServiceAuth() + { + $service = new CreditService( + $this->getConfig() + ); + + $authorization = $service->authorize(15) + ->withCurrency('USD') + ->withPaymentMethod($this->card) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $capture = $service->capture($authorization->transactionReference->transactionId) + ->withAmount(17) + ->withGratuity(2) + ->execute(); + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function testCreditSale() + { + $response = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditOfflineAuth() + { + $response = $this->card->authorize(16) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditOfflineSale() + { + $response = $this->card->charge(16) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditRefund() + { + $response = $this->card->refund(16) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditReverse() + { + $response = $this->card->reverse(15) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditVerify() + { + $response = $this->card->verify() + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeAuthorization() + { + $authorization = $this->track->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $capture = $authorization->capture(16) + ->withGratuity(2) + ->execute(); + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function testCreditServiceSwipeAuth() + { + $service = new CreditService( + $this->getConfig() + ); + + $authorization = $service->authorize(15) + ->withCurrency('USD') + ->withPaymentMethod($this->track) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $capture = $service->capture($authorization->transactionReference->transactionId) + ->withAmount(17) + ->withGratuity(2) + ->execute(); + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function testCreditSwipeSale() + { + $response = $this->track->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeOfflineAuth() + { + $response = $this->track->authorize(16) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeOfflineSale() + { + $response = $this->track->charge(16) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeAddValue() + { + $this->markTestSkipped('GSB not configured'); + + $response = $this->track->addValue(16) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeBalanceInquiry() + { + $response = $this->track->balanceInquiry() + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeRefund() + { + $response = $this->track->refund(16) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeReverse() + { + $response = $this->track->reverse(15) + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditSwipeVerify() + { + $response = $this->track->verify() + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + public function testCreditSaleWithCOF() + { + $response = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->cardBrandTransactionId); + + $nextResponse = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) + ->execute(); + + $this->assertNotNull($nextResponse); + $this->assertEquals('00', $nextResponse->responseCode); + } + + public function testCreditVerifyWithCOF() + { + $response = $this->card->verify() + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->cardBrandTransactionId); + + $nextResponse = $this->card->verify() + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) + ->execute(); + + $this->assertNotNull($nextResponse); + $this->assertEquals('00', $nextResponse->responseCode); + } + + public function testCreditAuthorizationWithCOF() + { + $response = $this->card->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::CARDHOLDER) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->cardBrandTransactionId); + + $nextResponse = $this->card->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withCardBrandStorage(StoredCredentialInitiator::MERCHANT, $response->cardBrandTransactionId) + ->execute(); + + $this->assertNotNull($nextResponse); + $this->assertEquals('00', $nextResponse->responseCode); + + $captureResponse = $nextResponse->capture(16) + ->withGratuity(2) + ->execute(); + + $this->assertNotNull($captureResponse); + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function testCreditReverseViaClientTxnId() + { + $clientTxnId = time(); + + $authorization = $this->card->charge(420.69) + ->withClientTransactionId($clientTxnId) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $reverse = Transaction::fromClientTransactionId($clientTxnId) + ->reverse(420.69) + ->execute(); + + $this->assertNotNull($reverse); + $this->assertEquals('00', $reverse->responseCode); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/DebitTest.php b/test/Integration/Gateways/PorticoConnector/DebitTest.php index 21e57e46..dc412eb6 100644 --- a/test/Integration/Gateways/PorticoConnector/DebitTest.php +++ b/test/Integration/Gateways/PorticoConnector/DebitTest.php @@ -1,73 +1,74 @@ -track = TestCards::asDebit(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - ServicesContainer::configure($this->getConfig()); - } - - public function testDebitSale() - { - $response = $this->track->charge(17.01) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testDebitAddValue() - { - $this->markTestSkipped('GSB not configured'); - - $response = $this->track->addValue(15.01) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testDebitRefund() - { - $response = $this->track->refund(16.01) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testDebitReverse() - { - $response = $this->track->reverse(17.01) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } -} +track = TestCards::asDebit(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + ServicesContainer::configureService($this->getConfig()); + } + + public function testDebitSale() + { + $response = $this->track->charge(17.01) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testDebitAddValue() + { + $this->markTestSkipped('GSB not configured'); + + $response = $this->track->addValue(15.01) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testDebitRefund() + { + $response = $this->track->refund(16.01) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testDebitReverse() + { + $response = $this->track->reverse(17.01) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } +} diff --git a/test/Integration/Gateways/PorticoConnector/EbtTest.php b/test/Integration/Gateways/PorticoConnector/EbtTest.php index 902e79cb..a8eb18f8 100644 --- a/test/Integration/Gateways/PorticoConnector/EbtTest.php +++ b/test/Integration/Gateways/PorticoConnector/EbtTest.php @@ -1,90 +1,90 @@ -card = TestCards::asEBTManual(TestCards::visaManual(), '32539F50C245A6A93D123412324000AA'); - $this->track = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); - - ServicesContainer::configure($this->getConfig()); - } - - public function testEbtBalanceInquiry() - { - $response = $this->card->balanceInquiry() - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testEbtSale() - { - $response = $this->card->charge(10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testEbtRefund() - { - $response = $this->card->refund(10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testEbtSwipeBalanceInquiry() - { - $response = $this->track->balanceInquiry() - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testEbtSwipeSale() - { - $response = $this->track->charge(10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testEbtSwipeRefund() - { - $response = $this->track->refund(10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } -} +card = TestCards::asEBTManual(TestCards::visaManual(), '32539F50C245A6A93D123412324000AA'); + $this->track = TestCards::asEBTTrack(TestCards::visaSwipeEncrypted(), '32539F50C245A6A93D123412324000AA'); + + ServicesContainer::configureService($this->getConfig()); + } + + public function testEbtBalanceInquiry() + { + $response = $this->card->balanceInquiry() + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEbtSale() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEbtRefund() + { + $response = $this->card->refund(10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEbtSwipeBalanceInquiry() + { + $response = $this->track->balanceInquiry() + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEbtSwipeSale() + { + $response = $this->track->charge(10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEbtSwipeRefund() + { + $response = $this->track->refund(10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } +} diff --git a/test/Integration/Gateways/PorticoConnector/GiftTest.php b/test/Integration/Gateways/PorticoConnector/GiftTest.php index 715f04eb..1e136271 100644 --- a/test/Integration/Gateways/PorticoConnector/GiftTest.php +++ b/test/Integration/Gateways/PorticoConnector/GiftTest.php @@ -1,119 +1,119 @@ -card = new GiftCard(); - $this->card->number = '5022440000000000007'; - - $this->track = new GiftCard(); - $this->track->trackData = '%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?'; - - ServicesContainer::configure($this->getConfig()); - } - - public function testGiftCreate() - { - $newCard = GiftCard::create('2145550199'); - $this->assertNotNull($newCard); - $this->assertNotNull($newCard->number); - $this->assertNotNull($newCard->alias); - $this->assertNotNull($newCard->pin); - } - - public function testGiftAddAlias() - { - $response = $this->card->addAlias('2145550199') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftAddValue() - { - $response = $this->card->addValue(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftBalanceInquiry() - { - $response = $this->card->balanceInquiry() - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftSale() - { - $response = $this->card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftDeactivate() - { - $response = $this->card->deactivate() - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftRemoveAlias() - { - $response = $this->card->removeAlias('2145550199') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftReplace() - { - $response = $this->card->replaceWith($this->track) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftReverse() - { - $response = $this->card->reverse(10) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testGiftRewards() - { - $response = $this->card->rewards(10) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } -} +card = new GiftCard(); + $this->card->number = '5022440000000000007'; + + $this->track = new GiftCard(); + $this->track->trackData = '%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?'; + + ServicesContainer::configureService($this->getConfig()); + } + + public function testGiftCreate() + { + $newCard = GiftCard::create('2145550199'); + $this->assertNotNull($newCard); + $this->assertNotNull($newCard->number); + $this->assertNotNull($newCard->alias); + $this->assertNotNull($newCard->pin); + } + + public function testGiftAddAlias() + { + $response = $this->card->addAlias('2145550199') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftAddValue() + { + $response = $this->card->addValue(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftBalanceInquiry() + { + $response = $this->card->balanceInquiry() + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftSale() + { + $response = $this->card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftDeactivate() + { + $response = $this->card->deactivate() + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftRemoveAlias() + { + $response = $this->card->removeAlias('2145550199') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftReplace() + { + $response = $this->card->replaceWith($this->track) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftReverse() + { + $response = $this->card->reverse(10) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testGiftRewards() + { + $response = $this->card->rewards(10) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } +} diff --git a/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php b/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php index c6053fb0..15274506 100644 --- a/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php +++ b/test/Integration/Gateways/PorticoConnector/PorticoReportingTests.php @@ -1,296 +1,297 @@ -card = new CreditCardData(); - $this->card->number = '4111111111111111'; - $this->card->expMonth = 12; - $this->card->expYear = TestCards::validCardExpYear(); - $this->card->cvn = '123'; - $this->card->cardHolderName = 'Joe Smith'; - - - $this->reportingService = new ReportingService(); - $this->searchCriteria = new SearchCriteriaBuilder(); - - ServicesContainer::configure($this->getConfig()); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; - $config->serviceUrl = ($this->enableCryptoUrl) ? - 'https://cert.api2-c.heartlandportico.com/': - 'https://cert.api2.heartlandportico.com'; - return $config; - } - - public function testReportActivity() - { - date_default_timezone_set("UTC"); - $dateFormat = 'Y-m-d\TH:i:s.00\Z'; - $dateMinus15days = new DateTime(); - $dateMinus15days->sub(new DateInterval('P15D')); - $dateMinus10Utc = gmdate($dateFormat, $dateMinus15days->Format('U')); - $nowUtc = gmdate($dateFormat); - - $response = $this->reportingService->activity() - ->withStartDate($dateMinus10Utc) - ->withEndDate($nowUtc) - ->execute(); - $this->assertNotNull($response); - $this->assertTrue(count($response) > 0); - } - - public function testReportActivityByDays() - { - date_default_timezone_set("UTC"); - $dateFormat = 'Y-m-d\TH:i:s.00\Z'; - $dateMinus5days = new DateTime(); - $dateMinus5days->sub(new DateInterval('P5D')); - $dateMinus10Utc = gmdate($dateFormat, $dateMinus5days->Format('U')); - $nowUtc = gmdate($dateFormat); - - $response = $this->reportingService->activity() - ->withStartDate($dateMinus10Utc) - ->withEndDate($nowUtc) - ->execute(); - $this->assertNotNull($response); - $this->assertTrue(count($response) > 0); - } - - public function testReportTransactionDetail() - { - $response = $this->reportingService->transactionDetail("1088532284")->execute(); - $this->assertNotNull($response); - } - - public function testInvoiceNumber() - { - $address = new Address(); - $address->postalCode = "12345"; - - $authResponse = $this->card->charge(10) - ->withCurrency("USD") - ->withAddress($address) - ->withInvoiceNumber('123456') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($authResponse); - $this->assertEquals('00', $authResponse->responseCode); - $this->assertNotNull($authResponse->transactionId); - - $report = ReportingService::transactionDetail($authResponse->transactionId) - ->execute(); - - $this->assertNotNull($report); - $this->assertEquals('123456', $report->invoiceNumber); - } - - public function testReportCardHolderName() - { - $gateway_response = $this->card->charge(10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $response = $this->reportingService->transactionDetail($gateway_response->transactionId)->execute(); - - $this->assertEquals('Joe', $response->cardHolderFirstName); - $this->assertEquals('Smith', $response->cardHolderLastName); - } - - public function testReportFindTransactionWithTransactionId() - { - $gateway_response = $this->card->charge(10) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $response = $this->reportingService->findTransactions($gateway_response->transactionId)->execute(); - $this->assertNotNull($response); - } - - public function testReportFindTransactionNoCriteria() - { - $response = $this->reportingService->findTransactions()->execute(); - $this->assertNotNull($response); - } - - public function testReportFindTransactionWithCriteria() - { - date_default_timezone_set("UTC"); - $dateFormat = 'Y-m-d\TH:i:s.00\Z'; - $dateMinus10days = new DateTime(); - $dateMinus10days->sub(new DateInterval('P5D')); - $dateMinus5Utc = gmdate($dateFormat, $dateMinus10days->Format('U')); - $nowUtc = gmdate($dateFormat); - - $response = $this->reportingService->findTransactions() - ->withTimeZoneConversion(TimeZoneConversion::MERCHANT) - ->where('startDate', $dateMinus5Utc) - ->and('endDate', $nowUtc) - ->execute(); - - $this->assertNotNull($response); - $this->assertTrue(count($response) > 0); - } - - public function testCreditAuthWithConvenienceAmount() - { - $authorization = $this->card->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withConvenienceAmount(2) - ->execute(); - - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $report = $this->reportingService->transactionDetail($authorization->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->convenienceAmount); - } - - public function testCreditAuthWithShippingAmount() - { - $authorization = $this->card->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withShippingAmount(2) - ->execute(); - - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $report = $this->reportingService->transactionDetail($authorization->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->shippingAmount); - } - - public function testCreditSaleWithConvenienceAmount() - { - $response = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withConvenienceAmount(2) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->convenienceAmount); - } - - public function testCreditSaleWithShippingAmount() - { - $response = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->withShippingAmount(2) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->shippingAmount); - } - - public function testCreditOfflineAuthWithConvenienceAmount() - { - $response = $this->card->authorize(16) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->withConvenienceAmount(2) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->convenienceAmount); - } - - public function testCreditOfflineAuthWithShippingAmount() - { - $response = $this->card->authorize(16) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->withShippingAmount(2) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->shippingAmount); - } - - public function testCreditOfflineSaleWithConvenienceAmount() - { - $response = $this->card->charge(17) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->WithConvenienceAmount(2) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->convenienceAmount); - } - - public function testCreditOfflineSaleWithShippingAmount() - { - $response = $this->card->charge(17) - ->withCurrency('USD') - ->withOfflineAuthCode('12345') - ->withAllowDuplicates(true) - ->withShippingAmount(2) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - - $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); - $this->assertNotNull($report); - $this->assertEquals('2', $report->shippingAmount); - } -} +card = new CreditCardData(); + $this->card->number = '4111111111111111'; + $this->card->expMonth = 12; + $this->card->expYear = TestCards::validCardExpYear(); + $this->card->cvn = '123'; + $this->card->cardHolderName = 'Joe Smith'; + + + $this->reportingService = new ReportingService(); + $this->searchCriteria = new SearchCriteriaBuilder(); + + ServicesContainer::configureService($this->getConfig()); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw'; + $config->serviceUrl = ($this->enableCryptoUrl) ? + 'https://cert.api2-c.heartlandportico.com/': + 'https://cert.api2.heartlandportico.com'; + return $config; + } + + public function testReportActivity() + { + date_default_timezone_set("UTC"); + $dateFormat = 'Y-m-d\TH:i:s.00\Z'; + $dateMinus15days = new DateTime(); + $dateMinus15days->sub(new DateInterval('P15D')); + $dateMinus10Utc = gmdate($dateFormat, $dateMinus15days->Format('U')); + $nowUtc = gmdate($dateFormat); + + $response = $this->reportingService->activity() + ->withStartDate($dateMinus10Utc) + ->withEndDate($nowUtc) + ->execute(); + $this->assertNotNull($response); + $this->assertTrue(count($response) > 0); + } + + public function testReportActivityByDays() + { + date_default_timezone_set("UTC"); + $dateFormat = 'Y-m-d\TH:i:s.00\Z'; + $dateMinus5days = new DateTime(); + $dateMinus5days->sub(new DateInterval('P5D')); + $dateMinus10Utc = gmdate($dateFormat, $dateMinus5days->Format('U')); + $nowUtc = gmdate($dateFormat); + + $response = $this->reportingService->activity() + ->withStartDate($dateMinus10Utc) + ->withEndDate($nowUtc) + ->execute(); + $this->assertNotNull($response); + $this->assertTrue(count($response) > 0); + } + + public function testReportTransactionDetail() + { + $response = $this->reportingService->transactionDetail("1088532284")->execute(); + $this->assertNotNull($response); + } + + public function testInvoiceNumber() + { + $address = new Address(); + $address->postalCode = "12345"; + + $authResponse = $this->card->charge(10) + ->withCurrency("USD") + ->withAddress($address) + ->withInvoiceNumber('123456') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($authResponse); + $this->assertEquals('00', $authResponse->responseCode); + $this->assertNotNull($authResponse->transactionId); + + $report = ReportingService::transactionDetail($authResponse->transactionId) + ->execute(); + + $this->assertNotNull($report); + $this->assertEquals('123456', $report->invoiceNumber); + } + + public function testReportCardHolderName() + { + $gateway_response = $this->card->charge(10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $response = $this->reportingService->transactionDetail($gateway_response->transactionId)->execute(); + + $this->assertEquals('Joe', $response->cardHolderFirstName); + $this->assertEquals('Smith', $response->cardHolderLastName); + } + + public function testReportFindTransactionWithTransactionId() + { + $gateway_response = $this->card->charge(10) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $response = $this->reportingService->findTransactions($gateway_response->transactionId)->execute(); + $this->assertNotNull($response); + } + + public function testReportFindTransactionNoCriteria() + { + $response = $this->reportingService->findTransactions()->execute(); + $this->assertNotNull($response); + } + + public function testReportFindTransactionWithCriteria() + { + date_default_timezone_set("UTC"); + $dateFormat = 'Y-m-d\TH:i:s.00\Z'; + $dateMinus10days = new DateTime(); + $dateMinus10days->sub(new DateInterval('P5D')); + $dateMinus5Utc = gmdate($dateFormat, $dateMinus10days->Format('U')); + $nowUtc = gmdate($dateFormat); + + $response = $this->reportingService->findTransactions() + ->withTimeZoneConversion(TimeZoneConversion::MERCHANT) + ->where('startDate', $dateMinus5Utc) + ->and('endDate', $nowUtc) + ->execute(); + + $this->assertNotNull($response); + $this->assertTrue(count($response) > 0); + } + + public function testCreditAuthWithConvenienceAmount() + { + $authorization = $this->card->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withConvenienceAmount(2) + ->execute(); + + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $report = $this->reportingService->transactionDetail($authorization->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->convenienceAmount); + } + + public function testCreditAuthWithShippingAmount() + { + $authorization = $this->card->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withShippingAmount(2) + ->execute(); + + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $report = $this->reportingService->transactionDetail($authorization->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->shippingAmount); + } + + public function testCreditSaleWithConvenienceAmount() + { + $response = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withConvenienceAmount(2) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->convenienceAmount); + } + + public function testCreditSaleWithShippingAmount() + { + $response = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->withShippingAmount(2) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->shippingAmount); + } + + public function testCreditOfflineAuthWithConvenienceAmount() + { + $response = $this->card->authorize(16) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->withConvenienceAmount(2) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->convenienceAmount); + } + + public function testCreditOfflineAuthWithShippingAmount() + { + $response = $this->card->authorize(16) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->withShippingAmount(2) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->shippingAmount); + } + + public function testCreditOfflineSaleWithConvenienceAmount() + { + $response = $this->card->charge(17) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->WithConvenienceAmount(2) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->convenienceAmount); + } + + public function testCreditOfflineSaleWithShippingAmount() + { + $response = $this->card->charge(17) + ->withCurrency('USD') + ->withOfflineAuthCode('12345') + ->withAllowDuplicates(true) + ->withShippingAmount(2) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + + $report = $this->reportingService->transactionDetail($response->transactionId)->execute(); + $this->assertNotNull($report); + $this->assertEquals('2', $report->shippingAmount); + } +} diff --git a/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php b/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php index c17be63a..78117b5a 100644 --- a/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php +++ b/test/Integration/Gateways/PorticoConnector/PorticoTokenManagementTest.php @@ -1,72 +1,73 @@ -getConfig()); - - try { - $card = new CreditCardData(); - $card->number = '4111111111111111'; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - - $this->token = $card->tokenize()->execute()->token; - $this->assertTrue(!empty($this->token), 'TOKEN COULD NOT BE GENERATED.'); - } catch (ApiException $exc) { - $this->fail($exc->message); - } - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; - $config->serviceUrl = 'https://cert.api2.heartlandportico.com'; - return $config; - } - - public function testUpdateToken() - { - $token = new CreditCardData(); - $token->token = $this->token; - $token->expMonth = 12; - $token->expYear = TestCards::validCardExpYear(); - - $this->assertTrue($token->updateTokenExpiry()); - - // should succeed - $response = $token->verify()->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testDeleteToken() - { - $token = new CreditCardData(); - $token->token = $this->token; - - $this->assertTrue($token->deleteToken()); - - // should fail - try { - $response = $token->verify()->execute(); - } catch (GatewayException $exc) { - $this->assertEquals('27', $exc->responseCode); - } - } -} +getConfig()); + + try { + $card = new CreditCardData(); + $card->number = '4111111111111111'; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + + $this->token = $card->tokenize()->execute()->token; + $this->assertTrue(!empty($this->token), 'TOKEN COULD NOT BE GENERATED.'); + } catch (ApiException $exc) { + $this->fail($exc->getMessage()); + } + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; + $config->serviceUrl = 'https://cert.api2.heartlandportico.com'; + return $config; + } + + public function testUpdateToken() + { + $token = new CreditCardData(); + $token->token = $this->token; + $token->expMonth = 12; + $token->expYear = TestCards::validCardExpYear(); + + $this->assertTrue($token->updateTokenExpiry()); + + // should succeed + $response = $token->verify()->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testDeleteToken() + { + $token = new CreditCardData(); + $token->token = $this->token; + + $this->assertTrue($token->deleteToken()); + + // should fail + try { + $response = $token->verify()->execute(); + $this->assertTrue(false, 'Expected exception'); + } catch (GatewayException $exc) { + $this->assertEquals('23', $exc->responseCode); + } + } +} diff --git a/test/Integration/Gateways/RealexConnector/CreditTest.php b/test/Integration/Gateways/RealexConnector/CreditTest.php index 104c718c..13107c87 100644 --- a/test/Integration/Gateways/RealexConnector/CreditTest.php +++ b/test/Integration/Gateways/RealexConnector/CreditTest.php @@ -1,286 +1,287 @@ -number = '4111111111111111'; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - $card->cardHolderName = 'Joe Smith'; - $this->card = $card; - - ServicesContainer::configure($this->getConfig()); - } - - public function testCreditAuthorization() - { - $authorization = $this->card->authorize(14) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $capture = $authorization->capture(16) - ->withGratuity(2) - ->execute(); - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function testCreditServiceAuth() - { - $service = new CreditService( - $this->getConfig() - ); - - $authorization = $service->authorize(15) - ->withCurrency('USD') - ->withPaymentMethod($this->card) - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($authorization); - $this->assertEquals('00', $authorization->responseCode); - - $capture = $service->capture($authorization->transactionReference) - ->withAmount(17) - ->withGratuity(2) - ->execute(); - $this->assertNotNull($capture); - $this->assertEquals('00', $capture->responseCode); - } - - public function testCreditSale() - { - $response = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditRefund() - { - $response = $this->card->refund(16) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCreditRebate() - { - $response = $this->card->charge(17) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode, $response->responseMessage); - - $rebate = $response->refund(17) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($rebate); - $this->assertEquals('00', $rebate->responseCode, $rebate->responseMessage); - } - - public function testCreditVoid() - { - $response = $this->card->charge(15) - ->withCurrency('USD') - ->withAllowDuplicates(true) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode, $response->responseMessage); - - $voidResponse = $response->void()->execute(); - $this->assertNotNull($voidResponse); - $this->assertEquals('00', $voidResponse->responseCode, $voidResponse->responseMessage); - } - - public function testCreditVerify() - { - $response = $this->card->verify() - ->withAllowDuplicates(true) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'api'; - $config->sharedSecret = 'secret'; - $config->rebatePassword = 'rebate'; - $config->refundPassword = 'refund'; - $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; - return $config; - } - - protected function dccSetup() - { - $config = new ServicesConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "apidcc"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - - ServicesContainer::configure($config); - } - - public function testCreditGetDccInfo() - { - $this->dccSetup(); - - $this->card->number = '4002933640008365'; - $orderId = GenerationUtils::generateOrderId(); - - $dccDetails = $this->card->getDccRate(DccRateType::SALE, 10, 'USD', DccProcessor::FEXCO, $orderId); - - $this->assertNotNull($dccDetails); - $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); - $this->assertNotNull($dccDetails->dccResponseResult); - } - - public function testCreditDccRateAuthorize() - { - $this->dccSetup(); - - $this->card->number = '4006097467207025'; - $orderId = GenerationUtils::generateOrderId(); - - $dccDetails = $this->card->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); - - $this->assertNotNull($dccDetails); - $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); - $this->assertNotNull($dccDetails->dccResponseResult); - - //set Currency conversion rates - $dccValues = new DccRateData(); - $dccValues->orderId = $dccDetails->transactionReference->orderId; - $dccValues->dccProcessor = DccProcessor::FEXCO; - $dccValues->dccType = 1; - $dccValues->dccRateType = DccRateType::SALE; - $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; - $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; - $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; - - $response = $this->card->authorize(1001) - ->withCurrency('EUR') - ->withAllowDuplicates(true) - ->withDccRateData($dccValues) - ->withOrderId($orderId) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode, $response->responseMessage); - } - - public function testCreditDccRateCharge() - { - $this->dccSetup(); - - $this->card->number = '4006097467207025'; - $orderId = GenerationUtils::generateOrderId(); - - $dccDetails = $this->card->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); - - $this->assertNotNull($dccDetails); - $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); - $this->assertNotNull($dccDetails->dccResponseResult); - - //set Currency conversion rates - $dccValues = new DccRateData(); - $dccValues->orderId = $dccDetails->transactionReference->orderId; - $dccValues->dccProcessor = DccProcessor::FEXCO; - $dccValues->dccType = 1; - $dccValues->dccRateType = DccRateType::SALE; - $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; - $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; - $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; - - $response = $this->card->charge(1001) - ->withCurrency('EUR') - ->withAllowDuplicates(true) - ->withDccRateData($dccValues) - ->withOrderId($orderId) - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode, $response->responseMessage); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage Unexpected Gateway Response: 105 - Cannot find DCC information for that card - */ - public function testCreditDccInfoNotFound() - { - $this->dccSetup(); - - $this->card->number = '4002933640008365'; - $orderId = GenerationUtils::generateOrderId(); - - $dccDetails = $this->card->getDccRate(DccRateType::SALE, 10, 'EUR', DccProcessor::FEXCO, $orderId); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage Unexpected Gateway Response: 508 - Incorrect DCC information - doesn't correspond to dccrate request - */ - public function testCreditDccInfoMismatch() - { - $this->dccSetup(); - - $this->card->number = '4006097467207025'; - $orderId = GenerationUtils::generateOrderId(); - - $dccDetails = $this->card->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); - - $this->assertNotNull($dccDetails); - $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); - $this->assertNotNull($dccDetails->dccResponseResult); - - $dccValues = new DccRateData(); - $dccValues->orderId = $dccDetails->transactionReference->orderId; - $dccValues->dccProcessor = DccProcessor::FEXCO; - $dccValues->dccType = 1; - $dccValues->dccRateType = DccRateType::SALE; - $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; - $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; - $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; - - $response = $this->card->authorize(100) - ->withCurrency('EUR') - ->withAllowDuplicates(true) - ->withDccRateData($dccValues) - ->withOrderId($orderId) - ->execute(); - } -} +number = '4111111111111111'; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + $card->cardHolderName = 'Joe Smith'; + $this->card = $card; + + ServicesContainer::configureService($this->getConfig()); + } + + public function testCreditAuthorization() + { + $authorization = $this->card->authorize(14) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $capture = $authorization->capture(16) + ->withGratuity(2) + ->execute(); + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function testCreditServiceAuth() + { + $service = new CreditService( + $this->getConfig() + ); + + $authorization = $service->authorize(15) + ->withCurrency('USD') + ->withPaymentMethod($this->card) + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($authorization); + $this->assertEquals('00', $authorization->responseCode); + + $capture = $service->capture($authorization->transactionReference) + ->withAmount(17) + ->withGratuity(2) + ->execute(); + $this->assertNotNull($capture); + $this->assertEquals('00', $capture->responseCode); + } + + public function testCreditSale() + { + $response = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditRefund() + { + $response = $this->card->refund(16) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCreditRebate() + { + $response = $this->card->charge(17) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode, $response->responseMessage); + + $rebate = $response->refund(17) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($rebate); + $this->assertEquals('00', $rebate->responseCode, $rebate->responseMessage); + } + + public function testCreditVoid() + { + $response = $this->card->charge(15) + ->withCurrency('USD') + ->withAllowDuplicates(true) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode, $response->responseMessage); + + $voidResponse = $response->void()->execute(); + $this->assertNotNull($voidResponse); + $this->assertEquals('00', $voidResponse->responseCode, $voidResponse->responseMessage); + } + + public function testCreditVerify() + { + $response = $this->card->verify() + ->withAllowDuplicates(true) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + protected function getConfig() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'api'; + $config->sharedSecret = 'secret'; + $config->rebatePassword = 'rebate'; + $config->refundPassword = 'refund'; + $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; + return $config; + } + + protected function dccSetup() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "apidcc"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + + ServicesContainer::configureService($config); + } + + public function testCreditGetDccInfo() + { + $this->dccSetup(); + + $this->card->number = '4002933640008365'; + $orderId = GenerationUtils::generateOrderId(); + + $dccDetails = $this->card->getDccRate(DccRateType::SALE, 10, 'USD', DccProcessor::FEXCO, $orderId); + + $this->assertNotNull($dccDetails); + $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); + $this->assertNotNull($dccDetails->dccResponseResult); + } + + public function testCreditDccRateAuthorize() + { + $this->dccSetup(); + + $this->card->number = '4006097467207025'; + $orderId = GenerationUtils::generateOrderId(); + + $dccDetails = $this->card->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); + + $this->assertNotNull($dccDetails); + $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); + $this->assertNotNull($dccDetails->dccResponseResult); + + //set Currency conversion rates + $dccValues = new DccRateData(); + $dccValues->orderId = $dccDetails->transactionReference->orderId; + $dccValues->dccProcessor = DccProcessor::FEXCO; + $dccValues->dccType = 1; + $dccValues->dccRateType = DccRateType::SALE; + $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; + $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; + $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; + + $response = $this->card->authorize(1001) + ->withCurrency('EUR') + ->withAllowDuplicates(true) + ->withDccRateData($dccValues) + ->withOrderId($orderId) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode, $response->responseMessage); + } + + public function testCreditDccRateCharge() + { + $this->dccSetup(); + + $this->card->number = '4006097467207025'; + $orderId = GenerationUtils::generateOrderId(); + + $dccDetails = $this->card->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); + + $this->assertNotNull($dccDetails); + $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); + $this->assertNotNull($dccDetails->dccResponseResult); + + //set Currency conversion rates + $dccValues = new DccRateData(); + $dccValues->orderId = $dccDetails->transactionReference->orderId; + $dccValues->dccProcessor = DccProcessor::FEXCO; + $dccValues->dccType = 1; + $dccValues->dccRateType = DccRateType::SALE; + $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; + $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; + $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; + + $response = $this->card->charge(1001) + ->withCurrency('EUR') + ->withAllowDuplicates(true) + ->withDccRateData($dccValues) + ->withOrderId($orderId) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode, $response->responseMessage); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage Unexpected Gateway Response: 105 - Cannot find DCC information for that card + */ + public function testCreditDccInfoNotFound() + { + $this->dccSetup(); + + $this->card->number = '4002933640008365'; + $orderId = GenerationUtils::generateOrderId(); + + $dccDetails = $this->card->getDccRate(DccRateType::SALE, 10, 'EUR', DccProcessor::FEXCO, $orderId); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage Unexpected Gateway Response: 508 - Incorrect DCC information - doesn't correspond to dccrate request + */ + public function testCreditDccInfoMismatch() + { + $this->dccSetup(); + + $this->card->number = '4006097467207025'; + $orderId = GenerationUtils::generateOrderId(); + + $dccDetails = $this->card->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); + + $this->assertNotNull($dccDetails); + $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); + $this->assertNotNull($dccDetails->dccResponseResult); + + $dccValues = new DccRateData(); + $dccValues->orderId = $dccDetails->transactionReference->orderId; + $dccValues->dccProcessor = DccProcessor::FEXCO; + $dccValues->dccType = 1; + $dccValues->dccRateType = DccRateType::SALE; + $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; + $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; + $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; + + $response = $this->card->authorize(100) + ->withCurrency('EUR') + ->withAllowDuplicates(true) + ->withDccRateData($dccValues) + ->withOrderId($orderId) + ->execute(); + } +} diff --git a/test/Integration/Gateways/RealexConnector/Hpp/RealexHppClient.php b/test/Integration/Gateways/RealexConnector/Hpp/RealexHppClient.php index 8dd1d89a..f67a188e 100644 --- a/test/Integration/Gateways/RealexConnector/Hpp/RealexHppClient.php +++ b/test/Integration/Gateways/RealexConnector/Hpp/RealexHppClient.php @@ -1,250 +1,251 @@ -sharedSecret = $sharedSecret; - } - - public function sendRequest($jsonData, $hppVersion = '') - { - $this->paymentData = GenerationUtils::decodeJson($jsonData, true, $hppVersion); - - $timestamp = $this->getValue('TIMESTAMP'); - $merchantId = $this->getValue('MERCHANT_ID'); - $account = $this->getValue('ACCOUNT'); - $orderId = $this->getValue('ORDER_ID'); - $amount = $this->getValue('AMOUNT'); - $currency = $this->getValue('CURRENCY'); - $autoSettle = $this->getValue('AUTO_SETTLE_FLAG'); - $requestHash = $this->getValue('SHA1HASH'); - $shippingCode = $this->getValue('SHIPPING_CODE'); - $shippingCountry = $this->getValue('SHIPPING_CO'); - $billingCode = $this->getValue('BILLING_CODE'); - $billingCountry = $this->getValue('BILLING_CO'); - - $config = new ServicesConfig(); - $config->merchantId = $merchantId; - $config->accountId = $account; - $config->sharedSecret = $this->sharedSecret; - $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - $config->hostedPaymentConfig->version = $hppVersion; - - ServicesContainer::configure($config); - - // create the card object - $card = new CreditCardData(); - $card->number = '4006097467207025'; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '131'; - $card->cardHolderName = 'James Mason'; - - // // check hash - $hashParam = [ - $timestamp, - $merchantId, - $orderId, - $amount, - $currency - ]; - - //for stored card - - if (!empty($this->paymentData['OFFER_SAVE_CARD'])) { - $hashParam[] = (!empty($this->paymentData['PAYER_REF'])) ? - $this->paymentData['PAYER_REF'] : null; - $hashParam[] = (!empty($this->paymentData['PMT_REF'])) ? - $this->paymentData['PMT_REF'] : null; - } - - $newHash = GenerationUtils::generateHash( - $this->sharedSecret, - implode('.', $hashParam) - ); - if ($newHash != $requestHash) { - throw new ApiException("Incorrect hash. Please check your code and the Developers Documentation."); - } - - // build request - if ($amount == null) { - $validate = $this->getValue("VALIDATE_CARD_ONLY"); - if ($validate) { - $gatewayRequest = $card->verify(); - } else { - $gatewayRequest = $card->verify()->WithRequestMultiUseToken(true); - } - } else { - $amount = $amount / 100; - if ($autoSettle) { - $gatewayRequest = $card->charge($amount); - } else { - $gatewayRequest = $card->authorize($amount); - } - } - - try { - $gatewayRequest - ->WithCurrency($currency) - ->WithOrderId($orderId) - ->withTimeStamp($timestamp); - - $this->addAddressDetails($gatewayRequest, $billingCode, $billingCountry, AddressType::BILLING); - $this->addAddressDetails($gatewayRequest, $shippingCode, $shippingCountry, AddressType::SHIPPING); - - //handle DCC - $this->addDCCInfo($gatewayRequest, $orderId); - - //handle fraud management - $this->addFraudManagementInfo($gatewayRequest, $orderId); - - $gatewayResponse = $gatewayRequest->execute(); - - if ($gatewayResponse->responseCode === '00') { - return $this->convertResponse($gatewayResponse); - } - } catch (ApiException $exc) { - throw $exc; - } - return null; - } - - public function getValue($value) - { - if (isset($this->paymentData[$value])) { - return $this->paymentData[$value]; - } - return null; - } - - public function addDCCInfo($gatewayRequest, $orderId) - { - if (!empty($this->paymentData['DCC_ENABLE'])) { - $dccInfo = $this->getValue('DCC_INFO'); - - $dccValues = new DccRateData(); - $dccValues->orderId = $orderId; - $dccValues->dccProcessor = $dccInfo['CCP']; - $dccValues->dccType = $dccInfo['TYPE']; - $dccValues->dccRateType = $dccInfo['RATE_TYPE']; - $dccValues->currency = $dccInfo['CURRENCY']; - $dccValues->dccRate = $dccInfo['RATE']; - $dccValues->amount = $dccInfo['AMOUNT']; - - $gatewayRequest - ->withDccRateData($dccValues); - } - } - - public function addFraudManagementInfo($gatewayRequest, $orderId) - { - if (!empty($this->paymentData['HPP_FRAUD_FILTER_MODE'])) { - $tssInfo = $this->getValue('TSS_INFO'); - - $this->addAddressDetails( - $gatewayRequest, - $tssInfo['BILLING_ADDRESS']['CODE'], - $tssInfo['BILLING_ADDRESS']['COUNTRY'], - AddressType::BILLING - ); - - $this->addAddressDetails( - $gatewayRequest, - $tssInfo['SHIPPING_ADDRESS']['CODE'], - $tssInfo['SHIPPING_ADDRESS']['COUNTRY'], - AddressType::SHIPPING - ); - - $gatewayRequest - ->withProductId($tssInfo['PRODID']) // prodid - ->withClientTransactionId($tssInfo['VARREF']) // varref - ->withCustomerId($tssInfo['CUSTNUM']) // custnum - ->withCustomerIpAddress($tssInfo['CUSTIPADDRESS']) - ->withFraudFilter($this->paymentData['HPP_FRAUD_FILTER_MODE']); - } - } - - public function addAddressDetails($gatewayRequest, $code, $country, $addressType = AddressType::BILLING) - { - if ($code != null || $country != null) { - $address = new Address(); - $address->postalCode = $code; - $address->country = $country; - - $gatewayRequest - ->WithAddress($address, $addressType); - } - } - - public function convertResponse($gatewayResponse) - { - $merchantId = $this->paymentData['MERCHANT_ID']; - $account = $this->paymentData['ACCOUNT']; - - $newHash = GenerationUtils::generateHash( - $this->sharedSecret, - implode('.', [ - $gatewayResponse->timestamp, - $merchantId, - $gatewayResponse->transactionReference->orderId, - $gatewayResponse->responseCode, - $gatewayResponse->responseMessage, - $gatewayResponse->transactionReference->transactionId, - $gatewayResponse->transactionReference->authCode - ]) - ); - - // begin building response - $response = [ - 'MERCHANT_ID' => $merchantId, - 'ACCOUNT' => $this->getValue('ACCOUNT'), - 'ORDER_ID' => $gatewayResponse->transactionReference->orderId, - 'TIMESTAMP' => $gatewayResponse->timestamp, - 'RESULT' => $gatewayResponse->responseCode, - 'PASREF' => $gatewayResponse->transactionReference->transactionId, - 'AUTHCODE' => $gatewayResponse->transactionReference->authCode, - 'AVSPOSTCODERESULT' => $gatewayResponse->avsResponseCode, - 'CVNRESULT' => $gatewayResponse->cvnResponseCode, - 'HPP_LANG' => $this->getValue('HPP_LANG'), - 'SHIPPING_CODE' => $this->getValue('SHIPPING_CODE'), - 'SHIPPING_CO' => $this->getValue('SHIPPING_CO'), - 'BILLING_CODE' => $this->getValue('BILLING_CODE'), - 'BILLING_CO' => $this->getValue('BILLING_CO'), - 'ECI' => $this->getValue('ECI'), - 'CAVV' => $this->getValue('CAVV'), - 'XID' => $this->getValue('XID'), - 'MERCHANT_RESPONSE_URL' => $this->getValue('MERCHANT_RESPONSE_URL'), - 'CARD_PAYMENT_BUTTON' => $this->getValue('CARD_PAYMENT_BUTTON'), - 'MESSAGE' => $gatewayResponse->responseMessage, - 'AMOUNT' => $this->getValue('AMOUNT'), - 'SHA1HASH' => $newHash, - 'DCC_INFO_REQUST' => $this->getValue('DCC_INFO'), - 'DCC_INFO_RESPONSE' => $gatewayResponse->dccResponseResult, - 'HPP_FRAUD_FILTER_MODE' => $this->getValue('HPP_FRAUD_FILTER_MODE'), - 'TSS_INFO' => $this->getValue('TSS_INFO') - ]; - - return json_encode($response); - } -} +sharedSecret = $sharedSecret; + } + + public function sendRequest($jsonData, $hppVersion = '') + { + $this->paymentData = GenerationUtils::decodeJson($jsonData, true, $hppVersion); + + $timestamp = $this->getValue('TIMESTAMP'); + $merchantId = $this->getValue('MERCHANT_ID'); + $account = $this->getValue('ACCOUNT'); + $orderId = $this->getValue('ORDER_ID'); + $amount = $this->getValue('AMOUNT'); + $currency = $this->getValue('CURRENCY'); + $autoSettle = $this->getValue('AUTO_SETTLE_FLAG'); + $requestHash = $this->getValue('SHA1HASH'); + $shippingCode = $this->getValue('SHIPPING_CODE'); + $shippingCountry = $this->getValue('SHIPPING_CO'); + $billingCode = $this->getValue('BILLING_CODE'); + $billingCountry = $this->getValue('BILLING_CO'); + + $config = new GpEcomConfig(); + $config->merchantId = $merchantId; + $config->accountId = $account; + $config->sharedSecret = $this->sharedSecret; + $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + $config->hostedPaymentConfig->version = $hppVersion; + + ServicesContainer::configureService($config); + + // create the card object + $card = new CreditCardData(); + $card->number = '4006097467207025'; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '131'; + $card->cardHolderName = 'James Mason'; + + // // check hash + $hashParam = [ + $timestamp, + $merchantId, + $orderId, + $amount, + $currency + ]; + + //for stored card + + if (!empty($this->paymentData['OFFER_SAVE_CARD'])) { + $hashParam[] = (!empty($this->paymentData['PAYER_REF'])) ? + $this->paymentData['PAYER_REF'] : null; + $hashParam[] = (!empty($this->paymentData['PMT_REF'])) ? + $this->paymentData['PMT_REF'] : null; + } + + $newHash = GenerationUtils::generateHash( + $this->sharedSecret, + implode('.', $hashParam) + ); + if ($newHash != $requestHash) { + throw new ApiException("Incorrect hash. Please check your code and the Developers Documentation."); + } + + // build request + if ($amount == null) { + $validate = $this->getValue("VALIDATE_CARD_ONLY"); + if ($validate) { + $gatewayRequest = $card->verify(); + } else { + $gatewayRequest = $card->verify()->WithRequestMultiUseToken(true); + } + } else { + $amount = $amount / 100; + if ($autoSettle) { + $gatewayRequest = $card->charge($amount); + } else { + $gatewayRequest = $card->authorize($amount); + } + } + + try { + $gatewayRequest + ->WithCurrency($currency) + ->WithOrderId($orderId) + ->withTimeStamp($timestamp); + + $this->addAddressDetails($gatewayRequest, $billingCode, $billingCountry, AddressType::BILLING); + $this->addAddressDetails($gatewayRequest, $shippingCode, $shippingCountry, AddressType::SHIPPING); + + //handle DCC + $this->addDCCInfo($gatewayRequest, $orderId); + + //handle fraud management + $this->addFraudManagementInfo($gatewayRequest, $orderId); + + $gatewayResponse = $gatewayRequest->execute(); + + if ($gatewayResponse->responseCode === '00') { + return $this->convertResponse($gatewayResponse); + } + } catch (ApiException $exc) { + throw $exc; + } + return null; + } + + public function getValue($value) + { + if (isset($this->paymentData[$value])) { + return $this->paymentData[$value]; + } + return null; + } + + public function addDCCInfo($gatewayRequest, $orderId) + { + if (!empty($this->paymentData['DCC_ENABLE'])) { + $dccInfo = $this->getValue('DCC_INFO'); + + $dccValues = new DccRateData(); + $dccValues->orderId = $orderId; + $dccValues->dccProcessor = $dccInfo['CCP']; + $dccValues->dccType = $dccInfo['TYPE']; + $dccValues->dccRateType = $dccInfo['RATE_TYPE']; + $dccValues->currency = $dccInfo['CURRENCY']; + $dccValues->dccRate = $dccInfo['RATE']; + $dccValues->amount = $dccInfo['AMOUNT']; + + $gatewayRequest + ->withDccRateData($dccValues); + } + } + + public function addFraudManagementInfo($gatewayRequest, $orderId) + { + if (!empty($this->paymentData['HPP_FRAUD_FILTER_MODE'])) { + $tssInfo = $this->getValue('TSS_INFO'); + + $this->addAddressDetails( + $gatewayRequest, + $tssInfo['BILLING_ADDRESS']['CODE'], + $tssInfo['BILLING_ADDRESS']['COUNTRY'], + AddressType::BILLING + ); + + $this->addAddressDetails( + $gatewayRequest, + $tssInfo['SHIPPING_ADDRESS']['CODE'], + $tssInfo['SHIPPING_ADDRESS']['COUNTRY'], + AddressType::SHIPPING + ); + + $gatewayRequest + ->withProductId($tssInfo['PRODID']) // prodid + ->withClientTransactionId($tssInfo['VARREF']) // varref + ->withCustomerId($tssInfo['CUSTNUM']) // custnum + ->withCustomerIpAddress($tssInfo['CUSTIPADDRESS']) + ->withFraudFilter($this->paymentData['HPP_FRAUD_FILTER_MODE']); + } + } + + public function addAddressDetails($gatewayRequest, $code, $country, $addressType = AddressType::BILLING) + { + if ($code != null || $country != null) { + $address = new Address(); + $address->postalCode = $code; + $address->country = $country; + + $gatewayRequest + ->WithAddress($address, $addressType); + } + } + + public function convertResponse($gatewayResponse) + { + $merchantId = $this->paymentData['MERCHANT_ID']; + $account = $this->paymentData['ACCOUNT']; + + $newHash = GenerationUtils::generateHash( + $this->sharedSecret, + implode('.', [ + $gatewayResponse->timestamp, + $merchantId, + $gatewayResponse->transactionReference->orderId, + $gatewayResponse->responseCode, + $gatewayResponse->responseMessage, + $gatewayResponse->transactionReference->transactionId, + $gatewayResponse->transactionReference->authCode + ]) + ); + + // begin building response + $response = [ + 'MERCHANT_ID' => $merchantId, + 'ACCOUNT' => $this->getValue('ACCOUNT'), + 'ORDER_ID' => $gatewayResponse->transactionReference->orderId, + 'TIMESTAMP' => $gatewayResponse->timestamp, + 'RESULT' => $gatewayResponse->responseCode, + 'PASREF' => $gatewayResponse->transactionReference->transactionId, + 'AUTHCODE' => $gatewayResponse->transactionReference->authCode, + 'AVSPOSTCODERESULT' => $gatewayResponse->avsResponseCode, + 'CVNRESULT' => $gatewayResponse->cvnResponseCode, + 'HPP_LANG' => $this->getValue('HPP_LANG'), + 'SHIPPING_CODE' => $this->getValue('SHIPPING_CODE'), + 'SHIPPING_CO' => $this->getValue('SHIPPING_CO'), + 'BILLING_CODE' => $this->getValue('BILLING_CODE'), + 'BILLING_CO' => $this->getValue('BILLING_CO'), + 'ECI' => $this->getValue('ECI'), + 'CAVV' => $this->getValue('CAVV'), + 'XID' => $this->getValue('XID'), + 'MERCHANT_RESPONSE_URL' => $this->getValue('MERCHANT_RESPONSE_URL'), + 'CARD_PAYMENT_BUTTON' => $this->getValue('CARD_PAYMENT_BUTTON'), + 'MESSAGE' => $gatewayResponse->responseMessage, + 'AMOUNT' => $this->getValue('AMOUNT'), + 'SHA1HASH' => $newHash, + 'DCC_INFO_REQUST' => $this->getValue('DCC_INFO'), + 'DCC_INFO_RESPONSE' => $gatewayResponse->dccResponseResult, + 'HPP_FRAUD_FILTER_MODE' => $this->getValue('HPP_FRAUD_FILTER_MODE'), + 'TSS_INFO' => $this->getValue('TSS_INFO') + ]; + + return json_encode($response); + } +} diff --git a/test/Integration/Gateways/RealexConnector/HppTest.php b/test/Integration/Gateways/RealexConnector/HppTest.php index a07129ee..a10bea65 100644 --- a/test/Integration/Gateways/RealexConnector/HppTest.php +++ b/test/Integration/Gateways/RealexConnector/HppTest.php @@ -1,755 +1,756 @@ -merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - return new HostedService($config); - } - - public function testCreditAuth() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - $address = new Address(); - $address->postalCode = "123|56"; - $address->country = "IRELAND"; - - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->authorize(1) - ->withCurrency("EUR") - ->withCustomerId("123456") - ->withAddress($address) - ->serialize(); - - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - public function testCreditSale() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - $address = new Address(); - $address->postalCode = "123|56"; - $address->country = "IRELAND"; - - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->charge(1) - ->withCurrency("EUR") - ->withCustomerId("123456") - ->withAddress($address) - ->serialize(); - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - - $this->assertNotNull($parsedResponse); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - /* 03. ProcessPaymentOtbRequest */ - - public function testCreditVerify() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - $address = new Address(); - $address->postalCode = "123|56"; - $address->country = "IRELAND"; - - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->verify() - ->withCurrency("EUR") - ->withCustomerId("123456") - ->withAddress($address) - ->serialize(); - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - $this->assertNotNull($parsedResponse); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testAuthNoAmount() - { - $service = $this->basicSetup(); - $service->authorize(null)->withCurrency("USD")->serialize(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testAuthNoCurrency() - { - $service = $this->basicSetup(); - $service->authorize(10)->serialize(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testSaleNoAmount() - { - $service = $this->basicSetup(); - $service->charge(null)->withCurrency("USD")->serialize(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testSaleNoCurrency() - { - $service = $this->basicSetup(); - $service->charge(10)->serialize(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testVerifyNoCurrency() - { - $service = $this->basicSetup(); - $service->verify()->serialize(); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testVerifyWithAmount() - { - $service = $this->basicSetup(); - $service->verify()->withAmount(10)->serialize(); - } - - /* 05. CardStorageCreatePayerStoreCardRequest */ - - public function testCardStorageCreatePayer() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "3dsecure"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - // data to be passed to the HPP along with transaction level settings - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box - $hostedPaymentData->customerExists = "0"; // new customer - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->charge(15) - ->withCurrency("EUR") - ->withHostedPaymentData($hostedPaymentData) - ->serialize(); - - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - $this->assertNotNull($parsedResponse); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - /* 07. CardStorageDisplayStoredCardsRequest */ - - public function testCardStorageDisplayStoredCard() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "3dsecure"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - // data to be passed to the HPP along with transaction level settings - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; - $hostedPaymentData->customerExists = "1"; - $hostedPaymentData->customerKey = "5e7e9152-2d53-466d-91bc-6d12ebc56b79"; - - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->charge(15) - ->withCurrency("EUR") - ->withHostedPaymentData($hostedPaymentData) - ->serialize(); - - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - $this->assertNotNull($parsedResponse); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - /* 09. ContinuousAuthorityRequest */ - - public function testContinuousAuthorityRequest() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "3dsecure"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->charge(15) - ->withCurrency("EUR") - ->withRecurringInfo(RecurringType::FIXED, RecurringSequence::FIRST) - ->serialize(); - - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - $this->assertNotNull($parsedResponse); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - /* 13. DynamicCurrencyConversionRequest */ - - public function testEnableDynamicCurrencyConversionRequest() - { - //set config for DCC - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - $config->hostedPaymentConfig->directCurrencyConversionEnabled = "1"; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - //serialize the request - $json = $service->Charge(19) - ->withCurrency("EUR") - ->withTimestamp("20170725154824") - ->withOrderId('GTI5Yxb0SumL_TkDMCAxQA') - ->serialize(); - - $this->assertNotNull($json); - $this->assertEquals($json, '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1900","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","DCC_ENABLE":"1","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","HPP_VERSION":"2","SHA1HASH":"448d742db89b05ce97152beb55157c904f3839cc"}'); - } - - public function testDisableDynamicCurrencyConversionRequest() - { - //set config for DCC - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - $config->hostedPaymentConfig->directCurrencyConversionEnabled = "0"; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - //serialize the request - $json = $service->Charge(19) - ->withCurrency("EUR") - ->withTimestamp("20170725154824") - ->withOrderId('GTI5Yxb0SumL_TkDMCAxQA') - ->serialize(); - - $this->assertNotNull($json); - $this->assertEquals($json, '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1900","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","DCC_ENABLE":"0","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","HPP_VERSION":"2","SHA1HASH":"448d742db89b05ce97152beb55157c904f3839cc"}'); - } - - /* 11. FraudManagementRequest */ - - public function testFraudManagementRequest() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "3dsecure"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - $config->hostedPaymentConfig->version = 2; - $config->hostedPaymentConfig->FraudFilterMode = FraudFilterMode::PASSIVE; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - // billing address - $billingAddress = new Address(); - $billingAddress->postalCode = "50001|Flat 123"; - $billingAddress->country = "US"; - - // shipping address - $shippingAddress = new Address(); - $shippingAddress->postalCode = "654|123"; - $shippingAddress->country = "GB"; - - // data to be passed to the HPP along with transaction level settings - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->customerNumber = "E8953893489"; // display the save card tick box - $hostedPaymentData->productId = "SID9838383"; // new customer - - //serialize the request - $json = $service->charge(19) - ->withCurrency("EUR") - ->withAddress($billingAddress, AddressType::BILLING) - ->withAddress($shippingAddress, AddressType::SHIPPING) - //->withProductId("SID9838383") // prodid - ->withClientTransactionId("Car Part HV") // varref - //->withCustomerId("E8953893489") // custnum - ->withCustomerIpAddress("123.123.123.123") - //->withFraudFilter(FraudFilterMode::PASSIVE) - ->withHostedPaymentData($hostedPaymentData) - ->serialize(); - - $this->assertNotNull($json); - - //make API call - $response = $client->sendRequest($json, $config->hostedPaymentConfig->version); - $this->assertNotNull($response); - - $parsedResponse = $service->parseResponse($response); - $this->assertNotNull($parsedResponse); - $this->assertEquals("00", $parsedResponse->responseCode); - } - - /* Serialize methods Test case */ - - public function testBasicAuthHppVersion1() - { - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_1; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - $json = $service->authorize(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"TWVyY2hhbnRJZA==","ACCOUNT":"aW50ZXJuZXQ=","ORDER_ID":"R1RJNVl4YjBTdW1MX1RrRE1DQXhRQQ==","AMOUNT":"MTk5OQ==","CURRENCY":"RVVS","TIMESTAMP":"MjAxNzA3MjUxNTQ4MjQ=","AUTO_SETTLE_FLAG":"MA==","HPP_LANG":"R0I=","MERCHANT_RESPONSE_URL":"aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vcmVzcG9uc2U=","HPP_VERSION":"MQ==","SHA1HASH":"MDYxNjA5Zjg1YThlMDE5MWRjN2Y0ODdmODI3OGU3MTg5OGEyZWUyZA=="}'; - $this->assertEquals($json, $expectedJson); - } - - public function testBasicAuthHppVersion2() - { - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - $json = $service->authorize(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"0","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","SHA1HASH":"061609f85a8e0191dc7f487f8278e71898a2ee2d"}'; - $this->assertEquals($json, $expectedJson); - } - - public function testBasicSale() - { - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - $json = $service->charge(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","SHA1HASH":"061609f85a8e0191dc7f487f8278e71898a2ee2d"}'; - $this->assertEquals($json, $expectedJson); - } - - public function testBasicHostedPaymentDataHppVersion1() - { - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_1; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box - $hostedPaymentData->customerExists = "0"; // new customer - $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; - $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; - - $json = $service->charge(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->WithHostedPaymentData($hostedPaymentData) - ->WithDescription("Mobile Channel") - ->WithClientTransactionId("My Legal Entity") - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"TWVyY2hhbnRJZA==","ACCOUNT":"aW50ZXJuZXQ=","ORDER_ID":"R1RJNVl4YjBTdW1MX1RrRE1DQXhRQQ==","AMOUNT":"MTk5OQ==","CURRENCY":"RVVS","TIMESTAMP":"MjAxNzA3MjUxNTQ4MjQ=","AUTO_SETTLE_FLAG":"MQ==","COMMENT1":"TW9iaWxlIENoYW5uZWw=","CUST_NUM":"YTAyODc3NGYtYmVmZi00N2JjLWJkNmUtZWQ3ZTA0ZjVkNzU4YTAyODc3NGYtYnRlZmE=","OFFER_SAVE_CARD":"MQ==","PAYER_EXIST":"MA==","PROD_ID":"YTBiMzhkZjUtYjIzYy00ZDgyLTg4ZmUtMmU5YzQ3NDM4OTcyLWIyM2MtNGQ4Mi04OGY=","VAR_REF":"TXkgTGVnYWwgRW50aXR5","HPP_LANG":"R0I=","MERCHANT_RESPONSE_URL":"aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vcmVzcG9uc2U=","HPP_VERSION":"MQ==","SHA1HASH":"NzExNmM0OTgyNjM2N2M2NTEzZWZkYzBjYzgxZTI0M2I4MDk1ZDc4Zg=="}'; - $this->assertEquals($json, $expectedJson); - } - - public function testBasicHostedPaymentDataHppVersion2() - { - $config = new GpEcomConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - - $service = new HostedService($config); - $client = new RealexHppClient("secret"); - - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box - $hostedPaymentData->customerExists = "0"; // new customer - $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; - $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; - - $json = $service->charge(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->WithHostedPaymentData($hostedPaymentData) - ->WithDescription("Mobile Channel") - ->WithClientTransactionId("My Legal Entity") - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; - $this->assertEquals($json, $expectedJson); - } - - public function testParseResponse() - { - $config = new GpEcomConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - - $client = new RealexHppClient("secret"); - - $address = new Address(); - $address->postalCode = "123|56"; - $address->country = "IRELAND"; - - //run test cases for different version - foreach ($this->hppVersionList as $hppVersion) { - $config->hostedPaymentConfig->version = $hppVersion; - $service = new HostedService($config); - - $json = $service->authorize(1) - ->withCurrency("EUR") - ->withCustomerId("123456") - ->withAddress($address) - ->serialize(); - - $this->assertNotNull($json); - - $response = $client->sendRequest($json, $hppVersion); - $this->assertNotNull($response); - - // Base64 encode values - $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator(json_decode($response, true))); - foreach ($iterator as $key => $value) { - $iterator->getInnerIterator()->offsetSet($key, base64_encode($value)); - } - - $response = json_encode($iterator->getArrayCopy()); - - $parsedResponse = $service->parseResponse($response, true); - $this->assertEquals("00", $parsedResponse->responseCode); - } - } - - public function testHostedPaymentDataSupplementaryDataSerialize() - { - $config = new ServicesConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - $config->gatewayProvider = GatewayProvider::GP_ECOM; - - $service = new HostedService($config); - - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box - $hostedPaymentData->customerExists = "0"; // new customer - $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; - $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; - $hostedPaymentData->supplementaryData = ['HPP_FRAUDFILTER_MODE' => 'ACTIVE']; - - $json = $service->charge(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->withOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->withHostedPaymentData($hostedPaymentData) - ->withDescription("Mobile Channel") - ->withClientTransactionId("My Legal Entity") - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_FRAUDFILTER_MODE":"ACTIVE","HPP_VERSION":"2","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; - $this->assertEquals($json, $expectedJson); - } - - public function testSupplementaryDataWithOneValueSerialized() { - $config = new ServicesConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - $config->gatewayProvider = GatewayProvider::GP_ECOM; - - $service = new HostedService($config); - - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box - $hostedPaymentData->customerExists = "0"; // new customer - $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; - $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; - - $json = $service->charge(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->withOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->withHostedPaymentData($hostedPaymentData) - ->withDescription("Mobile Channel") - ->withClientTransactionId("My Legal Entity") - ->withSupplementaryData('HPP_FRAUDFILTER_MODE', 'ACTIVE') - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","HPP_FRAUDFILTER_MODE":"ACTIVE","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; - $this->assertEquals($json, $expectedJson); - } - - public function testSupplementaryDataWithTwoValuesSerialized() - { - $config = new ServicesConfig(); - $config->merchantId = "MerchantId"; - $config->accountId = "internet"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; - $config->hostedPaymentConfig->version = HppVersion::VERSION_2; - $config->gatewayProvider = GatewayProvider::GP_ECOM; - - $service = new HostedService($config); - - $hostedPaymentData = new HostedPaymentData(); - $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box - $hostedPaymentData->customerExists = "0"; // new customer - $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; - $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; - - $json = $service->charge(19.99) - ->withCurrency("EUR") - ->withTimeStamp("20170725154824") - ->withOrderId("GTI5Yxb0SumL_TkDMCAxQA") - ->withHostedPaymentData($hostedPaymentData) - ->withDescription("Mobile Channel") - ->withClientTransactionId("My Legal Entity") - ->withSupplementaryData(["RANDOM_KEY1" => "VALUE_1", "RANDOM_KEY2" => "VALUE_2"]) - ->serialize(); - - $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","RANDOM_KEY1":"VALUE_1","RANDOM_KEY2":"VALUE_2","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; - $this->assertEquals($json, $expectedJson); - } -} +merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + return new HostedService($config); + } + + public function testCreditAuth() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + $address = new Address(); + $address->postalCode = "123|56"; + $address->country = "IRELAND"; + + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->authorize(1) + ->withCurrency("EUR") + ->withCustomerId("123456") + ->withAddress($address) + ->serialize(); + + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + public function testCreditSale() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + $address = new Address(); + $address->postalCode = "123|56"; + $address->country = "IRELAND"; + + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->charge(1) + ->withCurrency("EUR") + ->withCustomerId("123456") + ->withAddress($address) + ->serialize(); + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + + $this->assertNotNull($parsedResponse); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + /* 03. ProcessPaymentOtbRequest */ + + public function testCreditVerify() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + $address = new Address(); + $address->postalCode = "123|56"; + $address->country = "IRELAND"; + + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->verify() + ->withCurrency("EUR") + ->withCustomerId("123456") + ->withAddress($address) + ->serialize(); + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + $this->assertNotNull($parsedResponse); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testAuthNoAmount() + { + $service = $this->basicSetup(); + $service->authorize(null)->withCurrency("USD")->serialize(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testAuthNoCurrency() + { + $service = $this->basicSetup(); + $service->authorize(10)->serialize(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testSaleNoAmount() + { + $service = $this->basicSetup(); + $service->charge(null)->withCurrency("USD")->serialize(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testSaleNoCurrency() + { + $service = $this->basicSetup(); + $service->charge(10)->serialize(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testVerifyNoCurrency() + { + $service = $this->basicSetup(); + $service->verify()->serialize(); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testVerifyWithAmount() + { + $service = $this->basicSetup(); + $service->verify()->withAmount(10)->serialize(); + } + + /* 05. CardStorageCreatePayerStoreCardRequest */ + + public function testCardStorageCreatePayer() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "3dsecure"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + // data to be passed to the HPP along with transaction level settings + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box + $hostedPaymentData->customerExists = "0"; // new customer + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->charge(15) + ->withCurrency("EUR") + ->withHostedPaymentData($hostedPaymentData) + ->serialize(); + + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + $this->assertNotNull($parsedResponse); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + /* 07. CardStorageDisplayStoredCardsRequest */ + + public function testCardStorageDisplayStoredCard() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "3dsecure"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + // data to be passed to the HPP along with transaction level settings + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; + $hostedPaymentData->customerExists = "1"; + $hostedPaymentData->customerKey = "5e7e9152-2d53-466d-91bc-6d12ebc56b79"; + + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->charge(15) + ->withCurrency("EUR") + ->withHostedPaymentData($hostedPaymentData) + ->serialize(); + + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + $this->assertNotNull($parsedResponse); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + /* 09. ContinuousAuthorityRequest */ + + public function testContinuousAuthorityRequest() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "3dsecure"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->charge(15) + ->withCurrency("EUR") + ->withRecurringInfo(RecurringType::FIXED, RecurringSequence::FIRST) + ->serialize(); + + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + $this->assertNotNull($parsedResponse); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + /* 13. DynamicCurrencyConversionRequest */ + + public function testEnableDynamicCurrencyConversionRequest() + { + //set config for DCC + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + $config->hostedPaymentConfig->directCurrencyConversionEnabled = "1"; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + //serialize the request + $json = $service->Charge(19) + ->withCurrency("EUR") + ->withTimestamp("20170725154824") + ->withOrderId('GTI5Yxb0SumL_TkDMCAxQA') + ->serialize(); + + $this->assertNotNull($json); + $this->assertEquals($json, '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1900","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","DCC_ENABLE":"1","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","HPP_VERSION":"2","SHA1HASH":"448d742db89b05ce97152beb55157c904f3839cc"}'); + } + + public function testDisableDynamicCurrencyConversionRequest() + { + //set config for DCC + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + $config->hostedPaymentConfig->directCurrencyConversionEnabled = "0"; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + //serialize the request + $json = $service->Charge(19) + ->withCurrency("EUR") + ->withTimestamp("20170725154824") + ->withOrderId('GTI5Yxb0SumL_TkDMCAxQA') + ->serialize(); + + $this->assertNotNull($json); + $this->assertEquals($json, '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1900","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","DCC_ENABLE":"0","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","HPP_VERSION":"2","SHA1HASH":"448d742db89b05ce97152beb55157c904f3839cc"}'); + } + + /* 11. FraudManagementRequest */ + + public function testFraudManagementRequest() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "3dsecure"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + $config->hostedPaymentConfig->version = 2; + $config->hostedPaymentConfig->FraudFilterMode = FraudFilterMode::PASSIVE; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + // billing address + $billingAddress = new Address(); + $billingAddress->postalCode = "50001|Flat 123"; + $billingAddress->country = "US"; + + // shipping address + $shippingAddress = new Address(); + $shippingAddress->postalCode = "654|123"; + $shippingAddress->country = "GB"; + + // data to be passed to the HPP along with transaction level settings + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->customerNumber = "E8953893489"; // display the save card tick box + $hostedPaymentData->productId = "SID9838383"; // new customer + + //serialize the request + $json = $service->charge(19) + ->withCurrency("EUR") + ->withAddress($billingAddress, AddressType::BILLING) + ->withAddress($shippingAddress, AddressType::SHIPPING) + //->withProductId("SID9838383") // prodid + ->withClientTransactionId("Car Part HV") // varref + //->withCustomerId("E8953893489") // custnum + ->withCustomerIpAddress("123.123.123.123") + //->withFraudFilter(FraudFilterMode::PASSIVE) + ->withHostedPaymentData($hostedPaymentData) + ->serialize(); + + $this->assertNotNull($json); + + //make API call + $response = $client->sendRequest($json, $config->hostedPaymentConfig->version); + $this->assertNotNull($response); + + $parsedResponse = $service->parseResponse($response); + $this->assertNotNull($parsedResponse); + $this->assertEquals("00", $parsedResponse->responseCode); + } + + /* Serialize methods Test case */ + + public function testBasicAuthHppVersion1() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_1; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + $json = $service->authorize(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"TWVyY2hhbnRJZA==","ACCOUNT":"aW50ZXJuZXQ=","ORDER_ID":"R1RJNVl4YjBTdW1MX1RrRE1DQXhRQQ==","AMOUNT":"MTk5OQ==","CURRENCY":"RVVS","TIMESTAMP":"MjAxNzA3MjUxNTQ4MjQ=","AUTO_SETTLE_FLAG":"MA==","HPP_LANG":"R0I=","MERCHANT_RESPONSE_URL":"aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vcmVzcG9uc2U=","HPP_VERSION":"MQ==","SHA1HASH":"MDYxNjA5Zjg1YThlMDE5MWRjN2Y0ODdmODI3OGU3MTg5OGEyZWUyZA=="}'; + $this->assertEquals($json, $expectedJson); + } + + public function testBasicAuthHppVersion2() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + $json = $service->authorize(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"0","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","SHA1HASH":"061609f85a8e0191dc7f487f8278e71898a2ee2d"}'; + $this->assertEquals($json, $expectedJson); + } + + public function testBasicSale() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + $json = $service->charge(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","SHA1HASH":"061609f85a8e0191dc7f487f8278e71898a2ee2d"}'; + $this->assertEquals($json, $expectedJson); + } + + public function testBasicHostedPaymentDataHppVersion1() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_1; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box + $hostedPaymentData->customerExists = "0"; // new customer + $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; + $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; + + $json = $service->charge(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->WithHostedPaymentData($hostedPaymentData) + ->WithDescription("Mobile Channel") + ->WithClientTransactionId("My Legal Entity") + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"TWVyY2hhbnRJZA==","ACCOUNT":"aW50ZXJuZXQ=","ORDER_ID":"R1RJNVl4YjBTdW1MX1RrRE1DQXhRQQ==","AMOUNT":"MTk5OQ==","CURRENCY":"RVVS","TIMESTAMP":"MjAxNzA3MjUxNTQ4MjQ=","AUTO_SETTLE_FLAG":"MQ==","COMMENT1":"TW9iaWxlIENoYW5uZWw=","CUST_NUM":"YTAyODc3NGYtYmVmZi00N2JjLWJkNmUtZWQ3ZTA0ZjVkNzU4YTAyODc3NGYtYnRlZmE=","OFFER_SAVE_CARD":"MQ==","PAYER_EXIST":"MA==","PROD_ID":"YTBiMzhkZjUtYjIzYy00ZDgyLTg4ZmUtMmU5YzQ3NDM4OTcyLWIyM2MtNGQ4Mi04OGY=","VAR_REF":"TXkgTGVnYWwgRW50aXR5","HPP_LANG":"R0I=","MERCHANT_RESPONSE_URL":"aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vcmVzcG9uc2U=","HPP_VERSION":"MQ==","SHA1HASH":"NzExNmM0OTgyNjM2N2M2NTEzZWZkYzBjYzgxZTI0M2I4MDk1ZDc4Zg=="}'; + $this->assertEquals($json, $expectedJson); + } + + public function testBasicHostedPaymentDataHppVersion2() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + + $service = new HostedService($config); + $client = new RealexHppClient("secret"); + + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box + $hostedPaymentData->customerExists = "0"; // new customer + $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; + $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; + + $json = $service->charge(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->WithOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->WithHostedPaymentData($hostedPaymentData) + ->WithDescription("Mobile Channel") + ->WithClientTransactionId("My Legal Entity") + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; + $this->assertEquals($json, $expectedJson); + } + + public function testParseResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + + $client = new RealexHppClient("secret"); + + $address = new Address(); + $address->postalCode = "123|56"; + $address->country = "IRELAND"; + + //run test cases for different version + foreach ($this->hppVersionList as $hppVersion) { + $config->hostedPaymentConfig->version = $hppVersion; + $service = new HostedService($config); + + $json = $service->authorize(1) + ->withCurrency("EUR") + ->withCustomerId("123456") + ->withAddress($address) + ->serialize(); + + $this->assertNotNull($json); + + $response = $client->sendRequest($json, $hppVersion); + $this->assertNotNull($response); + + // Base64 encode values + $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator(json_decode($response, true))); + foreach ($iterator as $key => $value) { + $iterator->getInnerIterator()->offsetSet($key, base64_encode($value)); + } + + $response = json_encode($iterator->getArrayCopy()); + + $parsedResponse = $service->parseResponse($response, true); + $this->assertEquals("00", $parsedResponse->responseCode); + } + } + + public function testHostedPaymentDataSupplementaryDataSerialize() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + $config->gatewayProvider = GatewayProvider::GP_ECOM; + + $service = new HostedService($config); + + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box + $hostedPaymentData->customerExists = "0"; // new customer + $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; + $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; + $hostedPaymentData->supplementaryData = ['HPP_FRAUDFILTER_MODE' => 'ACTIVE']; + + $json = $service->charge(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->withOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->withHostedPaymentData($hostedPaymentData) + ->withDescription("Mobile Channel") + ->withClientTransactionId("My Legal Entity") + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_FRAUDFILTER_MODE":"ACTIVE","HPP_VERSION":"2","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; + $this->assertEquals($json, $expectedJson); + } + + public function testSupplementaryDataWithOneValueSerialized() { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + $config->gatewayProvider = GatewayProvider::GP_ECOM; + + $service = new HostedService($config); + + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box + $hostedPaymentData->customerExists = "0"; // new customer + $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; + $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; + + $json = $service->charge(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->withOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->withHostedPaymentData($hostedPaymentData) + ->withDescription("Mobile Channel") + ->withClientTransactionId("My Legal Entity") + ->withSupplementaryData('HPP_FRAUDFILTER_MODE', 'ACTIVE') + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","HPP_FRAUDFILTER_MODE":"ACTIVE","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; + $this->assertEquals($json, $expectedJson); + } + + public function testSupplementaryDataWithTwoValuesSerialized() + { + $config = new GpEcomConfig(); + $config->merchantId = "MerchantId"; + $config->accountId = "internet"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay"; + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "https://www.example.com/response"; + $config->hostedPaymentConfig->version = HppVersion::VERSION_2; + $config->gatewayProvider = GatewayProvider::GP_ECOM; + + $service = new HostedService($config); + + $hostedPaymentData = new HostedPaymentData(); + $hostedPaymentData->offerToSaveCard = "1"; // display the save card tick box + $hostedPaymentData->customerExists = "0"; // new customer + $hostedPaymentData->customerNumber = 'a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa'; + $hostedPaymentData->productId = 'a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f'; + + $json = $service->charge(19.99) + ->withCurrency("EUR") + ->withTimeStamp("20170725154824") + ->withOrderId("GTI5Yxb0SumL_TkDMCAxQA") + ->withHostedPaymentData($hostedPaymentData) + ->withDescription("Mobile Channel") + ->withClientTransactionId("My Legal Entity") + ->withSupplementaryData(["RANDOM_KEY1" => "VALUE_1", "RANDOM_KEY2" => "VALUE_2"]) + ->serialize(); + + $expectedJson = '{"MERCHANT_ID":"MerchantId","ACCOUNT":"internet","ORDER_ID":"GTI5Yxb0SumL_TkDMCAxQA","AMOUNT":"1999","CURRENCY":"EUR","TIMESTAMP":"20170725154824","AUTO_SETTLE_FLAG":"1","COMMENT1":"Mobile Channel","CUST_NUM":"a028774f-beff-47bc-bd6e-ed7e04f5d758a028774f-btefa","OFFER_SAVE_CARD":"1","PAYER_EXIST":"0","PROD_ID":"a0b38df5-b23c-4d82-88fe-2e9c47438972-b23c-4d82-88f","VAR_REF":"My Legal Entity","HPP_LANG":"GB","MERCHANT_RESPONSE_URL":"https:\/\/www.example.com\/response","HPP_VERSION":"2","RANDOM_KEY1":"VALUE_1","RANDOM_KEY2":"VALUE_2","SHA1HASH":"7116c49826367c6513efdc0cc81e243b8095d78f"}'; + $this->assertEquals($json, $expectedJson); + } +} diff --git a/test/Integration/Gateways/RealexConnector/HppTestCase.php b/test/Integration/Gateways/RealexConnector/HppTestCase.php index 936d6e53..9d000d8d 100644 --- a/test/Integration/Gateways/RealexConnector/HppTestCase.php +++ b/test/Integration/Gateways/RealexConnector/HppTestCase.php @@ -1,247 +1,241 @@ -merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - - $config->hostedPaymentConfig = new HostedPaymentConfig(); - $config->hostedPaymentConfig->language = "GB"; - $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; - return $config; - } - - public function setup() - { - $this->service = new HostedService($this->config()); - } - - /* 10. ThreedSecureResponse */ - - public function testThreedSecureResponse() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'hpp'; - $config->sharedSecret = 'secret'; - $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; - - $service = new HostedService( - $config - ); - - //response - // TODO: grab the response JSON from the client-side for example: - $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"hpp","ORDER_ID":"OTA4NUEzOEEtMkE3RjU2RQ","TIMESTAMP":"20180724124150","RESULT":"00","PASREF":"15324325098818233","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":"123|56","BILLING_CO":"IRELAND","ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":null,"SHA1HASH":"d1ff806b449b86375dbda74e2611760c348fcdeb","DCC_INFO_REQUST":null,"DCC_INFO_RESPONSE":null,"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; - - $parsedResponse = $service->parseResponse($responseJson); - $responseCode = $parsedResponse->responseCode; // 00 - $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised - $responseValues = $parsedResponse->responseValues; // get values accessible by key - - $eci = $responseValues["ECI"]; // 5 - fully authenticated - $cavv = $responseValues["CAVV"]; // AAACBUGDZYYYIgGFGYNlAAAAAAA= - $xid = $responseValues["XID"]; // vJ9NXpFueXsAqeb4iAbJJbe+66s= - // TODO: update your application and display transaction outcome to the customer - - $this->assertNotEquals(null, $parsedResponse); - $this->assertEquals("00", $responseCode); - } - - /* 02. ProcessPaymentConsumeHppResponse */ - - public function testprocessPaymentConsumeResponse() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'hpp'; - $config->sharedSecret = 'secret'; - $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; - - $service = new HostedService($config); - - $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"hpp","ORDER_ID":"NjMwNkMxMTAtMTA5RUNDRQ","TIMESTAMP":"20180720104340","RESULT":"00","PASREF":"15320798200414985","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":"123|56","BILLING_CO":"IRELAND","ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":"100","SHA1HASH":"32628cf3f887ab9f4f1c547a10ac365c2168f0e2","DCC_INFO":null,"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; - - // create the response object from the response JSON - $parsedResponse = $service->parseResponse($responseJson); - - $orderId = $parsedResponse->orderId; // GTI5Yxb0SumL_TkDMCAxQA - $responseCode = $parsedResponse->responseCode; // 00 - $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised - $responseValues = $parsedResponse->responseValues; // get values accessible by key - //$fraudFilterResult = $responseValues["HPP_FRAUDFILTER_RESULT"]; // PASS - - $this->assertNotEquals(null, $parsedResponse); - $this->assertEquals("00", $responseCode); - } - - /* 06. CardStorageCreatePayerStoreCardResponse */ - - public function testCardStorageCreatePayerStoreCardResponse() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'hpp'; - $config->sharedSecret = 'secret'; - $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; - - $service = new HostedService( - $config - ); - - // TODO: grab the response JSON from the client-side for example: - //sample response JSON: - $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"3dsecure","ORDER_ID":"NTgxMkMzODUtNTEwMkNCMw","TIMESTAMP":"20180723110112","RESULT":"00","PASREF":"15323400720177562","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":null,"BILLING_CO":null,"ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":"1500","SHA1HASH":"4c7a635401c57371a0931bb3a21a849181cc963d","DCC_INFO":null,"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; - - $parsedResponse = $service->parseResponse($responseJson); - $responseCode = $parsedResponse->responseCode; // 00 - $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised - $responseValues = $parsedResponse->responseValues; // get values accessible by key - /* - // Payer Setup Details - $payerSetupResult = $responseValues["PAYER_SETUP"]; // 00 - $payerSetupMessage = $responseValues["PAYER_SETUP_MSG"]; // Successful - $payerReference = $responseValues["SAVED_PAYER_REF"]; // 5e7e9152-2d53-466d-91bc-6d12ebc56b79 - // Card Setup Details - $cardSetupResult = $responseValues["PMT_SETUP"]; // 00 - $cardSetupMessage = $responseValues["PMT_SETUP_MSG"]; // Successful - $cardReference = $responseValues["SAVED_PMT_REF"]; // ca68dcac-9af2-4d65-b06c-eb54667dcd4a - // Card Details Stored - $cardType = $responseValues["SAVED_PMT_TYPE"]; // MC - $cardDigits = $responseValues["SAVED_PMT_DIGITS"]; // 542523xxxx4415 - $cardExpiry = $responseValues["SAVED_PMT_EXPDATE"]; // 1025 - $cardName = $responseValues["SAVED_PMT_NAME"]; // James Mason - */ - // TODO: update your application and display transaction outcome to the customer - - $this->assertNotEquals(null, $parsedResponse); - $this->assertEquals("00", $responseCode); - } - - /* 08. CardStorageDisplayStoredCardsResponse */ - - public function testCardStorageDisplayStoredCardsResponse() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'hpp'; - $config->sharedSecret = 'secret'; - $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; - - $service = new HostedService( - $config - ); - - // TODO: grab the response JSON from the client-side for example: - //sample response JSON: - $responseJson = array("MERCHANT_ID" => "MerchantId", "ACCOUNT" => "internet", "ORDER_ID" => "GTI5Yxb0SumL_TkDMCAxQA", "AMOUNT" => "1999", "TIMESTAMP" => "20170725154824", "SHA1HASH" => "843680654f377bfa845387fdbace35acc9d95778", "RESULT" => "00", "AUTHCODE" => "12345", "CARD_PAYMENT_BUTTON" => "Place Order", "AVSADDRESSRESULT" => "M", "AVSPOSTCODERESULT" => "M", "BATCHID" => "445196", "MESSAGE" => "[ test system ] Authorised", "PASREF" => "15011597872195765", "CVNRESULT" => "M", "HPP_FRAUDFILTER_RESULT" => "PASS", "HPP_CHOSEN_PMT_REF" => "099efeb4-eda2-4fd7-a04d-29647bb6c51d", "HPP_EDITED_PMT_REF" => "037bd26a-c76b-4ee4-8063-376d8858f23d", "HPP_DELETED_PMT_REF" => "3db4c72c-cd95-4743-8070-f17e2b56b642"); - - $parsedResponse = $service->parseResponse(json_encode($responseJson)); - $responseCode = $parsedResponse->responseCode; // 00 - $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised - $responseValues = $parsedResponse->responseValues; // get values accessible by key - // card used to complete payment, edited or deleted - $chosenCard = $responseValues["HPP_CHOSEN_PMT_REF"]; // 099efeb4-eda2-4fd7-a04d-29647bb6c51d - $editedCard = $responseValues["HPP_EDITED_PMT_REF"]; // 037bd26a-c76b-4ee4-8063-376d8858f23d - $deletedCard = $responseValues["HPP_DELETED_PMT_REF"]; // 3db4c72c-cd95-4743-8070-f17e2b56b642 - // TODO: update your application and display transaction outcome to the customer - - $this->assertNotEquals(null, $parsedResponse); - $this->assertEquals("00", $responseCode); - } - - /* 12. FraudManagementResponse */ - - public function testFraudManagementResponse() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'hpp'; - $config->sharedSecret = 'secret'; - $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; - - $service = new HostedService( - $config - ); - - // TODO: grab the response JSON from the client-side for example: - //sample response JSON: - $responseJson = array("MERCHANT_ID" => "MerchantId", "ACCOUNT" => "internet", "ORDER_ID" => "GTI5Yxb0SumL_TkDMCAxQA", "AMOUNT" => "1999", "TIMESTAMP" => "20170725154824", "SHA1HASH" => "843680654f377bfa845387fdbace35acc9d95778", "RESULT" => "00", "AUTHCODE" => "12345", "CARD_PAYMENT_BUTTON" => "Place Order", "AVSADDRESSRESULT" => "M", "AVSPOSTCODERESULT" => "M", "BATCHID" => "445196", "MESSAGE" => "[ test system ] Authorised", "PASREF" => "15011597872195765", "CVNRESULT" => "M", "HPP_FRAUDFILTER_RESULT" => "HOLD", "HPP_FRAUDFILTER_RULE_56257838-4590-4227-b946-11e061fb15fe" => "HOLD", "HPP_FRAUDFILTER_RULE_cf609cf9-9e5a-4700-ac69-8aa09c119305" => "PASS"); - ; - - $parsedResponse = $service->parseResponse(json_encode($responseJson)); - $responseCode = $parsedResponse->responseCode; // 00 - $responseValues = $parsedResponse->responseValues; // get values accessible by key - - $fraudFilterResult = $responseValues["HPP_FRAUDFILTER_RESULT"]; // HOLD - $cardRuleResult = $responseValues["HPP_FRAUDFILTER_RULE_56257838-4590-4227-b946-11e061fb15fe"]; // HOLD - $ipRuleResult = $responseValues["HPP_FRAUDFILTER_RULE_cf609cf9-9e5a-4700-ac69-8aa09c119305"]; // PASS - // TODO: update your application and display transaction outcome to the customer - - $this->assertNotEquals(null, $parsedResponse); - $this->assertEquals("00", $responseCode); - } - - /* 14. DynamicCurrencyConversionResponse */ - - public function testDynamicCurrencyConversionResponse() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = 'hpp'; - $config->sharedSecret = 'secret'; - $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; - - $service = new HostedService( - $config - ); - - // TODO: grab the response JSON from the client-side for example: - //sample response JSON: - $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"apidcc","ORDER_ID":"NTQyQzgxREMtMzVFQzlDNw","TIMESTAMP":"20180724095953","RESULT":"00","PASREF":"15324227932436743","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":null,"BILLING_CO":null,"ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":"100100","SHA1HASH":"320c7ddc49d292f5900c676168d5cc1f2a55306c","DCC_INFO_REQUST":{"CCP":"Fexco","TYPE":1,"RATE":"1.7203","RATE_TYPE":"S","AMOUNT":"172202","CURRENCY":"AUD"},"DCC_INFO_RESPONSE":{"cardHolderCurrency":"AUD","cardHolderAmount":"172202","cardHolderRate":"1.7203","merchantCurrency":"EUR","merchantAmount":"100100","marginRatePercentage":"","exchangeRateSourceName":"","commissionPercentage":"","exchangeRateSourceTimestamp":""},"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; - $parsedResponse = $service->parseResponse($responseJson); - - $responseCode = $parsedResponse->responseCode; // 00 - $responseValues = $parsedResponse->responseValues; // get values accessible by key - - $conversionProcessor = $responseValues['DCC_INFO_REQUST']["CCP"]; // fexco - $conversionRate = $responseValues['DCC_INFO_REQUST']["RATE"]; // 1.7203 - $merchantAmount = $responseValues['DCC_INFO_RESPONSE']["merchantAmount"]; // 1999 - $cardholderAmount = $responseValues['DCC_INFO_RESPONSE']["cardHolderAmount"]; // 3439 - $merchantCurrency = $responseValues['DCC_INFO_RESPONSE']["merchantCurrency"]; // EUR - $cardholderCurrency = $responseValues['DCC_INFO_RESPONSE']["cardHolderCurrency"]; // AUD - $marginPercentage = $responseValues['DCC_INFO_RESPONSE']["marginRatePercentage"]; // 3.75 - $exchangeSource = $responseValues['DCC_INFO_RESPONSE']["exchangeRateSourceName"]; // REUTERS WHOLESALE INTERBANK - $commissionPercentage = $responseValues['DCC_INFO_RESPONSE']["commissionPercentage"]; // 0 - $exchangeTimestamp = $responseValues['DCC_INFO_RESPONSE']["exchangeRateSourceTimestamp"]; // 20170518162700 - // TODO: update your application and display transaction outcome to the customer - $this->assertNotEquals(null, $parsedResponse); - $this->assertEquals("00", $responseCode); - } -} +merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + + $config->hostedPaymentConfig = new HostedPaymentConfig(); + $config->hostedPaymentConfig->language = "GB"; + $config->hostedPaymentConfig->responseUrl = "http://requestb.in/10q2bjb1"; + return $config; + } + + public function setup() + { + $this->service = new HostedService($this->config()); + } + + /* 10. ThreedSecureResponse */ + + public function testThreedSecureResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'hpp'; + $config->sharedSecret = 'secret'; + $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; + + $service = new HostedService( + $config + ); + + //response + // TODO: grab the response JSON from the client-side for example: + $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"hpp","ORDER_ID":"OTA4NUEzOEEtMkE3RjU2RQ","TIMESTAMP":"20180724124150","RESULT":"00","PASREF":"15324325098818233","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":"123|56","BILLING_CO":"IRELAND","ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":null,"SHA1HASH":"d1ff806b449b86375dbda74e2611760c348fcdeb","DCC_INFO_REQUST":null,"DCC_INFO_RESPONSE":null,"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; + + $parsedResponse = $service->parseResponse($responseJson); + $responseCode = $parsedResponse->responseCode; // 00 + $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised + $responseValues = $parsedResponse->responseValues; // get values accessible by key + + $eci = $responseValues["ECI"]; // 5 - fully authenticated + $cavv = $responseValues["CAVV"]; // AAACBUGDZYYYIgGFGYNlAAAAAAA= + $xid = $responseValues["XID"]; // vJ9NXpFueXsAqeb4iAbJJbe+66s= + // TODO: update your application and display transaction outcome to the customer + + $this->assertNotEquals(null, $parsedResponse); + $this->assertEquals("00", $responseCode); + } + + /* 02. ProcessPaymentConsumeHppResponse */ + + public function testprocessPaymentConsumeResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'hpp'; + $config->sharedSecret = 'secret'; + $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; + + $service = new HostedService($config); + + $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"hpp","ORDER_ID":"NjMwNkMxMTAtMTA5RUNDRQ","TIMESTAMP":"20180720104340","RESULT":"00","PASREF":"15320798200414985","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":"123|56","BILLING_CO":"IRELAND","ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":"100","SHA1HASH":"32628cf3f887ab9f4f1c547a10ac365c2168f0e2","DCC_INFO":null,"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; + + // create the response object from the response JSON + $parsedResponse = $service->parseResponse($responseJson); + + $orderId = $parsedResponse->orderId; // GTI5Yxb0SumL_TkDMCAxQA + $responseCode = $parsedResponse->responseCode; // 00 + $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised + $responseValues = $parsedResponse->responseValues; // get values accessible by key + //$fraudFilterResult = $responseValues["HPP_FRAUDFILTER_RESULT"]; // PASS + + $this->assertNotEquals(null, $parsedResponse); + $this->assertEquals("00", $responseCode); + } + + /* 06. CardStorageCreatePayerStoreCardResponse */ + + public function testCardStorageCreatePayerStoreCardResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'hpp'; + $config->sharedSecret = 'secret'; + $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; + + $service = new HostedService( + $config + ); + + // TODO: grab the response JSON from the client-side for example: + //sample response JSON: + $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"3dsecure","ORDER_ID":"NTgxMkMzODUtNTEwMkNCMw","TIMESTAMP":"20180723110112","RESULT":"00","PASREF":"15323400720177562","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":null,"BILLING_CO":null,"ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":"1500","SHA1HASH":"4c7a635401c57371a0931bb3a21a849181cc963d","DCC_INFO":null,"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; + + $parsedResponse = $service->parseResponse($responseJson); + $responseCode = $parsedResponse->responseCode; // 00 + $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised + $responseValues = $parsedResponse->responseValues; // get values accessible by key + /* + // Payer Setup Details + $payerSetupResult = $responseValues["PAYER_SETUP"]; // 00 + $payerSetupMessage = $responseValues["PAYER_SETUP_MSG"]; // Successful + $payerReference = $responseValues["SAVED_PAYER_REF"]; // 5e7e9152-2d53-466d-91bc-6d12ebc56b79 + // Card Setup Details + $cardSetupResult = $responseValues["PMT_SETUP"]; // 00 + $cardSetupMessage = $responseValues["PMT_SETUP_MSG"]; // Successful + $cardReference = $responseValues["SAVED_PMT_REF"]; // ca68dcac-9af2-4d65-b06c-eb54667dcd4a + // Card Details Stored + $cardType = $responseValues["SAVED_PMT_TYPE"]; // MC + $cardDigits = $responseValues["SAVED_PMT_DIGITS"]; // 542523xxxx4415 + $cardExpiry = $responseValues["SAVED_PMT_EXPDATE"]; // 1025 + $cardName = $responseValues["SAVED_PMT_NAME"]; // James Mason + */ + // TODO: update your application and display transaction outcome to the customer + + $this->assertNotEquals(null, $parsedResponse); + $this->assertEquals("00", $responseCode); + } + + /* 08. CardStorageDisplayStoredCardsResponse */ + + public function testCardStorageDisplayStoredCardsResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'hpp'; + $config->sharedSecret = 'secret'; + $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; + + $service = new HostedService( + $config + ); + + // TODO: grab the response JSON from the client-side for example: + //sample response JSON: + $responseJson = array("MERCHANT_ID" => "MerchantId", "ACCOUNT" => "internet", "ORDER_ID" => "GTI5Yxb0SumL_TkDMCAxQA", "AMOUNT" => "1999", "TIMESTAMP" => "20170725154824", "SHA1HASH" => "843680654f377bfa845387fdbace35acc9d95778", "RESULT" => "00", "AUTHCODE" => "12345", "CARD_PAYMENT_BUTTON" => "Place Order", "AVSADDRESSRESULT" => "M", "AVSPOSTCODERESULT" => "M", "BATCHID" => "445196", "MESSAGE" => "[ test system ] Authorised", "PASREF" => "15011597872195765", "CVNRESULT" => "M", "HPP_FRAUDFILTER_RESULT" => "PASS", "HPP_CHOSEN_PMT_REF" => "099efeb4-eda2-4fd7-a04d-29647bb6c51d", "HPP_EDITED_PMT_REF" => "037bd26a-c76b-4ee4-8063-376d8858f23d", "HPP_DELETED_PMT_REF" => "3db4c72c-cd95-4743-8070-f17e2b56b642"); + + $parsedResponse = $service->parseResponse(json_encode($responseJson)); + $responseCode = $parsedResponse->responseCode; // 00 + $responseMessage = $parsedResponse->responseMessage; // [ test system ] Authorised + $responseValues = $parsedResponse->responseValues; // get values accessible by key + // card used to complete payment, edited or deleted + $chosenCard = $responseValues["HPP_CHOSEN_PMT_REF"]; // 099efeb4-eda2-4fd7-a04d-29647bb6c51d + $editedCard = $responseValues["HPP_EDITED_PMT_REF"]; // 037bd26a-c76b-4ee4-8063-376d8858f23d + $deletedCard = $responseValues["HPP_DELETED_PMT_REF"]; // 3db4c72c-cd95-4743-8070-f17e2b56b642 + // TODO: update your application and display transaction outcome to the customer + + $this->assertNotEquals(null, $parsedResponse); + $this->assertEquals("00", $responseCode); + } + + /* 12. FraudManagementResponse */ + + public function testFraudManagementResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'hpp'; + $config->sharedSecret = 'secret'; + $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; + + $service = new HostedService( + $config + ); + + // TODO: grab the response JSON from the client-side for example: + //sample response JSON: + $responseJson = array("MERCHANT_ID" => "MerchantId", "ACCOUNT" => "internet", "ORDER_ID" => "GTI5Yxb0SumL_TkDMCAxQA", "AMOUNT" => "1999", "TIMESTAMP" => "20170725154824", "SHA1HASH" => "843680654f377bfa845387fdbace35acc9d95778", "RESULT" => "00", "AUTHCODE" => "12345", "CARD_PAYMENT_BUTTON" => "Place Order", "AVSADDRESSRESULT" => "M", "AVSPOSTCODERESULT" => "M", "BATCHID" => "445196", "MESSAGE" => "[ test system ] Authorised", "PASREF" => "15011597872195765", "CVNRESULT" => "M", "HPP_FRAUDFILTER_RESULT" => "HOLD", "HPP_FRAUDFILTER_RULE_56257838-4590-4227-b946-11e061fb15fe" => "HOLD", "HPP_FRAUDFILTER_RULE_cf609cf9-9e5a-4700-ac69-8aa09c119305" => "PASS"); + ; + + $parsedResponse = $service->parseResponse(json_encode($responseJson)); + $responseCode = $parsedResponse->responseCode; // 00 + $responseValues = $parsedResponse->responseValues; // get values accessible by key + + $fraudFilterResult = $responseValues["HPP_FRAUDFILTER_RESULT"]; // HOLD + $cardRuleResult = $responseValues["HPP_FRAUDFILTER_RULE_56257838-4590-4227-b946-11e061fb15fe"]; // HOLD + $ipRuleResult = $responseValues["HPP_FRAUDFILTER_RULE_cf609cf9-9e5a-4700-ac69-8aa09c119305"]; // PASS + // TODO: update your application and display transaction outcome to the customer + + $this->assertNotEquals(null, $parsedResponse); + $this->assertEquals("00", $responseCode); + } + + /* 14. DynamicCurrencyConversionResponse */ + + public function testDynamicCurrencyConversionResponse() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = 'hpp'; + $config->sharedSecret = 'secret'; + $config->serviceUrl = 'https://pay.sandbox.realexpayments.com/pay'; + + $service = new HostedService( + $config + ); + + // TODO: grab the response JSON from the client-side for example: + //sample response JSON: + $responseJson = '{"MERCHANT_ID":"heartlandgpsandbox","ACCOUNT":"apidcc","ORDER_ID":"NTQyQzgxREMtMzVFQzlDNw","TIMESTAMP":"20180724095953","RESULT":"00","PASREF":"15324227932436743","AUTHCODE":"12345","AVSPOSTCODERESULT":"U","CVNRESULT":"U","HPP_LANG":"GB","SHIPPING_CODE":null,"SHIPPING_CO":null,"BILLING_CODE":null,"BILLING_CO":null,"ECI":null,"CAVV":null,"XID":null,"MERCHANT_RESPONSE_URL":"http:\/\/requestb.in\/10q2bjb1","CARD_PAYMENT_BUTTON":null,"MESSAGE":"[ test system ] Authorised","AMOUNT":"100100","SHA1HASH":"320c7ddc49d292f5900c676168d5cc1f2a55306c","DCC_INFO_REQUST":{"CCP":"Fexco","TYPE":1,"RATE":"1.7203","RATE_TYPE":"S","AMOUNT":"172202","CURRENCY":"AUD"},"DCC_INFO_RESPONSE":{"cardHolderCurrency":"AUD","cardHolderAmount":"172202","cardHolderRate":"1.7203","merchantCurrency":"EUR","merchantAmount":"100100","marginRatePercentage":"","exchangeRateSourceName":"","commissionPercentage":"","exchangeRateSourceTimestamp":""},"HPP_FRAUD_FILTER_MODE":null,"TSS_INFO":null}'; + $parsedResponse = $service->parseResponse($responseJson); + + $responseCode = $parsedResponse->responseCode; // 00 + $responseValues = $parsedResponse->responseValues; // get values accessible by key + + $conversionProcessor = $responseValues['DCC_INFO_REQUST']["CCP"]; // fexco + $conversionRate = $responseValues['DCC_INFO_REQUST']["RATE"]; // 1.7203 + $merchantAmount = $responseValues['DCC_INFO_RESPONSE']["merchantAmount"]; // 1999 + $cardholderAmount = $responseValues['DCC_INFO_RESPONSE']["cardHolderAmount"]; // 3439 + $merchantCurrency = $responseValues['DCC_INFO_RESPONSE']["merchantCurrency"]; // EUR + $cardholderCurrency = $responseValues['DCC_INFO_RESPONSE']["cardHolderCurrency"]; // AUD + $marginPercentage = $responseValues['DCC_INFO_RESPONSE']["marginRatePercentage"]; // 3.75 + $exchangeSource = $responseValues['DCC_INFO_RESPONSE']["exchangeRateSourceName"]; // REUTERS WHOLESALE INTERBANK + $commissionPercentage = $responseValues['DCC_INFO_RESPONSE']["commissionPercentage"]; // 0 + $exchangeTimestamp = $responseValues['DCC_INFO_RESPONSE']["exchangeRateSourceTimestamp"]; // 20170518162700 + // TODO: update your application and display transaction outcome to the customer + $this->assertNotEquals(null, $parsedResponse); + $this->assertEquals("00", $responseCode); + } +} diff --git a/test/Integration/Gateways/RealexConnector/Realex3dSecureTests.php b/test/Integration/Gateways/RealexConnector/Realex3dSecureTests.php index d409af78..d29cc34f 100644 --- a/test/Integration/Gateways/RealexConnector/Realex3dSecureTests.php +++ b/test/Integration/Gateways/RealexConnector/Realex3dSecureTests.php @@ -1,501 +1,500 @@ -getConfig()); - } - - protected function getConfig() - { - $config = new ServicesConfig(); - $config->merchantId = 'heartlandgpsandbox'; - $config->accountId = '3dsecure'; - $config->sharedSecret = 'secret'; - $config->rebatePassword = 'rebate'; - $config->refundPassword = 'refund'; - $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; - return $config; - } - - public function testAcsClient() - { - $authClient = new ThreeDSecureAcsClient('https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MTNmMzI4NzgtNTdmZi00OWEzLWJhZTAtYzFhNzAxMDJkMGNi'); - $this->assertNotNull($authClient->authenticate('eJxlUsFSwjAQvfsVTO82TSm0MNs4FVBwRkUF8ZomK1Rpimkr6NebYBEdc8jsy27evrwNnO3ydesddZkVKnao6zktVKKQmVrGznx2cRo5Z+wEZiuNOHxAUWtkcI1lyZfYymTs+KIjZYRt30tl0H2WPRpFIuQyDULsdTvoMJgm9/jGoOnCTBPXB3KAhk2LFVcVAy7ezic3LAgD2ouANBBy1JMh6zULyDcGxXNkK+S6WnMll5vS7GmxA7JPgChqVekPFgUekAOAWq/Zqqo2ZZ+Q7Xbr/r/visKtX4HYSiBHcdPaRqVh3mWSJcM7Nb7t0O1iGs6n7cXnI025N7hSk1EMxFaA5BUy36MhpX7Y8r1+J+hTI39/Djy3kqwZRl4DYGN7JE3GJn4fgDFfm+EcnnRAgLtNodBUGFd/YiBHwYOx9VZUxrVxdjEb1aPXy5f5k27Tmzo/v75N4ti6vS+wbJlxikb0m84CIJaCNIMkzfxN9OdffAF4VML9')); - } - - public function testMerchantDataEnumerator() - { - $keys = ['Key1', 'Key2', 'Key3']; - $values = ['Value1', 'Value2', 'Value3']; - - $merchantData = new MerchantDataCollection(); - for ($i=0; $i<3; $i++) { - $merchantData->add($keys[$i], $values[$i]); - } - - $this->assertEquals(3, $merchantData->count()); - - foreach ($merchantData->getKeys() as $key) { - $this->assertTrue(in_array($key, $keys)); - $this->assertTrue(in_array($merchantData->get($key), $values)); - } - } - - public function testMerchantDataWithHiddenValues() - { - $card = new CreditCardData(); - $card->number = 4012001037141112; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'James Mason'; - - $enrolled = $card->verifyEnrolled(100, 'USD'); - $this->assertNotNull($enrolled); - if ($enrolled) { - $merchantData = $card->threeDSecure->getMerchantData(); - - $this->assertNotNull($merchantData); - $this->assertEquals(0, $merchantData->count()); - - $this->assertNull($merchantData->get('amount')); - $this->assertNull($merchantData->get('currency')); - $this->assertNull($merchantData->get('orderId')); - - for ($i=0; $i<3; $i++) { - $merchantData->add('Key'.$i, 'Value'.$i); - - $this->assertNotNull($merchantData->get('Key'.$i)); - $this->assertEquals('Value'.$i, $merchantData->get('Key'.$i)); - } - - $this->assertEquals(3, $merchantData->count()); - } - } - - public function testMerchantDataEncryptAndDecrypt() - { - $merchantData = new MerchantDataCollection(); - $merchantData->add('customerId', '12345'); - $merchantData->add('invoiceNumber', '54321'); - - $encoder = function ($input) { - $encoded = sprintf('%s.%s', $input, 'secret'); - return base64_encode($encoded); - }; - - $encrypted = $merchantData->toString($encoder); - - $decoder = function ($input) { - $decoded = explode('.', (string)base64_decode($input)); - $this->assertEquals('secret', $decoded[1]); - return $decoded[0]; - }; - - $decrypted = $merchantData->parse($encrypted, $decoder); - - $this->assertNotNull($decrypted); - $this->assertNotNull($decrypted->get('customerId')); - $this->assertEquals('12345', $decrypted->get('customerId')); - $this->assertNotNull($decrypted->get('invoiceNumber')); - $this->assertEquals('54321', $decrypted->get('invoiceNumber')); - } - - public function testMerchantDataMultiKey() - { - $this->expectExceptionMessage('Cannot access private property GlobalPayments\Api\Entities\MerchantDataCollection::$collection'); - - $mcd = new MerchantDataCollection(); - array_push($mcd->collection, array('amount'=>'10')); - array_push($mcd->collection, array('amount'=>'10')); - } - - public function testFullCycleWithMerchantData() - { - $card = new CreditCardData(); - $card->number = 4012001037141112; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(1, 'USD'); - if ($enrolled) { - $secureEcom = $card->threeDSecure; - if (!empty($secureEcom)) { - $merchantData = new MerchantDataCollection(); - $merchantData->add('client_txn_id', '123456'); - - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, (string)$secureEcom->getMerchantData()->toString()); - - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - $md = MerchantDataCollection::parse($authResponse->getMerchantData()); - - if ($card->verifySignature($payerAuthenticationResponse, $md)) { - $response = $card->charge(1) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } else { - $this->fail('Signature verification failed.'); - } - } else { - $this->fail('Secure3Data was null.'); - } - } else { - $this->fail('Card not enrolled.'); - } - } - - public function testFullCycleWithNoMerchantData() - { - $card = new CreditCardData(); - $card->number = 4012001037141112; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'James Mason'; - - $amount = 100; - $currency = 'USD'; - $orderId = GenerationUtils::generateOrderId(); - - $enrolled = $card->verifyEnrolled($amount, $currency, $orderId); - - if ($enrolled) { - $secureEcom = $card->threeDSecure; - - if ($secureEcom != null) { - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, (string)$secureEcom->getMerchantData()->toString()); - - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - - if ($card->verifySignature($payerAuthenticationResponse, null, $amount, $currency, $orderId)) { - $response = $card->charge($amount) - ->withCurrency($currency) - ->withOrderId($orderId) - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } else { - $this->fail('Signature verification failed.'); - } - } else { - $this->fail('Secure3Data was null.'); - } - } else { - $this->fail('Card not enrolled.'); - } - } - - public function testVerifyEnrolledTrue() - { - $card = new CreditCardData(); - $card->number = 4012001037141112; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(1, 'USD'); - $this->assertTrue($enrolled); - $this->assertNotNull($card->threeDSecure); - $this->assertNotNull($card->threeDSecure->payerAuthenticationRequest); - $this->assertNotNull($card->threeDSecure->issuerAcsUrl); - $this->assertNotNull($card->threeDSecure->xid); - } - - public function testVerifyEnrolledFalse() - { - $card = new CreditCardData(); - $card->number = 4012001038443335; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(1, 'USD'); - $this->assertFalse($enrolled); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - */ - public function testVerifySignatureBadOrderId() - { - $card = new CreditCardData(); - $card->verifySignature('eNrVWNmyozqy/ZWK6kfHOcwYOly7Q8yDwWYe3jBgRjPbYL7+4r1r16muWx3RfZ/68oKUSKlU5sqVQod/LLf6yyMdxqJtvn1F/oS/fvnH28HOhzTlrDS+D+nbQUvHMcrSL0Xy7SuNIjEMX1L8iiX4FUcudEQjURzhOEHHaHL9+nY4AzMd3wcTCEbS2Cb6vsDbpv9P9AB9djfNQ5xHzfR2iOKekfU3fI8jNHWAvncPt3SQuTf6+3OAPvoH6K+J5/urNW5mLkXyVvi9feR6zi2AGBCUZax3S3EeCI1T3w7Qa8Qhiab0DYWRPYKg1BcU/jtM/h3DD9C7/NC91IFbe990IzB8gH4WHDZ/DGkTP98ofPv0o3dIl65t0m3Etrkf7QP0l21d1LzBPz3Itvime5MebP/tMBW339r0Lj+MUzTdx7fgAH1vHeLo8XgDALAM5nAuq6OAk/mToTv8DF7Pttf3IYc0Lt5gYjNqe7/PAnXWDsWU316m/rPgAL1Mgd7D93awiqzZFhvSLxtCmvHb13yaur9D0DzPf87Yn+2QQei2EQimoW1AMhbZ375+zEoTubm2/9E0NmrapoijulijaUOGlk55m3z5Ydvv1NjmSxMCmTz7x6bqjxjBmz9eEhhDiE0n9HulP+3s31nlV2OHMfpjzCPktcAvit4OZnpNX4hIvzim/O3r337gnyuydJz+L+t9rvWzhk99blTf07e0Cz2ekj38LKW5mBLXiiFuoZWxN/7b57yPkQfoh4Hfrf8I1U8u+RgYUzvuaUx4FwaJURWc56HH/Yq5TX6sxTUIH7Kxm3TLLCiuVcwIo9nqtl8jNXLXCCmXR6CecFdoVjhC4P0ss+gsd6d67xE6QiD56kCcejLFztTiiAvNZfLHeL1h887PuAlrHBgMsnZf9YZfoTItL9UYe9J5ARby8CUM707lwz+x+lUzLCrHSh492mJNPOddfW8pUpq5py89JfPspIjDqTKDUiiAz3qwq0CU5UKVeyQU3KNmSHust3NjQcmezBAvOSV5ztJ9m1H3heSvdSYxDya+QNxMqTNrQS52c1RdURkVO6pPBdtrqrYwNuqT5nWOWX7p67lbMl1rply2U6rhNPQWdh3/OCdC9u3bT5D5HhE1fX5EwCdgmoum6KPFpsNUXDfsbpSkyTIX2iwLKjQDs8yATHbBSZIUbSr2QSqRbBeaZo3T64pHXJVpABZZqxct+YJxBs+wswM0MVu4FehMprsM0GymZhRXoDnD5l2N0USAODy7aJpbKZ4rumsi6Ejkm7VmwDM7B5xrGCo/m57l6oxmUDNnvMskfg750CPQ0JcX3gbnD/2ZzfL64yLSz8AzH5oxzuzHeJGfFddZQSrM8KKX/KyVYNFKftU4IXrJTtw/yzQJLMIK3O92a9yNeFxu7jVG6+ZS02XoK7BmOjP/YeORA4tn1KET+jrsYG6XiM7C2eD4Mb/VGCFUHJj/yRexxlRmfWnCOi55UwPUhy82RxsoPV4wJQ9FamFXoHyMD2xQu/YWE0YuXzqqPq8KkZ5hBhi8AMCJBQYFXt/ZTN3aPChKJ7Rv9KCfnfwsk6PchIR1U8M48i5zEp0LledpSOG5tbi7ir4Hec0jitt7GL460igVzY4wc1uYey7SfdW1S5k/L3dU4wpyycNsiloIRW6sGtmr7z5Hx9Af7NgB04GanE0umIPQqSxX4ERiWA0/aPKiaiEGY8I9FxktVagm0Mie6yCHw0zfjq3LxbaOKSaxK38DNGlCZ93jqskK9hBDOHkn7oQtMXYZlOPpNT6Fij4n4qmushGzm77B7cezjM+7ihNvqLg/kVe85x2a7vlHGISCrRot3YaKedX2I3dUC0bCgTyeI0BwxaTsl5AQ+diwMtO3XMqWYsNjS3a98hg4ZtE09VLoE4bMAQMwv8M6wLccMYDT+2ITZSu+gxf3dO010B4bFRodi5D7MyPkHMTR/R4ttIZrBm+cqGZ25ztSHsnlKktetpZ+kZQQEWiwaIrHliUSnofTEtu7nrwGbTBZZ4PjvAc7AEdr54WOWa9iNY0M66TH97tThmDoxh3skCgCz9Rk3lQMBJMeWyyqBS+RzUNkzN5dLC6eOtOi7JTRftNTUB92CUEw+ykOUpg44rf5stc78xgaa+pvEUSlNnpk5vV5PnYpSybdIg0R2en6rBaDDldX/o6wyLnMhqeHb4nBqWo3BpBYXMM6ijGrTNR85tNZvndnZfSMUJ661BokqlB8wgn5dKKQnWW70fRgm+xcuPpj5z32i3yAfmWn39EVL77oahY/6coExyCmt6DtJ2uxyULc8bfi5jovGlHUNpTzR6xvqXJkDDBvXjlqoHpPQybXWNfVfk5he0vhLkb55biC6UM22kr9Lsssj4A3SrgHvtldUCK/sIy99dHI02uZF9YYpcvIE+DIo++a2c4ieKcNjl8EL/L1XBbd8oIi0zanDC3GNOxPqgKEZldPjdNWnUteVPXU142mbH7WOQ1/yf67KHbzvyX/6l9m8y+XZfwZcNt3o2W3NgPUIQkhwylnnFurfSUQjR3uT0F/q5A9luGXR4abO1XCkXVa49m562eyHcZdOMYoZAlb4UO1qzYjp/mMboUvz+mWSpjc3SttyjtuTM+lDnsSye2mHkiXErai/pT3OUPdoTqqLXqRLt3jWUE8sYqlaJ/mdisAst9VKXW3SNS+E5KqMuLyyENIscH9mjCPI1bsHK2/Vrq9+AGvAjWBpYKUpOFxqup+5rcDzCh3+BoOXcBB5j3h8MGQxNm3DDiiGH0x1uet9cq2OI2aKwdqhjxqQw5nGh902m0uk9nCCTLUY9wBviX16pwwaCDeOE8O9/N8IUeB2xtCKyqJTflFxUjxxJHnMKWSBuumccM/D0B0Yh4cy9xtYL3iJpkaA64Uz3JABIYEgYwHmmS8sJHIwJw0cZwjIxBCnN/o7VXUQMlk2cBkvMAYMQvMwI8kE465dnNBgiVPAn3h9njbsGDRc4RW88kIZHUOtlg70pZ789EGgZALVugzY/DKA8FsI1/LNgziCQe4zQZG/NffT+92G9S73RuuN9wEs/TCmgmfGCbgBa3N0gqUocDEcgae1dWyIGXbqsIM/5qe2WHkCoDGO2+4IfaOtwlYT0Qa5baiUVQqUoxrz86GhAfpg0jKGXaZx55mE+s5DZqT5VAMp1CwIreOQ9aTrJ/Twm0Jq6kRpnzeK80g+RatfRPLhI0s2fUcjK2Otv5kzWJMFRpwpko25QwJUeqIybfWlfbxObYLz8yHgQLtXXa286SQdeOz3ThRkjpYs28rzt99Uh/ZbvcEnKIE2DASLCjtZ60FhokpIwm4wd5nz9MsXdHpURzVZkJYS5KeO4IlnzgVnfir0t72NjhleF3WVWUKJ5XzHCeuEYWppCldnGML+SHiyrhvHlMVjdUwInN/7ypLpTPwkXEG6ITjxf6xE0MvszWxo9SSX/5NehbKLf0f5Cc9G+l0Ryxt6RpeB01zWpHz7jzZv55uHAFwTPe/qYbXNTB+0Fuu8e6tXgObf2gs/El5t3eZxSiXxqzjG5EnYr2d4oRRFvQ6bsIuQJ3M8PX1gurdB3Xji1iC4JNKefeD3kNvg7mHbDpeMBUYjcF9zn6dFPntxAhWbY3hk9tuMu1X2X9ZWfkP6FmvnGut3rqGQKdAxsKJ0c/eOcBHXFUaSHK9WOB2lltEJ4fxckpMn8n9okMtO4vyVF3V5WEVnGnerCvryArTw17NG9g9BscLxOzk02DORlaMPXbRYTk8ghheJbl7ev79FrXVuB8j88GNEToPlxXiJ6SvNLiEWgl6nIat7KkSrdBEX7E9vpWNkY+fRKPOV67qBPTaVuEEO6oqTIsrxRZ/tnhk1XVkQ/Fi6d3+0fnP5XG0Rhbyk4ES9zaboRfkufieUA5nGLlvMOUbRbWbUMZZ1EnzeSk3NmWv1mhDQHwsXH71zsPAT4C02Zijh1NHc93s64WliOe1ih3Hu0rbb4Cf0WmQFTbf0ige/6Dnu80yU/lRVj/pmbE3Wtzo+f89NTMLJT2jxABejTP3113Rsv0lCnolr79S82bTJzWniIjm5xGAndnqLRy7DbKz05iygsRggLDv2eZIC2ke3fF9ipFXV9SL9VQ9ZZsGktgOpIkc5ShX/R1P3nrDDsa1USwi9xVKpGL4DN+W0rXiy/5ZzQYxM0Hvexp68dWuONpp4HpXBAyC13fIkxZJEwanqDmWt1k3GTBkzwdZI0Z42Tsaxlxpi6jh+yBoR3gDCsXs6bpOCR9D5QddXu/xnYwjeWCO1dlayKDf9VvxHXFKN62TvoPO/Y2WlhmRMOi5ov1RxFdb3i+Ky/FWKPJ+lBxnVvE58mSmPipAzOQkVI9iSemHFzco5CtPp5cBzzCEQJnaZaUQFZ/npMzl+zGVUMS92FDy5CUJ/Iaaob/++aEf9wB/3RC833K+X7y+buZ+vpD9HwzDHH8=', null, 1, 'USD', 'orderId'); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testVerifySignatureNoPaymentResponse() - { - $card = new CreditCardData(); - $card->verifySignature(null); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testVerifySignatureNoAmount() - { - $card = new CreditCardData(); - $card->verifySignature('paymentResponse', null, null, 'USD', 'orderId'); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testVerifySignatureNoCurrency() - { - $card = new CreditCardData(); - $card->verifySignature('paymentResponse', null, 10, null, 'orderId'); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException - */ - public function testVerifySignatureNoOrderId() - { - $card = new CreditCardData(); - $card->verifySignature('paymentResponse', null, 10, 'USD', null); - } - - public function testAuthorize3dSecure() - { - $secureEcom = new ThreeDSecure(); - $secureEcom->cavv = 'AAACBllleHchZTBWIGV4AAAAAAA='; - $secureEcom->xid = 'crqAeMwkEL9r4POdxpByWJ1/wYg='; - $secureEcom->eci = '5'; - - $card = new CreditCardData(); - $card->number = 4012001037141112; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'Philip Marlowe'; - $card->threeDSecure = $secureEcom; - - $response = $card->charge(10) - ->withCurrency('EUR') - ->execute(); - - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCardHolderNotEnrolled() - { - $card = new CreditCardData(); - $card->number = 4012001038443335; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertFalse($enrolled); - $this->assertNotNull($card->threeDSecure); - $this->assertEquals('6', $card->threeDSecure->eci); - - // .net test does not have amount or currency but validation would not allow this - $response = $card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testUnableToVerifyEnrollment() - { - $card = new CreditCardData(); - $card->number = 4012001038488884; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertFalse($enrolled); - $this->assertNotNull($card->threeDSecure); - $this->assertEquals('7', $card->threeDSecure->eci); - - $response = $card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - */ - public function testInvalidResponseFromEnrollmentServer() - { - $card = new CreditCardData(); - $card->number = 4012001036298889; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $card->verifyEnrolled(10, 'USD'); - } - - public function testCardHolderIsEnrolledACSAuthFailed() - { - $card = new CreditCardData(); - $card->number = 4012001036853337; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertTrue($enrolled); - - $secureEcom = $card->threeDSecure; - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); - - // $payerAuthenticationResponse = $authResponse->parse(); - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - $md = MerchantDataCollection::parse($authResponse->getMerchantData()); - - $verified = $card->verifySignature($payerAuthenticationResponse, $md); - $this->assertFalse($verified); - $this->assertNotNull($card->threeDSecure); - $this->assertEquals(7, $card->threeDSecure->eci); - - $response = $card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCardHolderIsEnrolledACSAcknowledged() - { - $card = new CreditCardData(); - $card->number = 4012001037167778; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertTrue($enrolled); - - $secureEcom = $card->threeDSecure; - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); - - // $payerAuthenticationResponse = $authResponse->parse(); - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - $md = MerchantDataCollection::parse($authResponse->getMerchantData()); - - $verified = $card->verifySignature($payerAuthenticationResponse, $md); - $this->assertTrue($verified); - $this->assertEquals('A', $card->threeDSecure->status); - - $response = $card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCardHolderIsEnrolledACSFailed() - { - $card = new CreditCardData(); - $card->number = 4012001037461114; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertTrue($enrolled); - - $secureEcom = $card->threeDSecure; - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); - - // $payerAuthenticationResponse = $authResponse->parse(); - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - $md = MerchantDataCollection::parse($authResponse->getMerchantData()); - - $verified = $card->verifySignature($payerAuthenticationResponse, $md); - $this->assertFalse($verified); - $this->assertEquals('N', $card->threeDSecure->status); - $this->assertEquals(7, $card->threeDSecure->eci); - - $response = $card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - public function testCardHolderIsEnrolledACSUnavailable() - { - $card = new CreditCardData(); - $card->number = 4012001037484447; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertTrue($enrolled); - - $secureEcom = $card->threeDSecure; - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); - - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - $md = MerchantDataCollection::parse($authResponse->getMerchantData()); - - $verified = $card->verifySignature($payerAuthenticationResponse, $md); - $this->assertFalse($verified); - $this->assertEquals('U', $card->threeDSecure->status); - $this->assertEquals(7, $card->threeDSecure->eci); - - $response = $card->charge(10) - ->withCurrency('USD') - ->execute(); - $this->assertNotNull($response); - $this->assertEquals('00', $response->responseCode); - } - - /** - * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException - */ - public function testCardHolderIsEnrolledACSInvalid() - { - $card = new CreditCardData(); - $card->number = 4012001037490006; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cardHolderName = 'John Smith'; - - $enrolled = $card->verifyEnrolled(10, 'USD'); - $this->assertTrue($enrolled); - - $secureEcom = $card->threeDSecure; - $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); - $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); - - $payerAuthenticationResponse = $authResponse->getAuthResponse(); - $md = MerchantDataCollection::parse($authResponse->getMerchantData()); - - $card->verifySignature($payerAuthenticationResponse, $md); - } -} +getConfig()); + } + + protected function getConfig() + { + $config = new GpEcomConfig(); + $config->merchantId = 'heartlandgpsandbox'; + $config->accountId = '3dsecure'; + $config->sharedSecret = 'secret'; + $config->rebatePassword = 'rebate'; + $config->refundPassword = 'refund'; + $config->serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi'; + return $config; + } + + public function testAcsClient() + { + $authClient = new ThreeDSecureAcsClient('https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MTNmMzI4NzgtNTdmZi00OWEzLWJhZTAtYzFhNzAxMDJkMGNi'); + $this->assertNotNull($authClient->authenticate('eJxlUsFSwjAQvfsVTO82TSm0MNs4FVBwRkUF8ZomK1Rpimkr6NebYBEdc8jsy27evrwNnO3ydesddZkVKnao6zktVKKQmVrGznx2cRo5Z+wEZiuNOHxAUWtkcI1lyZfYymTs+KIjZYRt30tl0H2WPRpFIuQyDULsdTvoMJgm9/jGoOnCTBPXB3KAhk2LFVcVAy7ezic3LAgD2ouANBBy1JMh6zULyDcGxXNkK+S6WnMll5vS7GmxA7JPgChqVekPFgUekAOAWq/Zqqo2ZZ+Q7Xbr/r/visKtX4HYSiBHcdPaRqVh3mWSJcM7Nb7t0O1iGs6n7cXnI025N7hSk1EMxFaA5BUy36MhpX7Y8r1+J+hTI39/Djy3kqwZRl4DYGN7JE3GJn4fgDFfm+EcnnRAgLtNodBUGFd/YiBHwYOx9VZUxrVxdjEb1aPXy5f5k27Tmzo/v75N4ti6vS+wbJlxikb0m84CIJaCNIMkzfxN9OdffAF4VML9')); + } + + public function testMerchantDataEnumerator() + { + $keys = ['Key1', 'Key2', 'Key3']; + $values = ['Value1', 'Value2', 'Value3']; + + $merchantData = new MerchantDataCollection(); + for ($i=0; $i<3; $i++) { + $merchantData->add($keys[$i], $values[$i]); + } + + $this->assertEquals(3, $merchantData->count()); + + foreach ($merchantData->getKeys() as $key) { + $this->assertTrue(in_array($key, $keys)); + $this->assertTrue(in_array($merchantData->get($key), $values)); + } + } + + public function testMerchantDataWithHiddenValues() + { + $card = new CreditCardData(); + $card->number = 4012001037141112; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'James Mason'; + + $enrolled = $card->verifyEnrolled(100, 'USD'); + $this->assertNotNull($enrolled); + if ($enrolled) { + $merchantData = $card->threeDSecure->getMerchantData(); + + $this->assertNotNull($merchantData); + $this->assertEquals(0, $merchantData->count()); + + $this->assertNull($merchantData->get('amount')); + $this->assertNull($merchantData->get('currency')); + $this->assertNull($merchantData->get('orderId')); + + for ($i=0; $i<3; $i++) { + $merchantData->add('Key'.$i, 'Value'.$i); + + $this->assertNotNull($merchantData->get('Key'.$i)); + $this->assertEquals('Value'.$i, $merchantData->get('Key'.$i)); + } + + $this->assertEquals(3, $merchantData->count()); + } + } + + public function testMerchantDataEncryptAndDecrypt() + { + $merchantData = new MerchantDataCollection(); + $merchantData->add('customerId', '12345'); + $merchantData->add('invoiceNumber', '54321'); + + $encoder = function ($input) { + $encoded = sprintf('%s.%s', $input, 'secret'); + return base64_encode($encoded); + }; + + $encrypted = $merchantData->toString($encoder); + + $decoder = function ($input) { + $decoded = explode('.', (string)base64_decode($input)); + $this->assertEquals('secret', $decoded[1]); + return $decoded[0]; + }; + + $decrypted = $merchantData->parse($encrypted, $decoder); + + $this->assertNotNull($decrypted); + $this->assertNotNull($decrypted->get('customerId')); + $this->assertEquals('12345', $decrypted->get('customerId')); + $this->assertNotNull($decrypted->get('invoiceNumber')); + $this->assertEquals('54321', $decrypted->get('invoiceNumber')); + } + + public function testMerchantDataMultiKey() + { + $this->expectExceptionMessage('Cannot access private property GlobalPayments\Api\Entities\MerchantDataCollection::$collection'); + + $mcd = new MerchantDataCollection(); + array_push($mcd->collection, array('amount'=>'10')); + array_push($mcd->collection, array('amount'=>'10')); + } + + public function testFullCycleWithMerchantData() + { + $card = new CreditCardData(); + $card->number = 4012001037141112; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(1, 'USD'); + if ($enrolled) { + $secureEcom = $card->threeDSecure; + if (!empty($secureEcom)) { + $merchantData = new MerchantDataCollection(); + $merchantData->add('client_txn_id', '123456'); + + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, (string)$secureEcom->getMerchantData()->toString()); + + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + $md = MerchantDataCollection::parse($authResponse->getMerchantData()); + + if ($card->verifySignature($payerAuthenticationResponse, $md)) { + $response = $card->charge(1) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } else { + $this->fail('Signature verification failed.'); + } + } else { + $this->fail('Secure3Data was null.'); + } + } else { + $this->fail('Card not enrolled.'); + } + } + + public function testFullCycleWithNoMerchantData() + { + $card = new CreditCardData(); + $card->number = 4012001037141112; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'James Mason'; + + $amount = 100; + $currency = 'USD'; + $orderId = GenerationUtils::generateOrderId(); + + $enrolled = $card->verifyEnrolled($amount, $currency, $orderId); + + if ($enrolled) { + $secureEcom = $card->threeDSecure; + + if ($secureEcom != null) { + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, (string)$secureEcom->getMerchantData()->toString()); + + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + + if ($card->verifySignature($payerAuthenticationResponse, null, $amount, $currency, $orderId)) { + $response = $card->charge($amount) + ->withCurrency($currency) + ->withOrderId($orderId) + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } else { + $this->fail('Signature verification failed.'); + } + } else { + $this->fail('Secure3Data was null.'); + } + } else { + $this->fail('Card not enrolled.'); + } + } + + public function testVerifyEnrolledTrue() + { + $card = new CreditCardData(); + $card->number = 4012001037141112; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(1, 'USD'); + $this->assertTrue($enrolled); + $this->assertNotNull($card->threeDSecure); + $this->assertNotNull($card->threeDSecure->payerAuthenticationRequest); + $this->assertNotNull($card->threeDSecure->issuerAcsUrl); + $this->assertNotNull($card->threeDSecure->xid); + } + + public function testVerifyEnrolledFalse() + { + $card = new CreditCardData(); + $card->number = 4012001038443335; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(1, 'USD'); + $this->assertFalse($enrolled); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + */ + public function testVerifySignatureBadOrderId() + { + $card = new CreditCardData(); + $card->verifySignature('eNrVWNmyozqy/ZWK6kfHOcwYOly7Q8yDwWYe3jBgRjPbYL7+4r1r16muWx3RfZ/68oKUSKlU5sqVQod/LLf6yyMdxqJtvn1F/oS/fvnH28HOhzTlrDS+D+nbQUvHMcrSL0Xy7SuNIjEMX1L8iiX4FUcudEQjURzhOEHHaHL9+nY4AzMd3wcTCEbS2Cb6vsDbpv9P9AB9djfNQ5xHzfR2iOKekfU3fI8jNHWAvncPt3SQuTf6+3OAPvoH6K+J5/urNW5mLkXyVvi9feR6zi2AGBCUZax3S3EeCI1T3w7Qa8Qhiab0DYWRPYKg1BcU/jtM/h3DD9C7/NC91IFbe990IzB8gH4WHDZ/DGkTP98ofPv0o3dIl65t0m3Etrkf7QP0l21d1LzBPz3Itvime5MebP/tMBW339r0Lj+MUzTdx7fgAH1vHeLo8XgDALAM5nAuq6OAk/mToTv8DF7Pttf3IYc0Lt5gYjNqe7/PAnXWDsWU316m/rPgAL1Mgd7D93awiqzZFhvSLxtCmvHb13yaur9D0DzPf87Yn+2QQei2EQimoW1AMhbZ375+zEoTubm2/9E0NmrapoijulijaUOGlk55m3z5Ydvv1NjmSxMCmTz7x6bqjxjBmz9eEhhDiE0n9HulP+3s31nlV2OHMfpjzCPktcAvit4OZnpNX4hIvzim/O3r337gnyuydJz+L+t9rvWzhk99blTf07e0Cz2ekj38LKW5mBLXiiFuoZWxN/7b57yPkQfoh4Hfrf8I1U8u+RgYUzvuaUx4FwaJURWc56HH/Yq5TX6sxTUIH7Kxm3TLLCiuVcwIo9nqtl8jNXLXCCmXR6CecFdoVjhC4P0ss+gsd6d67xE6QiD56kCcejLFztTiiAvNZfLHeL1h887PuAlrHBgMsnZf9YZfoTItL9UYe9J5ARby8CUM707lwz+x+lUzLCrHSh492mJNPOddfW8pUpq5py89JfPspIjDqTKDUiiAz3qwq0CU5UKVeyQU3KNmSHust3NjQcmezBAvOSV5ztJ9m1H3heSvdSYxDya+QNxMqTNrQS52c1RdURkVO6pPBdtrqrYwNuqT5nWOWX7p67lbMl1rply2U6rhNPQWdh3/OCdC9u3bT5D5HhE1fX5EwCdgmoum6KPFpsNUXDfsbpSkyTIX2iwLKjQDs8yATHbBSZIUbSr2QSqRbBeaZo3T64pHXJVpABZZqxct+YJxBs+wswM0MVu4FehMprsM0GymZhRXoDnD5l2N0USAODy7aJpbKZ4rumsi6Ejkm7VmwDM7B5xrGCo/m57l6oxmUDNnvMskfg750CPQ0JcX3gbnD/2ZzfL64yLSz8AzH5oxzuzHeJGfFddZQSrM8KKX/KyVYNFKftU4IXrJTtw/yzQJLMIK3O92a9yNeFxu7jVG6+ZS02XoK7BmOjP/YeORA4tn1KET+jrsYG6XiM7C2eD4Mb/VGCFUHJj/yRexxlRmfWnCOi55UwPUhy82RxsoPV4wJQ9FamFXoHyMD2xQu/YWE0YuXzqqPq8KkZ5hBhi8AMCJBQYFXt/ZTN3aPChKJ7Rv9KCfnfwsk6PchIR1U8M48i5zEp0LledpSOG5tbi7ir4Hec0jitt7GL460igVzY4wc1uYey7SfdW1S5k/L3dU4wpyycNsiloIRW6sGtmr7z5Hx9Af7NgB04GanE0umIPQqSxX4ERiWA0/aPKiaiEGY8I9FxktVagm0Mie6yCHw0zfjq3LxbaOKSaxK38DNGlCZ93jqskK9hBDOHkn7oQtMXYZlOPpNT6Fij4n4qmushGzm77B7cezjM+7ihNvqLg/kVe85x2a7vlHGISCrRot3YaKedX2I3dUC0bCgTyeI0BwxaTsl5AQ+diwMtO3XMqWYsNjS3a98hg4ZtE09VLoE4bMAQMwv8M6wLccMYDT+2ITZSu+gxf3dO010B4bFRodi5D7MyPkHMTR/R4ttIZrBm+cqGZ25ztSHsnlKktetpZ+kZQQEWiwaIrHliUSnofTEtu7nrwGbTBZZ4PjvAc7AEdr54WOWa9iNY0M66TH97tThmDoxh3skCgCz9Rk3lQMBJMeWyyqBS+RzUNkzN5dLC6eOtOi7JTRftNTUB92CUEw+ykOUpg44rf5stc78xgaa+pvEUSlNnpk5vV5PnYpSybdIg0R2en6rBaDDldX/o6wyLnMhqeHb4nBqWo3BpBYXMM6ijGrTNR85tNZvndnZfSMUJ661BokqlB8wgn5dKKQnWW70fRgm+xcuPpj5z32i3yAfmWn39EVL77oahY/6coExyCmt6DtJ2uxyULc8bfi5jovGlHUNpTzR6xvqXJkDDBvXjlqoHpPQybXWNfVfk5he0vhLkb55biC6UM22kr9Lsssj4A3SrgHvtldUCK/sIy99dHI02uZF9YYpcvIE+DIo++a2c4ieKcNjl8EL/L1XBbd8oIi0zanDC3GNOxPqgKEZldPjdNWnUteVPXU142mbH7WOQ1/yf67KHbzvyX/6l9m8y+XZfwZcNt3o2W3NgPUIQkhwylnnFurfSUQjR3uT0F/q5A9luGXR4abO1XCkXVa49m562eyHcZdOMYoZAlb4UO1qzYjp/mMboUvz+mWSpjc3SttyjtuTM+lDnsSye2mHkiXErai/pT3OUPdoTqqLXqRLt3jWUE8sYqlaJ/mdisAst9VKXW3SNS+E5KqMuLyyENIscH9mjCPI1bsHK2/Vrq9+AGvAjWBpYKUpOFxqup+5rcDzCh3+BoOXcBB5j3h8MGQxNm3DDiiGH0x1uet9cq2OI2aKwdqhjxqQw5nGh902m0uk9nCCTLUY9wBviX16pwwaCDeOE8O9/N8IUeB2xtCKyqJTflFxUjxxJHnMKWSBuumccM/D0B0Yh4cy9xtYL3iJpkaA64Uz3JABIYEgYwHmmS8sJHIwJw0cZwjIxBCnN/o7VXUQMlk2cBkvMAYMQvMwI8kE465dnNBgiVPAn3h9njbsGDRc4RW88kIZHUOtlg70pZ789EGgZALVugzY/DKA8FsI1/LNgziCQe4zQZG/NffT+92G9S73RuuN9wEs/TCmgmfGCbgBa3N0gqUocDEcgae1dWyIGXbqsIM/5qe2WHkCoDGO2+4IfaOtwlYT0Qa5baiUVQqUoxrz86GhAfpg0jKGXaZx55mE+s5DZqT5VAMp1CwIreOQ9aTrJ/Twm0Jq6kRpnzeK80g+RatfRPLhI0s2fUcjK2Otv5kzWJMFRpwpko25QwJUeqIybfWlfbxObYLz8yHgQLtXXa286SQdeOz3ThRkjpYs28rzt99Uh/ZbvcEnKIE2DASLCjtZ60FhokpIwm4wd5nz9MsXdHpURzVZkJYS5KeO4IlnzgVnfir0t72NjhleF3WVWUKJ5XzHCeuEYWppCldnGML+SHiyrhvHlMVjdUwInN/7ypLpTPwkXEG6ITjxf6xE0MvszWxo9SSX/5NehbKLf0f5Cc9G+l0Ryxt6RpeB01zWpHz7jzZv55uHAFwTPe/qYbXNTB+0Fuu8e6tXgObf2gs/El5t3eZxSiXxqzjG5EnYr2d4oRRFvQ6bsIuQJ3M8PX1gurdB3Xji1iC4JNKefeD3kNvg7mHbDpeMBUYjcF9zn6dFPntxAhWbY3hk9tuMu1X2X9ZWfkP6FmvnGut3rqGQKdAxsKJ0c/eOcBHXFUaSHK9WOB2lltEJ4fxckpMn8n9okMtO4vyVF3V5WEVnGnerCvryArTw17NG9g9BscLxOzk02DORlaMPXbRYTk8ghheJbl7ev79FrXVuB8j88GNEToPlxXiJ6SvNLiEWgl6nIat7KkSrdBEX7E9vpWNkY+fRKPOV67qBPTaVuEEO6oqTIsrxRZ/tnhk1XVkQ/Fi6d3+0fnP5XG0Rhbyk4ES9zaboRfkufieUA5nGLlvMOUbRbWbUMZZ1EnzeSk3NmWv1mhDQHwsXH71zsPAT4C02Zijh1NHc93s64WliOe1ih3Hu0rbb4Cf0WmQFTbf0ige/6Dnu80yU/lRVj/pmbE3Wtzo+f89NTMLJT2jxABejTP3113Rsv0lCnolr79S82bTJzWniIjm5xGAndnqLRy7DbKz05iygsRggLDv2eZIC2ke3fF9ipFXV9SL9VQ9ZZsGktgOpIkc5ShX/R1P3nrDDsa1USwi9xVKpGL4DN+W0rXiy/5ZzQYxM0Hvexp68dWuONpp4HpXBAyC13fIkxZJEwanqDmWt1k3GTBkzwdZI0Z42Tsaxlxpi6jh+yBoR3gDCsXs6bpOCR9D5QddXu/xnYwjeWCO1dlayKDf9VvxHXFKN62TvoPO/Y2WlhmRMOi5ov1RxFdb3i+Ky/FWKPJ+lBxnVvE58mSmPipAzOQkVI9iSemHFzco5CtPp5cBzzCEQJnaZaUQFZ/npMzl+zGVUMS92FDy5CUJ/Iaaob/++aEf9wB/3RC833K+X7y+buZ+vpD9HwzDHH8=', null, 1, 'USD', 'orderId'); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testVerifySignatureNoPaymentResponse() + { + $card = new CreditCardData(); + $card->verifySignature(null); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testVerifySignatureNoAmount() + { + $card = new CreditCardData(); + $card->verifySignature('paymentResponse', null, null, 'USD', 'orderId'); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testVerifySignatureNoCurrency() + { + $card = new CreditCardData(); + $card->verifySignature('paymentResponse', null, 10, null, 'orderId'); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\BuilderException + */ + public function testVerifySignatureNoOrderId() + { + $card = new CreditCardData(); + $card->verifySignature('paymentResponse', null, 10, 'USD', null); + } + + public function testAuthorize3dSecure() + { + $secureEcom = new ThreeDSecure(); + $secureEcom->cavv = 'AAACBllleHchZTBWIGV4AAAAAAA='; + $secureEcom->xid = 'crqAeMwkEL9r4POdxpByWJ1/wYg='; + $secureEcom->eci = '5'; + + $card = new CreditCardData(); + $card->number = 4012001037141112; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'Philip Marlowe'; + $card->threeDSecure = $secureEcom; + + $response = $card->charge(10) + ->withCurrency('EUR') + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCardHolderNotEnrolled() + { + $card = new CreditCardData(); + $card->number = 4012001038443335; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertFalse($enrolled); + $this->assertNotNull($card->threeDSecure); + $this->assertEquals('6', $card->threeDSecure->eci); + + // .net test does not have amount or currency but validation would not allow this + $response = $card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testUnableToVerifyEnrollment() + { + $card = new CreditCardData(); + $card->number = 4012001038488884; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertFalse($enrolled); + $this->assertNotNull($card->threeDSecure); + $this->assertEquals('7', $card->threeDSecure->eci); + + $response = $card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + */ + public function testInvalidResponseFromEnrollmentServer() + { + $card = new CreditCardData(); + $card->number = 4012001036298889; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $card->verifyEnrolled(10, 'USD'); + } + + public function testCardHolderIsEnrolledACSAuthFailed() + { + $card = new CreditCardData(); + $card->number = 4012001036853337; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertTrue($enrolled); + + $secureEcom = $card->threeDSecure; + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); + + // $payerAuthenticationResponse = $authResponse->parse(); + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + $md = MerchantDataCollection::parse($authResponse->getMerchantData()); + + $verified = $card->verifySignature($payerAuthenticationResponse, $md); + $this->assertFalse($verified); + $this->assertNotNull($card->threeDSecure); + $this->assertEquals(7, $card->threeDSecure->eci); + + $response = $card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCardHolderIsEnrolledACSAcknowledged() + { + $card = new CreditCardData(); + $card->number = 4012001037167778; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertTrue($enrolled); + + $secureEcom = $card->threeDSecure; + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); + + // $payerAuthenticationResponse = $authResponse->parse(); + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + $md = MerchantDataCollection::parse($authResponse->getMerchantData()); + + $verified = $card->verifySignature($payerAuthenticationResponse, $md); + $this->assertTrue($verified); + $this->assertEquals('A', $card->threeDSecure->status); + + $response = $card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCardHolderIsEnrolledACSFailed() + { + $card = new CreditCardData(); + $card->number = 4012001037461114; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertTrue($enrolled); + + $secureEcom = $card->threeDSecure; + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); + + // $payerAuthenticationResponse = $authResponse->parse(); + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + $md = MerchantDataCollection::parse($authResponse->getMerchantData()); + + $verified = $card->verifySignature($payerAuthenticationResponse, $md); + $this->assertFalse($verified); + $this->assertEquals('N', $card->threeDSecure->status); + $this->assertEquals(7, $card->threeDSecure->eci); + + $response = $card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testCardHolderIsEnrolledACSUnavailable() + { + $card = new CreditCardData(); + $card->number = 4012001037484447; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertTrue($enrolled); + + $secureEcom = $card->threeDSecure; + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); + + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + $md = MerchantDataCollection::parse($authResponse->getMerchantData()); + + $verified = $card->verifySignature($payerAuthenticationResponse, $md); + $this->assertFalse($verified); + $this->assertEquals('U', $card->threeDSecure->status); + $this->assertEquals(7, $card->threeDSecure->eci); + + $response = $card->charge(10) + ->withCurrency('USD') + ->execute(); + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + /** + * @expectedException GlobalPayments\Api\Entities\Exceptions\GatewayException + */ + public function testCardHolderIsEnrolledACSInvalid() + { + $card = new CreditCardData(); + $card->number = 4012001037490006; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cardHolderName = 'John Smith'; + + $enrolled = $card->verifyEnrolled(10, 'USD'); + $this->assertTrue($enrolled); + + $secureEcom = $card->threeDSecure; + $authClient = new ThreeDSecureAcsClient($secureEcom->issuerAcsUrl); + $authResponse = $authClient->authenticate($secureEcom->payerAuthenticationRequest, $secureEcom->getMerchantData()->toString()); + + $payerAuthenticationResponse = $authResponse->getAuthResponse(); + $md = MerchantDataCollection::parse($authResponse->getMerchantData()); + + $card->verifySignature($payerAuthenticationResponse, $md); + } +} diff --git a/test/Integration/Gateways/RealexConnector/RealexApmTest.php b/test/Integration/Gateways/RealexConnector/RealexApmTest.php index a0eddd4f..e52db0c5 100644 --- a/test/Integration/Gateways/RealexConnector/RealexApmTest.php +++ b/test/Integration/Gateways/RealexConnector/RealexApmTest.php @@ -1,194 +1,191 @@ -merchantId = "heartlandgpsandbox"; - $config->accountId = "hpp"; - $config->rebatePassword = 'refund'; - $config->refundPassword = 'refund'; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - return $config; - } - - public function setup() - { - ServicesContainer::configure($this->config()); - } - - public function testApmForCharge() - { - $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); - - $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; - $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; - $paymentMethod->descriptor = 'Test Transaction'; - $paymentMethod->country = 'DE'; - $paymentMethod->accountHolderName = 'James Mason'; - - $response = $paymentMethod->charge(10) - ->withCurrency("EUR") - ->withDescription('New APM') - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - // get the reponse details to save to the DB for future transaction management requests - $orderId = $response->orderId; - $authCode = $response->authorizationCode; - $paymentsReference = $response->transactionId; // pasref - $apmResponse = $response->alternativePaymentResponse; - - $this->assertNotNull($response); - $this->assertEquals("01", $response->responseCode); - $this->assertNotNull($response->alternativePaymentResponse); - } - - /** - * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage amount cannot be null for this transaction type - */ - public function testApmWithoutAmount() - { - $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); - - $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; - $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; - $paymentMethod->descriptor = 'Test Transaction'; - $paymentMethod->country = 'DE'; - $paymentMethod->accountHolderName = 'James Mason'; - - $response = $paymentMethod->charge() - ->withCurrency("EUR") - ->withDescription('New APM') - ->execute(); - } - - /** - * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage currency cannot be null for this transaction type - */ - public function testApmWithoutCurrency() - { - $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); - - $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; - $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; - $paymentMethod->descriptor = 'Test Transaction'; - $paymentMethod->country = 'DE'; - $paymentMethod->accountHolderName = 'James Mason'; - - $response = $paymentMethod->charge(10) - ->withDescription('New APM') - ->execute(); - } - - /** - * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage returnUrl cannot be null for this transaction type - */ - public function testApmWithoutReturnUrl() - { - $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); - - $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; - $paymentMethod->descriptor = 'Test Transaction'; - $paymentMethod->country = 'DE'; - $paymentMethod->accountHolderName = 'James Mason'; - - $response = $paymentMethod->charge(1001) - ->withCurrency("EUR") - ->withDescription('New APM') - ->execute(); - } - - /** - * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException - * @expectedExceptionMessage statusUpdateUrl cannot be null for this transaction type - */ - public function testApmWithoutstatusUpdateUrl() - { - $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); - - $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; - $paymentMethod->descriptor = 'Test Transaction'; - $paymentMethod->country = 'DE'; - $paymentMethod->accountHolderName = 'James Mason'; - - $response = $paymentMethod->charge(1001) - ->withCurrency("EUR") - ->withDescription('New APM') - ->execute(); - } - - /** - * @expectedException \GlobalPayments\Api\Entities\Exceptions\GatewayException - * @expectedExceptionMessage FAILED - */ - public function testAPMRefundPendingTransaction() - { - $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::TEST_PAY); - - $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; - $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; - $paymentMethod->descriptor = 'Test Transaction'; - $paymentMethod->country = 'DE'; - $paymentMethod->accountHolderName = 'James Mason'; - - $response = $paymentMethod->charge(10) - ->withCurrency("EUR") - ->withDescription('New APM') - ->execute(); - - $this->assertNotEquals(null, $response); - $this->assertEquals("01", $response->responseCode); - - // send the settle request, we must specify the amount and currency - $response = $response->refund(10) - ->withCurrency("EUR") - ->withAlternativePaymentType(AlternativePaymentType::TEST_PAY) - ->execute(); - } - - public function testApmForRefund() - { - // a settle request requires the original order id - $orderId = "20180912050207-5b989dcfc9433"; - // and the payments reference (pasref) from the authorization response - $paymentsReference = "15367285279651634"; - // and the auth code transaction response - $authCode = "12345"; - - // create the rebate transaction object - $transaction = Transaction::fromId($paymentsReference, $orderId); - $transaction->authorizationCode = $authCode; - - // send the settle request, we must specify the amount and currency - $response = $transaction->refund(10) - ->withCurrency("EUR") - ->withAlternativePaymentType(AlternativePaymentType::TEST_PAY) - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - - $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); - } -} +merchantId = "heartlandgpsandbox"; + $config->accountId = "hpp"; + $config->rebatePassword = 'refund'; + $config->refundPassword = 'refund'; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + return $config; + } + + public function setup() + { + ServicesContainer::configureService($this->config()); + } + + public function testApmForCharge() + { + $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); + + $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; + $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; + $paymentMethod->descriptor = 'Test Transaction'; + $paymentMethod->country = 'DE'; + $paymentMethod->accountHolderName = 'James Mason'; + + $response = $paymentMethod->charge(10) + ->withCurrency("EUR") + ->withDescription('New APM') + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + // get the reponse details to save to the DB for future transaction management requests + $orderId = $response->orderId; + $authCode = $response->authorizationCode; + $paymentsReference = $response->transactionId; // pasref + $apmResponse = $response->alternativePaymentResponse; + + $this->assertNotNull($response); + $this->assertEquals("01", $response->responseCode); + $this->assertNotNull($response->alternativePaymentResponse); + } + + /** + * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage amount cannot be null for this transaction type + */ + public function testApmWithoutAmount() + { + $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); + + $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; + $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; + $paymentMethod->descriptor = 'Test Transaction'; + $paymentMethod->country = 'DE'; + $paymentMethod->accountHolderName = 'James Mason'; + + $response = $paymentMethod->charge() + ->withCurrency("EUR") + ->withDescription('New APM') + ->execute(); + } + + /** + * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage currency cannot be null for this transaction type + */ + public function testApmWithoutCurrency() + { + $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); + + $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; + $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; + $paymentMethod->descriptor = 'Test Transaction'; + $paymentMethod->country = 'DE'; + $paymentMethod->accountHolderName = 'James Mason'; + + $response = $paymentMethod->charge(10) + ->withDescription('New APM') + ->execute(); + } + + /** + * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage returnUrl cannot be null for this transaction type + */ + public function testApmWithoutReturnUrl() + { + $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); + + $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; + $paymentMethod->descriptor = 'Test Transaction'; + $paymentMethod->country = 'DE'; + $paymentMethod->accountHolderName = 'James Mason'; + + $response = $paymentMethod->charge(1001) + ->withCurrency("EUR") + ->withDescription('New APM') + ->execute(); + } + + /** + * @expectedException \GlobalPayments\Api\Entities\Exceptions\BuilderException + * @expectedExceptionMessage statusUpdateUrl cannot be null for this transaction type + */ + public function testApmWithoutstatusUpdateUrl() + { + $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::SOFORTUBERWEISUNG); + + $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; + $paymentMethod->descriptor = 'Test Transaction'; + $paymentMethod->country = 'DE'; + $paymentMethod->accountHolderName = 'James Mason'; + + $response = $paymentMethod->charge(1001) + ->withCurrency("EUR") + ->withDescription('New APM') + ->execute(); + } + + /** + * @expectedException \GlobalPayments\Api\Entities\Exceptions\GatewayException + * @expectedExceptionMessage FAILED + */ + public function testAPMRefundPendingTransaction() + { + $paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::TEST_PAY); + + $paymentMethod->returnUrl = 'https://www.example.com/returnUrl'; + $paymentMethod->statusUpdateUrl = 'https://www.example.com/statusUrl'; + $paymentMethod->descriptor = 'Test Transaction'; + $paymentMethod->country = 'DE'; + $paymentMethod->accountHolderName = 'James Mason'; + + $response = $paymentMethod->charge(10) + ->withCurrency("EUR") + ->withDescription('New APM') + ->execute(); + + $this->assertNotEquals(null, $response); + $this->assertEquals("01", $response->responseCode); + + // send the settle request, we must specify the amount and currency + $response = $response->refund(10) + ->withCurrency("EUR") + ->withAlternativePaymentType(AlternativePaymentType::TEST_PAY) + ->execute(); + } + + public function testApmForRefund() + { + // a settle request requires the original order id + $orderId = "20180912050207-5b989dcfc9433"; + // and the payments reference (pasref) from the authorization response + $paymentsReference = "15367285279651634"; + // and the auth code transaction response + $authCode = "12345"; + + // create the rebate transaction object + $transaction = Transaction::fromId($paymentsReference, $orderId); + $transaction->authorizationCode = $authCode; + + // send the settle request, we must specify the amount and currency + $response = $transaction->refund(10) + ->withCurrency("EUR") + ->withAlternativePaymentType(AlternativePaymentType::TEST_PAY) + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + + $this->assertNotEquals(null, $response); + $this->assertEquals("00", $responseCode); + } +} diff --git a/test/Integration/Gateways/RealexConnector/RecurringTest.php b/test/Integration/Gateways/RealexConnector/RecurringTest.php index 83e573c3..f7b6c914 100644 --- a/test/Integration/Gateways/RealexConnector/RecurringTest.php +++ b/test/Integration/Gateways/RealexConnector/RecurringTest.php @@ -1,391 +1,391 @@ -format("Ymd")); - } - - public function getPaymentId($type) - { - return sprintf("%s-Realex-%s", (new \DateTime())->format("Ymd"), $type); - } - - protected function config() - { - $config = new ServicesConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "3dsecure"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - return $config; - } - - protected function dccSetup() - { - $config = new ServicesConfig(); - $config->merchantId = "heartlandgpsandbox"; - $config->accountId = "apidcc"; - $config->refundPassword = "refund"; - $config->sharedSecret = "secret"; - $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; - - ServicesContainer::configure($config); - } - - public function setup() - { - ServicesContainer::configure($this->config()); - - $this->newCustomer = new Customer(); - $this->newCustomer->key = $this->getCustomerId(); - $this->newCustomer->title = "Mr."; - $this->newCustomer->firstName = "James"; - $this->newCustomer->lastName = "Mason"; - $this->newCustomer->company = "Realex Payments"; - $this->newCustomer->address = new Address(); - $this->newCustomer->address->streetAddress1 = "Flat 123"; - $this->newCustomer->address->streetAddress2 = "House 456"; - $this->newCustomer->address->streetAddress3 = "The Cul-De-Sac"; - $this->newCustomer->address->city = "Halifax"; - $this->newCustomer->address->province = "West Yorkshire"; - $this->newCustomer->address->pstalCode = "W6 9HR"; - $this->newCustomer->address->country = "United Kingdom"; - $this->newCustomer->homePhone = "+35312345678"; - $this->newCustomer->workPhone = "+3531987654321"; - $this->newCustomer->fax = "+124546871258"; - $this->newCustomer->mobilePhone = "+25544778544"; - $this->newCustomer->email = "text@example.com"; - $this->newCustomer->comments = "Campaign Ref E7373G"; - } - - /* 08. Card Storage Create Payer */ - /* Request Type: payer-new */ - - public function testcardStorageCreatePayer() - { - try { - $response = $this->newCustomer->Create(); - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } catch (GatewayException $exc) { - if ($exc->responseCode != '501' && $exc->responseCode != '520') { - throw $exc; - } - } - } - - /* 09. Card Storage Store Card */ - /* Request Type: card-new */ - - public function testcardStorageStoreCard() - { - $card = new CreditCardData(); - $card->number = "4012001037141112"; - $card->expMonth = 10; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '123'; - $card->cardHolderName = 'James Mason'; - - try { - $paymentMethod = $this->newCustomer - ->addPaymentMethod($this->getPaymentId("Credit"), $card) - ->create(); - $this->assertNotNull($paymentMethod); - } catch (GatewayException $exc) { - if ($exc->responseCode != '501' && $exc->responseCode != '520') { - throw $exc; - } - } - } - - /* 10. Card Storage Charge Card */ - /* Request Type: receipt-in */ - - public function testcardStorageChargeCard() - { - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - $response = $paymentMethod->charge(10) - ->withCurrency("EUR") - ->withCvn("123") - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - // get the reponse details to save to the DB for future transaction management requests - $orderId = $response->orderId; - $authCode = $response->authorizationCode; - $paymentsReference = $response->transactionId; // pasref - - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } - - /* 11. CardStorage ThreeDSecure Verify Enrolled */ - /* Request Type: realvault-3ds-verifyenrolled */ - - public function testcardStorageThreeDSecureVerifyEnrolled() - { - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - $response = $paymentMethod->verify() - ->withAmount(10) - ->withCurrency('USD') - ->withModifier(TransactionModifier::SECURE3D) - ->execute(); - - // get the response details to update the DB - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } - - /* 12. CardStorage Dcc Rate Lookup */ - /* Request Type: realvault-dccrate */ - - public function testcardStorageDccRateLookup() - { - $this->dccSetup(); - - $orderId = GenerationUtils::generateOrderId(); - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - $dccDetails = $paymentMethod->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); - - $this->assertNotNull($dccDetails); - $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); - $this->assertNotNull($dccDetails->dccResponseResult); - } - - /* 14. CardStorage UpdatePayer */ - /* Request Type: payer-edit */ - - public function testcardStorageUpdatePayer() - { - $customer = new Customer(); - $customer->key = $this->getCustomerId(); - $customer->firstName = "Perry"; - - $response = $customer->saveChanges(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } - - /* 15. CardStorage Continuous Authority First */ - /* Request Type: auth */ - - public function testContinuousAuthorityFirst() - { - // create the card object - $card = new CreditCardData(); - $card->number = '5425230000004415'; - $card->expMonth = 12; - $card->expYear = TestCards::validCardExpYear(); - $card->cvn = '131'; - $card->cardHolderName = 'James Mason'; - - - // process an auto-settle authorization - $response = $card->charge(15) - ->withCurrency("EUR") - ->withRecurringInfo(RecurringType::VARIABLE, RecurringSequence::FIRST) - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - // get the details to save to the DB for future Transaction Management requests - $orderId = $response->orderId; - $authCode = $response->authorizationCode; - $paymentsReference = $response->transactionId; - - $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); - } - - /* 15. CardStorage Continuous Authority Subsequent */ - /* Request Type: receipt-in */ - - public function testContinuousAuthoritySubsequent() - { - // create the payment method object - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - // charge the stored card/payment method - $response = $paymentMethod->charge(15) - ->withCurrency("EUR") - ->withCvn("123") - ->withRecurringInfo(RecurringType::VARIABLE, RecurringSequence::SUBSEQUENT) - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - - $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); - } - - /* 15. CardStorage Continuous Authority Last */ - /* Request Type: receipt-in */ - - public function testContinuousAuthorityLast() - { - // create the payment method object - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - // charge the stored card/payment method - $response = $paymentMethod->charge(15) - ->withCurrency("EUR") - ->withCvn("123") - ->withRecurringInfo(RecurringType::VARIABLE, RecurringSequence::LAST) - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - - $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); - } - - /* 16. Card Storage Refund */ - /* Request Type: payment-out */ - - public function testcardStorageRefund() - { - // create the payment method object - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - // charge the stored card/payment method - $response = $paymentMethod->refund(10) - ->withCurrency("EUR") - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - - $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); - } - - /* 17. Card Storage UpdateCard */ - /* Request Type: card-update-card */ - - public function testcardStorageUpdateCard() - { - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - $paymentMethod->paymentMethod = new CreditCardData(); - $paymentMethod->paymentMethod->number = "5425230000004415"; - $paymentMethod->paymentMethod->expMonth = 10; - $paymentMethod->paymentMethod->expYear = TestCards::validCardExpYear(); - $paymentMethod->paymentMethod->cardHolderName = "Philip Marlowe"; - - $response = $paymentMethod->SaveChanges(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } - - /* 18. Card Storage Verify Card */ - /* Request Type: receipt-in-otb */ - - public function testcardStorageVerifyCard() - { - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - // verify the stored card/payment method is valid and active - $response = $paymentMethod->verify() - ->withCvn("123") - ->execute(); - - // get the response details to update the DB - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - - $this->assertNotEquals(null, $response); - $this->assertEquals("00", $responseCode); - } - - /* 13. CardStorage DeleteCard */ - /* Request Type: card-cancel-card */ - - public function testcardStorageDeleteCard() - { - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - // delete the stored card/payment method - // WARNING! This can't be undone - $response = $paymentMethod->Delete(); - - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } - - /* Request Type: receipt-in */ - - public function testcardStorageChargeCardDCC() - { - $this->dccSetup(); - $this->testcardStorageCreatePayer(); - $this->testcardStorageStoreCard(); - - $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); - - $orderId = GenerationUtils::generateOrderId(); - $dccDetails = $paymentMethod->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); - - $this->assertNotNull($dccDetails); - $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); - $this->assertNotNull($dccDetails->dccResponseResult); - - $dccValues = new DccRateData(); - $dccValues->orderId = $dccDetails->transactionReference->orderId; - $dccValues->dccProcessor = DccProcessor::FEXCO; - $dccValues->dccType = 1; - $dccValues->dccRateType = DccRateType::SALE; - $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; - $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; - $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; - - $response = $paymentMethod->charge(1001) - ->withCurrency("EUR") - ->withCvn("123") - ->withDccRateData($dccValues) - ->withOrderId($orderId) - ->execute(); - - $responseCode = $response->responseCode; // 00 == Success - $message = $response->responseMessage; // [ test system ] AUTHORISED - // get the reponse details to save to the DB for future transaction management requests - $orderId = $response->orderId; - $authCode = $response->authorizationCode; - $paymentsReference = $response->transactionId; // pasref - - $this->assertNotNull($response); - $this->assertEquals("00", $response->responseCode); - } -} +format("Ymd")); + } + + public function getPaymentId($type) + { + return sprintf("%s-Realex-%s", (new \DateTime())->format("Ymd"), $type); + } + + protected function config() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "3dsecure"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + return $config; + } + + protected function dccSetup() + { + $config = new GpEcomConfig(); + $config->merchantId = "heartlandgpsandbox"; + $config->accountId = "apidcc"; + $config->refundPassword = "refund"; + $config->sharedSecret = "secret"; + $config->serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"; + + ServicesContainer::configureService($config); + } + + public function setup() + { + ServicesContainer::configureService($this->config()); + + $this->newCustomer = new Customer(); + $this->newCustomer->key = $this->getCustomerId(); + $this->newCustomer->title = "Mr."; + $this->newCustomer->firstName = "James"; + $this->newCustomer->lastName = "Mason"; + $this->newCustomer->company = "Realex Payments"; + $this->newCustomer->address = new Address(); + $this->newCustomer->address->streetAddress1 = "Flat 123"; + $this->newCustomer->address->streetAddress2 = "House 456"; + $this->newCustomer->address->streetAddress3 = "The Cul-De-Sac"; + $this->newCustomer->address->city = "Halifax"; + $this->newCustomer->address->province = "West Yorkshire"; + $this->newCustomer->address->pstalCode = "W6 9HR"; + $this->newCustomer->address->country = "United Kingdom"; + $this->newCustomer->homePhone = "+35312345678"; + $this->newCustomer->workPhone = "+3531987654321"; + $this->newCustomer->fax = "+124546871258"; + $this->newCustomer->mobilePhone = "+25544778544"; + $this->newCustomer->email = "text@example.com"; + $this->newCustomer->comments = "Campaign Ref E7373G"; + } + + /* 08. Card Storage Create Payer */ + /* Request Type: payer-new */ + + public function testcardStorageCreatePayer() + { + try { + $response = $this->newCustomer->Create(); + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } catch (GatewayException $exc) { + if ($exc->responseCode != '501' && $exc->responseCode != '520') { + throw $exc; + } + } + } + + /* 09. Card Storage Store Card */ + /* Request Type: card-new */ + + public function testcardStorageStoreCard() + { + $card = new CreditCardData(); + $card->number = "4012001037141112"; + $card->expMonth = 10; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '123'; + $card->cardHolderName = 'James Mason'; + + try { + $paymentMethod = $this->newCustomer + ->addPaymentMethod($this->getPaymentId("Credit"), $card) + ->create(); + $this->assertNotNull($paymentMethod); + } catch (GatewayException $exc) { + if ($exc->responseCode != '501' && $exc->responseCode != '520') { + throw $exc; + } + } + } + + /* 10. Card Storage Charge Card */ + /* Request Type: receipt-in */ + + public function testcardStorageChargeCard() + { + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + $response = $paymentMethod->charge(10) + ->withCurrency("EUR") + ->withCvn("123") + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + // get the reponse details to save to the DB for future transaction management requests + $orderId = $response->orderId; + $authCode = $response->authorizationCode; + $paymentsReference = $response->transactionId; // pasref + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + /* 11. CardStorage ThreeDSecure Verify Enrolled */ + /* Request Type: realvault-3ds-verifyenrolled */ + + public function testcardStorageThreeDSecureVerifyEnrolled() + { + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + $response = $paymentMethod->verify() + ->withAmount(10) + ->withCurrency('USD') + ->withModifier(TransactionModifier::SECURE3D) + ->execute(); + + // get the response details to update the DB + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + /* 12. CardStorage Dcc Rate Lookup */ + /* Request Type: realvault-dccrate */ + + public function testcardStorageDccRateLookup() + { + $this->dccSetup(); + + $orderId = GenerationUtils::generateOrderId(); + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + $dccDetails = $paymentMethod->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); + + $this->assertNotNull($dccDetails); + $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); + $this->assertNotNull($dccDetails->dccResponseResult); + } + + /* 14. CardStorage UpdatePayer */ + /* Request Type: payer-edit */ + + public function testcardStorageUpdatePayer() + { + $customer = new Customer(); + $customer->key = $this->getCustomerId(); + $customer->firstName = "Perry"; + + $response = $customer->saveChanges(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + /* 15. CardStorage Continuous Authority First */ + /* Request Type: auth */ + + public function testContinuousAuthorityFirst() + { + // create the card object + $card = new CreditCardData(); + $card->number = '5425230000004415'; + $card->expMonth = 12; + $card->expYear = TestCards::validCardExpYear(); + $card->cvn = '131'; + $card->cardHolderName = 'James Mason'; + + + // process an auto-settle authorization + $response = $card->charge(15) + ->withCurrency("EUR") + ->withRecurringInfo(RecurringType::VARIABLE, RecurringSequence::FIRST) + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + // get the details to save to the DB for future Transaction Management requests + $orderId = $response->orderId; + $authCode = $response->authorizationCode; + $paymentsReference = $response->transactionId; + + $this->assertNotEquals(null, $response); + $this->assertEquals("00", $responseCode); + } + + /* 15. CardStorage Continuous Authority Subsequent */ + /* Request Type: receipt-in */ + + public function testContinuousAuthoritySubsequent() + { + // create the payment method object + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + // charge the stored card/payment method + $response = $paymentMethod->charge(15) + ->withCurrency("EUR") + ->withCvn("123") + ->withRecurringInfo(RecurringType::VARIABLE, RecurringSequence::SUBSEQUENT) + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + + $this->assertNotEquals(null, $response); + $this->assertEquals("00", $responseCode); + } + + /* 15. CardStorage Continuous Authority Last */ + /* Request Type: receipt-in */ + + public function testContinuousAuthorityLast() + { + // create the payment method object + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + // charge the stored card/payment method + $response = $paymentMethod->charge(15) + ->withCurrency("EUR") + ->withCvn("123") + ->withRecurringInfo(RecurringType::VARIABLE, RecurringSequence::LAST) + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + + $this->assertNotEquals(null, $response); + $this->assertEquals("00", $responseCode); + } + + /* 16. Card Storage Refund */ + /* Request Type: payment-out */ + + public function testcardStorageRefund() + { + // create the payment method object + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + // charge the stored card/payment method + $response = $paymentMethod->refund(10) + ->withCurrency("EUR") + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + + $this->assertNotEquals(null, $response); + $this->assertEquals("00", $responseCode); + } + + /* 17. Card Storage UpdateCard */ + /* Request Type: card-update-card */ + + public function testcardStorageUpdateCard() + { + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + $paymentMethod->paymentMethod = new CreditCardData(); + $paymentMethod->paymentMethod->number = "5425230000004415"; + $paymentMethod->paymentMethod->expMonth = 10; + $paymentMethod->paymentMethod->expYear = TestCards::validCardExpYear(); + $paymentMethod->paymentMethod->cardHolderName = "Philip Marlowe"; + + $response = $paymentMethod->SaveChanges(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + /* 18. Card Storage Verify Card */ + /* Request Type: receipt-in-otb */ + + public function testcardStorageVerifyCard() + { + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + // verify the stored card/payment method is valid and active + $response = $paymentMethod->verify() + ->withCvn("123") + ->execute(); + + // get the response details to update the DB + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + + $this->assertNotEquals(null, $response); + $this->assertEquals("00", $responseCode); + } + + /* 13. CardStorage DeleteCard */ + /* Request Type: card-cancel-card */ + + public function testcardStorageDeleteCard() + { + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + // delete the stored card/payment method + // WARNING! This can't be undone + $response = $paymentMethod->Delete(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + /* Request Type: receipt-in */ + + public function testcardStorageChargeCardDCC() + { + $this->dccSetup(); + $this->testcardStorageCreatePayer(); + $this->testcardStorageStoreCard(); + + $paymentMethod = new RecurringPaymentMethod($this->getCustomerId(), $this->getPaymentId("Credit")); + + $orderId = GenerationUtils::generateOrderId(); + $dccDetails = $paymentMethod->getDccRate(DccRateType::SALE, 1001, 'EUR', DccProcessor::FEXCO, $orderId); + + $this->assertNotNull($dccDetails); + $this->assertEquals('00', $dccDetails->responseCode, $dccDetails->responseMessage); + $this->assertNotNull($dccDetails->dccResponseResult); + + $dccValues = new DccRateData(); + $dccValues->orderId = $dccDetails->transactionReference->orderId; + $dccValues->dccProcessor = DccProcessor::FEXCO; + $dccValues->dccType = 1; + $dccValues->dccRateType = DccRateType::SALE; + $dccValues->currency = $dccDetails->dccResponseResult->cardHolderCurrency; + $dccValues->dccRate = $dccDetails->dccResponseResult->cardHolderRate; + $dccValues->amount = $dccDetails->dccResponseResult->cardHolderAmount; + + $response = $paymentMethod->charge(1001) + ->withCurrency("EUR") + ->withCvn("123") + ->withDccRateData($dccValues) + ->withOrderId($orderId) + ->execute(); + + $responseCode = $response->responseCode; // 00 == Success + $message = $response->responseMessage; // [ test system ] AUTHORISED + // get the reponse details to save to the DB for future transaction management requests + $orderId = $response->orderId; + $authCode = $response->authorizationCode; + $paymentsReference = $response->transactionId; // pasref + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } +} diff --git a/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php b/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php index 14f3ca79..c9da22ee 100644 --- a/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php +++ b/test/Integration/Gateways/TransITConnector/Certification/Ecommerce_3.php @@ -1,784 +1,786 @@ -getConfig()); - } - - protected function getConfig() { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'Hrcb^619'; - $config->deviceId = '88700000322601'; - $config->transactionKey = '57ZL83P6A2V8KGI49QWK017C7WXG03O8'; - $config->developerId = '003226G001'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - $config->acceptorConfig = new AcceptorConfig(); // might need to adjust this per transaction or per file - return $config; - } - - public static $test20VoidTarget; - public static $test21VoidTarget; - public static $test30MUT; - public static $test31MUT; - - // These are all stolen from dotnet cert file - public function test01VisaLevelII() { - $commercialData = new CommercialData(TaxType::NOT_USED); - $commercialData->poNumber = '9876543210'; - $commercialData->taxAmount = 0; - - $response = $this->getVisa1()->charge(.52) - ->withCurrency("USD") - ->withCommercialData($commercialData) - ->withDescription("test01VisaLevelII") - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test02MasterCardLevelII() { - $commercialData = new CommercialData(TaxType::SALES_TAX); - $commercialData->poNumber = '9876543210'; - $commercialData->taxAmount = .02; - - $response = $this->getMCKeyedTIC()->charge(.52) - ->withCurrency("USD") - ->withCommercialData($commercialData) - ->withDescription("test02MasterCardLevelII") - ->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->getAmex()->charge(1.50) - ->withCurrency('USD') - ->withCommercialData($commercialData) - ->withDescription('test03AmexManualLevelII') - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test04MasterCard2BINSale() { - $response = $this->getMC2BIN()->charge(11.10) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test04' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test05DiscoverSale() { - $response = $this->getDiscover()->charge(12.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test05' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test06DinersAuth() { - $response = $this->getDiners()->authorize(6.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test06' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - // $this->assertEquals(5.55, $response->authorizedAmount); test script is wrong, gateway doesn't return partial auth on this test - } - - public function test07MasterCardSale() { - $response = $this->getMCUnclassifiedTIC()->charge(15.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test07' . time()) - ->execute(); - - self::$test20VoidTarget = $response->transactionId; - - $this->assertEquals('00', $response->responseCode); - } - - public function test08MasterCardSale() { - $response = $this->getMCUnclassifiedTIC()->charge(34.13) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test08' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test09JCBSale() { - $response = $this->getJCB()->charge(13.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test09' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test10AMEX() { - $card = $this->getAmex(); - $card->cvn = null; - - $response = $card->charge(13.50) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test10' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test11VisaSale() { - $response = $this->getVisa1()->charge(32.49) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test11' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test12DiscoverCUPSale() { - $response = $this->getDiscoverCUP()->charge(10.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test12' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test13VisaSale() { - $response = $this->getVisa1()->charge(11.12) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test13' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test14AMEXSale() { - $response = $this->getAmex()->charge(4.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test14' . time()) - ->execute(); - - self::$test21VoidTarget = $response->transactionId; - - $this->assertEquals('00', $response->responseCode); - } - - public function test15VisaVerify() { - $response = $this->getVisa1()->verify() - ->withRequestMultiUseToken(true) - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test15' . time()) - ->execute(); - - self::$test30MUT = $response->token; - - $this->assertEquals('00', $response->responseCode); - } - - public function test15aVisaVerify() { - $response = $this->getVisa1()->verify() - // ->withRequestMultiUseToken(true) - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test15a' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test16MasterCardVerify() { - $response = $this->getMCUnclassifiedTIC()->verify() - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test16' . time()) - ->withRequestMultiUseToken(true) - ->execute(); - - self::$test31MUT = $response->token; - - $this->assertEquals('00', $response->responseCode); - } - - public function test16aMasterCardVerify() { - $response = $this->getMCUnclassifiedTIC()->verify() - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test16a' . time()) - // ->withRequestMultiUseToken(true) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test17AMEXVerify() { - $response = $this->getAmex()->verify() - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test17' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test18VisaLvl3() { - $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" - ); - $lineItem1->taxAmount = 0; - $lineItem1->taxName = 'item 1 name'; - - $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" - ); - $lineItem2->taxAmount = .03; - $lineItem2->taxName = 'a tax name here'; - $lineItem2->taxType = TaxType::SALES_TAX; - $lineItem2->taxPercentage = .69; - - $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times - - $response = $this->getVisa1()->charge(.53) - ->withCurrency('USD') - ->withCommercialData($commercialData) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test19MasterCardLvl3() { - $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; - $lineItem->discountDetails = new DiscountDetails( - .01, - 'little discount', - 1, - 'discount type 1' - ); - $lineItem->taxAmount = 1; - $lineItem->taxName = 'a tax name here'; - $lineItem->taxPercentage = 12; - - $commercialData->addLineItems($lineItem); - - $response = $this->getMCUnclassifiedTIC()->charge(.53) - ->withCurrency('USD') - ->withCommercialData($commercialData) - ->withAddress($this->getAVSData()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test20PartialVoid() { - $response = Transaction::fromId(self::$test20VoidTarget) - ->void(5.00) - ->withDescription('PARTIAL_REVERSAL') - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test21FullVoid() { - $response = Transaction::fromId(self::$test21VoidTarget) - ->void() - ->withDescription('POST_AUTH_USER_DECLINE') - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test22Visa3DS () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 5; - $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; - // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - // $threeDeeInfo->setVersion(Secure3dVersion::ONE); - - $card = $this->getVisa1(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(1.01) - ->withCurrency('USD') - ->withClientTransactionId('test22_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test23MC3DS_V1 () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 5; - $threeDeeInfo->secureCode = '12345678901234567890123456789012'; - $threeDeeInfo->authenticationType = '21'; - $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - $threeDeeInfo->setVersion(Secure3dVersion::ONE); - - $card = $this->getMCUnclassifiedTIC(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(34.02) - ->withCurrency('USD') - ->withClientTransactionId('test23_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test24MC3DS_V2 () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 5; - $threeDeeInfo->secureCode = '12345678901234567890123456789012'; - $threeDeeInfo->authenticationType = '21'; - $threeDeeInfo->directoryServerTransactionId = 'c272b04f-6e7b-43a2-bb78-90f4fb94aa25'; - $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - $threeDeeInfo->setVersion(Secure3dVersion::TWO); - - $card = $this->getMCUnclassifiedTIC(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(34.06) - ->withCurrency('USD') - ->withClientTransactionId('test24_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test25Discover3DS () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 5; - $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; - // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - // $threeDeeInfo->setVersion(Secure3dVersion::ONE); - - $card = $this->getDiscover(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(45.02) - ->withCurrency('USD') - ->withClientTransactionId('test25_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test26Amex3DS () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 5; - $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; - // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - // $threeDeeInfo->setVersion(Secure3dVersion::ONE); - - $card = $this->getAmex(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(32.02) - ->withCurrency('USD') - ->withClientTransactionId('test26_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test27MC3DS_V2_2 () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 5; - $threeDeeInfo->authenticationValue = 'ODQzNjgwNjU0ZjM3N2JmYTg0NTM='; - $threeDeeInfo->authenticationType = '24'; - $threeDeeInfo->directoryServerTransactionId = 'c272b04f-6e7b-43a2-bb78-90f4fb94aa25'; - $threeDeeInfo->ucafIndicator = UcafIndicator::MERCHANT_RISK_BASED; - $threeDeeInfo->setVersion(Secure3dVersion::TWO); - - $card = $this->getMCUnclassifiedTIC(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(34.05) - ->withCurrency('USD') - ->withClientTransactionId('test27_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test28Visa3DS_ECI6 () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 6; - $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; - // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - // $threeDeeInfo->setVersion(Secure3dVersion::TWO); - - $card = $this->getVisa1(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(.81) - ->withCurrency('USD') - ->withClientTransactionId('test28_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test29MC3DS_ECI6 () { - $threeDeeInfo = new ThreeDSecure(); - $threeDeeInfo->eci = 6; - $threeDeeInfo->secureCode = '12345678901234567890123456789012'; - $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; - $threeDeeInfo->setVersion(Secure3dVersion::ONE); - - $card = $this->getMCUnclassifiedTIC(); - $card->threeDSecure = $threeDeeInfo; - - $response = $card->charge(29.00) - ->withCurrency('USD') - ->withClientTransactionId('test29_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test30SaleVisaCIT () { - $storedcreds = new StoredCredential; - $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; - - $cardAsMUT = $this->getVisa1(); - $cardAsMUT->number = self::$test30MUT; - - $response = $cardAsMUT->charge(14.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test30_' . time()) - ->withStoredCredential($storedcreds) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test31SaleNonVisaCIT () { - $storedcreds = new StoredCredential; - $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; - - $cardAsMUT = $this->getMCUnclassifiedTIC(); - $cardAsMUT->number = self::$test31MUT; - - $response = $cardAsMUT->charge(15.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test31_' . time()) - ->withStoredCredential($storedcreds) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - } - - public function test32VisaMultiCapture () { - $response = $this->getVisa1()->authorize(30.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test32_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - - $firstCaptureResponse = $response->capture(15.00) - ->withMultiCapture(1, 2) - ->execute(); - - $this->assertEquals('00', $firstCaptureResponse->responseCode); - - $secondCaptureResponse = $response->capture(15.00) - ->withMultiCapture(2, 2) - ->execute(); - - $this->assertEquals('00', $secondCaptureResponse->responseCode); - } - - public function test33MCMultiCapture () { - $response = $this->getMCUnclassifiedTIC()->authorize(50.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test33_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - - $firstCaptureResponse = $response->capture(30.00) - ->withMultiCapture(1, 3) - ->execute(); - - $this->assertEquals('00', $firstCaptureResponse->responseCode); - - $secondCaptureResponse = $response->capture(10.00) - ->withMultiCapture(2, 3) - ->execute(); - - $this->assertEquals('00', $secondCaptureResponse->responseCode); - - $thirdCaptureResponse = $response->capture(10.00) - ->withMultiCapture(3, 3) - ->execute(); - - $this->assertEquals('00', $thirdCaptureResponse->responseCode); - } - - public function test34MCMultiCapture () { - $response = $this->getMCUnclassifiedTIC()->authorize(60.00) - ->withCurrency('USD') - ->withAddress($this->getAVSData()) - ->withClientTransactionId('test34_' . time()) - ->execute(); - - $this->assertEquals('00', $response->responseCode); - - $captureResponse = $response->capture() - ->withMultiCapture() - ->execute(); - - $this->assertEquals('00', $captureResponse->responseCode); - } - - public function test35CloseBatch () { - $response = BatchService::closeBatch(); - - $this->assertEquals('00', $response->responseCode); - } - - public function getVisa1 () { - $card = new CreditCardData; - $card->number = 4012000098765439; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 999; - $card->cardType = CardType::VISA; - return $card; - } - - public function getVisa2 () { - $card = new CreditCardData; - $card->number = 4012881888818888; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 999; - $card->cardType = CardType::VISA; - return $card; - } - - public function getMCUnclassifiedTIC () { - $card = new CreditCardData; - $card->number = 5146315000000055; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - return $card; - } - - public function getMCSwipeTIC () { - $card = new CreditCardData; - $card->number = 5146312200000035; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - return $card; - } - - public function getMCKeyedTIC () { - $card = new CreditCardData; - $card->number = 5146312620000045; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - return $card; - } - - public function getMC2BIN () { - $card = new CreditCardData; - $card->number = 2223000048400011; - $card->expYear = 25; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - return $card; - } - - public function getAmex () { - $card = new CreditCardData; - $card->number = 371449635392376; - $card->expYear = 25; // magic number - $card->expMonth = 12; - $card->cvn = 9997; - $card->cardType = CardType::AMEX; - return $card; - } - - public function getDiscover () { - $card = new CreditCardData; - $card->number = 6011000993026909; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DISCOVER; - return $card; - } - - public function getDiscoverCUP () { - $card = new CreditCardData; - $card->number = 6282000123842342; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DISCOVER; - return $card; - } - - public function getDiscoverCUP2 () { - $card = new CreditCardData; - $card->number = 6221261111112650; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DISCOVER; - return $card; - } - - public function getDiners () { - $card = new CreditCardData; - $card->number = 3055155515160018; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DINERS; - return $card; - } - - public function getJCB () { - $card = new CreditCardData; - $card->number = 3530142019945859; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::JCB; - return $card; - } - - public function getAVSData () { - $address = new Address(); - $address->streetAddress1 = '8320'; - $address->postalCode = '85284'; - return $address; - } -} +getConfig()); + } + + protected function getConfig() { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'Hrcb^619'; + $config->deviceId = '88700000322601'; + $config->transactionKey = '57ZL83P6A2V8KGI49QWK017C7WXG03O8'; + $config->developerId = '003226G001'; + $config->gatewayProvider = GatewayProvider::TRANSIT; + $config->acceptorConfig = new AcceptorConfig(); // might need to adjust this per transaction or per file + return $config; + } + + public static $test20VoidTarget; + public static $test21VoidTarget; + public static $test30MUT; + public static $test31MUT; + + // These are all stolen from dotnet cert file + public function test01VisaLevelII() { + $commercialData = new CommercialData(TaxType::NOT_USED); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = 0; + + $response = $this->getVisa1()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withDescription("test01VisaLevelII") + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test02MasterCardLevelII() { + $commercialData = new CommercialData(TaxType::SALES_TAX); + $commercialData->poNumber = '9876543210'; + $commercialData->taxAmount = .02; + + $response = $this->getMCKeyedTIC()->charge(.52) + ->withCurrency("USD") + ->withCommercialData($commercialData) + ->withDescription("test02MasterCardLevelII") + ->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->getAmex()->charge(1.50) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withDescription('test03AmexManualLevelII') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test04MasterCard2BINSale() { + $response = $this->getMC2BIN()->charge(11.10) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test04' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test05DiscoverSale() { + $response = $this->getDiscover()->charge(12.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test05' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test06DinersAuth() { + $response = $this->getDiners()->authorize(6.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test06' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + // $this->assertEquals(5.55, $response->authorizedAmount); test script is wrong, gateway doesn't return partial auth on this test + } + + public function test07MasterCardSale() { + $response = $this->getMCUnclassifiedTIC()->charge(15.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test07' . time()) + ->execute(); + + self::$test20VoidTarget = $response->transactionId; + + $this->assertEquals('00', $response->responseCode); + } + + public function test08MasterCardSale() { + $response = $this->getMCUnclassifiedTIC()->charge(34.13) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test08' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test09JCBSale() { + $response = $this->getJCB()->charge(13.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test09' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test10AMEX() { + $card = $this->getAmex(); + $card->cvn = null; + + $response = $card->charge(13.50) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test10' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test11VisaSale() { + $response = $this->getVisa1()->charge(32.49) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test11' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test12DiscoverCUPSale() { + $response = $this->getDiscoverCUP()->charge(10.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test12' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test13VisaSale() { + $response = $this->getVisa1()->charge(11.12) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test13' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test14AMEXSale() { + $response = $this->getAmex()->charge(4.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test14' . time()) + ->execute(); + + self::$test21VoidTarget = $response->transactionId; + + $this->assertEquals('00', $response->responseCode); + } + + public function test15VisaVerify() { + $response = $this->getVisa1()->verify() + ->withRequestMultiUseToken(true) + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test15' . time()) + ->execute(); + + self::$test30MUT = $response->token; + + $this->assertEquals('00', $response->responseCode); + } + + public function test15aVisaVerify() { + $response = $this->getVisa1()->verify() + // ->withRequestMultiUseToken(true) + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test15a' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test16MasterCardVerify() { + $response = $this->getMCUnclassifiedTIC()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test16' . time()) + ->withRequestMultiUseToken(true) + ->execute(); + + self::$test31MUT = $response->token; + + $this->assertEquals('00', $response->responseCode); + } + + public function test16aMasterCardVerify() { + $response = $this->getMCUnclassifiedTIC()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test16a' . time()) + // ->withRequestMultiUseToken(true) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test17AMEXVerify() { + $response = $this->getAmex()->verify() + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test17' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test18VisaLvl3() { + $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" + ); + $lineItem1->taxAmount = 0; + $lineItem1->taxName = 'item 1 name'; + + $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" + ); + $lineItem2->taxAmount = .03; + $lineItem2->taxName = 'a tax name here'; + $lineItem2->taxType = TaxType::SALES_TAX; + $lineItem2->taxPercentage = .69; + + $commercialData->addLineItems($lineItem1, $lineItem2); // can pass multiple line items or just call this function multiple times + + $response = $this->getVisa1()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test19MasterCardLvl3() { + $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; + $lineItem->discountDetails = new DiscountDetails( + .01, + 'little discount', + 1, + 'discount type 1' + ); + $lineItem->taxAmount = 1; + $lineItem->taxName = 'a tax name here'; + $lineItem->taxPercentage = 12; + + $commercialData->addLineItems($lineItem); + + $response = $this->getMCUnclassifiedTIC()->charge(.53) + ->withCurrency('USD') + ->withCommercialData($commercialData) + ->withAddress($this->getAVSData()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test20PartialVoid() { + $response = Transaction::fromId(self::$test20VoidTarget) + ->void(5.00) + ->withDescription('PARTIAL_REVERSAL') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test21FullVoid() { + $response = Transaction::fromId(self::$test21VoidTarget) + ->void() + ->withDescription('POST_AUTH_USER_DECLINE') + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test22Visa3DS () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getVisa1(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(1.01) + ->withCurrency('USD') + ->withClientTransactionId('test22_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test23MC3DS_V1 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '12345678901234567890123456789012'; + $threeDeeInfo->authenticationType = '21'; + $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(34.02) + ->withCurrency('USD') + ->withClientTransactionId('test23_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test24MC3DS_V2 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '12345678901234567890123456789012'; + $threeDeeInfo->authenticationType = '21'; + $threeDeeInfo->directoryServerTransactionId = 'c272b04f-6e7b-43a2-bb78-90f4fb94aa25'; + $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + $threeDeeInfo->setVersion(Secure3dVersion::TWO); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(34.06) + ->withCurrency('USD') + ->withClientTransactionId('test24_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test25Discover3DS () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getDiscover(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(45.02) + ->withCurrency('USD') + ->withClientTransactionId('test25_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test26Amex3DS () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getAmex(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(32.02) + ->withCurrency('USD') + ->withClientTransactionId('test26_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test27MC3DS_V2_2 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 5; + $threeDeeInfo->authenticationValue = 'ODQzNjgwNjU0ZjM3N2JmYTg0NTM='; + $threeDeeInfo->authenticationType = '24'; + $threeDeeInfo->directoryServerTransactionId = 'c272b04f-6e7b-43a2-bb78-90f4fb94aa25'; + $threeDeeInfo->ucafIndicator = UcafIndicator::MERCHANT_RISK_BASED; + $threeDeeInfo->setVersion(Secure3dVersion::TWO); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(34.05) + ->withCurrency('USD') + ->withClientTransactionId('test27_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test28Visa3DS_ECI6 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 6; + $threeDeeInfo->secureCode = '1234567890123456789012345678901234567890'; + // $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + // $threeDeeInfo->setVersion(Secure3dVersion::TWO); + + $card = $this->getVisa1(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(.81) + ->withCurrency('USD') + ->withClientTransactionId('test28_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test29MC3DS_ECI6 () { + $threeDeeInfo = new ThreeDSecure(); + $threeDeeInfo->eci = 6; + $threeDeeInfo->secureCode = '12345678901234567890123456789012'; + $threeDeeInfo->ucafIndicator = UcafIndicator::FULLY_AUTHENTICATED; + $threeDeeInfo->setVersion(Secure3dVersion::ONE); + + $card = $this->getMCUnclassifiedTIC(); + $card->threeDSecure = $threeDeeInfo; + + $response = $card->charge(29.00) + ->withCurrency('USD') + ->withClientTransactionId('test29_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test30SaleVisaCIT () { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + + $cardAsMUT = $this->getVisa1(); + $cardAsMUT->number = self::$test30MUT; + + $response = $cardAsMUT->charge(14.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test30_' . time()) + ->withStoredCredential($storedcreds) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test31SaleNonVisaCIT () { + $storedcreds = new StoredCredential; + $storedcreds->initiator = StoredCredentialInitiator::MERCHANT; + + $cardAsMUT = $this->getMCUnclassifiedTIC(); + $cardAsMUT->number = self::$test31MUT; + + $response = $cardAsMUT->charge(15.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test31_' . time()) + ->withStoredCredential($storedcreds) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + } + + public function test32VisaMultiCapture () { + $response = $this->getVisa1()->authorize(30.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test32_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $firstCaptureResponse = $response->capture(15.00) + ->withMultiCapture(1, 2) + ->execute(); + + $this->assertEquals('00', $firstCaptureResponse->responseCode); + + $secondCaptureResponse = $response->capture(15.00) + ->withMultiCapture(2, 2) + ->execute(); + + $this->assertEquals('00', $secondCaptureResponse->responseCode); + } + + public function test33MCMultiCapture () { + $response = $this->getMCUnclassifiedTIC()->authorize(50.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test33_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $firstCaptureResponse = $response->capture(30.00) + ->withMultiCapture(1, 3) + ->execute(); + + $this->assertEquals('00', $firstCaptureResponse->responseCode); + + $secondCaptureResponse = $response->capture(10.00) + ->withMultiCapture(2, 3) + ->execute(); + + $this->assertEquals('00', $secondCaptureResponse->responseCode); + + $thirdCaptureResponse = $response->capture(10.00) + ->withMultiCapture(3, 3) + ->execute(); + + $this->assertEquals('00', $thirdCaptureResponse->responseCode); + } + + public function test34MCMultiCapture () { + $response = $this->getMCUnclassifiedTIC()->authorize(60.00) + ->withCurrency('USD') + ->withAddress($this->getAVSData()) + ->withClientTransactionId('test34_' . time()) + ->execute(); + + $this->assertEquals('00', $response->responseCode); + + $captureResponse = $response->capture() + ->withMultiCapture() + ->execute(); + + $this->assertEquals('00', $captureResponse->responseCode); + } + + public function test35CloseBatch () { + $response = BatchService::closeBatch(); + + $this->assertEquals('00', $response->responseCode); + } + + public function getVisa1 () { + $card = new CreditCardData; + $card->number = 4012000098765439; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + return $card; + } + + public function getVisa2 () { + $card = new CreditCardData; + $card->number = 4012881888818888; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + return $card; + } + + public function getMCUnclassifiedTIC () { + $card = new CreditCardData; + $card->number = 5146315000000055; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getMCSwipeTIC () { + $card = new CreditCardData; + $card->number = 5146312200000035; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getMCKeyedTIC () { + $card = new CreditCardData; + $card->number = 5146312620000045; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getMC2BIN () { + $card = new CreditCardData; + $card->number = 2223000048400011; + $card->expYear = 25; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + return $card; + } + + public function getAmex () { + $card = new CreditCardData; + $card->number = 371449635392376; + $card->expYear = 25; // magic number + $card->expMonth = 12; + $card->cvn = 9997; + $card->cardType = CardType::AMEX; + return $card; + } + + public function getDiscover () { + $card = new CreditCardData; + $card->number = 6011000993026909; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + return $card; + } + + public function getDiscoverCUP () { + $card = new CreditCardData; + $card->number = 6282000123842342; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + return $card; + } + + public function getDiscoverCUP2 () { + $card = new CreditCardData; + $card->number = 6221261111112650; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + return $card; + } + + public function getDiners () { + $card = new CreditCardData; + $card->number = 3055155515160018; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DINERS; + return $card; + } + + public function getJCB () { + $card = new CreditCardData; + $card->number = 3530142019945859; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::JCB; + return $card; + } + + public function getAVSData () { + $address = new Address(); + $address->streetAddress1 = '8320'; + $address->postalCode = '85284'; + return $address; + } +} diff --git a/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php b/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php index d13e822e..8f218199 100644 --- a/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php +++ b/test/Integration/Gateways/TransITConnector/Certification/Token_Request_Only.php @@ -1,276 +1,262 @@ -getConfig()); - } - - public function getConfig() { - $config = new ServicesConfig(); - $config->merchantId = '887000003226'; - $config->username = 'TA5622118'; - $config->password = 'f8mapGqWrE^rVaA9'; - $config->deviceId = '88700000322601'; - $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; - $config->developerId = '003226G001'; - $config->gatewayProvider = GatewayProvider::TRANSIT; - $config->acceptorConfig = new AcceptorConfig(); - $config->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; - $config->acceptorConfig->cardDataSource = CardDataSource::INTERNET; - return $config; - } - - public function getMailConfig() { - $mailConfig = $this->getConfig(); - $mailConfig->acceptorConfig->cardDataSource = CardDataSource::MAIL; - $mailConfig->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; - return $mailConfig; - } - - public function getPhoneConfig() { - $phoneConfig = $this->getConfig(); - $phoneConfig->acceptorConfig->cardDataSource = CardDataSource::PHONE; - $phoneConfig->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; - return $phoneConfig; - } - - public function test01GenerateVisaMUT() { - $response = $this->getVisa1()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test02GenerateMasterCardMUT() { - $response = $this->getMCUnclassifiedTIC()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test03GenerateMasterCardBin2MUT() { - $response = $this->getMC2BIN()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test04GenerateDiscoverMUT() { - $response = $this->getDiscover()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test05GenerateAmexMUT() { - ServicesContainer::configure($this->getPhoneConfig()); - - $response = $this->getAmex()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test06GenerateJCB_MUT() { - ServicesContainer::configure($this->getMailConfig()); - - $response = $this->getJCB()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test07GeneratDiscoverCUP_MUT() { - ServicesContainer::configure($this->getMailConfig()); - - $response = $this->getDiscoverCUP()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function test08GenerateDinersMUT() { - ServicesContainer::configure($this->getPhoneConfig()); - - $response = $this->getDiners()->tokenize()->execute(); - - $this->assertEquals('00', $response->responseCode); - $this->assertNotNull($response->token); - } - - public function getVisa1 () { - $card = new CreditCardData; - $card->number = 4012000098765439; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 999; - $card->cardType = CardType::VISA; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getVisa2 () { - $card = new CreditCardData; - $card->number = 4012881888818888; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 999; - $card->cardType = CardType::VISA; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getMCUnclassifiedTIC () { - $card = new CreditCardData; - $card->number = 5146315000000055; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getMCSwipeTIC () { - $card = new CreditCardData; - $card->number = 5146312200000035; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getMCKeyedTIC () { - $card = new CreditCardData; - $card->number = 5146312620000045; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getMC2BIN () { - $card = new CreditCardData; - $card->number = 2223000048400011; - $card->expYear = 25; // magic number - $card->expMonth = 12; - $card->cvn = 998; - $card->cardType = CardType::MASTERCARD; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getAmex () { - $card = new CreditCardData; - $card->number = 371449635392376; - $card->expYear = 25; // magic number - $card->expMonth = 12; - $card->cvn = 9997; - $card->cardType = CardType::AMEX; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getDiscover () { - $card = new CreditCardData; - $card->number = 6011000993026909; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DISCOVER; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getDiscoverCUP () { - $card = new CreditCardData; - $card->number = 6282000123842342; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DISCOVER; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getDiscoverCUP2 () { - $card = new CreditCardData; - $card->number = 6221261111112650; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DISCOVER; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getDiners () { - $card = new CreditCardData; - $card->number = 3055155515160018; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::DINERS; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getJCB () { - $card = new CreditCardData; - $card->number = 3530142019945859; - $card->expYear = 20; // magic number - $card->expMonth = 12; - $card->cvn = 996; - $card->cardType = CardType::JCB; - // $card->readerPresent = true; - $card->cardPresent = false; - return $card; - } - - public function getAVSData () { - $address = new Address(); - $address->streetAddress1 = '8320'; - $address->postalCode = '85284'; - return $address; - } -} +getConfig()); + } + + public function getConfig() { + $config = new TransitConfig(); + $config->merchantId = '887000003226'; + $config->username = 'TA5622118'; + $config->password = 'f8mapGqWrE^rVaA9'; + $config->deviceId = '88700000322601'; + $config->transactionKey = '2HZFSJ98G4XEGHXGP31IRLLG8H3XAWB2'; + $config->developerId = '003226G001'; + $config->acceptorConfig = new AcceptorConfig(); + $config->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + $config->acceptorConfig->cardDataSource = CardDataSource::INTERNET; + return $config; + } + + public function getMailConfig() { + $mailConfig = $this->getConfig(); + $mailConfig->acceptorConfig->cardDataSource = CardDataSource::MAIL; + $mailConfig->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + return $mailConfig; + } + + public function getPhoneConfig() { + $phoneConfig = $this->getConfig(); + $phoneConfig->acceptorConfig->cardDataSource = CardDataSource::PHONE; + $phoneConfig->acceptorConfig->operatingEnvironment = OperatingEnvironment::ON_MERCHANT_PREMISES_ATTENDED; + return $phoneConfig; + } + + public function test01GenerateVisaMUT() { + $response = $this->getVisa1()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test02GenerateMasterCardMUT() { + $response = $this->getMCUnclassifiedTIC()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test03GenerateMasterCardBin2MUT() { + $response = $this->getMC2BIN()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test04GenerateDiscoverMUT() { + $response = $this->getDiscover()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test05GenerateAmexMUT() { + ServicesContainer::configureService($this->getPhoneConfig()); + + $response = $this->getAmex()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test06GenerateJCB_MUT() { + ServicesContainer::configureService($this->getMailConfig()); + + $response = $this->getJCB()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test07GeneratDiscoverCUP_MUT() { + ServicesContainer::configureService($this->getMailConfig()); + + $response = $this->getDiscoverCUP()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function test08GenerateDinersMUT() { + ServicesContainer::configureService($this->getPhoneConfig()); + + $response = $this->getDiners()->tokenize()->execute(); + + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->token); + } + + public function getVisa1 () { + $card = new CreditCardData; + $card->number = 4012000098765439; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getVisa2 () { + $card = new CreditCardData; + $card->number = 4012881888818888; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 999; + $card->cardType = CardType::VISA; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCUnclassifiedTIC () { + $card = new CreditCardData; + $card->number = 5146315000000055; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCSwipeTIC () { + $card = new CreditCardData; + $card->number = 5146312200000035; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMCKeyedTIC () { + $card = new CreditCardData; + $card->number = 5146312620000045; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getMC2BIN () { + $card = new CreditCardData; + $card->number = 2223000048400011; + $card->expYear = 25; // magic number + $card->expMonth = 12; + $card->cvn = 998; + $card->cardType = CardType::MASTERCARD; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getAmex () { + $card = new CreditCardData; + $card->number = 371449635392376; + $card->expYear = 25; // magic number + $card->expMonth = 12; + $card->cvn = 9997; + $card->cardType = CardType::AMEX; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscover () { + $card = new CreditCardData; + $card->number = 6011000993026909; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscoverCUP () { + $card = new CreditCardData; + $card->number = 6282000123842342; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiscoverCUP2 () { + $card = new CreditCardData; + $card->number = 6221261111112650; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DISCOVER; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getDiners () { + $card = new CreditCardData; + $card->number = 3055155515160018; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::DINERS; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getJCB () { + $card = new CreditCardData; + $card->number = 3530142019945859; + $card->expYear = 20; // magic number + $card->expMonth = 12; + $card->cvn = 996; + $card->cardType = CardType::JCB; + // $card->readerPresent = true; + $card->cardPresent = false; + return $card; + } + + public function getAVSData () { + $address = new Address(); + $address->streetAddress1 = '8320'; + $address->postalCode = '85284'; + return $address; + } +} 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); + } +}