Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* starting by case 'pp_pro' */
- /* ending before case 'authorize_aim' */
- case 'pp_pro' :
- global $errors, $wpcoDb, $Product, $Order, $Item, $Country, $wpcoHtml;
- require_once(dirname(__FILE__) . DS . 'includes' . DS . 'constants.php');
- $order_id = $Order -> current_order_id();
- $wpcoDb -> model = $Order -> model;
- $order = $wpcoDb -> find(array('id' => $order_id));
- $wpcoDb -> model = $Item -> model;
- $items = $wpcoDb -> find_all(array('order_id' => $order_id));
- $user = $this -> userdata($order -> user_id);
- $pmethod = "pp_pro";
- $success = false;
- $errors = null;
- if (empty($_POST['creditCardNumber'])) { $errors['creditCardNumber'] = __('Please fill in a credit card number.', $this -> plugin_name); }
- elseif (!is_numeric($_POST['creditCardNumber'])) { $errors['creditCardNumber'] = __('Only numbers are allowed in the credit card number.', $this -> plugin_name); }
- if (empty($_POST['expDateMonth']) || empty($_POST['expDateYear'])) { $errors['expDate'] = __('Please choose an expiry date.', $this -> plugin_name); }
- if (empty($_POST['cvv2Number'])) { $errors['cvv2Number'] = __('Please fill in a security code.', $this -> plugin_name); }
- elseif (!is_numeric($_POST['cvv2Number'])) { $errors['cvv2Number'] = __('Only numbers are allowed for the security code.', $this -> plugin_name); }
- if (empty($errors)) {
- //$pp_pro = $this -> vendor('pp_pro', "gateways" . DS);
- require_once $this -> plugin_base() . DS . 'vendors' . DS . 'gateways' . DS . 'class.pp_pro.php';
- $api_username = $this -> get_option('pp_pro_api_username');
- $api_password = $this -> get_option('pp_pro_api_password');
- $api_signature = $this -> get_option('pp_pro_api_signature');
- $api_endpoint = $this -> get_option('pp_pro_api_endpoint');
- $email = urlencode($user -> user_email);
- $firstName = urlencode($order -> bill_fname);
- $lastName = urlencode($order -> bill_lname);
- $creditCardType = urlencode($_POST['creditCardType']);
- $creditCardNumber = urlencode($_POST['creditCardNumber']);
- $expDateMonth = urlencode($_POST['expDateMonth']);
- $expDateYear = urlencode($_POST['expDateYear']);
- $cvv2Number = urlencode($_POST['cvv2Number']);
- $address1 = urlencode($order -> bill_address);
- $address2 = urlencode($order -> bill_address2);
- $city = urlencode($order -> bill_city);
- $state = urlencode($order -> bill_state);
- $zip = urlencode($order -> bill_zipcode);
- $amount = urlencode($order -> total);
- $currencyCode = urlencode($this -> get_option('currency'));
- $shiptophonenum = urlencode($order -> ship_phone);
- $SHIPTONAME = urlencode($order -> ship_fname . ' ' . $order -> ship_lname);
- $SHIPTOSTREET = urlencode($order -> ship_address);
- $SHIPTOSTREET2 = urlencode($order -> ship_address2);
- $shiptocity = urlencode($order -> ship_city);
- $shiptostate = urlencode($order -> ship_state);
- $shiptozip = urlencode($order -> ship_zipcode);
- $wpcoDb -> model = $Country -> model;
- $shiptocountry = $wpcoDb -> field('code', array('id' => $user -> ship_country));
- $paymentAction = urlencode("Sale");
- $IPADDRESS = urlencode($_SERVER['REMOTE_ADDR']);
- $nvpRecurring = '';
- $methodToCall = 'DoDirectPayment';
- $wpcoDb -> model = $Country -> model;
- $countrycode = $wpcoDb -> field('code', array('id' => $user -> bill_country));
- $shipmethod_name = $wpcoHtml -> shipmethod_name($order -> shipmethod_id);
- $nvpstr =
- '&PAYMENTACTION=' . $paymentAction .
- '&CUSTOM=' . $shipmethod_name .
- '&IPADDRESS=' . $IPADDRESS .
- '&AMT=' . $amount .
- '&CREDITCARDTYPE=' . $creditCardType .
- '&ACCT=' . $creditCardNumber .
- '&EXPDATE=' . $expDateMonth . $expDateYear .
- '&CVV2=' . $cvv2Number .
- '&EMAIL=' . $email .
- '&FIRSTNAME=' . $firstName .
- '&LASTNAME=' . $lastName .
- '&STREET=' . $address1 .
- '&STREET2=' . $address2 .
- '&CITY=' . $city .
- '&STATE=' . $state .
- '&ZIP=' . $zip .
- '&COUNTRYCODE=' . $countrycode .
- '&CURRENCYCODE=' . $currencyCode .
- '&SHIPTOPHONENUM=' . $shiptophonenum .
- '&SHIPTONAME=' . $SHIPTONAME .
- '&SHIPTOSTREET=' . $SHIPTOSTREET .
- '&SHIPTOSTREET2=' . $SHIPTOSTREET2 .
- '&SHIPTOCITY=' . $shiptocity .
- '&SHIPTOSTATE=' . $shiptostate .
- '&SHIPTOZIP=' . $shiptozip .
- '&SHIPTOCOUNTRY=' . $shiptocountry;
- $subtotal = $Order -> total($order_id, false, false, true, true, false);
- $shipping = $Order -> shipping_total($subtotal, $order_id);
- $tax = $Order -> tax_total($order_id);
- $n = 0;
- $itemamt = 0;
- if (!empty($items)) {
- foreach ($items as $item) {
- $itemamount = ($Product -> unit_price($item -> product -> id, $item -> count, $item -> id, false, true, false, false));
- $nvpstr .= '&L_NAME' . $n . '=' . urlencode($item -> product -> title);
- $nvpstr .= '&L_DESC' . $n . '=' . urlencode(substr(strip_tags($item -> product -> description), 0, 125));
- $nvpstr .= '&L_AMT' . $n . '=' . urlencode(number_format($itemamount, 2, '.', ''));
- $nvpstr .= '&L_NUMBER' . $n . '=' . urlencode($item -> product -> code);
- $nvpstr .= '&L_QTY' . $n . '=' . urlencode($item -> count);
- $n++;
- $itemamt += ($itemamount * $item -> count);
- $itemamount = 0;
- }
- $nvpstr .= '&ITEMAMT=' . urlencode(number_format($itemamt, 2, '.', ''));
- $nvpstr .= '&SHIPPINGAMT=' . urlencode(number_format($shipping, 2, '.', ''));
- $nvpstr .= '&TAXAMT=' . urlencode(number_format($tax, 2, '.', ''));
- }
- $nvpstr .= $nvpRecurring;
- $paypalPro = new wpcopp_pro($api_username, $api_password, $api_signature, '', '', false, false, '57.0', $api_endpoint);
- $resArray = $paypalPro -> hash_call($methodToCall, $nvpstr);
- $ack = strtoupper($resArray["ACK"]);
- $ack = strtoupper($resArray["ACK"]);
- if($ack != "SUCCESS") {
- $success = false;
- $message = __('The transaction has been declined. Please try again.', $this -> plugin_name);
- } else {
- $success = true;
- $message = __('The transaction was successful.', $this -> plugin_name);
- $user_id = $user -> ID;
- }
- $paypalPro -> message = $message;
- $paypalPro -> done($success, $order_id);
- } else {
- $title = __('Processing Order', $this -> plugin_name);
- $this -> process_order($title, $order, $user, $pmethod);
- }
- break;
Add Comment
Please, Sign In to add comment