public function testVisaPerformVoidOfPriorCredit()
 {
     // First create a credit to void
     $response = $this->gw->creditCardCredit($this->optsRetailSwiped(['TransactionAmount' => '100.02', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA')]))->send();
     $this->assertSame("0", $response->getCode());
     // Then void the credit
     $response = $this->gw->creditCardVoid($this->optsRetailKeyed(['ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'TransactionID' => $response->getTransactionId()]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa (perform Void of prior Credit)', '100.02', $response->getCode(), $response->getTransactionId()]);
 }
 public function testDeletePaymentAccountMastercard()
 {
     // Create a card token
     $response = $this->gw->paymentAccountCreate(['PaymentAccountType' => PaymentAccountType::CREDIT_CARD, 'PaymentAccountReferenceNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('MASTERCARD_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('MASTERCARD_ENCRYPTED_TRACK1_DATA'), 'BillingZipcode' => '90210'])->send();
     $this->assertSame("0", $response->getCode());
     // Delete PaymentAccount
     $response = $this->gw->paymentAccountDelete(['PaymentAccountID' => $response->getPaymentAccountId()])->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Delete Payment Account (Mastercard)', 'N/A', $response->getCode(), $response->getData()->ServicesID]);
 }
 public function testVisaPerformFullReversalOfPriorSale()
 {
     // First create a sale to reverse.
     $response = $this->gw->creditCardSale($this->optsRetailSwiped(['TransactionAmount' => '200.01', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA')]))->send();
     $this->assertSame("0", $response->getCode());
     // Then reverse the sale
     $response = $this->gw->creditCardReversal($this->optsRetailKeyed(['TransactionAmount' => '200.01', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'TransactionID' => $response->getTransactionId(), 'ReversalType' => ReversalType::FULL]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa (perform Full Reversal of prior Sale)', '200.01', $response->getCode(), $response->getTransactionId()]);
 }
 public function testQueryByExpirationMonthAndYear()
 {
     // Create a card token
     $response = $this->gw->paymentAccountCreate(['PaymentAccountType' => PaymentAccountType::CREDIT_CARD, 'PaymentAccountReferenceNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA'), 'BillingZipcode' => '90210'])->send();
     $this->assertSame("0", $response->getCode());
     // Query based on PaymentAccountReferenceNumber
     $response = $this->gw->paymentAccountQuery(['ExpirationMonthEnd' => '12', 'ExpirationYearEnd' => '19'])->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Query by ExpirationMonth and Year End', 'N/A', $response->getCode(), $response->getData()->ServicesID]);
 }
 public function testVisaDuplicateCheckDisabled()
 {
     // First create a sale.
     $response = $this->gw->creditCardSale($this->optsRetailSwiped(['TransactionAmount' => '0.23', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA')]))->send();
     $this->assertSame("23", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa (Sale)', '0.23', $response->getCode(), $response->getTransactionId()]);
     // Run it again with duplicate checks disabled set to true.
     $response = $this->gw->creditCardSale($this->optsRetailSwiped(['TransactionAmount' => '0.23', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA'), 'DuplicateCheckDisableFlag' => "1"]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa (Sale, DuplicateCheckDisableFlag=true)', '0.23', $response->getCode(), $response->getTransactionId()]);
 }
 public function testVisaPartialCreditCardReturn()
 {
     // First create a sale.
     $response = $this->gw->creditCardSale($this->optsRetailSwiped(['TransactionAmount' => '3.25', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA')]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa (Sale)', '3.25', $response->getCode(), $response->getTransactionId()]);
     // Perform a full return on the previous sale.
     $response = $this->gw->creditCardReturn($this->optsRetailKeyed(['TransactionAmount' => '2.25', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'TransactionID' => $response->getTransactionId()]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa (partial CreditCardReturn)', '2.25', $response->getCode(), $response->getTransactionId()]);
 }
 public function testCreditCardCreditVisa()
 {
     // Create a card token
     $response = $this->gw->paymentAccountCreate(['PaymentAccountType' => PaymentAccountType::CREDIT_CARD, 'PaymentAccountReferenceNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack1Data' => getenv('VISA_ENCRYPTED_TRACK1_DATA'), 'BillingZipcode' => '90210'])->send();
     $this->assertSame("0", $response->getCode());
     $paymentAccountId = $response->getPaymentAccountId();
     // Create a CreditCardSale to credit.
     $response = $this->gw->creditCardSale($this->optsRetailKeyed(['TransactionAmount' => '1.93', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'PaymentAccountID' => $paymentAccountId]))->send();
     $this->assertSame("0", $response->getCode());
     // Credit the CreditCardSale amount back to the card
     $response = $this->gw->creditCardCredit($this->optsRetailKeyed(['TransactionAmount' => '1.93', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'PaymentAccountID' => $paymentAccountId]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['CreditCardCredit (Visa)', '1.93', $response->getCode(), $response->getTransactionId()]);
 }
Esempio n. 8
0
 public function setEncryptedFormat($value)
 {
     $value = EncryptedFormat::memberByValue($value)->value();
     return $this->setParameter('EncryptedFormat', $value);
 }
Esempio n. 9
0
 /**
  * Model validation ensures that any data that is present in the model is
  * formatted correctly. No business logic validation is performed at this
  * level.
  *
  * @throws InvalidRequestException if validation fails.
  */
 public function validate()
 {
     if (strlen($this['CardNumber'])) {
         if (!preg_match('/^\\d{12,19}$/', $this['CardNumber'])) {
             throw new InvalidRequestException('CardNumber should have 12 to 19 digits');
         }
         if (!Helper::validateLuhn($this['CardNumber'])) {
             throw new InvalidRequestException('CardNumber is invalid');
         }
     }
     if (strlen($this['ExpirationMonth'] && strlen($this['ExpirationYear']))) {
         $time = gmmktime(0, 0, 0, $this['ExpirationMonth'], 1, $this['ExpirationYear']);
         if (gmdate('Ym', $time) < gmdate('Ym')) {
             throw new InvalidRequestException('Card has expired');
         }
     }
     if (strlen($this['Track1Data']) && !preg_match('/^.{1,76}$/', $this['Track1Data'])) {
         throw new InvalidRequestException('Track1Data should have 76 or fewer characters');
     }
     if (strlen($this['Track2Data']) && !preg_match('/^.{1,37}$/', $this['Track2Data'])) {
         throw new InvalidRequestException('Track2Data should have 37 or fewer characters');
     }
     if (strlen($this['MagneprintData']) && !preg_match('/^.{1,700}$/', $this['MagneprintData'])) {
         throw new InvalidRequestException('MagneprintData should have 700 or fewer characters');
     }
     if (strlen($this['CVV']) && !preg_match('/^\\d{1,4}$/', $this['CVV'])) {
         throw new InvalidRequestException('CVV should have 4 or fewer digits');
     }
     if (strlen($this['EncryptedTrack1Data']) && !preg_match('/^.{1,300}$/', $this['EncryptedTrack1Data'])) {
         throw new InvalidRequestException('EncryptedTrack1Data should have 300 or fewer characters');
     }
     if (strlen($this['EncryptedTrack2Data']) && !preg_match('/^.{1,200}$/', $this['EncryptedTrack2Data'])) {
         throw new InvalidRequestException('EncryptedTrack2Data should have 200 or fewer characters');
     }
     if (strlen($this['EncryptedCardData']) && !preg_match('/^.{1,200}$/', $this['EncryptedCardData'])) {
         throw new InvalidRequestException('EncryptedCardData should have 200 or fewer characters');
     }
     if (strlen($this['CardDataKeySerialNumber']) && !preg_match('/^.{1,26}$/', $this['CardDataKeySerialNumber'])) {
         throw new InvalidRequestException('CardDataKeySerialNumber should have 26 or fewer characters');
     }
     if (isset($this['EncryptedFormat'])) {
         try {
             EncryptedFormat::memberByValue($this['EncryptedFormat']);
         } catch (\Exception $e) {
             throw new InvalidRequestException('Invalid value for EncryptedFormat');
         }
     }
 }
 public function testVisaSwipedEncryptedTrack2Data()
 {
     $response = $this->gw->paymentAccountCreate(['PaymentAccountType' => PaymentAccountType::CREDIT_CARD, 'PaymentAccountReferenceNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack2Data' => getenv('VISA_ENCRYPTED_TRACK2_DATA'), 'BillingZipcode' => '90210'])->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa Swiped (EncryptedTrack2Data)', 'N/A', $response->getCode(), $response->getData()->ServicesID]);
 }
 public function testVisaSwipedEncryptedTrack2Data()
 {
     $response = $this->gw->creditCardCredit($this->optsRetailSwiped(['TransactionAmount' => '5.21', 'ReferenceNumber' => uniqid(), 'TicketNumber' => uniqid(), 'CardDataKeySerialNumber' => getenv('VISA_CARD_DATA_KEY_SERIAL_NUMBER'), 'EncryptedFormat' => EncryptedFormat::memberByKey(getenv('ENCRYPTED_FORMAT'))->value(), 'EncryptedTrack2Data' => getenv('VISA_ENCRYPTED_TRACK2_DATA')]))->send();
     $this->assertSame("0", $response->getCode());
     static::$buffer .= self::dataRow(...['Visa Swiped (EncryptedTrack2Data)', '5.21', $response->getCode(), $response->getTransactionId()]);
 }