/** * Build the query part of the URL from payment data and optional * helper data. * @param array $args Associative array of optional arguments that should * be appended to the URL. * @return string Query part of the URL with all parameters correctly escaped * */ function buildQuery($args = array()) { $out = array_merge($this->payment->getArgs(), $args, array("signature" => $this->payment->getSignature())); $str = array(); foreach ($out as $key => $val) { $str[] = rawurlencode($key) . "=" . rawurlencode($val); } return implode('&', $str); }
function get_payment_buttons($order_id) { //nacteme si cenu z objednavky $s = sql_query("select price from orders\n\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $order_id . "' and user = '******')"); $d = sql_fetch_object($s); if (!$d->price) { return; } $payment = new TpPayment($this->config); $payment->setValue($d->price); $payment->setDescription($this->l->t("thepay_title")); $payment->setMerchantData($order_id); $payment->setReturnUrl("http://www.cbdb.cz/pay_return.php?pay_type=thepay"); $tpHelper = new TpDivMerchantHelper($payment); return $tpHelper->render(); }
/** * Constructor. * @param args Optional arguments parameter, that can specify the * arguments of the returned payment. If not specified, it is taken * from the $_REQUEST superglobal array. */ function __construct(TpMerchantConfig $config, $args = NULL) { parent::__construct($config); if (is_null($args)) { $args =& $_REQUEST; } if (!empty($args['merchantId'])) { $this->requestMerchantId = $args['merchantId']; } if (!empty($args['accountId'])) { $this->requestAccountId = $args['accountId']; } foreach (self::$REQUIRED_ARGS as $arg) { if (!isset($args[$arg])) { throw new TpMissingParameterException($arg); } $this->{$arg} = $args[$arg]; } foreach (self::$OPTIONAL_ARGS_DEFAULT as $arg => $defaultValue) { if (!isset($args[$arg])) { $this->{$arg} = $defaultValue; } else { $this->{$arg} = $args[$arg]; } } $this->signature = $args["signature"]; }
/** * @return array|string */ public function getMerchantData() { return Helper::getData(parent::getMerchantData()); }
/** * 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; }