Example #1
0
 /**
  * Returns object as JSON.
  * Note that numeric values are without decimal point, ie 12.34 will be written as 1234.
  * @return string
  */
 public function toJSON()
 {
     $result = '{';
     $result .= '"first_name": ' . TpEscaper::jsonEncode($this->customer->getFirstName()) . ', ';
     $result .= '"last_name": ' . TpEscaper::jsonEncode($this->customer->getLastName()) . ', ';
     $result .= '"currency": ' . TpEscaper::jsonEncode($this->cart->getCurrency()) . ', ';
     $result .= '"amount": ' . TpEscaper::jsonEncode($this->cart->getTotalAmountWithoutDecimal()) . ', ';
     $mobilePhone = $this->customer->getMobilePhone();
     if (!is_null($mobilePhone) && $mobilePhone != "") {
         $result .= '"mobile_phone": ' . TpEscaper::jsonEncode($mobilePhone) . ', ';
     }
     $result .= '"city": ' . TpEscaper::jsonEncode($this->customer->getCity()) . ', ';
     $result .= '"postal_code": ' . TpEscaper::jsonEncode($this->customer->getPostalCode()) . ', ';
     $result .= '"address": ' . TpEscaper::jsonEncode($this->customer->getAddress()) . ', ';
     $result .= '"email": ' . TpEscaper::jsonEncode($this->customer->getEmail()) . ',';
     $result .= '"shopping_cart": ' . $this->cart->toJSON() . '}';
     return $result;
 }
 /**
  * Return the HTML code for the iframe.
  */
 function render()
 {
     $url = $this->payment->getMerchantConfig()->gateUrl;
     $queryArgs = array_filter(array('skin' => $this->skin));
     $out = "";
     if (!$this->disableButtonCss) {
         $skin = $this->skin == "" ? "" : "/{$this->skin}";
         $href = "{$url}div/style{$skin}/div.css?v=" . time();
         $href = TpEscaper::htmlEntityEncode($href);
         $out .= "<link href=\"{$href}\" type=\"text/css\" rel=\"stylesheet\" />\n";
     }
     $thepayGateUrl = $url . 'div/index.php?' . $this->buildQuery($queryArgs);
     $thepayGateUrl = TpEscaper::jsonEncode($thepayGateUrl);
     $disableThepayPopupCss = TpEscaper::jsonEncode($this->disablePopupCss);
     $out .= "<script type=\"text/javascript\">";
     $out .= "\tvar thepayGateUrl = {$thepayGateUrl},\n";
     $out .= "\t\tdisableThepayPopupCss = {$disableThepayPopupCss};\n";
     $out .= "</script>\n";
     $src = "{$url}div/js/jquery.js?v=" . time();
     $src = TpEscaper::htmlEntityEncode($src);
     $out .= "<script type=\"text/javascript\" src=\"{$src}\" async=\"async\"></script>\n";
     $src = "{$url}div/js/div.js?v=" . time();
     $src = TpEscaper::htmlEntityEncode($src);
     $out .= "<script type=\"text/javascript\" src=\"{$src}\" async=\"async\"></script>\n";
     $out .= "<div id=\"thepay-method-box\" style=\"border: 0;\"></div>\n";
     return $out;
 }
Example #3
0
 /**
  * Returns object as JSON.
  * Note that numeric values are without decimal point, ie 12.34 will be written as 1234.
  * @return string
  */
 public function toJSON()
 {
     return TpEscaper::jsonEncode(array('name' => $this->name, 'description' => $this->description, 'quantity' => $this->quantity, 'price' => $this->price));
 }
 /**
  * Show instruction for offline payment if ThePay payment method is selected and this method is offline.
  * Show output of this method somewhere on page with order confirmation.
  *
  * @param TpPayment $payment
  * @return string HTML code with component
  */
 public function showPaymentInstructions(TpPayment $payment)
 {
     if (empty($_REQUEST['tp_radio_value']) || empty($_REQUEST['tp_radio_is_offline'])) {
         return '';
     }
     $this->clearCookies();
     $href = "{$this->config->gateUrl}radiobuttons/style/radiobuttons.css?v=" . time();
     $href = TpEscaper::htmlEntityEncode($href);
     $out = "<link href=\"{$href}\" type=\"text/css\" rel=\"stylesheet\" />\n";
     $out .= "<script type=\"text/javascript\">\n";
     $payment->setMethodId(intval($_REQUEST['tp_radio_value']));
     $queryArgs = $payment->getArgs();
     $queryArgs['signature'] = $payment->getSignature();
     $thepayGateUrl = "{$this->config->gateUrl}?" . http_build_query($queryArgs);
     $thepayGateUrl = TpEscaper::jsonEncode($thepayGateUrl);
     $out .= "\tvar thepayGateUrl = {$thepayGateUrl},\n";
     $thepayDisablePopupCss = TpEscaper::jsonEncode($this->disablePopupCss);
     $out .= "\tthepayDisablePopupCss = {$thepayDisablePopupCss};\n";
     $out .= "</script>\n";
     $src = "{$this->config->gateUrl}radiobuttons/js/jquery.js?v=" . time();
     $src = TpEscaper::htmlEntityEncode($src);
     $out .= "<script type=\"text/javascript\" src=\"{$src}\" async=\"async\"></script>";
     $src = "{$this->config->gateUrl}radiobuttons/js/radiobuttons.js?v=" . time();
     $src = TpEscaper::htmlEntityEncode($src);
     $out .= "<script type=\"text/javascript\" src=\"{$src}\" async=\"async\"></script>";
     $out .= "<div id=\"thepay-method-result\"></div>";
     return $out;
 }