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; } }
//' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = "http://127.0.0.1/project/checkout/index2.php"; //'------------------------------------ //' 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 = 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"]); $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; } } else { if (($PaymentOption == "Visa" || $PaymentOption == "MasterCard" || $PaymentOption == "Amex" || $PaymentOption == "Discover") && $PaymentProcessorSelected == "PayPal Direct Payment") { //'------------------------------------
//' 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; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode;
$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']); break; case BuyCoursesPlugin::PRODUCT_TYPE_SESSION: $buyingSession = true; $session = $plugin->getSessionInfo($sale['product_id']); break; } $transferAccounts = $plugin->getTransferAccounts();
sendStockreordermail($product_option_id, $quantity); } } // end while } // end number of rows // Settle seller , Admin Amounts // End $payment_completed = true; } // End if ($ack == "SUCCESS" && $payment_completed) { if ("" == $preapprovalKey) { // redirect for web approval flow $cmd = "cmd=_ap-payment&paykey=" . urldecode($resArray["payKey"]); RedirectToPayPal($cmd); } else { // payKey is the key that you can use to identify the result from this Pay call $payKey = urldecode($resArray["payKey"]); // paymentExecStatus is the status of the payment $paymentExecStatus = urldecode($resArray["paymentExecStatus"]); } } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal //TODO - There can be more than 1 error, so check for "error(1).errorId", then "error(2).errorId", and so on until you find no more errors. $ErrorCode = urldecode($resArray["error(0).errorId"]); $ErrorMsg = urldecode($resArray["error(0).message"]); $ErrorDomain = urldecode($resArray["error(0).domain"]); $ErrorSeverity = urldecode($resArray["error(0).severity"]); $ErrorCategory = urldecode($resArray["error(0).category"]); $message .= $ErrorMsg;
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 = '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_billing($cart) { if ($PaymentOption == "PayPal") { // ================================== // 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 = $_SESSION["Payment_Amount"]; //'------------------------------------ //' When you integrate this code //' set the variables below with //' shipping address details //' entered by the user on the //' Shipping page. //'------------------------------------ $shipToName = "<<ShiptoName>>"; $shipToStreet = "<<ShipToStreet>>"; $shipToStreet2 = "<<ShipToStreet2>>"; //Leave it blank if there is no value $shipToCity = "<<ShipToCity>>"; $shipToState = "<<ShipToState>>"; $shipToCountryCode = "<<ShipToCountryCode>>"; // Please refer to the PayPal country codes in the API documentation $shipToZip = "<<ShipToZip>>"; $phoneNum = "<<PhoneNumber>>"; //'------------------------------------ //' 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 = "http://www.example.com/pp/gateway.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://www.example.com/pp/gateway.php"; //'------------------------------------ //' 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 = 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"]); $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; } } else { if (($PaymentOption == "Visa" || $PaymentOption == "MasterCard" || $PaymentOption == "Amex" || $PaymentOption == "Discover") && $PaymentProcessorSelected == "PayPal Direct Payment") { //'------------------------------------ //' The paymentAmount is the total value of //' the shopping cart, that was set //' earlier in a session variable //' by the shopping cart page //'------------------------------------ $paymentAmount = $_SESSION["Payment_Amount"]; } //'------------------------------------ //' The currencyCodeType and paymentType //' are set to the selections made on the Integration Assistant //'------------------------------------ $currencyCodeType = "USD"; $paymentType = "Sale"; //' Set these values based on what was selected by the user on the Billing page Html form $creditCardType = "<<Visa/MasterCard/Amex/Discover>>"; //' Set this to one of the acceptable values (Visa/MasterCard/Amex/Discover) match it to what was selected on your Billing page $creditCardNumber = "<<CC number>>"; //' Set this to the string entered as the credit card number on the Billing page $expDate = "<<Expiry Date>>"; //' Set this to the credit card expiry date entered on the Billing page $cvv2 = "<<cvv2>>"; //' Set this to the CVV2 string entered on the Billing page $firstName = "<<firstName>>"; //' Set this to the customer's first name that was entered on the Billing page $lastName = "<<lastName>>"; //' Set this to the customer's last name that was entered on the Billing page $street = "<<street>>"; //' Set this to the customer's street address that was entered on the Billing page $city = "<<city>>"; //' Set this to the customer's city that was entered on the Billing page $state = "<<state>>"; //' Set this to the customer's state that was entered on the Billing page $zip = "<<zip>>"; //' Set this to the zip code of the customer's address that was entered on the Billing page $countryCode = "<<PayPal Country Code>>"; //' Set this to the PayPal code for the Country of the customer's address that was entered on the Billing page $currencyCode = "<<PayPal Currency Code>>"; //' Set this to the PayPal code for the Currency used by the customer /* '------------------------------------------------ ' Calls the DoDirectPayment API call ' ' The DirectPayment function is defined in PayPalFunctions.php included at the top of this file. '------------------------------------------------- */ $resArray = DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { //Getting transaction ID from API responce. $TransactionID = urldecode($resArray["TRANSACTIONID"]); echo "Your payment has been successfully processed"; } 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 "Direct credit card payment API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; } } }