Exemplo n.º 1
0
 public function config($urls)
 {
     //$returnUrl = $this->getUrl('wirecard_checkoutpage/processing/return', array('_secure' => true, '_nosid' => true));
     $returnUrl = $urls['return'];
     $init = new \WirecardCEE_QPay_FrontendClient($this->_dataHelper->getConfigArray());
     $init->setPluginVersion($this->_dataHelper->getPluginVersion());
     $init->setOrderReference('Configtest #' . uniqid());
     if ($this->_dataHelper->getConfigData('options/sendconfirmemail')) {
         $init->setConfirmMail($this->_dataHelper->getStoreConfigData('trans_email/ident_general/email'));
     }
     $consumerData = new \WirecardCEE_Stdlib_ConsumerData();
     $consumerData->setIpAddress($this->_dataHelper->getClientIp());
     $consumerData->setUserAgent($this->_dataHelper->getUserAgent());
     $init->setAmount(10)->setCurrency('EUR')->setPaymentType(\WirecardCEE_QPay_PaymentType::SELECT)->setOrderDescription('Configtest #' . uniqid())->setSuccessUrl($returnUrl)->setPendingUrl($returnUrl)->setCancelUrl($returnUrl)->setFailureUrl($returnUrl)->setConfirmUrl($urls['confirm'])->setServiceUrl($this->_dataHelper->getConfigData('options/service_url'))->setConsumerData($consumerData);
     if (strlen($this->_dataHelper->getConfigData('options/bgcolor'))) {
         $init->setBackgroundColor($this->_dataHelper->getConfigData('options/bgcolor'));
     }
     if (strlen($this->_dataHelper->getConfigData('options/displaytext'))) {
         $init->setDisplayText($this->_dataHelper->getConfigData('options/displaytext'));
     }
     if (strlen($this->_dataHelper->getConfigData('options/imageurl'))) {
         $init->setImageUrl($this->_dataHelper->getConfigData('options/imageurl'));
     }
     $initResponse = $init->initiate();
     if ($initResponse->getStatus() == \WirecardCEE_QPay_Response_Initiation::STATE_FAILURE) {
         $msg = $initResponse->getError()->getConsumerMessage();
         if (!strlen($msg)) {
             $msg = $initResponse->getError()->getMessage();
         }
         throw new \Exception($msg);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * @return WirecardCEE_Stdlib_ConsumerData
  * @throws Zend_Controller_Request_Exception
  */
 protected function _getConsumerData()
 {
     $consumerData = new WirecardCEE_Stdlib_ConsumerData();
     $consumerData->setIpAddress(Mage::app()->getRequest()->getServer('REMOTE_ADDR'));
     $consumerData->setUserAgent(Mage::app()->getRequest()->getHeader('User-Agent'));
     $deliveryAddress = $this->getOrder()->getShippingAddress();
     $billingAddress = $this->getOrder()->getBillingAddress();
     $dob = $this->getCustomerDob();
     if ($this->_forceSendAdditionalData || $this->_getHelper()->getConfigData('options/sendadditionaldata')) {
         $consumerData->setEmail($this->getOrder()->getCustomerEmail());
         if ($dob !== false) {
             $consumerData->setBirthDate($dob);
         }
         $consumerData->addAddressInformation($this->_getAddress($billingAddress, 'billing'));
         $consumerData->addAddressInformation($this->_getAddress($deliveryAddress, 'shipping'));
     }
     return $consumerData;
 }
 /**
  * Checks to see if the consumer data object is set and has at least madatory fields set
  *
  * @return boolean
  */
 protected function _isConsumerDataValid()
 {
     // if consumer data is not an instance of WirecardCEE_Stdlib_ConsumerData
     // or if it's empty don't even bother with any checkings...
     if (empty($this->oConsumerData) || !$this->oConsumerData instanceof WirecardCEE_Stdlib_ConsumerData) {
         return false;
     }
     // @see WirecardCEE_QMore_Request_Initiation_ConsumerData
     $sConsumerIpAddressField = WirecardCEE_Stdlib_ConsumerData::getConsumerIpAddressFieldName();
     $sConsumerUserAgentField = WirecardCEE_Stdlib_ConsumerData::getConsumerUserAgentFieldName();
     // get all the consumer data in an array
     // @todo when 5.4 becomes available on our server we coulde use eg. $this->oConsumerData->getData()[$sConsumerIpAddressField]
     $aConsumerData = $this->oConsumerData->getData();
     // check
     return isset($aConsumerData[$sConsumerIpAddressField]) && !empty($aConsumerData[$sConsumerIpAddressField]) && (isset($aConsumerData[$sConsumerUserAgentField]) && !empty($aConsumerData[$sConsumerUserAgentField]));
 }
 /**
  * Tests WirecardCEE_QMore_FrontendClient->getResponse()
  */
 public function testGetResponse()
 {
     $consumerData = new WirecardCEE_Stdlib_ConsumerData();
     $consumerData->setIpAddress('10.1.0.11');
     $consumerData->setUserAgent('phpUnit');
     $this->object->setAmount(100)->setCurrency('eur')->setPaymentType(WirecardCEE_QMore_PaymentType::PAYPAL)->setOrderDescription(__METHOD__)->setSuccessUrl('http://foo.bar.com/tests/confirm.php')->setCancelUrl('http://foo.bar.com/tests/confirm.php')->setFailureUrl('http://foo.bar.com/tests/confirm.php')->setServiceUrl('http://foo.bar.com/tests/confirm.php')->setConfirmUrl('http://foo.bar.com/tests/confirm.php')->setConsumerData($consumerData)->initiate();
     $oResponse = $this->object->getResponse();
     $this->assertInstanceOf('WirecardCEE_QMore_Response_Initiation', $oResponse);
     $this->assertEquals($oResponse->getStatus(), 0);
     $this->assertEmpty($oResponse->getErrors());
     $this->assertStringStartsWith('https://', $oResponse->getRedirectUrl());
 }
 public function testGetData()
 {
     $data = $this->object->getData();
     $this->assertInternalType('array', $data);
 }
Exemplo n.º 6
0
 /**
  * @param Quote $quote
  *
  * @return \WirecardCEE_Stdlib_ConsumerData
  */
 protected function _getConsumerData($quote)
 {
     $consumerData = new \WirecardCEE_Stdlib_ConsumerData();
     $consumerData->setIpAddress($this->_dataHelper->getClientIp());
     $consumerData->setUserAgent($this->_dataHelper->getUserAgent());
     $deliveryAddress = $quote->getShippingAddress();
     $billingAddress = $quote->getBillingAddress();
     $dob = $this->getCustomerDob($quote);
     $consumerData->setEmail($quote->getCustomerEmail());
     if ($dob !== false) {
         $consumerData->setBirthDate($dob);
     }
     if (strlen($billingAddress->getCompany())) {
         $consumerData->setCompanyName($billingAddress->getCompany());
     }
     if (strlen($billingAddress->getVatId())) {
         $consumerData->setCompanyVatId($billingAddress->getVatId());
     }
     if ($this->_forceSendAdditionalData || $this->_dataHelper->getConfigData('options/sendbillingdata')) {
         $consumerData->addAddressInformation($this->_getAddress($billingAddress, 'billing'));
     }
     if ($this->_forceSendAdditionalData || $this->_dataHelper->getConfigData('options/sendshippingdata')) {
         $consumerData->addAddressInformation($this->_getAddress($deliveryAddress, 'shipping'));
     }
     return $consumerData;
 }