/** * Build the query part of the URL from payment data and optional * helper data. * @param args Associative array of optional arguments that should * be appended to the URL. * @return Query part of the URL with all parameters correctly escaped * */ public static function buildGatewayQuery(\dlds\thepay\api\TpPayment $payment, array $args = []) { $out = array_merge($payment->getArgs(), $args, ['signature' => $payment->getSignature()]); $str = array(); foreach ($out as $key => $val) { $str[] = rawurlencode($key) . '=' . rawurlencode($val); } return implode("&", $str); }
/** * 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(\dlds\thepay\api\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 = \dlds\thepay\api\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 = \dlds\thepay\api\TpEscaper::jsonEncode($thepayGateUrl); $out .= "\tvar thepayGateUrl = {$thepayGateUrl},\n"; $thepayDisablePopupCss = \dlds\thepay\api\TpEscaper::jsonEncode($this->disablePopupCss); $out .= "\tthepayDisablePopupCss = {$thepayDisablePopupCss};\n"; $out .= "</script>\n"; $src = "{$this->config->gateUrl}radiobuttons/js/jquery.js?v=" . time(); $src = \dlds\thepay\api\TpEscaper::htmlEntityEncode($src); $out .= "<script type=\"text/javascript\" src=\"{$src}\" async=\"async\"></script>"; $src = "{$this->config->gateUrl}radiobuttons/js/radiobuttons.js?v=" . time(); $src = \dlds\thepay\api\TpEscaper::htmlEntityEncode($src); $out .= "<script type=\"text/javascript\" src=\"{$src}\" async=\"async\"></script>"; $out .= "<div id=\"thepay-method-result\"></div>"; return $out; }
/** * Build the query part of the URL from payment data and optional * helper data. * @param args Associative array of optional arguments that should * be appended to the URL. * @return Query part of the URL with all parameters correctly escaped * */ public static function buildPaymentQuery(\dlds\thepay\api\TpPayment $payment, array $args = []) { $out = array_merge($payment->getArgs(), $args, ['signature' => $payment->getSignature()]); return http_build_query($out); }