/** * Return the HTML code for the iframe. */ function render() { $url = TpEscaper::htmlEntityEncode($this->payment->getMerchantConfig()->gateUrl . 'iframe/'); $queryArgs = array_filter(array('css' => $this->cssUrl, 'skin' => $this->skin)); $ret = '<script type="text/javascript" src="' . $url . 'js/jquery.js?v=' . time() . '" async="async"></script> <script type="text/javascript" src="' . $url . 'js/iframe.js?v=' . time() . '" async="async"></script>'; // The iframe is auto-sized to fit the height of the content, because the content height can change. $ret .= '<iframe src="' . $url . '?' . $this->buildQuery($queryArgs) . '" style="border: 0; width: 374px; height: 150px;" class="thepay-iframe"></iframe>'; $ret .= '<p>Rychlý bankovní převod zajišťuje společnost <a href="http://www.thepay.cz/" target="_blank">ThePay s.r.o.</a></p>'; return $ret; }
/** * Return the HTML code for the button. */ function render() { $gateUrl = $this->payment->getMerchantConfig()->gateUrl; $targetUrl = TpEscaper::htmlEntityEncode("{$gateUrl}iframe/"); $targetUrl = "{$targetUrl}?" . $this->buildQuery(); switch ($this->buttonStyle) { case "": return "<a href=\"{$targetUrl}\">{$this->buttonText}</a>"; break; default: $buttonStyle = rawurlencode($this->buttonStyle); $src = "{$gateUrl}buttons/{$buttonStyle}.png"; $src = TpEscaper::htmlEntityEncode($src); $title = TpEscaper::htmlEntityEncode($this->buttonText); return "<a href=\"" . $targetUrl . "\"><img src=\"{$src}\" alt=\"{$title}\" title=\"{$title}\" /></a>"; break; } }
/** * 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; }
/** * Get specific property from the customerData JSON string. * * @return mixed */ public function getCustomerDataField($field) { if (!$this->customerData) { return null; } $obj = TpEscaper::jsonDecode($this->customerData); if (!$obj instanceof stdClass) { return null; } return isset($obj->{$field}) ? $obj->{$field} : null; }
/** * 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; }
/** * Return the HTML code for the button. */ public function render() { $targetUrl = TpEscaper::htmlEntityEncode(self::buildUrl()); switch ($this->buttonStyle) { case "": return "<a href=\"{$targetUrl}\">{$this->buttonText}</a>"; break; default: $gateUrl = $this->payment->getMerchantConfig()->gateUrl; $buttonStyle = rawurlencode($this->buttonStyle); $src = TpEscaper::htmlEntityEncode($gateUrl . 'buttons/' . $buttonStyle . '.png'); $title = TpEscaper::htmlEntityEncode($this->buttonText); return "<a href=\"" . $targetUrl . "\"><img src=\"{$src}\" alt=\"{$title}\" title=\"{$title}\" /></a>"; break; } }
/** * 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; }