} $transactionData = $_POST; $res = moduleValidateTransaction($transactionData, $errorMessage); $localTranID = (int) $transactionData['cart_order_id']; if ($res != 2) { finishTransaction($localTranID, $transactionData['order_number'], $res == 1); } if ($res == 1) { $purchaseRes = purchaseTransaction($localTranID, $res); if (!$purchaseRes) { $errorMessage = 'Purchase failed'; $res = 0; } } processValidationResult($res, $errorMessage, $localTranID); return $res == 1; } if (!defined('PAYMENT_MODULE_AS_HEADER')) { $validateRes = moduleValidateConfiguration($errorMessage); if (!$validateRes) { PrintErrorPage($errorMessage); exit; } if ($providerConf['Debug']) { writeDebugLog('2Checkout checkout external call', '--------------', true); writeDebugLog('Conf', $providerConf, false); writeDebugLog('GET', $_GET, false); writeDebugLog('POST', $_POST, false); } moduleAcceptPayment(false); }
/** * start checkout process */ function StartCheckout(&$errorMessage) { global $dir; global $memberID; // defined in checkout.inc.php global $collectDataArr; global $enable_recurring; global $en_credits; global $credit2money; // these globals for module require call global $site; global $providerConf; global $checkoutFilename; global $checkoutURL; global $debugFilename; // if buy for credits if ($_REQUEST['use_credits'] == 'on' && $en_credits) { $amount = sprintf('%.2f', (double) $collectDataArr['amount']); $creditsAmount = sprintf("%.2f", (double) ($collectDataArr['amount'] * $credit2money)); $creditBalance = getProfileCredits($memberID); $result = 0; if ($collectDataArr['checkout_action'] == 'credits') { $errorMessage = 'Credits couldn\'t be bought by credits'; return false; } if ($creditBalance < $creditsAmount) { $result = 1000; } else { $purchaseRes = performPurchase($memberID, $collectDataArr['checkout_action'], $collectDataArr['data'], $amount, $result); if ($purchaseRes) { decProfileCredits($memberID, $creditsAmount); $result = 1; } else { $result = -1; } } $returnURL = returnURLByAction($collectDataArr['checkout_action'], $collectDataArr['data']); processValidationResult($result, $errorMessage, 0, $returnURL); } else { $providerID = (int) $_REQUEST['prov_id']; $providerRes = db_res("SELECT `Name`, `CheckoutFilename` FROM `PaymentProviders` WHERE `ID` = {$providerID} AND `Active`"); if (!$providerRes || mysql_num_rows($providerRes) == 0) { $errorMessage = 'Wrong payment provider specified'; return false; } $providerArr = mysql_fetch_assoc($providerRes); if (strlen(trim($providerArr['CheckoutFilename']))) { $checkoutFilename = $providerArr['CheckoutFilename']; } else { $checkoutFilename = $dir['checkout'] . $providerArr['Name'] . '.php'; } if (!file_exists($checkoutFilename)) { $errorMessage = 'Checkout file not found'; return false; } require_once $checkoutFilename; $validateRes = moduleValidateConfiguration($errorMessage); if (!$validateRes) { return false; } $localTranID = initiateTransaction($collectDataArr, $memberID, $providerID); if ($localTranID === false) { $errorMessage = 'Transaction initiating error'; return false; } $subscriptionalPayment = $enable_recurring && $collectDataArr['allow_subscribe'] == 'on' && $_REQUEST['prov_recurring'] == 'on'; if ($subscriptionalPayment) { $subsRes = initiateSubscription($localTranID, $collectDataArr['subscribe_days']); if (!$subsRes) { $errorMessage = 'Subscription initiating error'; return false; } } $startRes = moduleStartTransaction($localTranID, $subscriptionalPayment, $collectDataArr['subscribe_days']); if (!$startRes) { $errorMessage = 'Transaction starting error'; return false; } } return true; }
$provider_id = (int) $_REQUEST['prov_id']; $provider_res = db_res("SELECT `Name`, `CheckoutFilename` FROM `PaymentProviders` WHERE `ID` = {$provider_id}"); if (!$provider_res || mysql_num_rows($provider_res) == 0) { $status_text = 'Wrong payment provider specified'; } else { $provider_arr = mysql_fetch_assoc($provider_res); if (strlen(trim($provider_arr['CheckoutFilename']))) { $checkout_filename = $provider_arr['CheckoutFilename']; } else { $checkout_filename = $dir['checkout'] . $provider_arr['Name'] . '.php'; } if (!file_exists($checkout_filename)) { $status_text = 'Checkout file not found'; } else { require_once $checkout_filename; $validate_res = moduleValidateConfiguration($status_text); if ($validate_res) { $status_text = 'Configuration is valid'; } } } } elseif ($_REQUEST['action'] == 'save_settings') { $res_setparam1 = setParam('currency_code', $_POST['currency_code']); $res_setparam3 = setParam('enable_recurring', $_POST['enable_recurring']); if ($res_setparam1 && $res_setparam3) { $currency_code = process_pass_data($_POST['currency_code']); $enable_recurring = $_POST['enable_recurring'] == 'on'; $settings_status_text = 'Settings successfully saved'; } else { $settings_status_text = 'Failed to save settings'; }
/** * start checkout process */ function StartCheckout(&$errorMessage) { global $dir; global $memberID; // defined in checkout.inc.php global $collectDataArr; global $enable_recurring; // these globals for module require call global $site; global $providerConf; global $checkoutFilename; global $checkoutURL; global $debugFilename; $providerID = (int) $_REQUEST['prov_id']; $providerRes = db_res("SELECT `Name`, `CheckoutFilename` FROM `PaymentProviders` WHERE `ID` = {$providerID} AND `Active`"); if (!$providerRes || mysql_num_rows($providerRes) == 0) { $errorMessage = 'Wrong payment provider specified'; return false; } $providerArr = mysql_fetch_assoc($providerRes); if (strlen(trim($providerArr['CheckoutFilename']))) { $checkoutFilename = $providerArr['CheckoutFilename']; } else { $checkoutFilename = $dir['checkout'] . $providerArr['Name'] . '.php'; } if (!file_exists($checkoutFilename)) { $errorMessage = 'Checkout file not found'; return false; } require_once $checkoutFilename; $validateRes = moduleValidateConfiguration($errorMessage); if (!$validateRes) { return false; } $localTranID = initiateTransaction($collectDataArr, $memberID, $providerID); if ($localTranID === false) { $errorMessage = 'Transaction initiating error'; return false; } $subscriptionalPayment = $enable_recurring && $collectDataArr['allow_subscribe'] == 'on' && $_REQUEST['prov_recurring'] == 'on'; if ($subscriptionalPayment) { $subsRes = initiateSubscription($localTranID, $collectDataArr['subscribe_days']); if (!$subsRes) { $errorMessage = 'Subscription initiating error'; return false; } } $startRes = moduleStartTransaction($localTranID, $subscriptionalPayment, $collectDataArr['subscribe_days']); if (!$startRes) { $errorMessage = 'Transaction starting error'; return false; } return true; }