/** * @throws CheckoutException */ public function startPayment() { $total_amount = ($this->request->amount + $this->request->tax_amount - $this->request->discount_amount) * 100; if ($total_amount <= 0) { throw new CheckoutException('Amount (price) must be greater than zero (Check your discounts)'); } try { \WebToPay::redirectToPayment(array('projectid' => $this->projectId, 'sign_password' => $this->signPassword, 'orderid' => $this->request->transaction, 'amount' => $total_amount, 'currency' => $this->request->currency, 'accepturl' => $this->request->accept_url, 'cancelurl' => $this->request->cancel_url, 'callbackurl' => route('checkout::callback', ['transaction' => $this->request->transaction]), 'test' => $this->mode, 'paytext' => $this->request->description ? $this->request->description . ' ([order_nr], [site_name])' : null, 'p_firstname' => $this->request->customer_data->first_name, 'p_lastname' => $this->request->customer_data->last_name, 'p_personcode' => $this->request->customer_data->person_code, 'p_email' => $this->request->customer_data->email, 'p_street' => $this->request->customer_data->street, 'p_city' => $this->request->customer_data->city, 'p_state' => $this->request->customer_data->state, 'p_zip' => $this->request->customer_data->zip_code, 'p_countrycode' => $this->request->customer_data->country_code)); } catch (\WebToPayException $e) { throw new CheckoutException('Gateway had error.', 500, $e); } }
function payseraPayment() { $payconfig = $this->payconfig; $projectId = $payconfig->projectId; $signPassword = $payconfig->signPassword; $ppCurrency = $payconfig->psCurrency; $pstestmode = $payconfig->test; $details = $this->details; $taxrate = $details['taxrate']; $amount = $details['amount']; $totamt = (double) ($amount + $amount * ($taxrate / 100)); $totamt = round($totamt, 2) * 100; $item_num = $details['orderid']; $invoiceNo = $details['invoiceNo']; $user = JFactory::getUser($details['user_id']); $link_status = JURI::base() . 'index.php?option=com_jblance&task=membership.returnafterpayment&gateway=paysera'; $link_cancel = JRoute::_(JURI::base() . 'index.php?option=com_jblance&view=membership&layout=thankpayment&type=cancel'); $this->paysera_url = $ppTestmode ? 'https://www.paysera.com/pay/' : 'https://www.paysera.com/pay/'; $data['projectid'] = $projectId; $data['sign_password'] = $signPassword; $data['accepturl'] = $link_status; $data['callbackurl'] = $link_status; $data['cancelurl'] = $link_cancel; $data['orderid'] = $item_num; $data['invoiceNo'] = $invoiceNo; $data['p_firstname'] = $user->name; $data['p_email'] = $user->email; $data['currency'] = $ppCurrency; $data['amount'] = $totamt; $data['test'] = 1; $data['version'] = '1.6'; $request = WebToPay::redirectToPayment($data); $this->add_field('data', $request['data']); $this->add_field('sign', $request['sign']); $this->submit_paysera_post(); ?> <script> document.paysera_form.submit(); </script> <?php }
} else { $error = t("ERROR: api returns empty"); } } catch (WebToPayException $e) { $error = t("ERROR: Something went wrong") . ". " . $e; } } else { try { dump($amount_to_pay); $params_request = array('projectid' => $projectid, 'sign_password' => $password, 'orderid' => $payment_ref, 'amount' => $amount_to_pay * 100, 'currency' => $currency, 'country' => $country, 'accepturl' => $accepturl, 'cancelurl' => $cancel_url, 'callbackurl' => $callback, 'test' => $mode, 'lang' => $lang); if ($mode == 2) { unset($params_request['test']); } /*dump($params_request); die();*/ $request = WebToPay::redirectToPayment($params_request); } catch (WebToPayException $e) { $error = t("ERROR: Something went wrong") . ". " . $e; } } } else { $error = t("ERROR: Something went wrong"); } if (!empty($error)) { ?> <p class="uk-text-danger"><?php echo $error; ?> </p> <?php }
<?php require_once 'includes/helpers.php'; require_once 'includes/config.php'; require_once '../src/includes.php'; $post = removeQuotes($_POST); $id = $post['id']; if (!isset($shopItems[$id])) { redirect_to(get_address()); } $item = $shopItems[$id]; $data = load_data(); $orderid = isset($data['orderid']) ? $data['orderid'] + 1 : 1; $order = array('amount' => $item['price'], 'currency' => $item['currency'], 'orderid' => $orderid); $data['orderid'] = $orderid; $data['orders'][$orderid] = array('item' => $item, 'status' => 'new', 'additionalData' => $post); save_data($data); // this method builds request and sends Location header for redirecting to payment site // as an alternative, you can use WebToPay::buildRequest and make auto-post form WebToPay::redirectToPayment(array_merge($post, $config, $order));