sahaj_herbs Posted April 30, 2009 Posted April 30, 2009 Every time a customer fills out their info for a new account and then proceeds through the checkout pages and then clicks the Paypal link, this error occurs: Error An error occured when we tried to contact PayPal's servers. Shipping Address State Empty The field Shipping Address State is required (10729) The customer always fills in the state info. I have tried to create mock accounts several times as well, always entering all the info including the state and just get this error each time. Help Please!
Guest Posted April 30, 2009 Posted April 30, 2009 Can you post the code that is in the following file: includes/modules/payment/paypal_ipn.php (or which ever PayPal module you are using)
sahaj_herbs Posted April 30, 2009 Author Posted April 30, 2009 Can you post the code that is in the following file:includes/modules/payment/paypal_ipn.php (or which ever PayPal module you are using) Hi Richard... Hmm... I went there and it lists API username, password, signature and other info - but where is the code?
sahaj_herbs Posted April 30, 2009 Author Posted April 30, 2009 Hi Richard...Hmm... I went there and it lists API username, password, signature and other info - but where is the code? Sorry! I found it: <?php /** * $Id: paypal_wpp.php,v 0.7.3 2006/03/23 Brian Burton [email protected] Exp $ * * Copyright © 2005 Brian Burton - [email protected] * * Released under the GNU General Public License * * Copyright © 2007 PayPal Inc. * */ require_once dirname(__FILE__) . '/paypal_wpp/paypal_wpp_base.php'; class paypal_wpp extends paypal_wpp_base { var $cards = array(array('id' => 'Visa', 'text' => 'Visa'), array('id' => 'MasterCard', 'text' => 'MasterCard'), array('id' => 'Discover', 'text' => 'Discover'), array('id' => 'Amex', 'text' => 'American Express')); var $buttonSource = 'PayPalOscUS'; function paypal_wpp() { global $order; $this->code = 'paypal_wpp'; $this->codeTitle = 'PayPal Website Payments Pro'; $this->codeVersion = '0.7'; $this->enableDebugging = (MODULE_PAYMENT_PAYPAL_DP_DEBUGGING == 'True'); $this->enableDirectPayment = (MODULE_PAYMENT_PAYPAL_DP_DIRECT_ENABLED == 'True'); if (strpos($GLOBALS['PHP_SELF'], 'admin') !== false) { $this->title = MODULE_PAYMENT_PAYPAL_DP_MODULE_TITLE; } else { if (tep_paypal_wpp_enabled() && (tep_session_is_registered('paypal_ec_token') || tep_session_is_registered('paypal_ec_payer_id') && !tep_session_is_registered('paypal_ec_payer_info'))) { $this->title = MODULE_PAYMENT_PAYPAL_EC_TEXT_TITLE; } else { $this->title = MODULE_PAYMENT_PAYPAL_DP_TEXT_TITLE; } } $this->description = MODULE_PAYMENT_PAYPAL_DP_TEXT_DESCRIPTION; $this->sort_order = MODULE_PAYMENT_PAYPAL_DP_SORT_ORDER; $this->enabled = (MODULE_PAYMENT_PAYPAL_DP_STATUS == 'True'); if ((int)MODULE_PAYMENT_PAYPAL_DP_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_PAYPAL_DP_ORDER_STATUS_ID; } $this->zone = (int)MODULE_PAYMENT_PAYPAL_DP_ZONE; if (is_object($order)) $this->update_status(); } function away_with_you($error_msg = '', $kill_sess_vars = false, $goto_page = '') { global $customer_first_name, $customer_id, $navigation, $paypal_ec_token, $paypal_ec_payer_id, $paypal_ec_payer_info, $paypal_error, $paypal_ec_temp; if ($kill_sess_vars) { if ($paypal_ec_temp) { $this->ec_delete_user($customer_id); } //Unregister the paypal session variables making the user start over if (tep_session_is_registered('paypal_ec_temp')) tep_session_unregister('paypal_ec_temp'); if (tep_session_is_registered('paypal_ec_token')) tep_session_unregister('paypal_ec_token'); if (tep_session_is_registered('paypal_ec_markflow')) tep_session_unregister('paypal_ec_markflow'); if (tep_session_is_registered('paypal_ec_payer_id')) tep_session_unregister('paypal_ec_payer_id'); if (tep_session_is_registered('paypal_ec_payer_info')) tep_session_unregister('paypal_ec_payer_info'); } if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) { if ($goto_page == FILENAME_CHECKOUT_PAYMENT || MODULE_PAYMENT_PAYPAL_DP_DISPLAY_PAYMENT_PAGE == 'Yes') { $redirect_path = FILENAME_CHECKOUT_PAYMENT; } elseif ($goto_page) { $redirect_path = $goto_page; } else { $redirect_path = FILENAME_CHECKOUT_SHIPPING; } } else { $navigation->set_snapshot(FILENAME_CHECKOUT_SHIPPING); $redirect_path = FILENAME_LOGIN; } if ($error_msg) { $paypal_error = $error_msg; if (!tep_session_is_registered('paypal_error')) tep_session_register('paypal_error'); } else { if (tep_session_is_registered('paypal_error')) tep_session_unregister('paypal_error'); } tep_redirect(tep_href_link($redirect_path, '', 'SSL', true, false)); } function return_transaction_errors($errors) { // Paypal will sometimes send back more than one error message, // so we must loop through them if necessary. $error_return = ''; $iErr = 1; if (is_array($errors)) { foreach ($errors as $err) { if ($error_return) $error_return .= '<br><br>'; if (sizeof($errors) > 1) { $error_return .= 'Error #' . $iErr . ': '; } $error_return .= $err->ShortMessage . ' (' . $err->ErrorCode . ')<br>' . $err->LongMessage; $iErr++; } } else { $error_return = $errors->ShortMessage . ' (' . $errors->ErrorCode . ')<br>' . $errors->LongMessage; } return $error_return; } function process_button() { global $HTTP_POST_VARS, $paypal_ec_token, $paypal_ec_payer_id, $paypal_ec_payer_info; if (tep_session_is_registered('paypal_ec_token') && tep_session_is_registered('paypal_ec_payer_id') && tep_session_is_registered('paypal_ec_payer_info')) { return ''; } else { $process_button_string = tep_draw_hidden_field('wpp_cc_type', $HTTP_POST_VARS['paypalwpp_cc_type']) . tep_draw_hidden_field('wpp_cc_expdate_month', $HTTP_POST_VARS['paypalwpp_cc_expires_month']) . tep_draw_hidden_field('wpp_cc_expdate_year', $HTTP_POST_VARS['paypalwpp_cc_expires_year']) . tep_draw_hidden_field('wpp_cc_number', $HTTP_POST_VARS['paypalwpp_cc_number']) . tep_draw_hidden_field('wpp_cc_checkcode', $HTTP_POST_VARS['paypalwpp_cc_checkcode']) . tep_draw_hidden_field('wpp_payer_firstname', $HTTP_POST_VARS['paypalwpp_cc_firstname']) . tep_draw_hidden_field('wpp_payer_lastname', $HTTP_POST_VARS['paypalwpp_cc_lastname']) . tep_draw_hidden_field('wpp_redirect_url', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true)); return $process_button_string; } } /** * Initialize the connection with PayPal */ function paypal_init() { global $customer_id, $customer_first_name; set_include_path(dirname(__FILE__) . '/paypal_wpp' . PATH_SEPARATOR . get_include_path()); require_once 'PayPal.php'; require_once 'PayPal/Profile/Handler/Array.php'; require_once 'PayPal/Profile/API.php'; $handler =& ProfileHandler_Array::getInstance(array( 'username' => MODULE_PAYMENT_PAYPAL_DP_API_USERNAME, 'environment' => MODULE_PAYMENT_PAYPAL_DP_SERVER, 'certificateFile' => null, 'subject' => null, )); $profile = APIProfile::getInstance(MODULE_PAYMENT_PAYPAL_DP_API_USERNAME, $handler); $profile->setAPIPassword(MODULE_PAYMENT_PAYPAL_DP_API_PASSWORD); $profile->setSignature(MODULE_PAYMENT_PAYPAL_DP_API_SIGNATURE); $caller =& PayPal::getCallerServices($profile); if (PayPal::isError($caller)) { if ($this->enableDebugging) { tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'PayPal Error Dump', "In function: paypal_init()\r\n\r\n" . print_r($caller, true), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_GEN_ERROR . $caller->Errors->ShortMessage . '<br>' . $caller->Errors->LongMessage . ' (' . $caller->Errors->ErrorCode . ')', true); } else { if (trim(MODULE_PAYMENT_PAYPAL_DP_PROXY) != '') { $caller->setOpt('curl', CURLOPT_PROXYTYPE, CURLPROXY_HTTP); $caller->setOpt('curl', CURLOPT_PROXY, MODULE_PAYMENT_PAYPAL_DP_PROXY); } $caller->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); $caller->setOpt('curl', CURLOPT_TIMEOUT, 180); $caller->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); return $caller; } } /** * This method sends the user to PayPal's site. */ function ec_step1() { // set the globals global $order, $currency, $customer_first_name, $languages_id, $paypal_ec_token; // the method requires require(DIR_WS_CLASSES . 'order.php'); // init new order object $order = new order; // Find out the user's language so that if PayPal supports it, it'll // be the language used on PayPal's site. $lang_code = $this->getLanguageCode(); // Get the PayPal API object. $caller = $this->paypal_init(); // init for the order total object $ot =& PayPal::getType('BasicAmountType'); $ot->setval(number_format($order->info['total'], 2)); // set the currency attribute $ot->setattr('currencyID', $currency); // init for express checkout request details $ecdt =& PayPal::getType('SetExpressCheckoutRequestDetailsType'); // preserve an existing token if (tep_session_is_registered('paypal_ec_token') && !empty($paypal_ec_token)) { $ecdt->setToken($paypal_ec_token); } // set the transaction type $ecdt->setPaymentAction(MODULE_PAYMENT_PAYPAL_WPP_TRXTYPE); // set the order total $ecdt->setOrderTotal($ot); // this sets the return url for when the user is redirected // back from paypal, ie: ec_process.php $ecdt->setReturnURL(tep_href_link(FILENAME_EC_PROCESS, '', 'SSL')); // set the cancel url href link $ecdt->setCancelURL(tep_href_link(FILENAME_SHOPPING_CART, 'ec_cancel=1', 'SSL')); // this checks and sets if the admin value to see if the users // shipping information should be confirmed or not. if (MODULE_PAYMENT_PAYPAL_DP_CONFIRMED == 'Yes') { $ecdt->setReqConfirmShipping(1); } // language code set for request detail obj $ecdt->setLocaleCode($lang_code); // If we are in a "mark" flow and the customer has an usable // address, set the addressoverride variable to 1. This will // override the shipping address in paypal with the shipping // address that is in the osc db. if (($address_arr = $this->getOverrideAddress()) !== false) { // set the override var $ecdt->setAddressOverride('1'); // set the address info // init the AddressType $address_Type =& PayPal::getType('AddressType'); $address_Type->setName($address_arr['entry_firstname'] . ' ' . $address_arr['entry_lastname']); $address_Type->setStreet1($address_arr['entry_street_address']); $address_Type->setStreet2($address_arr['entry_suburb']); $address_Type->setCityName($address_arr['entry_city']); $address_Type->setPostalCode($address_arr['entry_postcode']); $address_Type->setStateOrProvince($address_arr['zone_code']); $address_Type->setCountry($address_arr['countries_iso_code_2']); // set it to the checkout request details $ecdt->setAddress($address_Type); } else { // no address no override, simple as that $ecdt->setAddressOverride('0'); } // set the shipping method if one is not already set $this->setShippingMethod(); // init the express checkout request type object $ec =& PayPal::getType('SetExpressCheckoutRequestType'); // set the express checkout request details object in the ec obj $ec->setSetExpressCheckoutRequestDetails($ecdt); // use the curl object to now send the express checkout information // and get the response back from paypal (CallerServices.php) $response = $caller->SetExpressCheckout($ec); // check for an error // check for success response // check for sucess with warning if (PayPal::isError($response) || ($response->Ack != 'Success' && $response->Ack != 'SuccessWithWarning')) { // we had an error // if the debugging is enabled send an email to the store owner if ($this->enableDebugging) { // send error report tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'PayPal Error Dump', "In function: ec_step1()\r\n\r\n" . print_r($response, true), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } // handle the error $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_GEN_ERROR . $response->Errors->ShortMessage . '<br>' . $response->Errors->LongMessage . ' (' . $response->Errors->ErrorCode . ')', true); } else { // get the ec token $paypal_ec_token = $response->getToken(); // register the ec token (step one is done) tep_session_register('paypal_ec_token'); $_SESSION['paypal_ec_token'] = $paypal_ec_token; // redirect to paypal so the user can fill out their information if (MODULE_PAYMENT_PAYPAL_DP_SERVER == 'live') { // live url $paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; } else { // sandbox url $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } // the redirect if (isset($_SESSION['paypal_ec_markflow'])) { tep_redirect($paypal_url . '?cmd=_express-checkout&token=' . $paypal_ec_token . '&useraction=commit'); } else { tep_redirect($paypal_url . '?cmd=_express-checkout&token=' . $paypal_ec_token); } } } /** * This method is for step 2 of the express checkout option * This retrieves the data set by step one from paypal and sets the osc * data accordingly depending on admin settings */ function ec_step2() { // globals needed global $HTTP_GET_VARS, $paypal_ec_token, $customer_id, $customer_first_name, $language; global $customer_default_address_id, $sendto; // Visitor just came back from PayPal and so we collect all the info // returned, create an account if necessary, then log them in, and then // send them to checkout_shipping.php. if ($paypal_ec_token == '') { // see if the token is set if not we can not continue if (isset($HTTP_GET_VARS['token'])) { // GET param 'token' $paypal_ec_token = $HTTP_GET_VARS['token']; } else { // not ready for this step $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_INVALID_RESPONSE, true); } } // init the paypal caller $caller = $this->paypal_init(); // init the paypal obj to get the express checkout details $ecdt =& PayPal::getType('GetExpressCheckoutDetailsRequestType'); // set the token for the obj $ecdt->setToken($paypal_ec_token); // with the token we'll retrieve the data about this user $response = $caller->GetExpressCheckoutDetails($ecdt); // see if we got an error or if we got some kind of success if (PayPal::isError($response) || ($response->Ack != 'Success' && $response->Ack != 'SuccessWithWarning')) { // we had an error // if the debugging is enabled send an email to the store owner if ($this->enableDebugging) { // send report tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'PayPal Error Dump', "In function: ec_step2()\r\n\r\n" . print_r($response, true), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } // handle the error $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_GEN_ERROR . $this->return_transaction_errors($response->Errors), true); } // This is an array of all the info sent back by PayPal $details = $response->getGetExpressCheckoutDetailsResponseDetails(); // This is the clients payer information $payer_info = $details->getPayerInfo(); // get the payer_id from the clients payer info $paypal_ec_payer_id = $payer_info->getPayerID(); // register the payer_id in the session tep_session_register('paypal_ec_payer_id'); $_SESSION['paypal_ec_payer_id'] = $paypal_ec_payer_id; $fullname = $payer_info->getPayerName(); $address_info = $payer_info->getAddress(); $phone = $details->getContactPhone(); $this->ec_step2_finish(array( 'payer_id' => $payer_info->PayerID, 'payer_email' => $payer_info->Payer, 'payer_firstname' => $fullname->FirstName, 'payer_lastname' => $fullname->LastName, 'payer_business' => $payer_info->PayerBusiness, 'payer_status' => $payer_info->PayerStatus, 'ship_owner' => $address_info->AddressOwner, 'ship_name' => $address_info->Name, 'ship_street_1' => $address_info->Street1, 'ship_street_2' => $address_info->Street2, 'ship_city' => $address_info->CityName, 'ship_state' => $address_info->StateOrProvince, 'ship_postal_code' => $address_info->PostalCode, 'ship_country' => $address_info->Country, 'ship_country_name' => $address_info->CountryName, 'ship_phone' => $address_info->Phone, 'ship_phone' => $phone, 'ship_address_status' => $address_info->AddressStatus), MODULE_PAYMENT_PAYPAL_DP_NEW_ACCT_NOTIFY); } function before_process() { global $HTTP_POST_VARS, $order, $currency, $paypal_ec_token, $paypal_ec_payer_id, $paypal_ec_payer_info; $caller = $this->paypal_init(); if (tep_session_is_registered('paypal_ec_token') && tep_session_is_registered('paypal_ec_payer_id') && tep_session_is_registered('paypal_ec_payer_info')) { //Do EC checkout $pdt =& PayPal::getType('PaymentDetailsType'); $pdt->setButtonSource($this->buttonSource); $at =& PayPal::getType('AddressType'); $at->setName($paypal_ec_payer_info['ship_name']); $at->setStreet1($paypal_ec_payer_info['ship_street_1']); $at->setStreet2($paypal_ec_payer_info['ship_street_2']); $at->setCityName($paypal_ec_payer_info['ship_city']); $at->setStateOrProvince($paypal_ec_payer_info['ship_state']); $at->setCountry($paypal_ec_payer_info['ship_country']); $at->setPostalCode($paypal_ec_payer_info['ship_postal_code']); $pdt->setShipToAddress($at); $order_total =& PayPal::getType('BasicAmountType'); $order_total->setval(number_format($order->info['total'], 2)); $order_total->setattr('currencyID', $order->info['currency']); $pdt->setOrderTotal($order_total); $details =& PayPal::getType('DoExpressCheckoutPaymentRequestDetailsType'); $details->setPaymentAction(MODULE_PAYMENT_PAYPAL_WPP_TRXTYPE); $details->setToken($paypal_ec_token); $details->setPayerID($paypal_ec_payer_id); $details->setPaymentDetails($pdt); $ecprt =& PayPal::getType('DoExpressCheckoutPaymentRequestType'); $ecprt->setDoExpressCheckoutPaymentRequestDetails($details); $response = $caller->DoExpressCheckoutPayment($ecprt); if (PayPal::isError($response) || ($response->Ack != 'Success' && $response->Ack != 'SuccessWithWarning')) { if ($this->enableDebugging) { //Send the store owner a complete dump of the transaction $final_req_dump = print_r($response, true); tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'PayPal Error Dump', "In function: before_process() - Express Checkout\r\n" . $final_req_dump . "\r\n\r\n", STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } if ($final_req->Errors->ErrorCode == '') { $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_DECLINED . 'No response from the payment processor<br>No response was received from the payment processor. Please contact the store owner for assistance.', true); } else { $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_ERROR . $this->return_transaction_errors($response->Errors), true); } } else { $details = $response->getDoExpressCheckoutPaymentResponseDetails(); $payment_info = $details->getPaymentInfo(); $this->payment_type = 'PayPal Express Checkout'; $this->trans_id = $payment_info->getTransactionID(); $this->payment_status = $payment_info->getPaymentStatus(); $this->avs = 'N/A'; $this->cvv2 = 'N/A'; if ($this->payment_status == 'Pending') { $this->pending_reason = $payment_info->getPendingReason(); $this->payment_status .= ' (' . $this->pending_reason . ')'; $order->info['order_status'] = 1; } } } else { // Do DP checkout $cc_type = $HTTP_POST_VARS['wpp_cc_type']; $cc_number = $HTTP_POST_VARS['wpp_cc_number']; $cc_checkcode = $HTTP_POST_VARS['wpp_cc_checkcode']; $cc_first_name = $HTTP_POST_VARS['wpp_payer_firstname']; $cc_last_name = $HTTP_POST_VARS['wpp_payer_lastname']; $cc_owner_ip = $_SERVER['REMOTE_ADDR']; $cc_expdate_month = $HTTP_POST_VARS['wpp_cc_expdate_month']; $cc_expdate_year = $HTTP_POST_VARS['wpp_cc_expdate_year']; if (strlen($cc_expdate_year) < 4) $cc_expdate_year = '20'.$cc_expdate_year; // Set state fields depending on what PayPal wants to see // for that country $this->setStateAndCountry($order->billing); if (tep_not_null($order->delivery['street_address'])) { $this->setStateAndCountry($order->delivery); } // If the cc type sent in the post var isn't any one of the accepted cards, send them back to the payment page // This error should never come up unless the visitor is playing with the post vars or they didn't get passed to checkout_confirmation.php if ($cc_type != 'Visa' && $cc_type != 'MasterCard' && $cc_type != 'Discover' && $cc_type != 'Amex') { $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_BAD_CARD, false, FILENAME_CHECKOUT_PAYMENT); } //If they're still here, and awake, set some of the order object's variables $order->info['cc_type'] = $cc_type; $order->info['cc_number'] = substr($cc_number, 0, 4) . str_repeat('X', (strlen($cc_number) - 8)) . substr($cc_number, -4); $order->info['cc_owner'] = $cc_first_name . ' ' . $cc_last_name; $order->info['cc_expires'] = $cc_expdate_month . substr($cc_expdate_year, -2); //It's time to start a'chargin. Initialize the paypal caller object $caller = $this->paypal_init(); if ( $order->delivery['street_address'] != '' ) { $sat =& PayPal::getType('AddressType'); $sat->setName($order->delivery['firstname'] . ' ' . $order->delivery['lastname']); $sat->setStreet1($order->delivery['street_address']); $sat->setStreet2($order->delivery['suburb']); $sat->setCityName($order->delivery['city']); $sat->setPostalCode($order->delivery['postcode']); $sat->setStateOrProvince($order->delivery['state']); $sat->setCountry($order->delivery['country']['iso_code_2']); } $pdt =& PayPal::getType('PaymentDetailsType'); $pdt->setButtonSource($this->buttonSource); $ot =& PayPal::getType('BasicAmountType'); $ot->setattr('currencyID', $currency); $ot->setval(number_format($order->info['total'], 2)); $pdt->setOrderTotal($ot); if (tep_not_null($order->delivery['street_address'])) $pdt->setShipToAddress($sat); $at =& PayPal::getType('AddressType'); $at->setStreet1($order->billing['street_address']); $at->setStreet2($order->billing['suburb']); $at->setCityName($order->billing['city']); $at->setStateOrProvince($order->billing['state']); $at->setCountry($order->billing['country']['iso_code_2']); $at->setPostalCode($order->billing['postcode']); $pnt =& PayPal::getType('PersonNameType'); $pnt->setFirstName($cc_first_name); $pnt->setLastName($cc_last_name); $pit =& PayPal::getType('PayerInfoType'); $pit->setPayerName($pnt); $pit->setAddress($at); // Send email address of payee -- WILLBRAND // $pit->setPayer($order->customer['email_address']); $ccdt =& PayPal::getType('CreditCardDetailsType'); $ccdt->setCardOwner($pit); $ccdt->setCreditCardType($cc_type); $ccdt->setCreditCardNumber($cc_number); $ccdt->setExpMonth($cc_expdate_month); $ccdt->setExpYear($cc_expdate_year); $ccdt->setCVV2($cc_checkcode); $ddp_req =& PayPal::getType('DoDirectPaymentRequestDetailsType'); $ddp_req->setPaymentAction(MODULE_PAYMENT_PAYPAL_WPP_TRXTYPE); $ddp_req->setPaymentDetails($pdt); $ddp_req->setCreditCard($ccdt); $ddp_req->setIPAddress($cc_owner_ip); $ddp_details =&PayPal::getType('DoDirectPaymentRequestType'); $ddp_details->setVersion('2.0'); $ddp_details->setDoDirectPaymentRequestDetails($ddp_req); $final_req = $caller->DoDirectPayment($ddp_details); //If the transaction wasn't a success, start the error checking if (strpos($final_req->Ack, 'Success') === false) { $error_occurred = false; $ts_result = false; //If an error or failure occurred, don't do a transaction check if (strpos($final_req->Ack, 'Error') !== false || strpos($final_req->Ack, 'Failure') !== false) { $error_occurred = true; $error_log = $this->return_transaction_errors($final_req->Errors); } else { //Do a transaction search to make sure the connection didn't just timeout //It searches by email of payer and amount. That should be accurate enough $ts =& PayPal::getType('TransactionSearchRequestType'); //Set to one day ago to avoid any time zone issues. This does introduce a possible bug, but //the chance of the same person buying the exact same amount of products within one day is pretty unlikely $ts->setStartDate(date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))) . 'T00:00:00-0700'); $ts->setPayer($order->customer['email_address']); $ts->setAmount(number_format($order->info['total'], 2)); $ts_req = $caller->TransactionSearch($ts); //If a matching transaction was found, tell us if (tep_not_null($ts_req->PaymentTransactions) && strpos($ts_req->Ack, 'Success') !== false) { $ts_result = true; } else { $error_log = $this->return_transaction_errors($final_req->Errors); } } if (!$error_occurred && $ts_result) { $return_codes = array($ts_req->PaymentTransactions[0]->TransactionID, 'No AVS Code Returned', 'No CVV2 Code Returned'); } else { if ($this->enableDebugging) { //Send the store owner a complete dump of the transaction $dp_dump = print_r($ddp_details, true); $final_req_dump = print_r($final_req, true); $spacer = "---------------------------------------------------------------------\r\n"; $dp_dump_title = "-------------------------------DP_DUMP-------------------------------\r\n"; $dp_dump_title .= "------------This is the information that was sent to PayPal----------\r\n"; $final_req_title = "-------------------------------FINAL_REQ-----------------------------\r\n"; $final_req_title .= "-------------------This is the response from PayPal------------------\r\n"; $ts_req_dump = print_r($ts_req, true); $ts_req_title = "---------------------------------TS_REQ------------------------------\r\n"; $ts_req_title .= "--------Results of the transaction search if it was executed---------\r\n"; tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'PayPal Error Dump', "In function: before_process() - Direct Payment\r\nDid first contact attempt return error? " . ($error_occurred ? "Yes" : "Nope") . " \r\n" . $spacer . $dp_dump_title . $spacer . $dp_dump . $spacer . $final_req_title . $spacer . $final_req_dump . "\r\n\r\n" . $spacer . $ts_req_title . $spacer . $ts_req_dump, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } //If the return is empty if (!tep_not_null($error_log)) { $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_DECLINED . 'No response from PayPal<br>No response was received from PayPal. Please contact the store owner for assistance.', false, FILENAME_CHECKOUT_PAYMENT); } else { $this->away_with_you(MODULE_PAYMENT_PAYPAL_DP_TEXT_DECLINED . $error_log, false, FILENAME_CHECKOUT_PAYMENT); } } } else { $return_codes = array($final_req->TransactionID, $final_req->AVSCode, $final_req->CVV2Code); } $this->payment_type = 'PayPal Direct Payment'; $this->trans_id = $return_codes[0]; $this->payment_status = 'Completed'; $ret_avs = $return_codes[1]; $ret_cvv2 = $return_codes[2]; switch ($ret_avs) { case 'A': $ret_avs_msg = 'Address Address only (no ZIP)'; break; case 'B': $ret_avs_msg = 'International “A” Address only (no ZIP)'; break; case 'C': $ret_avs_msg = 'International “N” None'; break; case 'D': $ret_avs_msg = 'International “X” Address and Postal Code'; break; case 'E': $ret_avs_msg = 'Not allowed for MOTO (Internet/Phone)'; break; case 'F': $ret_avs_msg = 'UK-specific “X” Address and Postal Code'; break; case 'G': $ret_avs_msg = 'Global Unavailable Not applicable'; break; case 'I': $ret_avs_msg = 'International Unavailable Not applicable'; break; case 'N': $ret_avs_msg = 'No None'; break; case 'P': $ret_avs_msg = 'Postal (International “Z”) Postal Code only (no Address)'; break; case 'R': $ret_avs_msg = 'Retry Not applicable'; break; case 'S': $ret_avs_msg = 'Service not Supported Not applicable'; break; case 'U': $ret_avs_msg = 'Unavailable Not applicable'; break; case 'W': $ret_avs_msg = 'Whole ZIP Nine-digit ZIP code (no Address)'; break; case 'X': $ret_avs_msg = 'Exact match Address and nine-digit ZIP code'; break; case 'Y': $ret_avs_msg = 'Yes Address and five-digit ZIP'; break; case 'Z': $ret_avs_msg = 'ZIP Five-digit ZIP code (no Address)'; break; default: $ret_avs_msg = 'Error'; } switch ($ret_cvv2) { case 'M': $ret_cvv2_msg = 'Match CVV2'; break; case 'N': $ret_cvv2_msg = 'No match None'; break; case 'P': $ret_cvv2_msg = 'Not Processed Not applicable'; break; case 'S': $ret_cvv2_msg = 'Service not Supported Not applicable'; break; case 'U': $ret_cvv2_msg = 'Unavailable Not applicable'; break; case 'X': $ret_cvv2_msg = 'No response Not applicable'; break; default: $ret_cvv2_msg = 'Error'; break; } $this->avs = $ret_avs_msg; $this->cvv2 = $ret_cvv2_msg; } } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_DP_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable this Payment Module', 'MODULE_PAYMENT_PAYPAL_DP_STATUS', 'True', 'Do you want to enable this payment module?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Direct Payment', 'MODULE_PAYMENT_PAYPAL_DP_DIRECT_ENABLED', 'True', 'Would you like to enable credit card payments through PayPal?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Debug Mode', 'MODULE_PAYMENT_PAYPAL_DP_DEBUGGING', 'False', 'Would you like to enable debug mode? A complete dump of failed transactions will be emailed to the store owner.', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Live or Sandbox API', 'MODULE_PAYMENT_PAYPAL_DP_SERVER', 'sandbox', 'Live: Live transactions<br>Sandbox: For developers and testing', '6', '1', 'tep_cfg_select_option(array(\'live\', \'sandbox\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('API Username', 'MODULE_PAYMENT_PAYPAL_DP_API_USERNAME', '', 'Your Paypal WPP API Username', '6', '3', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('API Password', 'MODULE_PAYMENT_PAYPAL_DP_API_PASSWORD', '', 'Your Paypal WPP API Password', '6', '4', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('API Signature', 'MODULE_PAYMENT_PAYPAL_DP_API_SIGNATURE', '', 'Your Paypal WPP API Signature', '6', '4', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Proxy Address', 'MODULE_PAYMENT_PAYPAL_DP_PROXY', '', 'If curl transactions need to go through a proxy, type the address here. Otherwise, leave it blank.', '6', '12', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Type', 'MODULE_PAYMENT_PAYPAL_WPP_TRXTYPE', 'Sale', 'Should customers be charged immediately, or should we perform an authorization? If we perform authorizations, capture must be handled manually by the store owner.)', '6', '0', 'tep_cfg_select_option(array(\'Sale\', \'Authorization\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Express Checkout: Confirmed Address', 'MODULE_PAYMENT_PAYPAL_DP_CONFIRMED', 'No', 'Do you want to require that your customers\' shipping address with PayPal is confirmed?', '6', '7', 'tep_cfg_select_option(array(\'Yes\', \'No\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Express Checkout: Display Payment Page', 'MODULE_PAYMENT_PAYPAL_DP_DISPLAY_PAYMENT_PAGE', 'No', 'If someone\'s checking out with Express Checkout, do you want to display the checkout_payment.php page? The payment options will be hidden. (Yes, if you have CCGV installed)', '6', '8', 'tep_cfg_select_option(array(\'Yes\', \'No\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Express Checkout: Automatic Account Creation', 'MODULE_PAYMENT_PAYPAL_DP_NEW_ACCT_NOTIFY', 'Yes', 'If a visitor is not an existing customer, an account is created for them. Would you like make it a permanent account and send them an email containing their login information?', '6', '9', 'tep_cfg_select_option(array(\'Yes\', \'No\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYPAL_DP_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '12', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYPAL_DP_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '13', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_PAYPAL_DP_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '14', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())"); } function keys() { return array('MODULE_PAYMENT_PAYPAL_DP_STATUS', 'MODULE_PAYMENT_PAYPAL_DP_DIRECT_ENABLED', 'MODULE_PAYMENT_PAYPAL_DP_DEBUGGING', 'MODULE_PAYMENT_PAYPAL_DP_SERVER', 'MODULE_PAYMENT_PAYPAL_DP_API_USERNAME', 'MODULE_PAYMENT_PAYPAL_DP_API_PASSWORD', 'MODULE_PAYMENT_PAYPAL_DP_API_SIGNATURE', 'MODULE_PAYMENT_PAYPAL_DP_PROXY', 'MODULE_PAYMENT_PAYPAL_WPP_TRXTYPE', 'MODULE_PAYMENT_PAYPAL_DP_CONFIRMED', 'MODULE_PAYMENT_PAYPAL_DP_DISPLAY_PAYMENT_PAGE', 'MODULE_PAYMENT_PAYPAL_DP_NEW_ACCT_NOTIFY', 'MODULE_PAYMENT_PAYPAL_DP_SORT_ORDER', 'MODULE_PAYMENT_PAYPAL_DP_ZONE', 'MODULE_PAYMENT_PAYPAL_DP_ORDER_STATUS_ID'); } }
Guest Posted April 30, 2009 Posted April 30, 2009 Try removing the following line: 'ship_state' => $address_info->StateOrProvince, You may need to uninstall and reinstall via the admin section, also just double check that the file above is the actual file you are using. (osCommerce comes standard now with more than 1 PayPal file so always best to check!)
sahaj_herbs Posted April 30, 2009 Author Posted April 30, 2009 Try removing the following line: 'ship_state' => $address_info->StateOrProvince, You may need to uninstall and reinstall via the admin section, also just double check that the file above is the actual file you are using. (osCommerce comes standard now with more than 1 PayPal file so always best to check!) I went back into the modules/payment/paypal page and removed that line. This is what came up: Restricted (403 - Forbidden) Access to this site is currently restricted. Please try again in one hour. If you own this website, please contact your web host. Thank you! Is that not the correct way to remove that line? What else should I do instead?
Guest Posted May 1, 2009 Posted May 1, 2009 That doesn't sound like a problem with the code you removed? If you put the code back in does it still come up with that error?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.