/** * @test * /// Discover authorize and capture should return response code '00'. */ public function testDiscoverAuthorizeAndCaptureShouldReturnOk() { $chargeService = new HpsCreditService(TestServicesConfig::validMultiUseConfig()); $auth = $chargeService->authorize(17.08, "usd", TestCreditCard::validDiscoverCreditCard(), TestCardHolder::ValidCardHolder()); $this->assertEquals("00", $auth->responseCode); $capture = $chargeService->capture($auth->transactionId, 17.08); $this->assertEquals("0", $capture->responseCode); }
/** * @test * /// Discover authorize should return response code '00'. */ public function testDiscoverCaptureShouldReturnOk() { // Authorize the card. $testConfig = new TestServicesConfig(); $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig()); $authResponse = $chargeSvc->authorize(50, "usd", TestCreditCard::validDiscoverCreditCard(), TestCardHolder::ValidCardHolder()); $this->assertEquals("00", $authResponse->responseCode); // Capture the authorization. $captureResponse = $chargeSvc->capture($authResponse->transactionId); $this->assertEquals("0", $captureResponse->responseCode); }
/** * @test * /// Visa authorize should return response code '00' and return multiuse token */ public function testVisaTokenAuthorizeShouldReturnOkandMultiuse() { $token = $this->getToken(TestCreditCard::validVisaCreditCard()); $chargeService = new HpsCreditService(TestServicesConfig::ValidMultiUseConfig()); $auth = $chargeService->authorize(50, "usd", $token, TestCardHolder::ValidCardHolder(), true); $this->assertEquals("00", $auth->responseCode); $this->assertNotNull($auth->tokenData->tokenValue); $multiToken = $auth->tokenData; $chargeMulti = $chargeService->authorize(1, 'usd', $multiToken); $this->assertNotNull($chargeMulti->transactionId); $this->assertEquals('00', $chargeMulti->responseCode); }
/** * @test * Visa auth and CPC Req should return cpcIndicator 'S'. */ public function testVisaAuthCPCReqShouldReturnPurchasing() { $testConfig = new TestServicesConfig(); $chargeSvc = new HpsCreditService($testConfig->validMultiUseConfig()); $response = $chargeSvc->authorize(134.56, "usd", TestCreditCard::validVisaCreditCard(), TestCardHolder::ValidCardHolder(), false, null, null, false, true); $this->assertEquals("00", $response->responseCode); $this->assertEquals("S", $response->cpcIndicator); $cpcData = new HpsCPCData(); $cpcData->CardHolderPONbr = "123456789"; $cpcData->TaxType = HpsTaxType::SALES_TAX; $cpcData->TaxAmt = '15'; $response2 = $chargeSvc->cpcEdit($response->transactionId, $cpcData); $this->assertEquals("00", $response2->responseCode); }
public function authorize($feed, $submission_data, $form, $entry) { $this->populateCreditCardLastFour($form); $this->includeSecureSubmitSDK(); if ($this->getSecureSubmitJsError()) { return $this->authorization_error($this->getSecureSubmitJsError()); } $isAuth = $this->getAuthorizeOrCharge($feed) == 'authorize'; $config = new HpsServicesConfig(); $config->secretApiKey = $this->getSecretApiKey($feed); $config->developerId = '002914'; $config->versionNumber = '1916'; $service = new HpsCreditService($config); $cardHolder = $this->buildCardHolder($feed, $submission_data, $entry); try { $response = $this->getSecureSubmitJsResponse(); $token = new HpsTokenData(); $token->tokenValue = $response != null ? $response->token_value : ''; $transaction = null; if ($isAuth) { $transaction = $service->authorize($submission_data['payment_amount'], GFCommon::get_currency(), $token, $cardHolder); } else { $transaction = $service->charge($submission_data['payment_amount'], GFCommon::get_currency(), $token, $cardHolder); } self::get_instance()->transaction_response = $transaction; if ($this->getSendEmail() == 'yes') { $this->sendEmail($form, $entry, $transaction, $cardHolder); } $type = $isAuth ? 'Authorization' : 'Payment'; $amount_formatted = GFCommon::to_money($submission_data['payment_amount'], GFCommon::get_currency()); $note = sprintf(__('%s has been completed. Amount: %s. Transaction Id: %s.', 'gravityforms-securesubmit'), $type, $amount_formatted, $transaction->transactionId); if ($isAuth) { $note .= sprintf(__(' Authorization Code: %s', 'gravityforms-securesubmit'), $transaction->authorizationCode); } $auth = array('is_authorized' => true, 'captured_payment' => array('is_success' => true, 'transaction_id' => $transaction->transactionId, 'amount' => $submission_data['payment_amount'], 'payment_method' => $response->card_type, 'securesubmit_payment_action' => $this->getAuthorizeOrCharge($feed), 'note' => $note)); } catch (HpsException $e) { $auth = $this->authorization_error($e->getMessage()); } return $auth; }
/** * @test * /// Visa authorize should return response code '00'. */ public function testVisaTokenAuthorizeShouldReturnOk() { $token = $this->getToken(TestCreditCard::validVisaCreditCard()); $chargeService = new HpsCreditService(TestServicesConfig::validMultiUseConfig()); $response = $chargeService->authorize(50, "usd", $token, TestCardHolder::validCardHolder()); $this->assertEquals("00", $response->responseCode); }
public function testAuthAndReversalAmex() { $amount = '63.00'; $card = TestCreditCard::validAmexCreditCard(); $card->cvv = null; $chargeSvc = new HpsCreditService(TestServicesConfig::validMultiUseConfig()); $response = $chargeSvc->authorize($amount, "usd", $card); $chargeSvc->capture($response->transactionId); $chargeSvc->reverse($response->transactionId, $amount, 'usd'); if ($response == null) { $this->fail("Response is null."); } $this->assertEquals($response->responseCode, "00"); }
/** * @test /// Visa Auth Dynamic Descriptor test */ public function Visa_Dynamic_Descriptor_Auth() { $txnDescriptor = "Best Company Every"; $testConfig = new TestServicesConfig(); $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig()); $descriptorTest = $chargeSvc->authorize(25, "usd", TestCreditCard::validVisaCreditCard(), TestCardHolder::ValidCardHolder(), false, null, $txnDescriptor); //This is being printed so that you can look it up on the gate way to make sure it actually worked. print_r($descriptorTest->transactionId); $this->assertEquals("0", $descriptorTest->responseCode); }
/** * Creates an authorization transaction through the HpsCreditService */ public function execute() { parent::execute(); $authorizationSvc = new HpsCreditService($this->service->servicesConfig()); return $authorizationSvc->authorize($this->amount, $this->currency, isset($this->card) ? $this->card : $this->token, $this->cardHolder, $this->requestMultiUseToken, $this->details, $this->txnDescriptor, $this->allowPartialAuth, $this->cpcReq); }