PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-e-commerce/merchants/paypal_multiple.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 649 lines | 554 code | 63 blank | 32 comment | 94 complexity | 348d7a07511ad58ff61c27a20997a026 MD5 | raw file
  1. <?php
  2. $nzshpcrt_gateways[$num]['name'] = 'Paypal Payments Standard';
  3. $nzshpcrt_gateways[$num]['internalname'] = 'paypal_multiple';
  4. $nzshpcrt_gateways[$num]['function'] = 'gateway_paypal_multiple';
  5. $nzshpcrt_gateways[$num]['form'] = "form_paypal_multiple";
  6. $nzshpcrt_gateways[$num]['submit_function'] = "submit_paypal_multiple";
  7. $nzshpcrt_gateways[$num]['payment_type'] = "paypal";
  8. $nzshpcrt_gateways[$num]['supported_currencies']['currency_list'] = array('USD', 'CAD', 'AUD', 'EUR', 'GBP', 'JPY', 'NZD', 'CHF', 'HKD', 'SGD', 'SEK', 'HUF', 'DKK', 'PLN', 'NOK', 'CZK', 'MXN');
  9. $nzshpcrt_gateways[$num]['supported_currencies']['option_name'] = 'paypal_curcode';
  10. function gateway_paypal_multiple($seperator, $sessionid) {
  11. global $wpdb, $wpsc_cart;
  12. $purchase_log = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= ".$sessionid." LIMIT 1",ARRAY_A) ;
  13. if ($purchase_log['totalprice']==0) {
  14. header("Location: ".get_option('transact_url').$seperator."sessionid=".$sessionid);
  15. exit();
  16. }
  17. $cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='".$purchase_log['id']."'";
  18. $cart = $wpdb->get_results($cart_sql,ARRAY_A) ;
  19. //written by allen
  20. //exit("<pre>".print_r($cart,true)."</pre>");
  21. $member_subtype = get_product_meta($cart[0]['prodid'],'is_permenant',true);
  22. $status = get_product_meta($cart[0]['prodid'],'is_membership',true);
  23. $is_member = $status;
  24. $is_perm = $member_subtype;
  25. //end of written by allen
  26. $transact_url = get_option('transact_url');
  27. // paypal connection variables
  28. $data['business'] = get_option('paypal_multiple_business');
  29. $data['return'] = urlencode($transact_url.$seperator."sessionid=".$sessionid."&gateway=paypal");
  30. $data['cancel_return'] = urlencode($transact_url);
  31. $data['notify_url'] =urlencode(get_option('siteurl')."/?ipn_request=true");
  32. $data['rm'] = '2';
  33. //data['bn'] = 'Instinct-WP-e-commerce_ShoppingCart_EC';
  34. // look up the currency codes and local price
  35. $currency_code = $wpdb->get_results("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A);
  36. $local_currency_code = $currency_code[0]['code'];
  37. $paypal_currency_code = get_option('paypal_curcode');
  38. if($paypal_currency_code == '') {
  39. $paypal_currency_code = 'US';
  40. }
  41. //exit(get_option('currency_type'). " ".$paypal_currency_code);
  42. // Stupid paypal only accepts payments in one of 5 currencies. Convert from the currency of the users shopping cart to the curency which the user has specified in their paypal preferences.
  43. $curr=new CURRENCYCONVERTER();
  44. $data['currency_code'] = $paypal_currency_code;
  45. // $data['lc'] = 'US';
  46. $data['lc'] = $paypal_currency_code;
  47. $data['bn'] = 'wp-e-commerce';
  48. if(get_option('address_override') == 1) {
  49. $data['address_override'] = '1';
  50. }
  51. if((int)(bool)get_option('paypal_ship') == '1'){
  52. $data['no_shipping'] = '0';
  53. $data['address_override'] = '1';
  54. }
  55. $data['no_note'] = '1';
  56. switch($paypal_currency_code) {
  57. case "JPY":
  58. $decimal_places = 0;
  59. break;
  60. case "HUF":
  61. $decimal_places = 0;
  62. default:
  63. $decimal_places = 2;
  64. break;
  65. }
  66. $i = 1;
  67. $all_donations = true;
  68. $all_no_shipping = true;
  69. $total = $wpsc_cart->calculate_total_price();
  70. $discount = $wpsc_cart->coupons_amount;
  71. //exit($discount);
  72. if(($discount > 0)) {
  73. if($paypal_currency_code != $local_currency_code) {
  74. $paypal_currency_productprice = $curr->convert( $wpsc_cart->calculate_total_price(),$paypal_currency_code,$local_currency_code);
  75. $paypal_currency_shipping = $curr->convert($local_currency_shipping,$paypal_currency_code,$local_currency_code);
  76. $base_shipping = $curr->convert($wpsc_cart->calculate_total_shipping(),$paypal_currency_code, $local_currency_code);
  77. $tax_price = $curr->convert($item['tax_charged'],$paypal_currency_code, $local_currency_code);
  78. } else {
  79. $paypal_currency_productprice = $wpsc_cart->calculate_total_price();
  80. $paypal_currency_shipping = $local_currency_shipping;
  81. $base_shipping = $wpsc_cart->calculate_total_shipping();
  82. $tax_price = $item['tax_charged'];
  83. }
  84. $data['item_name_'.$i] = "Your Shopping Cart";
  85. $data['amount_'.$i] = number_format(sprintf("%01.2f",$paypal_currency_productprice),$decimal_places,'.','');
  86. $data['quantity_'.$i] = 1;
  87. // $data['item_number_'.$i] = 0;
  88. $data['shipping_'.$i] = 0;
  89. $data['shipping2_'.$i] = 0;
  90. $data['handling_'.$i] = 0;
  91. $i++;
  92. } else {
  93. foreach((array)$cart as $item) {
  94. $product_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$item['prodid']."' LIMIT 1",ARRAY_A);
  95. $product_data = $product_data[0];
  96. if ((float)$item['price'] == 0 ) {
  97. continue;
  98. }
  99. $variation_count = count($product_variations);
  100. $local_currency_productprice = $item['price'];
  101. $local_currency_shipping = $item['pnp'];
  102. if($paypal_currency_code != $local_currency_code) {
  103. $paypal_currency_productprice = $curr->convert($local_currency_productprice,$paypal_currency_code,$local_currency_code);
  104. $paypal_currency_shipping = $curr->convert($local_currency_shipping,$paypal_currency_code,$local_currency_code);
  105. // exit($paypal_currency_productprice . " " . $paypal_currency_shipping.' '.$local_currency_productprice . " " . $local_currency_code);
  106. $base_shipping = $curr->convert($wpsc_cart->calculate_total_shipping(),$paypal_currency_code, $local_currency_code);
  107. //exit($paypal_currency_productprice.' Local>'.$local_currency_productprice.' Base shp'.$base_shipping);
  108. $tax_price = $curr->convert($item['tax_charged'],$paypal_currency_code, $local_currency_code);
  109. } else {
  110. $paypal_currency_productprice = $local_currency_productprice;
  111. $paypal_currency_shipping = $local_currency_shipping;
  112. $base_shipping = $wpsc_cart->calculate_total_shipping();
  113. $tax_price = $item['tax_charged'];
  114. }
  115. //exit("<pre>".print_r(, true).'</pre>');
  116. $data['item_name_'.$i] = urlencode(stripslashes($item['name']));
  117. $data['amount_'.$i] = number_format(sprintf("%01.2f", $paypal_currency_productprice),$decimal_places,'.','');
  118. $data['tax_'.$i] = number_format(sprintf("%01.2f",$tax_price),$decimal_places,'.','');
  119. $data['quantity_'.$i] = $item['quantity'];
  120. $data['item_number_'.$i] = $product_data['id'];
  121. if($item['donation'] !=1) {
  122. $all_donations = false;
  123. $data['shipping_'.$i] = number_format($paypal_currency_shipping,$decimal_places,'.','');
  124. $data['shipping2_'.$i] = number_format($paypal_currency_shipping,$decimal_places,'.','');
  125. } else {
  126. $data['shipping_'.$i] = number_format(0,$decimal_places,'.','');
  127. $data['shipping2_'.$i] = number_format(0,$decimal_places,'.','');
  128. }
  129. if($product_data['no_shipping'] != 1) {
  130. $all_no_shipping = false;
  131. }
  132. $data['handling_'.$i] = '';
  133. $i++;
  134. }
  135. }
  136. $data['tax'] = '';
  137. //exit($base_shipping);
  138. if(($base_shipping > 0) && ($all_donations == false) && ($all_no_shipping == false)) {
  139. $data['handling_cart'] = number_format($base_shipping,$decimal_places,'.','');
  140. }
  141. $data['custom'] = '';
  142. $data['invoice'] = $sessionid;
  143. // User details
  144. if($_POST['collected_data'][get_option('paypal_form_first_name')] != '') {
  145. $data['first_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_first_name')]);
  146. }
  147. if($_POST['collected_data'][get_option('paypal_form_last_name')] != '') {
  148. $data['last_name'] = urlencode($_POST['collected_data'][get_option('paypal_form_last_name')]);
  149. }
  150. if($_POST['collected_data'][get_option('paypal_form_address')] != '') {
  151. $address_rows = explode("\n\r",$_POST['collected_data'][get_option('paypal_form_address')]);
  152. $data['address1'] = urlencode(str_replace(array("\n", "\r"), '', $address_rows[0]));
  153. unset($address_rows[0]);
  154. if($address_rows != null) {
  155. $data['address2'] = implode(", ",$address_rows);
  156. } else {
  157. $data['address2'] = '';
  158. }
  159. }
  160. if($_POST['collected_data'][get_option('paypal_form_city')] != '') {
  161. $data['city'] = urlencode($_POST['collected_data'][get_option('paypal_form_city')]);
  162. }
  163. if($_POST['collected_data'][get_option('paypal_form_state')] != '') {
  164. if(!is_array($_POST['collected_data'][get_option('paypal_form_state')])){
  165. $data['state'] = urlencode($_POST['collected_data'][get_option('paypal_form_state')]);
  166. }
  167. }
  168. if($_POST['collected_data'][get_option('paypal_form_country')] != '') {
  169. if(is_array($_POST['collected_data'][get_option('paypal_form_country')])) {
  170. $country = $_POST['collected_data'][get_option('paypal_form_country')][0];
  171. $id = $_POST['collected_data'][get_option('paypal_form_country')][1];
  172. $state = wpsc_get_state_by_id($id, 'code');
  173. } else {
  174. $country = $_POST['collected_data'][get_option('paypal_form_country')];
  175. }
  176. $data['country'] = urlencode($country);
  177. if($state != ''){
  178. $data['state'] = $state;
  179. }
  180. }
  181. if(is_numeric($_POST['collected_data'][get_option('paypal_form_post_code')])) {
  182. $data['zip'] = urlencode($_POST['collected_data'][get_option('paypal_form_post_code')]);
  183. }
  184. // Change suggested by waxfeet@gmail.com, if email to be sent is not there, dont send an email address
  185. $email_data = $wpdb->get_results("SELECT `id`,`type` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` IN ('email') AND `active` = '1'",ARRAY_A);
  186. foreach((array)$email_data as $email) {
  187. $data['email'] = $_POST['collected_data'][$email['id']];
  188. }
  189. if(($_POST['collected_data'][get_option('email_form_field')] != null) && ($data['email'] == null)) {
  190. $data['email'] = $_POST['collected_data'][get_option('email_form_field')];
  191. }
  192. $data['upload'] = '1';
  193. $data['cmd'] = "_ext-enter";
  194. $data['redirect_cmd'] = "_cart";
  195. $data = apply_filters('wpsc_paypal_standard_post_data',$data);
  196. $datacount = count($data);
  197. $num = 0;
  198. foreach($data as $key=>$value) {
  199. $amp = '&';
  200. $num++;
  201. if($num == $datacount) {
  202. $amp = '';
  203. }
  204. //$output .= $key.'='.urlencode($value).$amp;
  205. $output .= $key.'='.$value.$amp;
  206. }
  207. if(get_option('paypal_ipn') == 0) { //ensures that digital downloads still work for people without IPN, less secure, though
  208. //$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '2' WHERE `sessionid` = ".$sessionid." LIMIT 1");
  209. }
  210. //written by allen
  211. if ($is_member == '1') {
  212. $membership_length = get_product_meta($cart[0]['prodid'],'membership_length',true);
  213. if ($is_perm == '1'){
  214. $permsub = '&src=1';
  215. } else {
  216. $permsub = '';
  217. }
  218. $output = 'cmd=_xclick-subscriptions&currency_code='.urlencode($data['currency_code']).'&lc='.urlencode($data['lc']).'&business='.urlencode($data['business']).'&no_note=1&item_name='.urlencode($data['item_name_1']).'&return='.urlencode($data['return']).'&cancel_return='.urlencode($data['cancel_return']).$permsub.'&a3='.urlencode($data['amount_1']).'&p3='.urlencode($membership_length['length']).'&t3='.urlencode(strtoupper($membership_length['unit']));
  219. }
  220. if(defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true) ) {
  221. echo "<a href='".get_option('paypal_multiple_url')."?".$output."'>Test the URL here</a>";
  222. echo "<pre>".print_r($data,true)."</pre>";
  223. // echo "<pre>".print_r($_POST,true)."</pre>";
  224. exit();
  225. }
  226. header("Location: ".get_option('paypal_multiple_url')."?".$output);
  227. exit();
  228. }
  229. function nzshpcrt_paypal_ipn() {
  230. global $wpdb;
  231. // needs to execute on page start
  232. // look at page 36
  233. //exit(WPSC_GATEWAY_DEBUG );
  234. if(($_GET['ipn_request'] == 'true') && (get_option('paypal_ipn') == 1)) {
  235. // read the post from PayPal system and add 'cmd'
  236. $fields = 'cmd=_notify-validate';
  237. $message = "";
  238. foreach ($_POST as $key => $value) {
  239. $value = urlencode(stripslashes($value));
  240. $fields .= "&$key=$value";
  241. }
  242. // post back to PayPal system to validate
  243. $results = '';
  244. if(function_exists('curl_init')) {
  245. $ch=curl_init();
  246. curl_setopt($ch, CURLOPT_URL, get_option('paypal_multiple_url'));
  247. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  248. curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
  249. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  250. curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
  251. curl_setopt($ch, CURLOPT_POST, 1);
  252. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  253. curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  254. curl_setopt($ch, CURLOPT_USERAGENT, "WP e-Commerce ".WPSC_PRESENTABLE_VERSION);
  255. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  256. $results = curl_exec($ch);
  257. curl_close($ch);
  258. } else {
  259. $replace_strings[0] = 'http://';
  260. $replace_strings[1] = 'https://';
  261. $replace_strings[2] = '/cgi-bin/webscr';
  262. $paypal_url = str_replace($replace_strings, "",get_option('paypal_multiple_url'));
  263. $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  264. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  265. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  266. $fp = fsockopen($paypal_url, 80, $errno, $errstr, 30);
  267. if($fp) {
  268. fputs ($fp, $header . $fields);
  269. while (!feof($fp)) {
  270. $res = fgets ($fp, 1024);
  271. $results .= $fields;
  272. }
  273. fclose ($fp);
  274. }
  275. }
  276. // assign posted variables to local variables
  277. $sessionid = $_POST['invoice'];
  278. $transaction_id = $_POST['txn_id'];
  279. $verification_data['item_name'] = $_POST['item_name'];
  280. $verification_data['item_number'] = $_POST['item_number'];
  281. $verification_data['payment_status'] = $_POST['payment_status'];
  282. $verification_data['payment_amount'] = $_POST['mc_gross'];
  283. $verification_data['payment_currency'] = $_POST['mc_currency'];
  284. $verification_data['txn_id'] = $_POST['txn_id'];
  285. $verification_data['receiver_email'] = $_POST['receiver_email'];
  286. $verification_data['payer_email'] = $_POST['payer_email'];
  287. if(strcmp ($results, "VERIFIED") == 0){
  288. switch($verification_data['payment_status']) {
  289. case 'Processed': // I think this is mostly equivalent to Completed
  290. case 'Completed':
  291. $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '2' WHERE `sessionid` = ".$sessionid." LIMIT 1");
  292. transaction_results($sessionid, false, $transaction_id);
  293. break;
  294. case 'Failed': // if it fails, delete it
  295. $log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`='$sessionid' LIMIT 1");
  296. $delete_log_form_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$log_id'";
  297. $cart_content = $wpdb->get_results($delete_log_form_sql,ARRAY_A);
  298. foreach((array)$cart_content as $cart_item) {
  299. $cart_item_variations = $wpdb->query("DELETE FROM `".WPSC_TABLE_CART_ITEM_VARIATIONS."` WHERE `cart_id` = '".$cart_item['id']."'", ARRAY_A);
  300. }
  301. $wpdb->query("DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$log_id'");
  302. $wpdb->query("DELETE FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` IN ('$log_id')");
  303. $wpdb->query("DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='$log_id' LIMIT 1");
  304. break;
  305. case 'Pending': // need to wait for "Completed" before processing
  306. $sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."' WHERE `sessionid` = ".$sessionid." LIMIT 1";
  307. $wpdb->query($sql) ;
  308. break;
  309. default: // if nothing, do nothing, safest course of action here.
  310. break;
  311. }
  312. } else if (strcmp ($results, "INVALID") == 0) {
  313. // Its already logged, not much need to do more
  314. }
  315. /*
  316. * Detect use of sandbox mode, if sandbox mode is present, send debugging email.
  317. */
  318. if(stristr(get_option('paypal_multiple_url'), "sandbox") || (defined('WPSC_ADD_DEBUG_PAGE') and (WPSC_ADD_DEBUG_PAGE == true)) ) {
  319. $message = "This is a debugging message sent because it appears that you are using sandbox mode.\n\rIt is only sent if the paypal URL contains the word \"sandbox\"\n\r\n\r";
  320. $message .= "RESULTS:\n\r".print_r($results,true)."\n\r\n\r";
  321. $message .= "OUR_POST:\n\r".print_r($header . $req,true)."\n\r\n\r";
  322. $message .= "THEIR_POST:\n\r".print_r($_POST,true)."\n\r\n\r";
  323. $message .= "GET:\n\r".print_r($_GET,true)."\n\r\n\r";
  324. $message .= "SERVER:\n\r".print_r($_SERVER,true)."\n\r\n\r";
  325. //$wpdb->query("INSERT INTO `paypal_log` ( `id` , `text` , `date` ) VALUES ( '', '$message', NOW( ) );");
  326. mail(get_option('purch_log_email'), "IPN Data", $message);
  327. }
  328. exit();
  329. }
  330. }
  331. function submit_paypal_multiple(){
  332. if($_POST['paypal_multiple_business'] != null) {
  333. update_option('paypal_multiple_business', $_POST['paypal_multiple_business']);
  334. }
  335. if($_POST['paypal_multiple_url'] != null) {
  336. update_option('paypal_multiple_url', $_POST['paypal_multiple_url']);
  337. }
  338. if($_POST['paypal_curcode'] != null) {
  339. update_option('paypal_curcode', $_POST['paypal_curcode']);
  340. }
  341. if($_POST['paypal_curcode'] != null) {
  342. update_option('paypal_curcode', $_POST['paypal_curcode']);
  343. }
  344. if($_POST['paypal_ipn'] != null) {
  345. update_option('paypal_ipn', (int)$_POST['paypal_ipn']);
  346. }
  347. if($_POST['address_override'] != null) {
  348. update_option('address_override', (int)$_POST['address_override']);
  349. }
  350. if($_POST['paypal_ship'] != null) {
  351. update_option('paypal_ship', (int)$_POST['paypal_ship']);
  352. }
  353. foreach((array)$_POST['paypal_form'] as $form => $value) {
  354. update_option(('paypal_form_'.$form), $value);
  355. }
  356. return true;
  357. }
  358. function form_paypal_multiple() {
  359. global $wpdb, $wpsc_gateways;
  360. $output = "
  361. <tr>
  362. <td>Username:
  363. </td>
  364. <td>
  365. <input type='text' size='40' value='".get_option('paypal_multiple_business')."' name='paypal_multiple_business' />
  366. </td>
  367. </tr>
  368. <tr>
  369. <td>Url:
  370. </td>
  371. <td>
  372. <input type='text' size='40' value='".get_option('paypal_multiple_url')."' name='paypal_multiple_url' /> <br />
  373. </td>
  374. </tr>
  375. ";
  376. $paypal_ipn = get_option('paypal_ipn');
  377. $paypal_ipn1 = "";
  378. $paypal_ipn2 = "";
  379. switch($paypal_ipn) {
  380. case 0:
  381. $paypal_ipn2 = "checked ='checked'";
  382. break;
  383. case 1:
  384. $paypal_ipn1 = "checked ='checked'";
  385. break;
  386. }
  387. $paypal_ship = get_option('paypal_ship');
  388. $paypal_ship1 = "";
  389. $paypal_ship2 = "";
  390. switch($paypal_ship){
  391. case 1:
  392. $paypal_ship1 = "checked='checked'";
  393. break;
  394. case 0:
  395. default:
  396. $paypal_ship2 = "checked='checked'";
  397. break;
  398. }
  399. $address_override = get_option('address_override');
  400. $address_override1 = "";
  401. $address_override2 = "";
  402. switch($address_override) {
  403. case 1:
  404. $address_override1 = "checked ='checked'";
  405. break;
  406. case 0:
  407. default:
  408. $address_override2 = "checked ='checked'";
  409. break;
  410. }
  411. $output .= "
  412. <tr>
  413. <td>IPN :
  414. </td>
  415. <td>
  416. <input type='radio' value='1' name='paypal_ipn' id='paypal_ipn1' ".$paypal_ipn1." /> <label for='paypal_ipn1'>".__('Yes', 'wpsc')."</label> &nbsp;
  417. <input type='radio' value='0' name='paypal_ipn' id='paypal_ipn2' ".$paypal_ipn2." /> <label for='paypal_ipn2'>".__('No', 'wpsc')."</label>
  418. </td>
  419. </tr>
  420. <tr>
  421. <td style='padding-bottom: 0px;'>Send shipping details:
  422. </td>
  423. <td style='padding-bottom: 0px;'>
  424. <input type='radio' value='1' name='paypal_ship' id='paypal_ship1' ".$paypal_ship1." /> <label for='paypal_ship1'>".__('Yes', 'wpsc')."</label> &nbsp;
  425. <input type='radio' value='0' name='paypal_ship' id='paypal_ship2' ".$paypal_ship2." /> <label for='paypal_ship2'>".__('No', 'wpsc')."</label>
  426. </td>
  427. </tr>
  428. <tr>
  429. <td colspan='2'>
  430. <span class='wpscsmall description'>
  431. Note: If your checkout page does not have a shipping details section, or if you don't want to send Paypal shipping information. You should change Send shipping details option to No.</span>
  432. </td>
  433. </tr>
  434. <tr>
  435. <td style='padding-bottom: 0px;'>
  436. Address Override:
  437. </td>
  438. <td style='padding-bottom: 0px;'>
  439. <input type='radio' value='1' name='address_override' id='address_override1' ".$address_override1." /> <label for='address_override1'>".__('Yes', 'wpsc')."</label> &nbsp;
  440. <input type='radio' value='0' name='address_override' id='address_override2' ".$address_override2." /> <label for='address_override2'>".__('No', 'wpsc')."</label>
  441. </td>
  442. </tr>
  443. <tr>
  444. <td colspan='2'>
  445. <span class='wpscsmall description'>
  446. This setting affects your PayPal purchase log. If your customers already have a PayPal account PayPal will try to populate your PayPal Purchase Log with their PayPal address. This setting tries to replace the address in the PayPal purchase log with the Address customers enter on your Checkout page.
  447. </span>
  448. </td>
  449. </tr>\n";
  450. $store_currency_data = $wpdb->get_row("SELECT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN ('".absint(get_option('currency_type'))."')", ARRAY_A);
  451. $current_currency = get_option('paypal_curcode');
  452. if(($current_currency == '') && in_array($store_currency_data['code'], $wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'])) {
  453. update_option('paypal_curcode', $store_currency_data['code']);
  454. $current_currency = $store_currency_data['code'];
  455. }
  456. // exit($current_currency.'<br />'.$store_currency_data['code']);
  457. if($current_currency != $store_currency_data['code']) {
  458. $output .= "
  459. <tr>
  460. <td colspan='2'><strong class='form_group'>".__('Currency Converter')."</td>
  461. </tr>
  462. <tr>
  463. <td colspan='2'>".sprintf(__('Your website uses <strong>%s</strong>. This currency is not supported by PayPal, please select a currency using the drop down menu below. Buyers on your site will still pay in your local currency however we will send the order through to Paypal using the currency you choose below.', 'wpsc'), $store_currency_data['currency'])."</td>
  464. </tr>\n";
  465. $output .= " <tr>\n";
  466. $output .= " <td>Select Currency:</td>\n";
  467. $output .= " <td>\n";
  468. $output .= " <select name='paypal_curcode'>\n";
  469. $paypal_currency_list = $wpsc_gateways['paypal_multiple']['supported_currencies']['currency_list'];
  470. $currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
  471. foreach($currency_list as $currency_item) {
  472. $selected_currency = '';
  473. if($current_currency == $currency_item['code']) {
  474. $selected_currency = "selected='selected'";
  475. }
  476. $output .= "<option ".$selected_currency." value='{$currency_item['code']}'>{$currency_item['currency']}</option>";
  477. }
  478. $output .= " </select> \n";
  479. $output .= " </td>\n";
  480. $output .= " </tr>\n";
  481. }
  482. $output .= "
  483. <tr class='update_gateway' >
  484. <td colspan='2'>
  485. <div class='submit'>
  486. <input type='submit' value='".__('Update &raquo;', 'wpsc')."' name='updateoption'/>
  487. </div>
  488. </td>
  489. </tr>
  490. <tr class='firstrowth'>
  491. <td style='border-bottom: medium none;' colspan='2'>
  492. <strong class='form_group'>Forms Sent to Gateway</strong>
  493. </td>
  494. </tr>
  495. <tr>
  496. <td>
  497. First Name Field
  498. </td>
  499. <td>
  500. <select name='paypal_form[first_name]'>
  501. ".nzshpcrt_form_field_list(get_option('paypal_form_first_name'))."
  502. </select>
  503. </td>
  504. </tr>
  505. <tr>
  506. <td>
  507. Last Name Field
  508. </td>
  509. <td>
  510. <select name='paypal_form[last_name]'>
  511. ".nzshpcrt_form_field_list(get_option('paypal_form_last_name'))."
  512. </select>
  513. </td>
  514. </tr>
  515. <tr>
  516. <td>
  517. Address Field
  518. </td>
  519. <td>
  520. <select name='paypal_form[address]'>
  521. ".nzshpcrt_form_field_list(get_option('paypal_form_address'))."
  522. </select>
  523. </td>
  524. </tr>
  525. <tr>
  526. <td>
  527. City Field
  528. </td>
  529. <td>
  530. <select name='paypal_form[city]'>
  531. ".nzshpcrt_form_field_list(get_option('paypal_form_city'))."
  532. </select>
  533. </td>
  534. </tr>
  535. <tr>
  536. <td>
  537. State Field
  538. </td>
  539. <td>
  540. <select name='paypal_form[state]'>
  541. ".nzshpcrt_form_field_list(get_option('paypal_form_state'))."
  542. </select>
  543. </td>
  544. </tr>
  545. <tr>
  546. <td>
  547. Postal code/Zip code Field
  548. </td>
  549. <td>
  550. <select name='paypal_form[post_code]'>
  551. ".nzshpcrt_form_field_list(get_option('paypal_form_post_code'))."
  552. </select>
  553. </td>
  554. </tr>
  555. <tr>
  556. <td>
  557. Country Field
  558. </td>
  559. <td>
  560. <select name='paypal_form[country]'>
  561. ".nzshpcrt_form_field_list(get_option('paypal_form_country'))."
  562. </select>
  563. </td>
  564. </tr> ";
  565. return $output;
  566. }
  567. add_action('init', 'nzshpcrt_paypal_ipn');
  568. ?>