/app/class-ms-gateway.php

  1. <?php 
  2. /** 
  3. * Gateway parent model. 
  4. * 
  5. * Every payment gateway extends from this class. 
  6. * A payment gateway can process payments using three possible functions: 
  7. * 
  8. * - - - - - - - - - - 
  9. * 
  10. * function handle_return() 
  11. * This function is called by M2 when the IPN URL was called. 
  12. * E.g. calling "/ms-payment-return/paypalstandard" will trigger the function 
  13. * handle_return() for the PayPal Standard gateway. 
  14. * Subscription data must be fetched from the $_POST data collection. 
  15. * 
  16. * function process_purchase( $subscription ) 
  17. * Called automatically by M2 when a new subscription was created, i.e. 
  18. * handles the first payment of any subscription. 
  19. * This function might create a new customer account/etc via the gateway API. 
  20. * 
  21. * function request_payment( $subscription ) 
  22. * Called automatically by M2 when a payment is due, i.e. when the second 
  23. * payment of a recurring subscription is due. 
  24. * 
  25. * - - - - - - - - - - 
  26. * 
  27. * A single gateway should not implement all three payment methods! Either use 
  28. * handle_return - or - 
  29. * process_purchase and request_payment 
  30. * 
  31. * @since 1.0.0 
  32. * @package Membership2 
  33. * @subpackage Model 
  34. */ 
  35. class MS_Gateway extends MS_Model_Option { 
  36.  
  37. /** 
  38. * Gateway opertaion mode contants. 
  39. * 
  40. * @since 1.0.0 
  41. * @see $mode 
  42. * @var string The operation mode. 
  43. */ 
  44. const MODE_SANDBOX = 'sandbox'; 
  45. const MODE_LIVE = 'live'; 
  46.  
  47. /** 
  48. * Singleton object. 
  49. * 
  50. * @since 1.0.0 
  51. * @see $type 
  52. * @var string The singleton object. 
  53. */ 
  54. public static $instance; 
  55.  
  56. /** 
  57. * Gateway group. 
  58. * 
  59. * This is a label that is used to group settings together on the Payment 
  60. * Settings page. 
  61. * 
  62. * @since 1.0.0 
  63. * @var string 
  64. */ 
  65. protected $group = ''; 
  66.  
  67. /** 
  68. * Gateway ID. 
  69. * 
  70. * @since 1.0.0 
  71. * @var int $id 
  72. */ 
  73. protected $id = 'admin'; 
  74.  
  75. /** 
  76. * Gateway name. 
  77. * 
  78. * @since 1.0.0 
  79. * @var string $name 
  80. */ 
  81. protected $name = ''; 
  82.  
  83. /** 
  84. * Gateway description. 
  85. * 
  86. * @since 1.0.0 
  87. * @var string $description 
  88. */ 
  89. protected $description = ''; 
  90.  
  91. /** 
  92. * Gateway active status. 
  93. * 
  94. * @since 1.0.0 
  95. * @var string $active 
  96. */ 
  97. protected $active = false; 
  98.  
  99. /** 
  100. * Manual payment indicator. 
  101. * 
  102. * True: Recurring payments need to be made manually. 
  103. * False: Gateway is capable of automatic recurring payments. 
  104. * 
  105. * @since 1.0.0 
  106. * @var bool $manual_payment 
  107. */ 
  108. protected $manual_payment = true; 
  109.  
  110. /** 
  111. * List of payment_type IDs that are not supported by this gateway. 
  112. * 
  113. * @since 1.0.0 
  114. * @var array $unsupported_payment_types 
  115. */ 
  116. protected $unsupported_payment_types = array(); 
  117.  
  118. /** 
  119. * Gateway allows Pro rating. 
  120. * 
  121. * Pro rating means that a user will get a discount for a new subscription 
  122. * when he upgrades from another subscription that is not fully consumed 
  123. * yet. 
  124. * 
  125. * @since 1.0.0 
  126. * @var bool 
  127. */ 
  128. protected $pro_rate = false; 
  129.  
  130. /** 
  131. * Custom payment button text or url. 
  132. * 
  133. * Overrides default purchase button. 
  134. * 
  135. * @since 1.0.0 
  136. * @var string $pay_button_url The url or button label (text). 
  137. */ 
  138. protected $pay_button_url; 
  139.  
  140. /** 
  141. * Custom cancel button text or url. 
  142. * 
  143. * Overrides default cancel button. 
  144. * 
  145. * @since 1.0.0 
  146. * @var string $cancel_button_url The url or button label (text). 
  147. */ 
  148. protected $cancel_button_url; 
  149.  
  150. /** 
  151. * Gateway operation mode. 
  152. * 
  153. * Live or sandbox (test) mode. 
  154. * 
  155. * @since 1.0.0 
  156. * @var string $mode 
  157. */ 
  158. protected $mode; 
  159.  
  160. /** 
  161. * Hook to process gateway returns (IPN). 
  162. * 
  163. * @see MS_Controller_Gateway: handle_payment_return() 
  164. * 
  165. * @since 1.0.0 
  166. */ 
  167. public function after_load() { 
  168. do_action( 'ms_gateway_after_load', $this ); 
  169.  
  170. if ( $this->active ) { 
  171. $this->add_action( 
  172. 'ms_gateway_handle_payment_return_' . $this->id,  
  173. 'handle_return' 
  174. ); 
  175.  
  176. $this->add_filter( 'ms_model_gateway_register', 'register' ); 
  177.  
  178. /** 
  179. * Registers the Gateway 
  180. * 
  181. * @since 1.0.0 
  182. * @param array $list The gateway list. 
  183. * @return array The updated gateway list. 
  184. */ 
  185. public function register( $list ) { 
  186. $class = get_class( $this ); 
  187. $id = constant( $class . '::ID' ); 
  188.  
  189. $list[$id] = $class; 
  190.  
  191. return $list; 
  192.  
  193. /** 
  194. * Checks if the specified payment type is supported by the current gateway. 
  195. * 
  196. * @since 1.0.0 
  197. * @param string|MS_Model_Membership $payment_type Either a payment type 
  198. * identifier or a membership model object. 
  199. * @return bool 
  200. */ 
  201. public function payment_type_supported( $payment_type ) { 
  202. if ( is_object( $payment_type ) ) { 
  203. $payment_type = $payment_type->payment_type; 
  204.  
  205. $types = $this->supported_payment_types(); 
  206. $result = isset( $types[$payment_type] ); 
  207.  
  208. return $result; 
  209.  
  210. /** 
  211. * Returns a list of supported payment types. 
  212. * 
  213. * @since 1.0.0 
  214. * @return array Payment types, index is the type-key / value the label. 
  215. */ 
  216. public function supported_payment_types() { 
  217. static $Payment_Types = array(); 
  218.  
  219. if ( ! isset( $Payment_Types[$this->id] ) ) { 
  220. $Payment_Types[$this->id] = MS_Model_Membership::get_payment_types(); 
  221.  
  222. foreach ( $this->unsupported_payment_types as $remove ) { 
  223. unset( $Payment_Types[$this->id][$remove] ); 
  224.  
  225. return $Payment_Types[$this->id]; 
  226.  
  227. /** 
  228. * Processes gateway IPN return. 
  229. * 
  230. * Overridden in child gateway classes. 
  231. * 
  232. * @since 1.0.0 
  233. * @param MS_Model_Transactionlog $log Optional. A transaction log item 
  234. * that will be updated instead of creating a new log entry. 
  235. */ 
  236. public function handle_return( $log = false ) { 
  237. do_action( 
  238. 'ms_gateway_handle_return',  
  239. $this,  
  240. $log 
  241. ); 
  242.  
  243. /** 
  244. * Processes purchase action. 
  245. * 
  246. * This function is called when a payment was made: We check if the 
  247. * transaction was successful. If it was we call `$invoice->changed()` which 
  248. * will update the membership status accordingly. 
  249. * 
  250. * Overridden in child classes. 
  251. * This parent method only covers free purchases. 
  252. * 
  253. * @since 1.0.0 
  254. * @param MS_Model_Relationship $ms_relationship The related membership relationship. 
  255. */ 
  256. public function process_purchase( $subscription ) { 
  257. do_action( 
  258. 'ms_gateway_process_purchase_before',  
  259. $subscription,  
  260. $this 
  261. ); 
  262.  
  263. $invoice = $subscription->get_current_invoice(); 
  264. $invoice->gateway_id = $this->id; 
  265. $invoice->save(); 
  266.  
  267. // The default handler only processes free subscriptions. 
  268. if ( 0 == $invoice->total ) { 
  269. $invoice->changed(); 
  270.  
  271. return apply_filters( 
  272. 'ms_gateway_process_purchase',  
  273. $invoice 
  274. ); 
  275.  
  276. /** 
  277. * Propagate membership cancelation to the gateway. 
  278. * 
  279. * Overridden in child classes. 
  280. * 
  281. * @since 1.0.0 
  282. * @param MS_Model_Relationship $subscription The membership relationship. 
  283. */ 
  284. public function cancel_membership( $subscription ) { 
  285. do_action( 
  286. 'ms_gateway_cancel_membership',  
  287. $subscription,  
  288. $this 
  289. ); 
  290.  
  291. /** 
  292. * Request automatic payment to the gateway. 
  293. * 
  294. * Overridden in child gateway classes. 
  295. * 
  296. * @since 1.0.0 
  297. * @param MS_Model_Relationship $subscription The membership relationship. 
  298. * @return bool True on success. 
  299. */ 
  300. public function request_payment( $subscription ) { 
  301. do_action( 
  302. 'ms_gateway_request_payment',  
  303. $subscription,  
  304. $this 
  305. ); 
  306.  
  307. // Default to "Payment successful" 
  308. return true; 
  309.  
  310. /** 
  311. * Check for card expiration date. 
  312. * 
  313. * Save event for card expire soon. 
  314. * 
  315. * @since 1.0.0 
  316. * 
  317. * @access protected 
  318. * @param MS_Model_Relationship $subscription The membership relationship. 
  319. */ 
  320. public function check_card_expiration( $subscription ) { 
  321. do_action( 'ms_gateway_check_card_expiration_before', $this ); 
  322.  
  323. $member = MS_Factory::load( 'MS_Model_Member', $subscription->user_id ); 
  324. $card_exp = $member->get_gateway_profile( $this->id, 'card_exp' ); 
  325.  
  326. if ( ! empty( $card_exp ) ) { 
  327. $comm = MS_Model_Communication::get_communication( 
  328. MS_Model_Communication::COMM_TYPE_CREDIT_CARD_EXPIRE 
  329. ); 
  330.  
  331. $days = MS_Helper_Period::get_period_in_days( 
  332. $comm->period['period_unit'],  
  333. $comm->period['period_type'] 
  334. ); 
  335. $card_expire_days = MS_Helper_Period::subtract_dates( 
  336. $card_exp,  
  337. MS_Helper_Period::current_date() 
  338. ); 
  339. if ( $card_expire_days < 0 || ( $days == $card_expire_days ) ) { 
  340. MS_Model_Event::save_event( 
  341. MS_Model_Event::TYPE_CREDIT_CARD_EXPIRE,  
  342. $subscription 
  343. ); 
  344.  
  345. do_action( 
  346. 'ms_gateway_check_card_expiration_after',  
  347. $this,  
  348. $subscription 
  349. ); 
  350.  
  351. /** 
  352. * Url that fires handle_return of this gateway (IPN). 
  353. * 
  354. * @since 1.0.0 
  355. * @return string The return url. 
  356. */ 
  357. public function get_return_url() { 
  358. $url = MS_Helper_Utility::home_url( '/ms-payment-return/' . $this->id ); 
  359.  
  360. return apply_filters( 
  361. 'ms_gateway_get_return_url',  
  362. $url,  
  363. $this 
  364. ); 
  365.  
  366. /** 
  367. * Get gateway mode types. 
  368. * 
  369. * @since 1.0.0 
  370. * @return array { 
  371. * Returns array of ( $mode_type => $description ). 
  372. * @type string $mode_type The mode type. 
  373. * @type string $description The mode type description. 
  374. * } 
  375. */ 
  376. public function get_mode_types() { 
  377. $mode_types = array( 
  378. self::MODE_LIVE => __( 'Live Site', 'membership2' ),  
  379. self::MODE_SANDBOX => __( 'Sandbox Mode (test)', 'membership2' ),  
  380. ); 
  381.  
  382. return apply_filters( 
  383. 'ms_gateway_get_mode_types',  
  384. $mode_types,  
  385. $this 
  386. ); 
  387.  
  388. /** 
  389. * Return if is live mode. 
  390. * 
  391. * @since 1.0.0 
  392. * 
  393. * @return boolean True if is in live mode. 
  394. */ 
  395. public function is_live_mode() { 
  396. $is_live_mode = ( self::MODE_SANDBOX !== $this->mode ); 
  397.  
  398. return apply_filters( 
  399. 'ms_gateway_is_live_mode',  
  400. $is_live_mode 
  401. ); 
  402.  
  403. /** 
  404. * Verify required fields. 
  405. * 
  406. * To be overridden in children classes. 
  407. * 
  408. * @since 1.0.0 
  409. * 
  410. * @return boolean 
  411. */ 
  412. public function is_configured() { 
  413. MS_Helper_Debug::log( 
  414. sprintf( 
  415. __( 'Override the is_configured method of the %s-gateway', 'membership2' ),  
  416. $this->id 
  417. ); 
  418.  
  419. return false; 
  420.  
  421. /** 
  422. * Validate specific property before set. 
  423. * 
  424. * @since 1.0.0 
  425. * 
  426. * @param string $property The name of a property to associate. 
  427. * @param mixed $value The value of a property. 
  428. */ 
  429. public function __set( $property, $value ) { 
  430. if ( property_exists( $this, $property ) ) { 
  431. switch ( $property ) { 
  432. case 'id': 
  433. case 'name': 
  434. break; 
  435.  
  436. case 'description': 
  437. case 'pay_button_url': 
  438. case 'upgrade_button_url': 
  439. case 'cancel_button_url': 
  440. $this->$property = trim( sanitize_text_field( $value ) ); 
  441. break; 
  442.  
  443. case 'active': 
  444. case 'manual_payment': 
  445. $this->$property = ( ! empty( $value ) ? true : false ); 
  446. break; 
  447.  
  448. default: 
  449. if ( is_string( $value ) ) { 
  450. $this->$property = trim( $value ); 
  451. break; 
  452.  
  453. do_action( 
  454. 'ms_gateway__set_after',  
  455. $property,  
  456. $value,  
  457. $this 
  458. ); 
  459.  
  460. /** 
  461. * Return a property value 
  462. * 
  463. * @since 1.0.0 
  464. * 
  465. * @access public 
  466. * @param string $name The name of a property to associate. 
  467. * @return mixed The value of a property. 
  468. */ 
  469. public function __get( $property ) { 
  470. $value = null; 
  471.  
  472. if ( property_exists( $this, $property ) ) { 
  473. switch ( $property ) { 
  474. case 'active': 
  475. case 'manual_payment': 
  476. return ( ! empty( $this->$property ) ? true : false ); 
  477. break; 
  478.  
  479. case 'id': 
  480. case 'name': 
  481. case 'description': 
  482. case 'pay_button_url': 
  483. case 'upgrade_button_url': 
  484. case 'cancel_button_url': 
  485. case 'mode': 
  486. $value = trim( $this->$property ); 
  487. break; 
  488.  
  489. default: 
  490. $value = $this->$property; 
  491. break; 
  492.  
  493. return apply_filters( 
  494. 'ms_gateway__get',  
  495. $value,  
  496. $property,  
  497. $this 
  498. ); 
  499.  
  500. /** 
  501. * Get countries code and names. 
  502. * 
  503. * @since 1.0.0 
  504. * 
  505. * @return array { 
  506. * Returns array of ( $code => $name ). 
  507. * @type string $code The country code. 
  508. * @type string $name The country name. 
  509. * } 
  510. */ 
  511. static public function get_country_codes() { 
  512. static $Countries = null; 
  513.  
  514. if ( is_null( $Countries ) ) { 
  515. $Countries = array( 
  516. '' => '- ' . __( 'Select country', 'membership2' ) . ' -',  
  517. 'AX' => __( 'Aland Islands', 'membership2' ),  
  518. 'AL' => __( 'Albania', 'membership2' ),  
  519. 'DZ' => __( 'Algeria', 'membership2' ),  
  520. 'AS' => __( 'American Samoa', 'membership2' ),  
  521. 'AD' => __( 'Andorra', 'membership2' ),  
  522. 'AI' => __( 'Anguilla', 'membership2' ),  
  523. 'AQ' => __( 'Antarctica', 'membership2' ),  
  524. 'AG' => __( 'Antigua And Barbuda', 'membership2' ),  
  525. 'AR' => __( 'Argentina', 'membership2' ),  
  526. 'AM' => __( 'Armenia', 'membership2' ),  
  527. 'AW' => __( 'Aruba', 'membership2' ),  
  528. 'AU' => __( 'Australia', 'membership2' ),  
  529. 'AT' => __( 'Austria', 'membership2' ),  
  530. 'AZ' => __( 'Azerbaijan', 'membership2' ),  
  531. 'BS' => __( 'Bahamas', 'membership2' ),  
  532. 'BH' => __( 'Bahrain', 'membership2' ),  
  533. 'BD' => __( 'Bangladesh', 'membership2' ),  
  534. 'BB' => __( 'Barbados', 'membership2' ),  
  535. 'BE' => __( 'Belgium', 'membership2' ),  
  536. 'BZ' => __( 'Belize', 'membership2' ),  
  537. 'BJ' => __( 'Benin', 'membership2' ),  
  538. 'BM' => __( 'Bermuda', 'membership2' ),  
  539. 'BT' => __( 'Bhutan', 'membership2' ),  
  540. 'BA' => __( 'Bosnia-herzegovina', 'membership2' ),  
  541. 'BW' => __( 'Botswana', 'membership2' ),  
  542. 'BV' => __( 'Bouvet Island', 'membership2' ),  
  543. 'BR' => __( 'Brazil', 'membership2' ),  
  544. 'IO' => __( 'British Indian Ocean Territory', 'membership2' ),  
  545. 'BN' => __( 'Brunei Darussalam', 'membership2' ),  
  546. 'BG' => __( 'Bulgaria', 'membership2' ),  
  547. 'BF' => __( 'Burkina Faso', 'membership2' ),  
  548. 'CA' => __( 'Canada', 'membership2' ),  
  549. 'CV' => __( 'Cape Verde', 'membership2' ),  
  550. 'KY' => __( 'Cayman Islands', 'membership2' ),  
  551. 'CF' => __( 'Central African Republic', 'membership2' ),  
  552. 'CL' => __( 'Chile', 'membership2' ),  
  553. 'CN' => __( 'China', 'membership2' ),  
  554. 'CX' => __( 'Christmas Island', 'membership2' ),  
  555. 'CC' => __( 'Cocos (keeling) Islands', 'membership2' ),  
  556. 'CO' => __( 'Colombia', 'membership2' ),  
  557. 'CK' => __( 'Cook Islands', 'membership2' ),  
  558. 'CR' => __( 'Costa Rica', 'membership2' ),  
  559. 'CY' => __( 'Cyprus', 'membership2' ),  
  560. 'CZ' => __( 'Czech Republic', 'membership2' ),  
  561. 'DK' => __( 'Denmark', 'membership2' ),  
  562. 'DJ' => __( 'Djibouti', 'membership2' ),  
  563. 'DM' => __( 'Dominica', 'membership2' ),  
  564. 'DO' => __( 'Dominican Republic', 'membership2' ),  
  565. 'EC' => __( 'Ecuador', 'membership2' ),  
  566. 'EG' => __( 'Egypt', 'membership2' ),  
  567. 'SV' => __( 'El Salvador', 'membership2' ),  
  568. 'EE' => __( 'Estonia', 'membership2' ),  
  569. 'FK' => __( 'Falkland Islands (malvinas)', 'membership2' ),  
  570. 'FO' => __( 'Faroe Islands', 'membership2' ),  
  571. 'FJ' => __( 'Fiji', 'membership2' ),  
  572. 'FI' => __( 'Finland', 'membership2' ),  
  573. 'FR' => __( 'France', 'membership2' ),  
  574. 'GF' => __( 'French Guiana', 'membership2' ),  
  575. 'PF' => __( 'French Polynesia', 'membership2' ),  
  576. 'TF' => __( 'French Southern Territories', 'membership2' ),  
  577. 'GA' => __( 'Gabon', 'membership2' ),  
  578. 'GM' => __( 'Gambia', 'membership2' ),  
  579. 'GE' => __( 'Georgia', 'membership2' ),  
  580. 'DE' => __( 'Germany', 'membership2' ),  
  581. 'GH' => __( 'Ghana', 'membership2' ),  
  582. 'GI' => __( 'Gibraltar', 'membership2' ),  
  583. 'GR' => __( 'Greece', 'membership2' ),  
  584. 'GL' => __( 'Greenland', 'membership2' ),  
  585. 'GD' => __( 'Grenada', 'membership2' ),  
  586. 'GP' => __( 'Guadeloupe', 'membership2' ),  
  587. 'GU' => __( 'Guam', 'membership2' ),  
  588. 'GG' => __( 'Guernsey', 'membership2' ),  
  589. 'GY' => __( 'Guyana', 'membership2' ),  
  590. 'HM' => __( 'Heard Island And Mcdonald Islands', 'membership2' ),  
  591. 'VA' => __( 'Holy See (vatican City State)', 'membership2' ),  
  592. 'HN' => __( 'Honduras', 'membership2' ),  
  593. 'HK' => __( 'Hong Kong', 'membership2' ),  
  594. 'HU' => __( 'Hungary', 'membership2' ),  
  595. 'IS' => __( 'Iceland', 'membership2' ),  
  596. 'IN' => __( 'India', 'membership2' ),  
  597. 'ID' => __( 'Indonesia', 'membership2' ),  
  598. 'IE' => __( 'Ireland', 'membership2' ),  
  599. 'IM' => __( 'Isle Of Man', 'membership2' ),  
  600. 'IL' => __( 'Israel', 'membership2' ),  
  601. 'IT' => __( 'Italy', 'membership2' ),  
  602. 'JM' => __( 'Jamaica', 'membership2' ),  
  603. 'JP' => __( 'Japan', 'membership2' ),  
  604. 'JE' => __( 'Jersey', 'membership2' ),  
  605. 'JO' => __( 'Jordan', 'membership2' ),  
  606. 'KZ' => __( 'Kazakhstan', 'membership2' ),  
  607. 'KI' => __( 'Kiribati', 'membership2' ),  
  608. 'KR' => __( 'Korea, Republic Of', 'membership2' ),  
  609. 'KW' => __( 'Kuwait', 'membership2' ),  
  610. 'KG' => __( 'Kyrgyzstan', 'membership2' ),  
  611. 'LV' => __( 'Latvia', 'membership2' ),  
  612. 'LS' => __( 'Lesotho', 'membership2' ),  
  613. 'LI' => __( 'Liechtenstein', 'membership2' ),  
  614. 'LT' => __( 'Lithuania', 'membership2' ),  
  615. 'LU' => __( 'Luxembourg', 'membership2' ),  
  616. 'MO' => __( 'Macao', 'membership2' ),  
  617. 'MK' => __( 'Macedonia', 'membership2' ),  
  618. 'MG' => __( 'Madagascar', 'membership2' ),  
  619. 'MW' => __( 'Malawi', 'membership2' ),  
  620. 'MY' => __( 'Malaysia', 'membership2' ),  
  621. 'MT' => __( 'Malta', 'membership2' ),  
  622. 'MH' => __( 'Marshall Islands', 'membership2' ),  
  623. 'MQ' => __( 'Martinique', 'membership2' ),  
  624. 'MR' => __( 'Mauritania', 'membership2' ),  
  625. 'MU' => __( 'Mauritius', 'membership2' ),  
  626. 'YT' => __( 'Mayotte', 'membership2' ),  
  627. 'MX' => __( 'Mexico', 'membership2' ),  
  628. 'FM' => __( 'Micronesia, Federated States Of', 'membership2' ),  
  629. 'MD' => __( 'Moldova, Republic Of', 'membership2' ),  
  630. 'MC' => __( 'Monaco', 'membership2' ),  
  631. 'MN' => __( 'Mongolia', 'membership2' ),  
  632. 'ME' => __( 'Montenegro', 'membership2' ),  
  633. 'MS' => __( 'Montserrat', 'membership2' ),  
  634. 'MA' => __( 'Morocco', 'membership2' ),  
  635. 'MZ' => __( 'Mozambique', 'membership2' ),  
  636. 'NA' => __( 'Namibia', 'membership2' ),  
  637. 'NR' => __( 'Nauru', 'membership2' ),  
  638. 'NP' => __( 'Nepal', 'membership2' ),  
  639. 'NL' => __( 'Netherlands', 'membership2' ),  
  640. 'AN' => __( 'Netherlands Antilles', 'membership2' ),  
  641. 'NC' => __( 'New Caledonia', 'membership2' ),  
  642. 'NZ' => __( 'New Zealand', 'membership2' ),  
  643. 'NI' => __( 'Nicaragua', 'membership2' ),  
  644. 'NE' => __( 'Niger', 'membership2' ),  
  645. 'NU' => __( 'Niue', 'membership2' ),  
  646. 'NF' => __( 'Norfolk Island', 'membership2' ),  
  647. 'MP' => __( 'Northern Mariana Islands', 'membership2' ),  
  648. 'NO' => __( 'Norway', 'membership2' ),  
  649. 'OM' => __( 'Oman', 'membership2' ),  
  650. 'PW' => __( 'Palau', 'membership2' ),  
  651. 'PS' => __( 'Palestine', 'membership2' ),  
  652. 'PA' => __( 'Panama', 'membership2' ),  
  653. 'PY' => __( 'Paraguay', 'membership2' ),  
  654. 'PE' => __( 'Peru', 'membership2' ),  
  655. 'PH' => __( 'Philippines', 'membership2' ),  
  656. 'PN' => __( 'Pitcairn', 'membership2' ),  
  657. 'PL' => __( 'Poland', 'membership2' ),  
  658. 'PT' => __( 'Portugal', 'membership2' ),  
  659. 'PR' => __( 'Puerto Rico', 'membership2' ),  
  660. 'QA' => __( 'Qatar', 'membership2' ),  
  661. 'RE' => __( 'Reunion', 'membership2' ),  
  662. 'RO' => __( 'Romania', 'membership2' ),  
  663. 'RU' => __( 'Russian Federation', 'membership2' ),  
  664. 'RW' => __( 'Rwanda', 'membership2' ),  
  665. 'SH' => __( 'Saint Helena', 'membership2' ),  
  666. 'KN' => __( 'Saint Kitts And Nevis', 'membership2' ),  
  667. 'LC' => __( 'Saint Lucia', 'membership2' ),  
  668. 'PM' => __( 'Saint Pierre And Miquelon', 'membership2' ),  
  669. 'VC' => __( 'Saint Vincent And The Grenadines', 'membership2' ),  
  670. 'WS' => __( 'Samoa', 'membership2' ),  
  671. 'SM' => __( 'San Marino', 'membership2' ),  
  672. 'ST' => __( 'Sao Tome And Principe', 'membership2' ),  
  673. 'SA' => __( 'Saudi Arabia', 'membership2' ),  
  674. 'SN' => __( 'Senegal', 'membership2' ),  
  675. 'RS' => __( 'Serbia', 'membership2' ),  
  676. 'SC' => __( 'Seychelles', 'membership2' ),  
  677. 'SG' => __( 'Singapore', 'membership2' ),  
  678. 'SK' => __( 'Slovakia', 'membership2' ),  
  679. 'SI' => __( 'Slovenia', 'membership2' ),  
  680. 'SB' => __( 'Solomon Islands', 'membership2' ),  
  681. 'ZA' => __( 'South Africa', 'membership2' ),  
  682. 'GS' => __( 'South Georgia And The South Sandwich Islands', 'membership2' ),  
  683. 'ES' => __( 'Spain', 'membership2' ),  
  684. 'SR' => __( 'Suriname', 'membership2' ),  
  685. 'SJ' => __( 'Svalbard And Jan Mayen', 'membership2' ),  
  686. 'SZ' => __( 'Swaziland', 'membership2' ),  
  687. 'SE' => __( 'Sweden', 'membership2' ),  
  688. 'CH' => __( 'Switzerland', 'membership2' ),  
  689. 'TW' => __( 'Taiwan, Province Of China', 'membership2' ),  
  690. 'TZ' => __( 'Tanzania, United Republic Of', 'membership2' ),  
  691. 'TH' => __( 'Thailand', 'membership2' ),  
  692. 'TL' => __( 'Timor-leste', 'membership2' ),  
  693. 'TG' => __( 'Togo', 'membership2' ),  
  694. 'TK' => __( 'Tokelau', 'membership2' ),  
  695. 'TO' => __( 'Tonga', 'membership2' ),  
  696. 'TT' => __( 'Trinidad And Tobago', 'membership2' ),  
  697. 'TN' => __( 'Tunisia', 'membership2' ),  
  698. 'TR' => __( 'Turkey', 'membership2' ),  
  699. 'TM' => __( 'Turkmenistan', 'membership2' ),  
  700. 'TC' => __( 'Turks And Caicos Islands', 'membership2' ),  
  701. 'TV' => __( 'Tuvalu', 'membership2' ),  
  702. 'UG' => __( 'Uganda', 'membership2' ),  
  703. 'UA' => __( 'Ukraine', 'membership2' ),  
  704. 'AE' => __( 'United Arab Emirates', 'membership2' ),  
  705. 'GB' => __( 'United Kingdom', 'membership2' ),  
  706. 'US' => __( 'United States', 'membership2' ),  
  707. 'UM' => __( 'United States Minor Outlying Islands', 'membership2' ),  
  708. 'UY' => __( 'Uruguay', 'membership2' ),  
  709. 'UZ' => __( 'Uzbekistan', 'membership2' ),  
  710. 'VU' => __( 'Vanuatu', 'membership2' ),  
  711. 'VE' => __( 'Venezuela', 'membership2' ),  
  712. 'VN' => __( 'Viet Nam', 'membership2' ),  
  713. 'VG' => __( 'Virgin Islands, British', 'membership2' ),  
  714. 'VI' => __( 'Virgin Islands, U.s.', 'membership2' ),  
  715. 'WF' => __( 'Wallis And Futuna', 'membership2' ),  
  716. 'EH' => __( 'Western Sahara', 'membership2' ),  
  717. 'ZM' => __( 'Zambia', 'membership2' ),  
  718. ); 
  719.  
  720. $Countries = apply_filters( 
  721. 'ms_gateway_get_country_codes',  
  722. $Countries 
  723. ); 
  724.  
  725. return $Countries; 
.