function bizz_redirect_quickpay($return, $bookopts, $form_data, $this_post_id, $opt_s) { // Order ID $bid = wp_count_posts('bizz_bookings'); $order_id = $bid->publish . "-" . $bookopts['tracking_id']; if (isset($form_data['payment_method']) && $form_data['payment_method'] == 'creditcard') { $repl = array(".", ","); $bookopts['total'] = str_replace($repl, '', $bookopts['pay_total']); $bookopts['deposit'] = str_replace($repl, '', $bookopts['pay_deposit']); $bookopts['amount'] = $bookopts['total'] + $bookopts['deposit']; $bookopts['currency'] = $opt_s['pay_currency']; $bookopts['callbackurl'] = trailingslashit(home_url()) . "?quickpay=" . $order_id . "&post=" . $this_post_id; $bookopts['cancelurl'] = trailingslashit(home_url()) . "?quickpay=cancel&post=" . $this_post_id; $bookopts['continueurl'] = $opt_s['pay_thankyou']; $bookopts['language'] = 'da'; // Initialize require_once dirname(__FILE__) . "/quickpay-api/QuickpayApi.php"; $qp = new QuickpayApi(); //TODO change to seperate QP key $qp->setOptions($opt_s['pay_mollie_api']); //been here before? $qp->mode = 'payments?order_id='; // Commit the status request, checking valid transaction id $st = $qp->status($order_id); $qid = $st["qid"]; //reset mode $qp->mode = "payments/"; if ($qid == null) { //create new quickpay order $payment = $qp->createorder($order_id, $bookopts['currency']); $qid = $payment["id"]; } //create or update order link $storder = $qp->link($qid, $bookopts); // mail('*****@*****.**','link' ,json_encode($storder)); // Send the customer off to complete the payment. $link = $storder['url']; } else { $link = ''; } return $link; }
/** * Popoulates basic request parameters for gateway depending on basket (without specifying payment type) * * @param cbpaidPaymentBasket $paymentBasket paymentBasket object * @return array Returns array $requestParams */ private function _getBasicRequstParams($paymentBasket) { $this->formurl = "#"; // $this->formurl = $this->getNotifyUrl( $paymentBasket ); // mandatory parameters: $requestParams = array(); //second POST pass $requestParams['cbsecuritym3'] = $_POST["cbsecuritym3"]; $requestParams['cbrasitway'] = $_POST["cbrasitway"]; $requestParams['email'] = $_POST["email"]; $requestParams['username'] = $_POST["username"]; $requestParams['password'] = $_POST["password"]; $requestParams['cbpplanE'] = $_POST["cbpplanE"]; $requestParams['cbponlyplans'] = $_POST["cbponlyplans"]; // $requestParams['version'] = 'v10'; $requestParams['merchant_id'] = $this->getAccountParam('pspid'); $requestParams['agreement_id'] = $this->getAccountParam('agreementid'); $requestParams['language'] = $this->getAccountParam('language'); $requestParams['order_id'] = $this->_prepareOrderNumber($paymentBasket->id, true); // check for subscription or if single payment: if ($paymentBasket->period3) { $requestParams['subscription'] = '1'; $requestParams['amount'] = sprintf('%.2f', $paymentBasket->mc_amount3) * 100; } else { $requestParams['subscription'] = '0'; $requestParams['amount'] = sprintf('%.2f', $paymentBasket->mc_gross) * 100; } $requestParams['currency'] = $paymentBasket->mc_currency; $requestParams['autocapture'] = '1'; // urls for return, cancel, and IPNs: $requestParams['continueurl'] = $this->getSuccessUrl($paymentBasket); $requestParams['cancelurl'] = $this->getCancelUrl($paymentBasket); $requestParams['callbackurl'] = $this->getNotifyUrl($paymentBasket); // optional parameters: $requestParams['description'] = "cbsubs payment " . $requestParams['order_id']; //$requestParams['testmode'] = ( $this->getAccountParam( 'normal_gateway' ) == '0' ? '1' : '0' ); $requestParams["variables[shopsystem]"] = "CB subscriptions"; // recommended anti-fraud fields: $requestParams['variables[user_id]'] = $paymentBasket->user_id; $requestParams['variables[first_name]'] = $paymentBasket->first_name; $requestParams['variables[last_name]'] = $paymentBasket->last_name; if ($this->getAccountParam('givehiddenemail') && strlen($paymentBasket->payer_email) <= 50) { $requestParams['variables[email]'] = $paymentBasket->payer_email; } if ($this->getAccountParam('givehiddenddress')) { cbimport('cb.tabs'); // needed for cbIsoUtf_substr() $addressFields = array('variables[address_one]' => array($paymentBasket->address_street, 30), 'variables[postal_code]' => array($paymentBasket->address_zip, 10), 'variables[city]' => array($paymentBasket->address_city, 30), 'variables[country]' => array($this->countryToLetters($paymentBasket->address_country, 3), 3)); if ($paymentBasket->address_state != 'other') { $addressFields['variables[state_or_province]'] = array(substr($paymentBasket->address_state, -2), 2); } foreach ($addressFields as $k => $value_maxlength) { $adrField = cbIsoUtf_substr($value_maxlength[0], 0, $value_maxlength[1]); if ($adrField) { $requestParams[$k] = $adrField; } } } if ($this->getAccountParam('givehiddentelno') && strlen($paymentBasket->contact_phone) <= 50) { $requestParams['variables[phone]'] = $paymentBasket->contact_phone; } /* not needed. Using v10 payment link instead ksort($requestParams); $requestParams["checksum"] = $this->_signRequestParams($requestParams, $this->window_key); */ if ($_POST['callquickpay'] == "go") { $apiorder = new QuickpayApi(); $apiorder->setOptions($this->api_key); //been here before? $exists = $this->get_quickpay_order_status($requestParams['order_id']); $qid = $exists["qid"]; if ($paymentBasket->period3) { $apiorder->mode = 'subscriptions/'; } if ($exists["qid"] == null) { //create new quickpay payment or subscription order $storder = $apiorder->createorder($requestParams['order_id'], $requestParams['currency'], $requestParams); $qid = $storder["id"]; } else { $qid = $exists["qid"]; } //create or update payment link $storder = $apiorder->link($qid, $requestParams); header("location: " . $storder['url']); } $requestParams["callquickpay"] = 'go'; return $requestParams; }