function express_checkout($paymenAmount) { $resArray = CallShortcutExpressCheckout($paymenAmount, $this->currencyCodeType, $this->paymentType, $this->returnURL, $this->cancelURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { RedirectToPayPal($resArray["TOKEN"]); } else { $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; } }
//'------------------------------------ $returnURL = $_SESSION[$guid]["absoluteURL"] . "/" . $_GET["return"]; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = $_SESSION[$guid]["absoluteURL"] . "/" . $_GET["fail"]; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, urlencode($returnURL), urlencode($cancelURL), $guid); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); if ($ErrorLongMsg = "Currency is not supported") { $URL = $_SESSION[$guid]["gatewayCurrencyNoSupportReturnURL"]; header("Location: {$URL}"); } else { echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg;
api_not_allowed(true); } $currency = $plugin->getCurrency($sale['currency_id']); switch ($sale['payment_type']) { case BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL: $paypalParams = $plugin->getPaypalParams(); $pruebas = $paypalParams['sandbox'] == 1; $paypalUsername = $paypalParams['username']; $paypalPassword = $paypalParams['password']; $paypalSignature = $paypalParams['signature']; require_once "paypalfunctions.php"; $i = 0; $extra = "&L_PAYMENTREQUEST_0_NAME0={$sale['product_name']}"; $extra .= "&L_PAYMENTREQUEST_0_AMT0={$sale['price']}"; $extra .= "&L_PAYMENTREQUEST_0_QTY0=1"; $expressCheckout = CallShortcutExpressCheckout($sale['price'], $currency['iso_code'], 'paypal', api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/success.php', api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/error.php', $extra); if ($expressCheckout["ACK"] !== 'Success') { $erroMessage = vsprintf($plugin->get_lang('ErrorOccurred'), [$expressCheckout['L_ERRORCODE0'], $expressCheckout['L_LONGMESSAGE0']]); Display::addFlash(Display::return_message($erroMessage, 'error', false)); header('Location: ../index.php'); exit; } RedirectToPayPal($expressCheckout["TOKEN"]); break; case BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER: $buyingCourse = false; $buyingSession = false; switch ($sale['product_type']) { case BuyCoursesPlugin::PRODUCT_TYPE_COURSE: $buyingCourse = true; $course = $plugin->getCourseInfo($sale['product_id']);
//'------------------------------------ $returnURL = "http://localhost/reference-transaction/review.php"; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = "http://localhost/reference-transaction/index.php"; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; }
function gateway_paypal_certified($seperator, $sessionid) { $_SESSION['paypalExpressMessage'] = ' <h4>Transaction Canceled</h4>'; // ================================== // PayPal Express Checkout Module // ================================== //'------------------------------------ //' The paymentAmount is the total value of //' the shopping cart, that was set //' earlier in a session variable //' by the shopping cart page //'------------------------------------ //exit('<pre>'.print_r($_SESSION, true).'</pre>'); $paymentAmount = wpsc_cart_total(false); $_SESSION['paypalAmount'] = $paymentAmount; $_SESSION['paypalexpresssessionid'] = $sessionid; paypal_certified_currencyconverter(); //exit($_SESSION['paypalAmount']); //'------------------------------------ //' The currencyCodeType and paymentType //' are set to the selections made on the Integration Assistant //'------------------------------------ $currencyCodeType = get_option('paypal_curcode'); $paymentType = "Sale"; //'------------------------------------ //' The returnURL is the location where buyers return to when a //' payment has been succesfully authorized. //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ //exit(get_option('transact_url')); $transact_url = get_option('transact_url'); $returnURL = $transact_url . $seperator . "sessionid=" . $sessionid . "&gateway=paypal"; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = $transact_url; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($_SESSION['paypalAmount'], $currencyCodeType, $paymentType, $returnURL, $cancelURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS") { RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; } // header("Location: ".get_option('paypal_multiple_url')."?".$output); exit; }
//'------------------------------------ $returnURL = $_SESSION['checkout']['return_url']; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = $_SESSION['checkout']['cancel_url']; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallMarkExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($paymentAmount, $EXname, $shipping, $shipping_status, $currencyCodeType, $paymentType, $returnURL, $cancelURL); /*$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum ); */ $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); $_SESSION['reshash'] = $token; RedirectToPayPal($token); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$_SESSION["paymentType"] = "Sale"; //Sale, Authorization, Order; //'------------------------------------ //' The returnURL is the location where buyers return to when a //' payment has been succesfully authorized. //'------------------------------------ $returnURL = $_PAY_CONF['site_url'] . '/recurring-payment/review.php'; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //'------------------------------------ $cancelURL = $_PAY_CONF['site_url'] . '/index.php?mode=cancel'; //'------------------------------------ //' Calls the SetExpressCheckout API call //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($_SESSION["Payment_Amount"], $_SESSION["currencyCodeType"], $_SESSION["paymentType"], $returnURL, $cancelURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); $display .= "<p>SetExpressCheckout API call failed.</p>"; if ($_SESSION['curl_error_no'] != '') { $ErrorCode = $_SESSION['curl_error_no']; } if ($_SESSION['curl_error_msg'] != '') { $ErrorLongMsg = $_SESSION['curl_error_msg'];
?> ', { button: 'placeOrderBtn', environment: '<?php echo $env; ?> ', condition: function () { return document.getElementById('paypal_payment_option').checked === true; } }); }; </script> <?php } else { $resArray = CallShortcutExpressCheckout($_POST, $returnURL, $cancelURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; }
//'------------------------------------ $returnURL = 'add return URL'; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = 'add cancel URL'; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $planSelect, $planPrice, $planNumberSelect); $ack = strtoupper($resArray['ACK']); if ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING') { RedirectToPayPal($resArray['TOKEN']); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray['L_ERRORCODE0']); $ErrorShortMsg = urldecode($resArray['L_SHORTMESSAGE0']); $ErrorLongMsg = urldecode($resArray['L_LONGMESSAGE0']); $ErrorSeverityCode = urldecode($resArray['L_SEVERITYCODE0']); echo 'SetExpressCheckout API call failed. '; echo 'Detailed Error Message: ' . $ErrorLongMsg; echo 'Short Error Message: ' . $ErrorShortMsg; echo 'Error Code: ' . $ErrorCode; echo 'Error Severity Code: ' . $ErrorSeverityCode; var_dump($nvpstr);
function display($tmpl = null) { global $_js_helper; $headers = array('Content-Type: text/html; charset=UTF-8', "From: JOBSSHOP <*****@*****.**>"); if (JS_Helper::get_input('snap_task') == 'make-payment') { $tmpl = 'register.jobsboss-make-payment'; } if ('POST' == $_SERVER['REQUEST_METHOD']) { $redirect_to = site_url(); if (JS_Helper::get_input('snap_task') == 'make-payment') { $returnURL = RETURN_URL; $cancelURL = CANCEL_URL; $resArray = CallShortcutExpressCheckout($_POST, $returnURL, $cancelURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; } } $userdata = $_POST['_snap_data']; $userdata['role'] = $this->user_role; $userdata['user_login'] = sanitize_title($userdata['user_login']); $errors = wp_insert_user($userdata); $this->message = ''; if (!is_wp_error($errors)) { $meta = $userdata['meta']; $meta_success = 0; foreach ($meta as $meta_key => $meta_value) { $meta_success += update_user_meta($errors, $meta_key, $meta_value) ? 1 : 0; } if ($meta_success > 0) { $user_email = $userdata['user_email']; $email_subject = "Account Details for {$userdata['first_name']} at Jobs Shop"; $site_url = site_url(); $email_content = <<<EOB Hello {$userdata['first_name']},<br /> <br /> Thank you for registering at Jobs Shop.<br /> <br /> You may now log in to {$site_url} using the following username and password:<br /> <br /> Username: {$userdata['user_login']}<br /> Password: {$userdata['user_pass']} EOB; $headers = array('Content-Type: text/html; charset=UTF-8', "From: JOBSSHOP <*****@*****.**>"); wp_mail($user_email, $email_subject, $email_content, $headers); $action = isset($_POST['action']); if ($action) { $redirect_to = site_url('jobsboss/register/make-payment'); $redirect_to = add_query_arg(array('uid' => $errors), $redirect_to); } wp_redirect($redirect_to); exit; } } else { $this->message = $errors->errors; } $this->userdata = $userdata; } $this->assignRef('user_role', $this->user_role); parent::display($tmpl, true); }
function mx_checkout($cart) { global $mxuser; // ================================== // PayPal Express Checkout Module // ================================== //'------------------------------------ //' The paymentAmount is the total value of //' the shopping cart, that was set //' earlier in a session variable //' by the shopping cart page //'------------------------------------ $paymentAmount = $cart->total + $cart->taxes; $_SESSION["Payment_Amount"] = $paymentAmount; //'------------------------------------ //' The currencyCodeType and paymentType //' are set to the selections made on the Integration Assistant //'------------------------------------ $currencyCodeType = "USD"; $paymentType = "Sale"; //'------------------------------------ //' The returnURL is the location where buyers return to when a //' payment has been succesfully authorized. //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $returnURL = mx_optionurl_secure('cart', ''); //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = mx_actionurl('cart', '', 'ppcancel'); // callback URL to calculate taxes (and shipping fees) $callbackURL = mx_option('secure_siteurl') . '/paypal.php'; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallShortcutExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $resArray = CallShortcutExpressCheckout($cart, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $callbackURL); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $mxuser->setcart($cart->id, 'token', $resArray['TOKEN']); $mxuser->setcart($cart->id, 'ordertime', preg_replace('%[^0-9]%', '', $resArray['TIMESTAMP'])); RedirectToPayPal($resArray["TOKEN"]); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); //echo "SetExpressCheckout API call failed. <br/>" //."Detailed Error Message: " . $ErrorLongMsg.'<br/>' //."Short Error Message: " . $ErrorShortMsg.'<br/>' //."Error Code: " . $ErrorCode.'<br/>' //."Error Severity Code: " . $ErrorSeverityCode; } return $resArray; }