public function getBalanceAction() { try { $giftCardNumber = $this->getRequest()->getParam('giftcard_number'); if (!$giftCardNumber) { throw new Mage_Core_Exception($this->__('No number received.')); } $config = new HpsServicesConfig(); $config->secretApiKey = Mage::getModel('hps_securesubmit/payment')->getConfigData('secretapikey'); $config->versionNumber = '1573'; $config->developerId = '002914'; $giftService = new HpsGiftCardService($config); try { $card = new HpsGiftCard(); $card->number = $_GET["giftcard_number"]; $response = $giftService->balance($card); $result = array('error' => FALSE, 'balance' => $response->balanceAmount); } catch (HpsException $e) { $result = array('error' => TRUE, 'message' => $e->getMessage()); } } catch (Mage_Core_Exception $e) { $result = array('error' => TRUE, 'message' => $e->getMessage()); } catch (Exception $e) { Mage::logException($e); $result = array('error' => TRUE, 'message' => $this->__('An unexpected error occurred retrieving your stored card. We apologize for the inconvenience, please contact us for further support.')); } $this->getResponse()->setHeader('Content-Type', 'application/json', TRUE); $this->getResponse()->setBody(json_encode($result)); }
public function testGiftCardManualCardShouldReverseUsingGiftCard() { $giftService = new HpsGiftCardService(TestServicesConfig::ValidMultiUseConfig()); $response = $giftService->sale(TestGiftCard::validGiftCardNotEncrypted(), 10.0); $this->assertEquals('0', $response->responseCode); $reverseResponse = $giftService->reverse(TestGiftCard::validGiftCardNotEncrypted(), 10.0); $this->assertEquals('0', $reverseResponse->responseCode); }
/** * Creates a balance transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $balanceSvc = new HpsGiftCardService($this->service->servicesConfig()); return $balanceSvc->balance($this->card); }
/** * Creates an addValue transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $addValueSvc = new HpsGiftCardService($this->service->servicesConfig()); return $addValueSvc->addValue($this->amount, $this->currency, $this->card); }
<?php require_once "../../Hps.php"; $config = new HpsServicesConfig(); $config->secretApiKey = 'skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ'; $config->versionNumber = '0000'; $config->developerId = '000000'; $giftService = new HpsGiftCardService($config); try { $card = new HpsGiftCard(); $card->number = $_GET["card-number"]; $response = $giftService->sale($card, 1.0); } catch (HpsException $e) { echo $e->getMessage(); } //echo $response->responseCode; echo "Transaction Id: " . $response->transactionId;
/** * Creates a sale transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $saleSvc = new HpsGiftCardService($this->service->servicesConfig()); return $saleSvc->sale($this->card, $this->amount, $this->currency, $this->gratuity, $this->tax); }
/** * Creates an alias transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $aliasSvc = new HpsGiftCardService($this->service->servicesConfig()); return $aliasSvc->alias($this->action, $this->card, $this->alias); }
/** * @expectedException HpsException * @expectedExceptionMessage The pin is invalid * @expectedExceptionCode HpsExceptionCodes::INVALID_PIN */ public function testGiftCardManualCardWithInvalidPin() { $giftService = new HpsGiftCardService(TestServicesCOnfig::validMultiUseConfig()); $response = $giftService->sale(TestGiftCard::validGiftCardNotEncrypted(), 3.05); }
/** * Creates a reverse transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $reverseSvc = new HpsGiftCardService($this->service->servicesConfig()); return $reverseSvc->reverse(isset($this->card) ? $this->card : $this->transactionId, $this->amount, $this->currency); }
/** * Creates a void transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $voidSvc = new HpsGiftCardService($this->service->servicesConfig()); return $voidSvc->void($this->transactionId); }
/** * Creates a replace transaction through the HpsGiftCardService */ public function execute() { parent::execute(); $replaceSvc = new HpsGiftCardService($this->service->servicesConfig()); return $replaceSvc->replace($this->oldCard, $this->newCard); }