static function getOrderPaymentResponse($payment_params, $order_number)
 {
     $xml = '<inquiry><orderInquiry orderCode="' . $order_number . '"/></inquiry>';
     $xmlResult = self::sendXML($payment_params, $xml);
     if (!empty($xmlResult)) {
         $xmlElement = new SimpleXMLElement($xmlResult);
         $xmlArray = self::xml2phpArray($xmlElement);
         if (!empty($payment_params->showVars)) {
             self::showXMLReply($xmlArray);
         }
         if (!rbsglobalgateway_helper::validService($xmlArray, $payment_params)) {
             return null;
         }
         $orderStatus = $xmlArray['reply'][0]['orderStatus'][0];
         if ($orderStatus['orderCode'] != $order_number) {
             rbsglobalgateway_helper::raiseError($payment_params->showVars, 'ERROR -> Order ID mismatch.');
             return NULL;
         }
     }
     return $xmlResult;
 }
예제 #2
0
 function onAfterOrderConfirm(&$order, &$methods, $method_id)
 {
     $method =& $methods[$method_id];
     $currencyClass = hikashop_get('class.currency');
     $currencies = null;
     $currencies = $currencyClass->getCurrencies($order->order_currency_id, $currencies);
     $currency = $currencies[$order->order_currency_id];
     $method->payment_params->_exponent = (int) $currency->currency_locale['int_frac_digits'];
     $method->payment_params->_currency_symbol = $currency->currency_symbol;
     $method->payment_params->payment_type = $method->payment_type;
     $user = hikashop_loadUser(true);
     $lang = JFactory::getLanguage();
     $locale = strtolower(substr($lang->get('tag'), 0, 2));
     if (!empty($method->payment_params->instid)) {
         $method->payment_params->contactInformation = null;
         $method->payment_params->billingNotice = null;
     }
     $xml = '<submit>';
     $xml .= '<order orderCode="' . $order->order_number . '"';
     if (!empty($method->payment_params->instid)) {
         $xml .= ' installationId="' . $method->payment_params->instid . '"';
     }
     $xml .= '>';
     $xml .= '<description>' . htmlspecialchars($method->payment_params->description) . '</description>';
     $xml .= '<amount value="' . round($order->order_full_price * pow(10, $method->payment_params->_exponent)) . '" ' . 'currencyCode="' . $currency->currency_code . '" ' . 'exponent="' . $method->payment_params->_exponent . '"/>';
     $cdata = null;
     if (empty($method->payment_params->instid)) {
         if (!empty($method->payment_params->orderContentCSS)) {
             $cdata .= '<style type="text/css">' . rbsglobalgateway_helper::parseCSS($method->payment_params->orderContentCSS) . '</style>';
         }
     }
     $cdata .= $this->_display($method->payment_params, $order, $user);
     $xml .= '<orderContent><![CDATA[' . $cdata . ']]></orderContent>';
     $xml .= '<paymentMethodMask>';
     foreach (preg_split('/[, ]+/', $method->payment_params->paymentMethodMask) as $include) {
         if (!empty($include)) {
             $xml .= '<include code="' . $include . '"/>';
         }
     }
     $xml .= '</paymentMethodMask>';
     $xml .= '<shopper>';
     $xml .= '<shopperEmailAddress>' . $user->user_email . '</shopperEmailAddress>';
     $xml .= '</shopper>';
     if (!empty($method->payment_params->address_type)) {
         switch ($method->payment_params->address_type) {
             case 'billing':
                 $xml .= rbsglobalgateway_helper::xmlAddress($method->payment_params, $user, $order, 'billing_address', 'shippingAddress');
                 break;
             case 'shipping':
             case 'billing,shipping':
             case 'shipping,billing':
                 $xml .= rbsglobalgateway_helper::xmlAddress($method->payment_params, $user, $order, 'shipping_address', 'shippingAddress');
                 break;
         }
     }
     $xml .= '</order>';
     $xml .= '</submit>';
     $xmlResult = rbsglobalgateway_helper::sendXML($method->payment_params, $xml);
     if (empty($xmlResult)) {
         return false;
     }
     $xmlElement = new SimpleXMLElement($xmlResult);
     $xmlArray = rbsglobalgateway_helper::xml2phpArray($xmlElement);
     if (!empty($method->payment_params->showVars)) {
         rbsglobalgateway_helper::showXMLReply($xmlArray);
     }
     if (!rbsglobalgateway_helper::validService($xmlArray, $method->payment_params)) {
         return false;
     }
     $error = @$xmlArray['reply'][0]['error'][0];
     if (!empty($error)) {
         self::raiseError($payment_params->showVars, 'ERROR (' . $error['code'] . ')<br />' . $error[0]);
         return false;
     }
     $orderStatus = $xmlArray['reply'][0]['orderStatus'][0];
     if ($orderStatus['orderCode'] != $order->order_number) {
         rbsglobalgateway_helper::raiseError($method->payment_params->showVars, 'ERROR -> Order ID mismatch.');
         return false;
     }
     $reference = $orderStatus['reference'][0];
     $RBSRedirectURL = $reference[0];
     if (empty($RBSRedirectURL)) {
         rbsglobalgateway_helper::raiseError($method->payment_params->showVars, 'ERROR -> Redirect URL not specified.');
         return false;
     }
     $RBSPaymentReference = $xmlElement->reply->orderStatus->reference['id'];
     if (empty($RBSPaymentReference)) {
         rbsglobalgateway_helper::raiseError($method->payment_params->showVars, 'ERROR -> Payment reference not specified.');
         return false;
     }
     rbsglobalgateway_helper::saveRBSReference($order->order_id, $method->payment_params->paymentRefField, $RBSPaymentReference);
     $vars = array('country' => 'GB', 'language' => 'EN');
     if (empty($method->payment_params->instid)) {
         if (!empty($method->payment_params->bodyAttr)) {
             $RBSRedirectURL .= '&bodyAttr=' . rbsglobalgateway_helper::encodeAttribute($method->payment_params->bodyAttr);
         }
         if (!empty($method->payment_params->fontAttr)) {
             $RBSRedirectURL .= '&fontAttr=' . rbsglobalgateway_helper::encodeAttribute($method->payment_params->fontAttr);
         }
     }
     if ($method->payment_params->notification) {
         $vars['successURL'] = rbsglobalgateway_helper::notificationURL($method->payment_params, $locale);
         $vars['pendingURL'] = rbsglobalgateway_helper::notificationURL($method->payment_params, $locale);
         $vars['failureURL'] = rbsglobalgateway_helper::notificationURL($method->payment_params, $locale);
         $vars['cancelURL'] = rbsglobalgateway_helper::notificationURL($method->payment_params, $locale);
     }
     if (!HIKASHOP_J30) {
         JHTML::_('behavior.mootools');
     } else {
         JHTML::_('behavior.framework');
     }
     $app = JFactory::getApplication();
     $name = $method->payment_type . '_end.php';
     $path = JPATH_THEMES . DS . $app->getTemplate() . DS . 'hikashoppayment' . DS . $name;
     if (!file_exists($path)) {
         if (version_compare(JVERSION, '1.6', '<')) {
             $path = JPATH_PLUGINS . DS . 'hikashoppayment' . DS . $name;
         } else {
             $path = JPATH_PLUGINS . DS . 'hikashoppayment' . DS . $method->payment_type . DS . $name;
         }
         if (!file_exists($path)) {
             return true;
         }
     }
     require $path;
     return true;
 }