Example #1
0
 public function testCancelValidationSuccess()
 {
     $request = new Cancel($this->config);
     $request->setOrderID(1);
     $validation = new Validation();
     $validation->getValidator($request);
     $data = $validation->performValidation();
     $this->assertEmpty($data, "Validation found an issue when there should be none");
 }
Example #2
0
 /**
  * Make an successful call
  * Create a transaction then do the reserve call
  */
 public function testSuccessfulApiCall()
 {
     if (is_null($this->config)) {
         $this->markTestSkipped('Config is not set, please set up the required environment variables');
         return false;
     }
     $request = new CreateTransactionRequest($this->config);
     //unique ID for the tests
     $orderId = hash('crc32b', microtime());
     $captureId = hash('crc32b', microtime());
     $userId = "GUEST:" . hash('md5', microtime());
     $paymentInstrumentId = hash('crc32b', microtime());
     $request->setOrderID($orderId)->setUserID($userId)->setIntegrationType(CreateTransactionRequest::INTEGRATION_TYPE_API)->setAutoCapture(false)->setContext(CreateTransactionRequest::CONTEXT_ONLINE)->setMerchantReference("TEST")->setUserType(CreateTransactionRequest::USER_TYPE_PRIVATE)->setUserRiskClass(RiskClass::RISK_CLASS_DEFAULT)->setUserData($this->getUser())->setBillingAddress($this->getAddress())->setAmount($this->getAmount())->addBasketItem($this->getBasketItem())->setLocale(Codes::LOCALE_EN);
     $apiEndPoint = new CreateTransaction($this->config, $request);
     $createTransactionResult = $apiEndPoint->sendRequest();
     $this->assertEquals(0, $createTransactionResult->getData('resultCode'));
     $allowedPayments = $createTransactionResult->getData('allowedPaymentMethods');
     $this->assertTrue(in_array('CC', $createTransactionResult->getData('allowedPaymentMethods')));
     if (!in_array('CC', $allowedPayments)) {
         $this->fail("Allowed payment from CreateTransaction lacks CC can not continue");
     }
     /**
      * Register payment instrument
      */
     $registerUserPaymentInstrumentRequest = new RegisterUserPaymentInstrumentRequest($this->config);
     $registerUserPaymentInstrumentRequest->setUserID($userId)->setPaymentInstrument($this->getPaymentInstrument());
     $registerUserPaymentInstrument = new RegisterUserPaymentInstrumentApi($this->config, $registerUserPaymentInstrumentRequest);
     $registerUserPaymentInstrumentResult = $registerUserPaymentInstrument->sendRequest();
     $paymentInstrumentId = $registerUserPaymentInstrumentResult->getData('paymentInstrumentID');
     $reserveRequest = new ReserveRequest($this->config);
     $reserveRequest->setOrderID($orderId)->setPaymentMethod(Methods::PAYMENT_METHOD_TYPE_CC)->setPaymentInstrumentID($paymentInstrumentId)->setCcv(123);
     $reserveApi = new ReserveApi($this->config, $reserveRequest);
     $reserveApi->sendRequest();
     /**
      * Do the cancel
      */
     $cancelRequest = new CancelRequest($this->config);
     $cancelRequest->setOrderID($orderId);
     $cancelApi = new CancelApi($this->config, $cancelRequest);
     $result = $cancelApi->sendRequest();
     $this->assertEquals(0, $result->getData('resultCode'));
     $this->assertEmpty($result->getData('message'));
     $this->assertNotEmpty($result->getData('salt'));
 }