Source Code Documentation


s2member-pro\includes\classes\gateways\alipay\alipay-button-in.inc.php


  1. <?php
  2. /**
  3. * Shortcode `[s2Member-Pro-AliPay-Button /]` ( 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\AliPay
  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_alipay_button_in"))
  37. {
  38. /**
  39. * Shortcode `[s2Member-Pro-AliPay-Button /]` ( inner processing routines ).
  40. *
  41. * @package s2Member\AliPay
  42. * @since 1.5
  43. */
  44. class c_ws_plugin__s2member_pro_alipay_button_in
  45. {
  46. /**
  47. * Shortcode `[s2Member-Pro-AliPay-Button /]`.
  48. *
  49. * @package s2Member\AliPay
  50. * @since 1.5
  51. *
  52. * @attaches-to ``add_shortcode("s2Member-Pro-AliPay-Button");``
  53. *
  54. * @param array $attr An array of Attributes.
  55. * @param str $content Content inside the Shortcode.
  56. * @param str $shortcode The actual Shortcode name itself.
  57. * @return str The resulting AliPay® Button Code, HTML markup.
  58. */
  59. public static function sc_alipay_button ($attr = FALSE, $content = FALSE, $shortcode = FALSE)
  60. {
  61. c_ws_plugin__s2member_no_cache::no_cache_constants /* No caching on pages that contain this Payment Button. */ (true);
  62. /**/
  63. $attr = /* Force array. Trim quote entities. */ c_ws_plugin__s2member_utils_strings::trim_qts_deep ((array)$attr);
  64. /**/
  65. $attr = shortcode_atts (array ("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "custom" => $_SERVER["HTTP_HOST"], "ra" => "0.01", "rp" => "1", "rt" => "M", "sp" => "0", "success" => "", "image" => "default", "output" => "anchor"), $attr);
  66. /**/
  67. $attr["rt"] = /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */ strtoupper ($attr["rt"]);
  68. $attr["ccaps"] = /* Custom Capabilities must be typed in lower-case format. Only after running shortcode_atts(). */ strtolower ($attr["ccaps"]);
  69. $attr["success"] = /* Convert ampersands. */ str_ireplace (array ("&#038;", "&amp;"), "&", $attr["success"]);
  70. /**/
  71. if /* Specific Post/Page Buttons. */ ($attr["sp"])
  72. {
  73. $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/alipay-button.gif";
  74. /**/
  75. $attr["sp_ids_exp"] = /* Combined "sp:ids:expiration hours". */ "sp:" . $attr["ids"] . ":" . $attr["exp"];
  76. /**/
  77. $code = trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (dirname (dirname (__FILE__)))) . "/templates/buttons/alipay-sp-checkout-button.php")));
  78. $code = preg_replace ("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
  79. $code = preg_replace ("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ())), $code);
  80. /**/
  81. $vars = array ("service" => "create_direct_pay_by_user", "payment_type" => 1, "partner" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_partner_id"], "seller_email" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_seller_email"], "subject" => $_SERVER["HTTP_HOST"], "body" => $attr["desc"], "out_trade_no" => uniqid () . "~" . $attr["sp_ids_exp"] . (($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id ()) ? "~" . $referencing : "~") . "~" . $_SERVER["REMOTE_ADDR"], "extra_common_param" => $attr["custom"], "total_fee" => $attr["ra"], "paymethod" => "directPay", "show_url" => home_url ("/"), "return_url" => (($attr["success"]) ? $attr["success"] : site_url ("/?s2member_pro_alipay_return=1")), "notify_url" => site_url ("/"));
  82. /**/
  83. $code = preg_replace ("/%%url%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($url = c_ws_plugin__s2member_pro_alipay_utilities::alipay_link_gen ($vars))), $code);
  84. /**/
  85. $code = $_code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
  86. /**/
  87. $code = ($attr["output"] === "anchor") ? /* Buttons already in anchor format. */ $code : $code;
  88. $code = ($attr["output"] === "url") ? /* From the routine above. */ $url : $code;
  89. /**/
  90. unset /* Just a little housekeeping */ ($href, $url, $m);
  91. }
  92. else if /* Independent Custom Capabilities. */ ($attr["level"] === "*")
  93. {
  94. $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/alipay-button.gif";
  95. /**/
  96. $attr["level_ccaps_eotper"] = ($attr["rt"] !== "L") ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"];
  97. $attr["level_ccaps_eotper"] = /* Clean any trailing separators from this string. */ rtrim ($attr["level_ccaps_eotper"], ":");
  98. /**/
  99. $code = trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (dirname (dirname (__FILE__)))) . "/templates/buttons/alipay-ccaps-checkout-button.php")));
  100. $code = preg_replace ("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
  101. $code = preg_replace ("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ())), $code);
  102. /**/
  103. $vars = array ("service" => "create_direct_pay_by_user", "payment_type" => 1, "partner" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_partner_id"], "seller_email" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_seller_email"], "subject" => $_SERVER["HTTP_HOST"], "body" => $attr["desc"], "out_trade_no" => uniqid () . "~" . $attr["level_ccaps_eotper"] . (($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id ()) ? "~" . $referencing : "~") . "~" . $_SERVER["REMOTE_ADDR"], "extra_common_param" => $attr["custom"], "total_fee" => $attr["ra"], "paymethod" => "directPay", "show_url" => home_url ("/"), "return_url" => (($attr["success"] && !$referencing) ? $attr["success"] : site_url ("/?s2member_pro_alipay_return=1")), "notify_url" => site_url ("/"));
  104. /**/
  105. $code = preg_replace ("/%%url%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($url = c_ws_plugin__s2member_pro_alipay_utilities::alipay_link_gen ($vars))), $code);
  106. /**/
  107. $code = $_code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
  108. /**/
  109. $code = ($attr["output"] === "anchor") ? /* Buttons already in anchor format. */ $code : $code;
  110. $code = ($attr["output"] === "url") ? /* From the routine above. */ $url : $code;
  111. /**/
  112. unset /* Just a little housekeeping */ ($href, $url, $m);
  113. }
  114. else /* Otherwise, we'll process this Button normally, using Membership routines. */
  115. {
  116. $default_image = $GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images/alipay-button.gif";
  117. /**/
  118. $attr["desc"] = (!$attr["desc"]) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"];
  119. /**/
  120. $attr["level_ccaps_eotper"] = ($attr["rt"] !== "L") ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"];
  121. $attr["level_ccaps_eotper"] = /* Clean any trailing separators from this string. */ rtrim ($attr["level_ccaps_eotper"], ":");
  122. /**/
  123. $code = trim (c_ws_plugin__s2member_utilities::evl (file_get_contents (dirname (dirname (dirname (dirname (__FILE__)))) . "/templates/buttons/alipay-checkout-button.php")));
  124. $code = preg_replace ("/%%images%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($GLOBALS["WS_PLUGIN__"]["s2member_pro"]["c"]["dir_url"] . "/images")), $code);
  125. $code = preg_replace ("/%%wpurl%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr (site_url ())), $code);
  126. /**/
  127. $vars = array ("service" => "create_direct_pay_by_user", "payment_type" => 1, "partner" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_partner_id"], "seller_email" => $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_seller_email"], "subject" => $_SERVER["HTTP_HOST"], "body" => $attr["desc"], "out_trade_no" => uniqid () . "~" . $attr["level_ccaps_eotper"] . (($referencing = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id ()) ? "~" . $referencing : "~") . "~" . $_SERVER["REMOTE_ADDR"], "extra_common_param" => $attr["custom"], "total_fee" => $attr["ra"], "paymethod" => "directPay", "show_url" => home_url ("/"), "return_url" => (($attr["success"] && !$referencing) ? $attr["success"] : site_url ("/?s2member_pro_alipay_return=1")), "notify_url" => site_url ("/"));
  128. /**/
  129. $code = preg_replace ("/%%url%%/", c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($url = c_ws_plugin__s2member_pro_alipay_utilities::alipay_link_gen ($vars))), $code);
  130. /**/
  131. $code = $_code = ($attr["image"] && $attr["image"] !== "default") ? preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($attr["image"])) . '"', $code) : preg_replace ('/ src\="(.*?)"/', ' src="' . c_ws_plugin__s2member_utils_strings::esc_ds (esc_attr ($default_image)) . '"', $code);
  132. /**/
  133. $code = ($attr["output"] === "anchor") ? /* Buttons already in anchor format. */ $code : $code;
  134. $code = ($attr["output"] === "url") ? /* From the routine above. */ $url : $code;
  135. /**/
  136. unset /* Just a little housekeeping */ ($href, $url, $m);
  137. }
  138. /**/
  139. return /* Button. */ $code;
  140. }
  141. }
  142. }
  143. ?>

s2member-pro\includes\classes\gateways\alipay\alipay-button-in.inc.php

Source Code Documentation