Esempio n. 1
0
 public function getHtmlFields()
 {
     $language = JBusinessUtil::getCurrentLanguageCode();
     $html = '';
     $html .= sprintf('<input type="hidden" name="sid" id="sid" value="%s">', $this->accountNumber);
     $html .= sprintf('<input type="hidden" name="mode" id="mode" value="2CO">');
     $html .= sprintf('<input type="hidden" name="li_0_type" id="li_#_type" value="product">');
     $html .= sprintf('<input type="hidden" name="li_0_name" id="li_#_name" value="%s">', $this->itemName);
     $html .= sprintf('<input type="hidden" name="li_0_tangible" id="li_#_tangible" value="N">');
     $html .= sprintf('<input type="hidden" name="li_0_quantity" id="li_#_quantity" value="1">');
     $html .= sprintf('<input type="hidden" name="x_receipt_link_url" id="x_receipt_link_url" value="%s">', $this->returnUrl);
     $html .= sprintf('<input type="hidden" name="li_0_price" value="%.2f" />', $this->amount);
     $html .= sprintf('<input type="hidden" name="currency_code" value="%s" />', $this->currencyCode);
     $html .= sprintf('<input type="hidden" name="merchant_order_id" value="%s" />', $this->itemNumber);
     $html .= sprintf('<input type="hidden" name="lang" value="%s" />', $language);
     $html .= sprintf('<input type="hidden" name="street_address" value="%s" />', $this->billingDetails->address);
     $html .= sprintf('<input type="hidden" name="city" value="%s" />', $this->billingDetails->city);
     $html .= sprintf('<input type="hidden" name="state" value="%s" />', $this->billingDetails->region);
     $html .= sprintf('<input type="hidden" name="zip" value="%s" />', $this->billingDetails->postal_code);
     $html .= sprintf('<input type="hidden" name="country" value="%s" />', $this->billingDetails->country);
     $html .= sprintf('<input type="hidden" name="phone" value="%s" />', $this->billingDetails->phone);
     $html .= sprintf('<input type="hidden" name="card_holder_name" value="%s" />', $this->billingDetails->first_name . " " . $this->billingDetails->last_name);
     $html .= sprintf('<input type="hidden" name="email" value="%s" />', $this->billingDetails->email);
     return $html;
 }
Esempio n. 2
0
 public function processTransaction($data)
 {
     $appSettings = JBusinessUtil::getInstance()->getApplicationSettings();
     $language = JBusinessUtil::getCurrentLanguageCode();
     $this->returnUrl = urlencode(JRoute::_('index.php?option=com_jbusinessdirectory&task=payment.processResponse&processor=eway', false, -1));
     $this->cancelUrl = urlencode(JRoute::_('index.php?option=com_jbusinessdirectory&task=payment.processCancelResponse&processor=eway', false, -1));
     $result = new stdClass();
     $result->transaction_id = 0;
     $result->amount = $data->amount;
     $result->payment_date = date("Y-m-d");
     $result->response_code = 0;
     $result->order_id = $data->id;
     $result->currency = $data->currency;
     $result->processor_type = $this->type;
     $ewayurl = "";
     $ewayurl .= "?CustomerID=" . $this->customerId;
     $ewayurl .= "&UserName="******"&Amount=" . $data->amount;
     $ewayurl .= "&Currency=" . $data->currency;
     $ewayurl .= "&PageTitle=" . $data->service;
     $ewayurl .= "&PageDescription=" . $data->service . " " . $data->description;
     $ewayurl .= "&Language=" . $language;
     $ewayurl .= "&CompanyName=" . $appSettings->company_name;
     $ewayurl .= "&CustomerFirstName=" . $data->billingDetails->first_name;
     $ewayurl .= "&CustomerLastName=" . $data->billingDetails->last_name;
     $ewayurl .= "&CustomerAddress=" . $data->billingDetails->address;
     $ewayurl .= "&CustomerCity=" . $data->billingDetails->city;
     $ewayurl .= "&CustomerState=" . $data->billingDetails->region;
     $ewayurl .= "&CustomerPostCode=" . $data->billingDetails->postal_code;
     $ewayurl .= "&CustomerCountry=" . $data->billingDetails->country;
     $ewayurl .= "&CustomerPhone=" . $data->billingDetails->phone;
     $ewayurl .= "&CustomerEmail=" . $data->billingDetails->email;
     $ewayurl .= "&InvoiceDescription=" . $data->service . " " . $data->description;
     $ewayurl .= "&CancelURL=" . $this->cancelUrl;
     $ewayurl .= "&ReturnUrl=" . $this->returnUrl;
     //$ewayurl.="&CompanyLogo=".$_POST['CompanyLogo'];
     //$ewayurl.="&PageBanner=".$_POST['(PageBanner'];
     $ewayurl .= "&MerchantReference=" . $data->id;
     //$ewayurl.="&MerchantInvoice=".$_POST['Invoice'];
     $spacereplace = str_replace(" ", "%20", $ewayurl);
     $posturl = "https://nz.ewaygateway.com/Request/{$spacereplace}";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $posturl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     if (defined("CURL_PROXY_REQUIRED") && CURL_PROXY_REQUIRED == 'True') {
         $proxy_tunnel_flag = defined('CURL_PROXY_TUNNEL_FLAG') && strtoupper(CURL_PROXY_TUNNEL_FLAG) == 'FALSE' ? false : true;
         curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_tunnel_flag);
         curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
         curl_setopt($ch, CURLOPT_PROXY, CURL_PROXY_SERVER_DETAILS);
     }
     $response = curl_exec($ch);
     $responsemode = $this->fetch_data($response, '<result>', '</result>');
     $responseurl = $this->fetch_data($response, '<uri>', '</uri>');
     $this->paymentUrl = $responseurl;
     if ($responsemode == "True") {
         $result->status = PAYMENT_REDIRECT;
         $result->payment_status = PAYMENT_STATUS_PENDING;
     } else {
         $result->status = PAYMENT_ERROR;
         $result->payment_status = PAYMENT_STATUS_FAILURE;
     }
     return $result;
 }