Source Code Documentation


s2member-pro\includes\classes\gateways\authnet\authnet-checkout-in.inc.php


  1. <?php
  2. /**
  3. * Authorize.Net® Checkout Form handler ( inner processing routines ).
  4. *
  5. * Copyright: © 2009-2011
  6. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  7. * ( coded in the USA )
  8. *
  9. * This WordPress® plugin ( s2Member Pro ) is comprised of two parts:
  10. *
  11. * o (1) Its PHP code is licensed under the GPL license, as is WordPress®.
  12. * You should have received a copy of the GNU General Public License,
  13. * along with this software. In the main directory, see: /licensing/
  14. * If not, see: {@link http://www.gnu.org/licenses/}.
  15. *
  16. * o (2) All other parts of ( s2Member Pro ); including, but not limited to:
  17. * the CSS code, some JavaScript code, images, and design;
  18. * are licensed according to the license purchased.
  19. * See: {@link http://www.s2member.com/prices/}
  20. *
  21. * Unless you have our prior written consent, you must NOT directly or indirectly license,
  22. * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module;
  23. * or make an offer to do any of these things. All of these things are strictly
  24. * prohibited with part (2) of the s2Member Pro Module.
  25. *
  26. * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com
  27. * ( i.e. new features, bug fixes, updates, improvements ); along with full access
  28. * to our video tutorial library: {@link http://www.s2member.com/videos/}
  29. *
  30. * @package s2Member\AuthNet
  31. * @since 1.5
  32. */
  33. if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
  34. exit("Do not access this file directly.");
  35. /**/
  36. if(!class_exists("c_ws_plugin__s2member_pro_authnet_checkout_in"))
  37. {
  38. /**
  39. * Authorize.Net® Checkout Form handler ( inner processing routines ).
  40. *
  41. * @package s2Member\AuthNet
  42. * @since 1.5
  43. */
  44. class c_ws_plugin__s2member_pro_authnet_checkout_in
  45. {
  46. /**
  47. * Handles processing of Pro Form checkouts.
  48. *
  49. * @package s2Member\AuthNet
  50. * @since 1.5
  51. *
  52. * @attaches-to ``add_action("init");``
  53. *
  54. * @return null Or exits script execution after a custom URL redirection.
  55. *
  56. * @todo Add support for `rrt=""` Attribute.
  57. * @todo Build in routine to void first payment if Recurring Profile creation fails for some reason? Seems logical, even though highly unlikely.
  58. */
  59. public static function authnet_checkout()
  60. {
  61. if(!empty($_POST["s2member_pro_authnet_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_authnet_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-checkout"))
  62. {
  63. $GLOBALS["ws_plugin__s2member_pro_authnet_checkout_response"] = array(); /* This holds the global response details. */
  64. $global_response = &$GLOBALS["ws_plugin__s2member_pro_authnet_checkout_response"]; /* This is a shorter reference. */
  65. /**/
  66. $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_authnet_checkout"]));
  67. $post_vars["attr"] = unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])); /* And Filter. */
  68. $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_authnet_checkout_post_attr", $post_vars["attr"], get_defined_vars());
  69. /**/
  70. $post_vars["recaptcha_challenge_field"] = (!$post_vars["recaptcha_challenge_field"]) ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
  71. $post_vars["recaptcha_response_field"] = (!$post_vars["recaptcha_response_field"]) ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
  72. /**/
  73. $post_vars["name"] = trim($post_vars["first_name"]." ".$post_vars["last_name"]);
  74. $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
  75. $post_vars["username"] = preg_replace("/\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
  76. /**/
  77. if(!c_ws_plugin__s2member_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) /* Attr errors? */
  78. {
  79. if(!($error = c_ws_plugin__s2member_pro_authnet_responses::authnet_form_submission_validation_errors("checkout", $post_vars)))
  80. {
  81. $cp_attr = c_ws_plugin__s2member_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
  82. $cost_calculations = c_ws_plugin__s2member_pro_authnet_utilities::authnet_cost($cp_attr["ta"], $cp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_attr["cc"], $cp_attr["desc"]);
  83. /**/
  84. $use_recurring_profile = ($post_vars["attr"]["rr"] === "BN" || (!$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"])) ? false : true;
  85. $is_independent_ccaps_sale = ($post_vars["attr"]["level"] === "*") ? true : false; /* Selling Independent Custom Capabilities? */
  86. /**/
  87. if($use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID))
  88. {
  89. $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"]." ".$post_vars["attr"]["tt"]);
  90. $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"]." ".$post_vars["attr"]["rt"]);
  91. /**/
  92. $start_time = ($post_vars["attr"]["tp"]) ? /* If there's an Initial/Trial Period; start when it's over. */
  93. c_ws_plugin__s2member_pro_authnet_utilities::authnet_start_time($period1) : /* After Trial is over. */
  94. c_ws_plugin__s2member_pro_authnet_utilities::authnet_start_time($period3); /* Or next billing cycle. */
  95. /**/
  96. $reference = $start_time.":".$period1.":".$period3."~".$_SERVER["HTTP_HOST"]."~".$post_vars["attr"]["level_ccaps_eotper"];
  97. /**/
  98. update_user_meta($user_id, "first_name", $post_vars["first_name"]).update_user_meta($user_id, "last_name", $post_vars["last_name"]);
  99. /**/
  100. if(!($_authnet = array()) /* A first Initial/Trial payment? */
  101. && (!$post_vars["attr"]["tp"] || ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)))
  102. {
  103. $_authnet["x_type"] = "AUTH_CAPTURE";
  104. $_authnet["x_method"] = "CC";
  105. /**/
  106. $_authnet["x_email"] = $user->user_email;
  107. $_authnet["x_first_name"] = $post_vars["first_name"];
  108. $_authnet["x_last_name"] = $post_vars["last_name"];
  109. $_authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
  110. /**/
  111. $_authnet["x_invoice_num"] = "s2-".uniqid();
  112. $_authnet["x_description"] = $cost_calculations["desc"];
  113. /**/
  114. $_authnet["s2_initial_payment"] = "1"; /* Initial. */
  115. /**/
  116. $_authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
  117. $_authnet["s2_custom"] = $post_vars["attr"]["custom"];
  118. /**/
  119. if($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)
  120. {
  121. $_authnet["x_tax"] = $cost_calculations["trial_tax"];
  122. $_authnet["x_amount"] = $cost_calculations["trial_total"];
  123. }
  124. else /* Otherwise, charge for the first Regular payment. */
  125. {
  126. $_authnet["x_tax"] = $cost_calculations["tax"];
  127. $_authnet["x_amount"] = $cost_calculations["total"];
  128. }
  129. /**/
  130. $_authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
  131. $_authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
  132. $_authnet["x_card_code"] = $post_vars["card_verification"];
  133. /**/
  134. #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
  135. # if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
  136. # $_authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
  137. # else /* Otherwise, we assume they provided an issue number instead. */
  138. # $_authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
  139. /**/
  140. $_authnet["x_address"] = $post_vars["street"];
  141. $_authnet["x_city"] = $post_vars["city"];
  142. $_authnet["x_state"] = $post_vars["state"];
  143. $_authnet["x_country"] = $post_vars["country"];
  144. $_authnet["x_zip"] = $post_vars["zip"];
  145. }
  146. /**/
  147. if(!($authnet = array())) /* Recurring Profile. */
  148. {
  149. $authnet["x_method"] = "create";
  150. /**/
  151. $authnet["x_email"] = $user->user_email;
  152. $authnet["x_first_name"] = $post_vars["first_name"];
  153. $authnet["x_last_name"] = $post_vars["last_name"];
  154. $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
  155. /**/
  156. $authnet["x_invoice_num"] = ($_authnet) ? $_authnet["x_invoice_num"] : "s2-".uniqid();
  157. $authnet["x_description"] = $cost_calculations["desc"];
  158. $authnet["x_description"] .= " ((".$reference."))";
  159. /**/
  160. $authnet["x_amount"] = $cost_calculations["total"];
  161. /**/
  162. $authnet["x_start_date"] = date("Y-m-d", $start_time);
  163. /**/
  164. $authnet["x_unit"] = "days"; /* Always calculated in days. */
  165. $authnet["x_length"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_per_term_2_days($post_vars["attr"]["rp"], $post_vars["attr"]["rt"]);
  166. $authnet["x_total_occurrences"] = ($post_vars["attr"]["rr"]) ? (($post_vars["attr"]["rrt"]) ? $post_vars["attr"]["rrt"] : "9999") : "1";
  167. /**/
  168. $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
  169. $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
  170. $authnet["x_card_code"] = $post_vars["card_verification"];
  171. /**/
  172. #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
  173. # if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
  174. # $authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
  175. # else /* Otherwise, we assume they provided an issue number instead. */
  176. # $authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
  177. /**/
  178. $authnet["x_address"] = $post_vars["street"];
  179. $authnet["x_city"] = $post_vars["city"];
  180. $authnet["x_state"] = $post_vars["state"];
  181. $authnet["x_country"] = $post_vars["country"];
  182. $authnet["x_zip"] = $post_vars["zip"];
  183. }
  184. /**/
  185. if(!$_authnet || (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($_authnet)) && empty($_authnet["__error"])))
  186. {
  187. if(($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && (empty($authnet["__error"]) || ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")))
  188. {
  189. /* $authnet["response_reason_code"] === "E00018" ... Card expires before start time. */
  190. /**/
  191. $new__txn_id = ($_authnet && !empty($_authnet["transaction_id"])) ? $_authnet["transaction_id"] : false;
  192. $new__subscr_id = ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") ? $new__txn_id : $authnet["subscription_id"];
  193. $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
  194. $old__subscr_id = get_user_option("s2member_subscr_id");
  195. /**/
  196. if(!($ipn = array())) /* Simulated PayPal® IPN. */
  197. {
  198. $ipn["txn_type"] = "subscr_signup";
  199. $ipn["subscr_id"] = $new__subscr_id;
  200. $ipn["custom"] = $post_vars["attr"]["custom"];
  201. /**/
  202. $ipn["txn_id"] = ($new__txn_id) ? $new__txn_id : $new__subscr_id;
  203. /**/
  204. $ipn["period1"] = $period1;
  205. $ipn["period3"] = $period3;
  206. /**/
  207. $ipn["mc_amount1"] = $cost_calculations["trial_total"];
  208. $ipn["mc_amount3"] = $cost_calculations["total"];
  209. /**/
  210. $ipn["mc_gross"] = (preg_match("/^[1-9]/", $ipn["period1"])) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
  211. /**/
  212. $ipn["mc_currency"] = $cost_calculations["cur"];
  213. $ipn["tax"] = $cost_calculations["tax"];
  214. /**/
  215. $ipn["recurring"] = ($post_vars["attr"]["rr"]) ? "1" : "";
  216. /**/
  217. $ipn["payer_email"] = $user->user_email;
  218. $ipn["first_name"] = $post_vars["first_name"];
  219. $ipn["last_name"] = $post_vars["last_name"];
  220. /**/
  221. $ipn["option_name1"] = "Referencing Customer ID";
  222. $ipn["option_selection1"] = $old__subscr_or_wp_id;
  223. /**/
  224. $ipn["option_name2"] = "Customer IP Address";
  225. $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
  226. /**/
  227. $ipn["item_name"] = $cost_calculations["desc"];
  228. $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
  229. /**/
  230. $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
  231. $ipn_q .= ($ipn["mc_gross"] > 0) ? ",subscr-signup-as-subscr-payment" : ""; /* Use as first payment? */
  232. $ipn_q .= "&s2member_paypal_proxy_verification=".urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
  233. $ipn_q .= "&s2member_paypal_proxy_return_url=".rawurlencode($post_vars["attr"]["success"]);
  234. /**/
  235. $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20)));
  236. }
  237. /**/
  238. if($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")
  239. {
  240. update_user_option($user_id, "s2member_auto_eot_time", $start_time);
  241. }
  242. /**/
  243. if(($authnet = array("x_method" => "cancel")) && ($authnet["x_subscription_id"] = $old__subscr_id))
  244. {
  245. c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
  246. }
  247. /**/
  248. $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
  249. /**/
  250. if($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url))))
  251. wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")).exit();
  252. }
  253. else /* Else, an error. */
  254. {
  255. $global_response = array("response" => $authnet["__error"], "error" => true);
  256. }
  257. }
  258. else /* Else, an error. */
  259. {
  260. $global_response = array("response" => $_authnet["__error"], "error" => true);
  261. }
  262. }
  263. /**/
  264. else if($use_recurring_profile && !is_user_logged_in()) /* Create a new account. */
  265. {
  266. $period1 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"]." ".$post_vars["attr"]["tt"]);
  267. $period3 = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"]." ".$post_vars["attr"]["rt"]);
  268. /**/
  269. $start_time = ($post_vars["attr"]["tp"]) ? /* If there's an Initial/Trial Period; start when it's over. */
  270. c_ws_plugin__s2member_pro_authnet_utilities::authnet_start_time($period1) : /* After Trial is over. */
  271. c_ws_plugin__s2member_pro_authnet_utilities::authnet_start_time($period3); /* Or next billing cycle. */
  272. /**/
  273. $reference = $start_time.":".$period1.":".$period3."~".$_SERVER["HTTP_HOST"]."~".$post_vars["attr"]["level_ccaps_eotper"];
  274. /**/
  275. if(!($_authnet = array()) /* A first Initial/Trial payment? */
  276. && (!$post_vars["attr"]["tp"] || ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)))
  277. {
  278. $_authnet["x_type"] = "AUTH_CAPTURE";
  279. $_authnet["x_method"] = "CC";
  280. /**/
  281. $_authnet["x_email"] = $post_vars["email"];
  282. $_authnet["x_first_name"] = $post_vars["first_name"];
  283. $_authnet["x_last_name"] = $post_vars["last_name"];
  284. $_authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
  285. /**/
  286. $_authnet["x_invoice_num"] = "s2-".uniqid();
  287. $_authnet["x_description"] = $cost_calculations["desc"];
  288. /**/
  289. $_authnet["s2_initial_payment"] = "1"; /* Initial. */
  290. /**/
  291. $_authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
  292. $_authnet["s2_custom"] = $post_vars["attr"]["custom"];
  293. /**/
  294. if($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)
  295. {
  296. $_authnet["x_tax"] = $cost_calculations["trial_tax"];
  297. $_authnet["x_amount"] = $cost_calculations["trial_total"];
  298. }
  299. else /* Otherwise, charge for the first Regular payment. */
  300. {
  301. $_authnet["x_tax"] = $cost_calculations["tax"];
  302. $_authnet["x_amount"] = $cost_calculations["total"];
  303. }
  304. /**/
  305. $_authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
  306. $_authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
  307. $_authnet["x_card_code"] = $post_vars["card_verification"];
  308. /**/
  309. #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
  310. # if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
  311. # $_authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
  312. # else /* Otherwise, we assume they provided an issue number instead. */
  313. # $_authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
  314. /**/
  315. $_authnet["x_address"] = $post_vars["street"];
  316. $_authnet["x_city"] = $post_vars["city"];
  317. $_authnet["x_state"] = $post_vars["state"];
  318. $_authnet["x_country"] = $post_vars["country"];
  319. $_authnet["x_zip"] = $post_vars["zip"];
  320. }
  321. /**/
  322. if(!($authnet = array())) /* Recurring Profile. */
  323. {
  324. $authnet["x_method"] = "create";
  325. /**/
  326. $authnet["x_email"] = $post_vars["email"];
  327. $authnet["x_first_name"] = $post_vars["first_name"];
  328. $authnet["x_last_name"] = $post_vars["last_name"];
  329. $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
  330. /**/
  331. $authnet["x_invoice_num"] = ($_authnet) ? $_authnet["x_invoice_num"] : "s2-".uniqid();
  332. $authnet["x_description"] = $cost_calculations["desc"];
  333. $authnet["x_description"] .= " ((".$reference."))";
  334. /**/
  335. $authnet["x_amount"] = $cost_calculations["total"];
  336. /**/
  337. $authnet["x_start_date"] = date("Y-m-d", $start_time);
  338. /**/
  339. $authnet["x_unit"] = "days"; /* Always calculated in days. */
  340. $authnet["x_length"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_per_term_2_days($post_vars["attr"]["rp"], $post_vars["attr"]["rt"]);
  341. $authnet["x_total_occurrences"] = ($post_vars["attr"]["rr"]) ? (($post_vars["attr"]["rrt"]) ? $post_vars["attr"]["rrt"] : "9999") : "1";
  342. /**/
  343. $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
  344. $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
  345. $authnet["x_card_code"] = $post_vars["card_verification"];
  346. /**/
  347. #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
  348. # if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
  349. # $authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
  350. # else /* Otherwise, we assume they provided an issue number instead. */
  351. # $authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
  352. /**/
  353. $authnet["x_address"] = $post_vars["street"];
  354. $authnet["x_city"] = $post_vars["city"];
  355. $authnet["x_state"] = $post_vars["state"];
  356. $authnet["x_country"] = $post_vars["country"];
  357. $authnet["x_zip"] = $post_vars["zip"];
  358. }
  359. /**/
  360. if(!$_authnet || (($_authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($_authnet)) && empty($_authnet["__error"])))
  361. {
  362. if(($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && (empty($authnet["__error"]) || ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")))
  363. {
  364. /* $authnet["response_reason_code"] === "E00018" ... Card expires before start time. */
  365. /**/
  366. $new__txn_id = ($_authnet && !empty($_authnet["transaction_id"])) ? $_authnet["transaction_id"] : false;
  367. $new__subscr_id = ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") ? $new__txn_id : $authnet["subscription_id"];
  368. /**/
  369. if(!($ipn = array())) /* Simulated PayPal® IPN. */
  370. {
  371. $ipn["txn_type"] = "subscr_signup";
  372. $ipn["subscr_id"] = $new__subscr_id;
  373. $ipn["custom"] = $post_vars["attr"]["custom"];
  374. /**/
  375. $ipn["txn_id"] = ($new__txn_id) ? $new__txn_id : $new__subscr_id;
  376. /**/
  377. $ipn["period1"] = $period1;
  378. $ipn["period3"] = $period3;
  379. /**/
  380. $ipn["mc_amount1"] = $cost_calculations["trial_total"];
  381. $ipn["mc_amount3"] = $cost_calculations["total"];
  382. /**/
  383. $ipn["mc_gross"] = (preg_match("/^[1-9]/", $ipn["period1"])) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
  384. /**/
  385. $ipn["mc_currency"] = $cost_calculations["cur"];
  386. $ipn["tax"] = $cost_calculations["tax"];
  387. /**/
  388. $ipn["recurring"] = ($post_vars["attr"]["rr"]) ? "1" : "";
  389. /**/
  390. $ipn["payer_email"] = $post_vars["email"];
  391. $ipn["first_name"] = $post_vars["first_name"];
  392. $ipn["last_name"] = $post_vars["last_name"];
  393. /**/
  394. $ipn["option_name1"] = "Originating Domain";
  395. $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
  396. /**/
  397. $ipn["option_name2"] = "Customer IP Address";
  398. $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
  399. /**/
  400. $ipn["item_name"] = $cost_calculations["desc"];
  401. $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
  402. /**/
  403. $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
  404. $ipn_q .= ($ipn["mc_gross"] > 0) ? ",subscr-signup-as-subscr-payment" : ""; /* Use as first payment? */
  405. $ipn_q .= "&s2member_paypal_proxy_verification=".urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
  406. $ipn_q .= "&s2member_paypal_proxy_return_url=".rawurlencode($post_vars["attr"]["success"]);
  407. }
  408. /**/
  409. if(!($create_user = array())) /* Build post fields for registration configuration, and then the creation array. */
  410. {
  411. $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"]; /* Fake this for registration configuration. */
  412. $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"]; /* Fake this for registration configuration. */
  413. $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"]; /* Fake this for registration configuration. */
  414. $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"]; /* Fake this too. */
  415. /**/
  416. if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
  417. foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
  418. {
  419. $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
  420. $field_id_class = preg_replace("/_/", "-", $field_var);
  421. /**/
  422. if(isset($post_vars["custom_fields"][$field_var]))
  423. $_POST["ws_plugin__s2member_custom_reg_field_".$field_var] = $post_vars["custom_fields"][$field_var];
  424. }
  425. /**/
  426. $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt("authnet"); /* Fake this for registration configuration. */
  427. $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id); /* Fake this for registration configuration. */
  428. $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]); /* Fake this for registration configuration. */
  429. $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]); /* Fake this too. */
  430. /**/
  431. $create_user["user_login"] = $post_vars["username"]; /* Copy this into a separate array for `wp_create_user()`. */
  432. $create_user["user_pass"] = wp_generate_password(); /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
  433. $create_user["user_email"] = $post_vars["email"]; /* Copy this into a separate array for `wp_create_user()`. */
  434. }
  435. /**/
  436. if($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) /* A custom Password is being used? */
  437. {
  438. if(((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"]))) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id))
  439. {
  440. wp_new_user_notification($new__user_id, $create_user["user_pass"]);
  441. /**/
  442. $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20)));
  443. /**/
  444. if($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")
  445. update_user_option($new__user_id, "s2member_auto_eot_time", $start_time);
  446. /**/
  447. $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
  448. /**/
  449. if($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url))))
  450. wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")).exit();
  451. }
  452. else /* Else, an error reponse should be given. */
  453. {
  454. c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20));
  455. /**/
  456. $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
  457. }
  458. }
  459. else /* Otherwise, they'll need to check their email for the auto-generated Password. */
  460. {
  461. if(((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"]))) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id))
  462. {
  463. update_user_option($new__user_id, "default_password_nag", true, true); /* Password nag. */
  464. wp_new_user_notification($new__user_id, $create_user["user_pass"]);
  465. /**/
  466. $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20)));
  467. /**/
  468. if($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")
  469. update_user_option($new__user_id, "s2member_auto_eot_time", $start_time);
  470. /**/
  471. $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
  472. /**/
  473. if($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url))))
  474. wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")).exit();
  475. }
  476. else /* Else, an error reponse should be given. */
  477. {
  478. c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20));
  479. /**/
  480. $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
  481. }
  482. }
  483. }
  484. else /* Else, an error. */
  485. {
  486. $global_response = array("response" => $authnet["__error"], "error" => true);
  487. }
  488. }
  489. else /* Else, an error. */
  490. {
  491. $global_response = array("response" => $_authnet["__error"], "error" => true);
  492. }
  493. }
  494. /**/
  495. else if(!$use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID))
  496. {
  497. update_user_meta($user_id, "first_name", $post_vars["first_name"]).update_user_meta($user_id, "last_name", $post_vars["last_name"]);
  498. /**/
  499. if(!($authnet = array())) /* Direct payments. */
  500. {
  501. $authnet["x_type"] = "AUTH_CAPTURE";
  502. $authnet["x_method"] = "CC";
  503. /**/
  504. $authnet["x_email"] = $user->user_email;
  505. $authnet["x_first_name"] = $post_vars["first_name"];
  506. $authnet["x_last_name"] = $post_vars["last_name"];
  507. $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
  508. /**/
  509. $authnet["x_invoice_num"] = "s2-".uniqid();
  510. $authnet["x_description"] = $cost_calculations["desc"];
  511. /**/
  512. $authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
  513. $authnet["s2_custom"] = $post_vars["attr"]["custom"];
  514. /**/
  515. $authnet["x_tax"] = $cost_calculations["tax"];
  516. $authnet["x_amount"] = $cost_calculations["total"];
  517. /**/
  518. $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
  519. $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
  520. $authnet["x_card_code"] = $post_vars["card_verification"];
  521. /**/
  522. #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
  523. # if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
  524. # $authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
  525. # else /* Otherwise, we assume they provided an issue number instead. */
  526. # $authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
  527. /**/
  528. $authnet["x_address"] = $post_vars["street"];
  529. $authnet["x_city"] = $post_vars["city"];
  530. $authnet["x_state"] = $post_vars["state"];
  531. $authnet["x_country"] = $post_vars["country"];
  532. $authnet["x_zip"] = $post_vars["zip"];
  533. }
  534. /**/
  535. if(($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"]))
  536. {
  537. $old__subscr_or_wp_id = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id();
  538. $old__subscr_id = get_user_option("s2member_subscr_id");
  539. $new__subscr_id = $new__txn_id = $authnet["transaction_id"];
  540. /**/
  541. if(!($ipn = array())) /* Simulated PayPal® IPN. */
  542. {
  543. $ipn["txn_type"] = "web_accept";
  544. $ipn["txn_id"] = $new__subscr_id;
  545. $ipn["custom"] = $post_vars["attr"]["custom"];
  546. /**/
  547. $ipn["mc_gross"] = $cost_calculations["total"];
  548. $ipn["mc_currency"] = $cost_calculations["cur"];
  549. $ipn["tax"] = $cost_calculations["tax"];
  550. /**/
  551. $ipn["payer_email"] = $user->user_email;
  552. $ipn["first_name"] = $post_vars["first_name"];
  553. $ipn["last_name"] = $post_vars["last_name"];
  554. /**/
  555. $ipn["option_name1"] = "Referencing Customer ID";
  556. $ipn["option_selection1"] = $old__subscr_or_wp_id;
  557. /**/
  558. $ipn["option_name2"] = "Customer IP Address";
  559. $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
  560. /**/
  561. $ipn["item_name"] = $cost_calculations["desc"];
  562. $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
  563. /**/
  564. $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
  565. $ipn_q .= "&s2member_paypal_proxy_verification=".urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
  566. $ipn_q .= "&s2member_paypal_proxy_return_url=".rawurlencode($post_vars["attr"]["success"]);
  567. /**/
  568. $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20)));
  569. }
  570. /**/
  571. if(!$is_independent_ccaps_sale) /* Independent? */
  572. if(($authnet = array("x_method" => "cancel")) && ($authnet["x_subscription_id"] = $old__subscr_id))
  573. {
  574. c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
  575. }
  576. /**/
  577. if($is_independent_ccaps_sale) /* Independent? */
  578. setcookie("s2member_tracking", ($s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id)), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN).setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN).($_COOKIE["s2member_tracking"] = $s2member_tracking);
  579. /**/
  580. $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
  581. /**/
  582. if($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url))))
  583. wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")).exit();
  584. }
  585. else /* Else, an error. */
  586. {
  587. $global_response = array("response" => $authnet["__error"], "error" => true);
  588. }
  589. }
  590. /**/
  591. else if(!$use_recurring_profile && !is_user_logged_in()) /* Create a new account. */
  592. {
  593. if(!($authnet = array())) /* Direct payments. */
  594. {
  595. $authnet["x_type"] = "AUTH_CAPTURE";
  596. $authnet["x_method"] = "CC";
  597. /**/
  598. $authnet["x_email"] = $post_vars["email"];
  599. $authnet["x_first_name"] = $post_vars["first_name"];
  600. $authnet["x_last_name"] = $post_vars["last_name"];
  601. $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
  602. /**/
  603. $authnet["x_invoice_num"] = "s2-".uniqid();
  604. $authnet["x_description"] = $cost_calculations["desc"];
  605. /**/
  606. $authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
  607. $authnet["s2_custom"] = $post_vars["attr"]["custom"];
  608. /**/
  609. $authnet["x_tax"] = $cost_calculations["tax"];
  610. $authnet["x_amount"] = $cost_calculations["total"];
  611. /**/
  612. $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
  613. $authnet["x_exp_date"] = c_ws_plugin__s2member_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
  614. $authnet["x_card_code"] = $post_vars["card_verification"];
  615. /**/
  616. #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
  617. # if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
  618. # $authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
  619. # else /* Otherwise, we assume they provided an issue number instead. */
  620. # $authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
  621. /**/
  622. $authnet["x_address"] = $post_vars["street"];
  623. $authnet["x_city"] = $post_vars["city"];
  624. $authnet["x_state"] = $post_vars["state"];
  625. $authnet["x_country"] = $post_vars["country"];
  626. $authnet["x_zip"] = $post_vars["zip"];
  627. }
  628. /**/
  629. if(($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"]))
  630. {
  631. $new__subscr_id = $authnet["transaction_id"];
  632. /**/
  633. if(!($ipn = array())) /* Simulated PayPal® IPN. */
  634. {
  635. $ipn["txn_type"] = "web_accept";
  636. $ipn["txn_id"] = $new__subscr_id;
  637. $ipn["custom"] = $post_vars["attr"]["custom"];
  638. /**/
  639. $ipn["mc_gross"] = $cost_calculations["total"];
  640. $ipn["mc_currency"] = $cost_calculations["cur"];
  641. $ipn["tax"] = $cost_calculations["tax"];
  642. /**/
  643. $ipn["payer_email"] = $post_vars["email"];
  644. $ipn["first_name"] = $post_vars["first_name"];
  645. $ipn["last_name"] = $post_vars["last_name"];
  646. /**/
  647. $ipn["option_name1"] = "Originating Domain";
  648. $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
  649. /**/
  650. $ipn["option_name2"] = "Customer IP Address";
  651. $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
  652. /**/
  653. $ipn["item_name"] = $cost_calculations["desc"];
  654. $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
  655. /**/
  656. $ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
  657. $ipn_q .= "&s2member_paypal_proxy_verification=".urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
  658. $ipn_q .= "&s2member_paypal_proxy_return_url=".rawurlencode($post_vars["attr"]["success"]);
  659. }
  660. /**/
  661. if(!($create_user = array())) /* Build post fields for registration configuration, and then the creation array. */
  662. {
  663. $_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"]; /* Fake this for registration configuration. */
  664. $_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"]; /* Fake this for registration configuration. */
  665. $_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"]; /* Fake this for registration configuration. */
  666. $_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"]; /* Fake this too. */
  667. /**/
  668. if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
  669. foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
  670. {
  671. $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
  672. $field_id_class = preg_replace("/_/", "-", $field_var);
  673. /**/
  674. if(isset($post_vars["custom_fields"][$field_var]))
  675. $_POST["ws_plugin__s2member_custom_reg_field_".$field_var] = $post_vars["custom_fields"][$field_var];
  676. }
  677. /**/
  678. $_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt("authnet"); /* Fake this for registration configuration. */
  679. $_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($new__subscr_id); /* Fake this for registration configuration. */
  680. $_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["custom"]); /* Fake this for registration configuration. */
  681. $_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]); /* Fake this too. */
  682. /**/
  683. $create_user["user_login"] = $post_vars["username"]; /* Copy this into a separate array for `wp_create_user()`. */
  684. $create_user["user_pass"] = wp_generate_password(); /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
  685. $create_user["user_email"] = $post_vars["email"]; /* Copy this into a separate array for `wp_create_user()`. */
  686. }
  687. /**/
  688. if($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) /* A custom Password is being used? */
  689. {
  690. if(((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"]))) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id))
  691. {
  692. wp_new_user_notification($new__user_id, $create_user["user_pass"]);
  693. /**/
  694. $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20)));
  695. /**/
  696. $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
  697. /**/
  698. if($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url))))
  699. wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")).exit();
  700. }
  701. else /* Else, an error reponse should be given. */
  702. {
  703. c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20));
  704. /**/
  705. $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
  706. }
  707. }
  708. else /* Otherwise, they'll need to check their email for the auto-generated Password. */
  709. {
  710. if(((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"]))) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id))
  711. {
  712. update_user_option($new__user_id, "default_password_nag", true, true); /* Password nag. */
  713. wp_new_user_notification($new__user_id, $create_user["user_pass"]);
  714. /**/
  715. $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20)));
  716. /**/
  717. $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
  718. /**/
  719. if($post_vars["attr"]["success"] && substr($ipn["s2member_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url))))
  720. wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")).exit();
  721. }
  722. else /* Else, an error reponse should be given. */
  723. {
  724. c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1".$ipn_q), $ipn, array("timeout" => 20));
  725. /**/
  726. $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
  727. }
  728. }
  729. }
  730. else /* Else, an error. */
  731. {
  732. $global_response = array("response" => $authnet["__error"], "error" => true);
  733. }
  734. }
  735. else /* Else, we have an unknown scenario. */
  736. {
  737. $global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
  738. }
  739. }
  740. else /* Else, an error. */
  741. {
  742. $global_response = $error;
  743. }
  744. }
  745. }
  746. }
  747. }
  748. }
  749. ?>

s2member-pro\includes\classes\gateways\authnet\authnet-checkout-in.inc.php

Source Code Documentation