Guest User

paypalBB

a guest
Mar 8th, 2013
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.33 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by Hackforums.al
  5. * @ Decoder (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : v2@ Albanian
  8. * @ Author : hackforums.al
  9. * @ Release on : 10.07.2012
  10. * @ Official site : http://hackforums.al
  11. *
  12. */
  13.  
  14. function paypal_config() {
  15. global $CONFIG;
  16.  
  17. $configarray = array( 'FriendlyName' => array( 'Type' => 'System', 'Value' => 'PayPal' ), 'UsageNotes' => array( 'Type' => 'System', 'Value' => 'You must enable IPN inside your PayPal account and set the URL to ' . $CONFIG['SystemURL'] ), 'email' => array( 'FriendlyName' => 'PayPal Email', 'Type' => 'text', 'Size' => '40' ), 'forceonetime' => array( 'FriendlyName' => 'Force One Time Payments', 'Type' => 'yesno', 'Description' => 'Never show the subscription payment button' ), 'forcesubscriptions' => array( 'FriendlyName' => 'Force Subscriptions', 'Type' => 'yesno', 'Description' => 'Hide the one time payment button when a subscription can be created' ), 'requireshipping' => array( 'FriendlyName' => 'Require Shipping Address', 'Type' => 'yesno', 'Description' => 'Tick this box to request a shipping address from a user on PayPal\'s site' ), 'overrideaddress' => array( 'FriendlyName' => 'Client Address Matching', 'Type' => 'yesno', 'Description' => 'Tick this box to force using client profile information entered into WHMCS at PayPal' ), 'apiusername' => array( 'FriendlyName' => 'API Username', 'Type' => 'text', 'Size' => '40', 'Description' => 'API fields only required for refunds' ), 'apipassword' => array( 'FriendlyName' => 'API Password', 'Type' => 'text', 'Size' => '40' ), 'apisignature' => array( 'FriendlyName' => 'API Signature', 'Type' => 'text', 'Size' => '70' ) );
  18. return $configarray;
  19. }
  20.  
  21. function paypal_link($params) {
  22. global $CONFIG;
  23.  
  24. $params['invoiceid'];
  25. $invoiceid = ;
  26. $params['email'];
  27. $paypalemails = ;
  28. explode( ',', $paypalemails );
  29. $paypalemails = ;
  30. trim( $paypalemails[0] );
  31. $paypalemail = ;
  32. getRecurringBillingValues( $invoiceid );
  33. $recurrings = ;
  34. $recurrings['primaryserviceid'];
  35. $primaryserviceid = ;
  36. $recurrings['firstpaymentamount'];
  37. $firstpaymentamount = ;
  38. $recurrings['firstcycleperiod'];
  39. $firstcycleperiod = ;
  40. strtoupper( substr( $recurrings['firstcycleunits'], 0, 1 ) );
  41. $firstcycleunits = ;
  42. $recurrings['recurringamount'];
  43. $recurringamount = ;
  44. $recurrings['recurringcycleperiod'];
  45. $recurringcycleperiod = ;
  46. strtoupper( substr( $recurrings['recurringcycleunits'], 0, 1 ) );
  47. $recurringcycleunits = ;
  48.  
  49. if (( $params['clientdetails']['country'] == 'US' || $params['clientdetails']['country'] == 'CA' )) {
  50. preg_replace( '/[^0-9]/', '', $params['clientdetails']['phonenumber'] );
  51. $phonenumber = ;
  52. substr( $phonenumber, 0, 3 );
  53. $phone1 = ;
  54. substr( $phonenumber, 3, 3 );
  55. $phone2 = ;
  56. substr( $phonenumber, 6 );
  57. $phone3 = ;
  58. }
  59. else {
  60. $params['clientdetails']['phonecc'];
  61. $phone1 = ;
  62. $params['clientdetails']['phonenumber'];
  63. $phone2 = ;
  64. }
  65.  
  66. $subnotpossible = false;
  67.  
  68. if (!$recurrings) {
  69. $subnotpossible = true;
  70. }
  71.  
  72.  
  73. if ($recurrings['overdue']) {
  74. $subnotpossible = true;
  75. }
  76.  
  77.  
  78. if ($params['forceonetime']) {
  79. $subnotpossible = true;
  80. }
  81.  
  82.  
  83. if ($recurringamount <= 0) {
  84. $subnotpossible = true;
  85. }
  86.  
  87.  
  88. if (( 90 < $firstcycleperiod && $firstcycleunits == 'D' )) {
  89. $subnotpossible = true;
  90. }
  91.  
  92.  
  93. if (( 24 < $firstcycleperiod && $firstcycleunits == 'M' )) {
  94. $subnotpossible = true;
  95. }
  96.  
  97.  
  98. if (( 5 < $firstcycleperiod && $firstcycleunits == 'Y' )) {
  99. $subnotpossible = true;
  100. }
  101.  
  102. $code = '<table><tr>';
  103.  
  104. if (!$subnotpossible) {
  105. $code .= '<td><form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paymentfrm">
  106. <input type="hidden" name="cmd" value="_xclick-subscriptions">
  107. <input type="hidden" name="business" value="' . $paypalemail . '">
  108. <input type="hidden" name="item_name" value="' . $params['description'] . '">
  109. <input type="hidden" name="no_shipping" value="' . ($params['requireshipping'] ? '2' : '1') . '">
  110. <input type="hidden" name="address_override" value="' . ($params['overrideaddress'] ? '1' : '0') . '">
  111. <input type="hidden" name="first_name" value="' . $params['clientdetails']['firstname'] . '">
  112. <input type="hidden" name="last_name" value="' . $params['clientdetails']['lastname'] . '">
  113. <input type="hidden" name="address1" value="' . $params['clientdetails']['address1'] . '">
  114. <input type="hidden" name="city" value="' . $params['clientdetails']['city'] . '">
  115. <input type="hidden" name="state" value="' . $params['clientdetails']['state'] . '">
  116. <input type="hidden" name="zip" value="' . $params['clientdetails']['postcode'] . '">
  117. <input type="hidden" name="country" value="' . $params['clientdetails']['country'] . '">
  118. <input type="hidden" name="night_phone_a" value="' . $phone1 . '">
  119. <input type="hidden" name="night_phone_b" value="' . $phone2 . '">';
  120.  
  121. if ($phone3) {
  122. $code .= '<input type="hidden" name="night_phone_c" value="' . $phone3 . '">';
  123. }
  124.  
  125. $code .= '<input type="hidden" name="no_note" value="1">
  126. <input type="hidden" name="currency_code" value="' . $params['currency'] . '">
  127. <input type="hidden" name="bn" value="WHMCS_ST">';
  128.  
  129. if ($firstpaymentamount) {
  130. $code .= '
  131. <input type="hidden" name="a1" value="' . $firstpaymentamount . '">
  132. <input type="hidden" name="p1" value="' . $firstcycleperiod . '">
  133. <input type="hidden" name="t1" value="' . $firstcycleunits . '">';
  134. }
  135.  
  136. $code .= '
  137. <input type="hidden" name="a3" value="' . $recurringamount . '">
  138. <input type="hidden" name="p3" value="' . $recurringcycleperiod . '">
  139. <input type="hidden" name="t3" value="' . $recurringcycleunits . '">
  140. <input type="hidden" name="src" value="1">
  141. <input type="hidden" name="sra" value="1">
  142. <input type="hidden" name="charset" value="' . $CONFIG['Charset'] . '">
  143. <input type="hidden" name="custom" value="' . $primaryserviceid . '">
  144. <input type="hidden" name="return" value="' . $params['returnurl'] . '&paymentsuccess=true">
  145. <input type="hidden" name="cancel_return" value="' . $params['returnurl'] . '&paymentfailed=true">
  146. <input type="hidden" name="notify_url" value="' . $params['systemurl'] . '/modules/gateways/callback/paypal.php">
  147. <input type="hidden" name="rm" value="2">';
  148.  
  149. if (( !$firstpaymentamount && $params['modifysubscriptions'] )) {
  150. $code .= '
  151. <input type="hidden" name="modify" value="1">';
  152. }
  153.  
  154. $code .= '
  155. <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif" border="0" name="submit" alt="Subscribe with PayPal for Automatic Payments">
  156. </form></td>';
  157. }
  158.  
  159.  
  160. if (( ( !$subnotpossible && $params['forcesubscriptions'] ) && !$params['forceonetime'] )) {
  161. }
  162. else {
  163. $code .= '<td><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  164. <input type="hidden" name="cmd" value="_xclick">
  165. <input type="hidden" name="business" value="' . $paypalemail . '">';
  166.  
  167. if ($params['style']) {
  168. $code .= '<input type="hidden" name="page_style" value="' . $params['style'] . '">';
  169. }
  170.  
  171. $code .= '<input type="hidden" name="item_name" value="' . $params['description'] . '">
  172. <input type="hidden" name="amount" value="' . $params['amount'] . '">
  173. <input type="hidden" name="tax" value="0.00">
  174. <input type="hidden" name="no_note" value="1">
  175. <input type="hidden" name="no_shipping" value="' . ($params['requireshipping'] ? '2' : '1') . '">
  176. <input type="hidden" name="address_override" value="' . ($params['overrideaddress'] ? '1' : '0') . '">
  177. <input type="hidden" name="first_name" value="' . $params['clientdetails']['firstname'] . '">
  178. <input type="hidden" name="last_name" value="' . $params['clientdetails']['lastname'] . '">
  179. <input type="hidden" name="address1" value="' . $params['clientdetails']['address1'] . '">
  180. <input type="hidden" name="city" value="' . $params['clientdetails']['city'] . '">
  181. <input type="hidden" name="state" value="' . $params['clientdetails']['state'] . '">
  182. <input type="hidden" name="zip" value="' . $params['clientdetails']['postcode'] . '">
  183. <input type="hidden" name="country" value="' . $params['clientdetails']['country'] . '">
  184. <input type="hidden" name="night_phone_a" value="' . $phone1 . '">
  185. <input type="hidden" name="night_phone_b" value="' . $phone2 . '">';
  186.  
  187. if ($phone3) {
  188. $code .= '<input type="hidden" name="night_phone_c" value="' . $phone3 . '">';
  189. }
  190.  
  191. $code .= '<input type="hidden" name="charset" value="' . $CONFIG['Charset'] . '">
  192. <input type="hidden" name="currency_code" value="' . $params['currency'] . '">
  193. <input type="hidden" name="custom" value="' . $params['invoiceid'] . '">
  194. <input type="hidden" name="return" value="' . $params['returnurl'] . '&paymentsuccess=true">
  195. <input type="hidden" name="cancel_return" value="' . $params['returnurl'] . '&paymentfailed=true">
  196. <input type="hidden" name="notify_url" value="' . $params['systemurl'] . '/modules/gateways/callback/paypal.php">
  197. <input type="hidden" name="bn" value="WHMCS_ST">
  198. <input type="hidden" name="rm" value="2">
  199. <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make a one time payment with PayPal">
  200. </form></td>';
  201. }
  202.  
  203. $code .= '</tr></table>';
  204. return $code;
  205. }
  206.  
  207. function paypal_refund($params) {
  208. if ($params['sandbox']) {
  209. $url = 'https://api-3t.sandbox.paypal.com/nvp';
  210. }
  211. else {
  212. $url = 'https://api-3t.paypal.com/nvp';
  213. }
  214.  
  215. $postfields = array( );
  216. $postfields['VERSION'] = '3.0';
  217. $postfields['METHOD'] = 'RefundTransaction';
  218. $postfields['BUTTONSOURCE'] = 'WHMCS_WPP_DP';
  219. $postfields['USER'] = $params['apiusername'];
  220. $postfields['PWD'] = $params['apipassword'];
  221. $postfields['SIGNATURE'] = $params['apisignature'];
  222. $postfields['TRANSACTIONID'] = $params['transid'];
  223. $postfields['REFUNDTYPE'] = 'Partial';
  224. $postfields['AMT'] = $params['amount'];
  225. $postfields['CURRENCYCODE'] = $params['currency'];
  226. curlCall( $url, $postfields );
  227. $result = ;
  228. explode( '&', $result );
  229. $resultsarray2 = ;
  230. foreach ($resultsarray2 as ) {
  231. [0];
  232. $line = ;
  233. explode( '=', $line );
  234. $line = ;
  235. $resultsarray[$line[0]] = urldecode( $line[1] );
  236. }
  237.  
  238.  
  239. if (strtoupper( $resultsarray['ACK'] ) == 'SUCCESS') {
  240. return array( 'status' => 'success', 'rawdata' => $resultsarray, 'transid' => $resultsarray['REFUNDTRANSACTIONID'], 'fees' => $resultsarray['FEEREFUNDAMT'] );
  241. }
  242.  
  243. return array( 'status' => 'error', 'rawdata' => $resultsarray );
  244. }
  245.  
  246. ?>
Add Comment
Please, Sign In to add comment