/**
  * Creates a cpcEdit transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $cpcEditSvc = new HpsCreditService($this->service->servicesConfig());
     return $cpcEditSvc->cpcEdit($this->transactionId, $this->cpcData);
 }
 /**
  * Creates a listTransactions transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $listTransactionsSvc = new HpsCreditService($this->service->servicesConfig());
     return $listTransactionsSvc->listTransactions($this->startDate, $this->endDate, $this->filterBy);
 }
 /**
  * Creates a verify transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $verifySvc = new HpsCreditService($this->service->servicesConfig());
     return $verifySvc->verify(isset($this->card) ? $this->card : $this->token, $this->cardHolder, $this->requestMultiUseToken, $this->clientTransactionId);
 }
 public function testGatewayResponseAccessible()
 {
     $chargeSvc = new HpsCreditService(TestServicesConfig::validMultiUseConfig());
     echo $response = $chargeSvc->charge(10, 'usd', TestCreditCard::validVisaCreditCard(), TestCardHolder::validCardHolder());
     $this->assertEquals('00', $response->responseCode);
     $this->assertNotNull($response->gatewayResponse()->code);
     $this->assertNotNull($response->gatewayResponse()->message);
 }
 /**
  * @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);
 }
Exemple #6
0
 public function testCvvWithLeadingZero()
 {
     $chargeSvc = new HpsCreditService(TestServicesConfig::validMultiUseConfig());
     $card = new HpsCreditCard();
     $card->number = "4111111111111111";
     $card->expMonth = 12;
     $card->expYear = 2025;
     $card->cvv = "012";
     $response = $chargeSvc->charge(10, 'usd', $card, TestCardHolder::validCardHolder());
     $this->assertEquals('00', $response->responseCode);
     $this->assertNotNull($response->gatewayResponse()->code);
     $this->assertNotNull($response->gatewayResponse()->message);
 }
 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;
 }
 private function chargeValidVisa($amt, $multiUseRequest = false, $details = null, $txnDescriptors = null)
 {
     $testConfig = new TestServicesConfig();
     $chargeSvc = new HpsCreditService($testConfig->validMultiUseConfig());
     $response = $chargeSvc->charge($amt, "usd", TestCreditCard::validVisaCreditCard(), TestCardHolder::ValidCardHolder(), $multiUseRequest, $details, $txnDescriptors);
     if ($response == null) {
         $this->fail("Response is null.");
     }
     return $response;
 }
 /**
  * @test
  * /// Visa Token refund test with token
  */
 public function testVisaTokenReverseShouldBeOk()
 {
     $testConfig = new TestServicesConfig();
     $token = $this->getToken(TestCreditCard::validVisaCreditCard());
     $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig());
     $reverse = $chargeSvc->reverse($token, 50, 'usd');
     $this->assertEquals('00', $reverse->responseCode);
 }
 function _process()
 {
     $app = JFactory::getApplication();
     $data = $app->input->getArray($_POST);
     $api_key = $this->_secret_key;
     // get order data from table using response data
     $json = array();
     if (!JRequest::checkToken()) {
         $json['error'] = JText::_('J2STORE_HEARTLAND_INVALID_TOKEN');
     }
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     $order = JTable::getInstance('Orders', 'Table');
     $order->load($data['orderpayment_id']);
     $error = false;
     // validate order and params
     if (empty($data['hearttoken'])) {
         $json['error'] = JText::_('J2STORE_HEARTLAND_TOKEN_MISSING');
         $error = true;
     }
     if (empty($order->order_id)) {
         $json['error'] = JText::_('J2STORE_HEARTLAND_INVALID_ORDER');
         $error = true;
     }
     if (empty($api_key)) {
         $json['error'] = JText::_('J2STORE_HEARTLAND_MESSAGE_MISSING_LOGIN_APIKEY');
         $error = true;
     }
     // erroring:
     if (!$error) {
         try {
             // heartland config code
             $config = new HpsServicesConfig();
             $config->secretApiKey = $api_key;
             $config->versionNumber = '1929';
             $config->developerId = '002914';
             $chargeService = new HpsCreditService($config);
             // add cardholder details
             $address = new HpsAddress();
             $address->address = html_entity_decode($data['address'], ENT_QUOTES, 'UTF-8');
             $address->city = html_entity_decode($data['city'], ENT_QUOTES, 'UTF-8');
             $address->state = html_entity_decode($data['region'], ENT_QUOTES, 'UTF-8');
             $address->country = html_entity_decode($data['country'], ENT_QUOTES, 'UTF-8');
             $address->zip = html_entity_decode($data['postal_code'], ENT_QUOTES, 'UTF-8');
             $cardHolder = new HpsCardHolder();
             $cardHolder->firstName = html_entity_decode($data['first_name'], ENT_QUOTES, 'UTF-8');
             $cardHolder->lastName = html_entity_decode($data['last_name'], ENT_QUOTES, 'UTF-8');
             $cardHolder->email = $data['email'];
             $cardHolder->address = $address;
             $currency_values = $this->getCurrency($order);
             $orderpayment_amount = $this->getAmount($data['orderpayment_amount'], $currency_values['currency_code'], $curency_value, true);
             $suToken = new HpsTokenData();
             $suToken->tokenValue = $data['hearttoken'];
             $response = $chargeService->charge($orderpayment_amount, strtolower($currency_values['currency_code']), $suToken, $cardHolder);
             $data['transaction_details'] = $response;
             if (isset($response->transactionId)) {
                 $data['transaction_id'] = (string) $response->transactionId;
             }
             if (isset($response->responseText)) {
                 $data['status'] = (string) $response->responseText;
             }
         } catch (HpsException $e) {
             $json['error'] = $e;
         }
     }
     if (empty($data['transaction_id'])) {
         $json['error'] = JText::_('J2STORE_HEARTLAND_MESSAGE_MISSING_TRANSACTION_ID');
     }
     if (empty($data['status'])) {
         $json['error'] = JText::_('J2STORE_HEARTLAND_MESSAGE_MISSING_TRANSACTION_STATUS');
     }
     if (!$json) {
         // change order status and log data
         $order->transaction_details = $data['transaction_details'];
         $order->transaction_id = $data['transaction_id'];
         $order->transaction_status = $data['status'];
         // TODO:we have to check confirm status message
         if ($data['status'] == "APPROVAL") {
             $order->order_state = trim(JText::_('J2STORE_CONFIRMED'));
             // CONFIRMED
             $order->order_state_id = 1;
             // CONFIRMED
             $order->paypal_status = @$data['status'];
             // Paypal's original status
             JLoader::register('J2StoreHelperCart', JPATH_SITE . '/components/com_j2store/helpers/cart.php');
             // remove items from cart
             // J2StoreHelperCart::removeOrderItems( $orderpayment->id );
             if (!empty($data['cart_session_id'])) {
                 // load session with id
                 $options = array('id' => $data['cart_session_id']);
                 $session = JFactory::getSession($options);
                 $session->set('j2store_cart', array());
             }
         } else {
             // failed status
             $order->order_state = JText::_('J2STORE_FAILED');
             // FAILED
             $order->order_state_id = 3;
             // FAILED
         }
         if ($order->store()) {
         } else {
             $json['error'] = $order->getError();
         }
     }
     if (!$json) {
         $json['success'] = JText::_($this->params->get('onafterpayment', ''));
         $json['redirect'] = JRoute::_('index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=' . $this->_element . '&paction=display');
         require_once JPATH_SITE . '/components/com_j2store/helpers/orders.php';
         J2StoreOrdersHelper::sendUserEmail($order->user_id, $order->order_id, $data['status'], $order->order_state, $order->order_state_id);
     } else {
         $this->_sendErrorEmails($error, $data['transaction_details']);
     }
     return $json;
 }
 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 refund test with token
 */
 public function Visa_Token_Refund_ShouldBe_Ok()
 {
     $testConfig = new TestServicesConfig();
     $token = $this->_getToken(TestCreditCard::validVisaCreditCard());
     $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig());
     $response = $chargeSvc->refund(15.15, "usd", $token, TestCardHolder::certCardHolderShortZip());
     $this->assertEquals($response->responseCode, "0");
 }
 /**
  * Creates a charge transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $chargeSvc = new HpsCreditService($this->service->servicesConfig());
     return $chargeSvc->charge($this->amount, $this->currency, isset($this->card) ? $this->card : $this->token, $this->cardHolder, $this->requestMultiUseToken, $this->details, $this->txnDescriptor, $this->allowPartialAuth, $this->cpcReq, $this->directMarketData);
 }
<?php

use Tygh\Registry;
if (!defined('AREA')) {
    die('Access denied');
}
if (defined('PAYMENT_NOTIFICATION')) {
    if ($mode == 'return' && !empty($_REQUEST['merchant_order_id'])) {
        include_once 'heartland/Hps.php';
        $merchant_order_id = heartlandplace_order($_REQUEST['merchant_order_id']);
        $order_info = fn_get_session_data('order_info');
        $config = new HpsServicesConfig();
        $config->secretApiKey = fn_get_session_data('secretkey');
        $config->versionNumber = '2102';
        $config->developerId = '002914';
        $chargeService = new HpsCreditService($config);
        $address = new HpsAddress();
        $address->address = $order_info['b_address'];
        $address->city = $order_info['b_city'];
        $address->state = $order_info['b_state'];
        $address->zip = preg_replace('/[^0-9]/', '', $order_info['b_zipcode']);
        $address->country = $order_info['b_country'];
        $validCardHolder = new HpsCardHolder();
        $validCardHolder->firstName = $order_info['b_firstname'];
        $validCardHolder->lastName = $order_info['b_lastname'];
        $validCardHolder->address = $address;
        $validCardHolder->phoneNumber = preg_replace('/[^0-9]/', '', $order_info['b_phone']);
        $suToken = new HpsTokenData();
        $suToken->tokenValue = $_REQUEST['securesubmit_token'];
        try {
            $pp_response = array('reason_text' => '', 'order_status' => 'F');
 /**
  * @test
  * /// Visa Reverse multi Token tests
  */
 public function testVisaMultiTokenReverseShouldBeOk()
 {
     $testConfig = new TestServicesConfig();
     $token = $this->getToken(TestCreditCard::validVisaCreditCard());
     $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig());
     $chargeResponse = $chargeSvc->charge(17.01, 'usd', $token, null, true);
     $this->assertEquals($chargeResponse->responseCode, "0");
     $muToken = $chargeResponse->tokenData;
     $response = $chargeSvc->reverse($muToken, 17.01, "usd");
     $this->assertEquals($response->responseCode, "0");
 }
 /**
  * Creates an edit transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $editSvc = new HpsCreditService($this->service->servicesConfig());
     return $editSvc->edit($this->transactionId, $this->amount, $this->gratuity, $this->clientTransactionId);
 }
 /**
  * Creates a void transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $voidSvc = new HpsCreditService($this->service->servicesConfig());
     return $voidSvc->void($this->transactionId);
 }
 /**
  * Creates a refund transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $refundSvc = new HpsCreditService($this->service->servicesConfig());
     return $refundSvc->refund($this->amount, $this->currency, isset($this->card) ? $this->card : (isset($this->token) ? $this->token : $this->transactionId), $this->cardHolder, $this->details);
 }
Exemple #19
0
 public function testSecretKeyWhitespaceTrimming()
 {
     $keyConfig = TestServicesConfig::validMultiUseConfig();
     $keyConfig->secretApiKey = " " . $keyConfig->secretApiKey . "  ";
     $chargeSvc = new HpsCreditService($keyConfig);
     $card = new HpsCreditCard();
     $card->number = "4111111111111111";
     $card->expMonth = 12;
     $card->expYear = 2025;
     $card->cvv = "012";
     $response = $chargeSvc->charge(10, 'usd', $card, TestCardHolder::validCardHolder());
     $this->assertEquals('00', $response->responseCode);
     $this->assertNotNull($response->gatewayResponse()->code);
     $this->assertNotNull($response->gatewayResponse()->message);
 }
 private function chargeValidDiscover($amt)
 {
     $testConfig = new TestServicesConfig();
     $chargeSvc = new HpsCreditService($testConfig->ValidMultiUseConfig());
     $response = $chargeSvc->charge($amt, "usd", TestCreditCard::validDiscoverCreditCard(), TestCardHolder::ValidCardHolder());
     if ($response == null) {
         $this->fail("Response is null.");
     }
     return $response;
 }
 /**
  * Creates a capture transaction through the HpsCreditService
  */
 public function execute()
 {
     parent::execute();
     $captureSvc = new HpsCreditService($this->service->servicesConfig());
     return $captureSvc->capture($this->transactionId, $this->amount, $this->gratuity, $this->clientTransactionId, $this->directMarketData);
 }