/**
  * Hook to show payment info.
  * This is called by the MS_Factory
  *
  * @since  1.0.0
  */
 public function after_load()
 {
     parent::after_load();
     $this->id = self::ID;
     $this->name = __('2Checkout', 'membership2');
     $this->group = __('2Checkout', 'membership2');
     $this->manual_payment = false;
     // Recurring charged automatically
 }
 /**
  * Initialize the object.
  *
  * @since  1.0.0
  */
 public function after_load()
 {
     parent::after_load();
     $this->id = self::ID;
     $this->name = __('Authorize.net Gateway', 'membership2');
     $this->group = 'Authorize.net';
     $this->manual_payment = true;
     // Recurring billed/paid manually
     $this->pro_rate = true;
 }
 /**
  * Hook to show payment info.
  * This is called by the MS_Factory
  *
  * @since  1.0.0
  */
 public function after_load()
 {
     parent::after_load();
     $this->id = self::ID;
     $this->name = __('Free Gateway', 'membership2');
     $this->group = '';
     $this->active = true;
     $this->manual_payment = true;
     // Recurring billed/paid manually
 }
 /**
  * Initialize the object.
  *
  * @since  1.0.0
  * @internal
  */
 public function after_load()
 {
     parent::after_load();
     $this->_api = MS_Factory::load('MS_Gateway_Stripe_Api');
     $this->id = self::ID;
     $this->name = __('Stripe Single Gateway', 'membership2');
     $this->group = 'Stripe';
     $this->manual_payment = true;
     // Recurring billed/paid manually
     $this->pro_rate = true;
 }
 /**
  * Initialize the object.
  *
  * @since  1.0.0
  * @internal
  */
 public function after_load()
 {
     parent::after_load();
     $this->_api = MS_Factory::load('MS_Gateway_Stripe_Api');
     $this->id = self::ID;
     $this->name = __('Stripe Single Gateway', 'membership2');
     $this->group = 'Stripe';
     $this->manual_payment = true;
     // Recurring billed/paid manually
     $this->pro_rate = true;
     $this->add_filter('ms_model_pages_get_ms_page_url', 'ms_model_pages_get_ms_page_url_cb', 99, 4);
 }
 /**
  * Hook to show payment info.
  * This is called by the MS_Factory
  *
  * @since  1.0.0
  */
 public function after_load()
 {
     parent::after_load();
     $this->id = self::ID;
     $this->name = __('Free Gateway', 'membership2');
     $this->group = '';
     $this->active = true;
     $this->manual_payment = true;
     // Recurring billed/paid manually
     /**
      * No sandbox option for manual payment gateway
      * The mode is always set to live
      */
     $this->mode = 'live';
 }
 /**
  * Validate specific property before set.
  *
  * @since  1.0.0
  *
  * @access public
  * @param string $name The name of a property to associate.
  * @param mixed $value The value of a property.
  */
 public function __set($property, $value)
 {
     if (property_exists($this, $property)) {
         switch ($property) {
             case 'paypal_site':
                 if (array_key_exists($value, self::get_paypal_sites())) {
                     $this->{$property} = $value;
                 }
                 break;
             default:
                 parent::__set($property, $value);
                 break;
         }
     }
     do_action('ms_gateway_paypalstandard__set_after', $property, $value, $this);
 }
 /**
  * Returns a list of all taxamo relevant EU countries.
  *
  * @since  1.0.0
  * @api
  *
  * @param  string $type [prefix|name|vat]
  *         name ..   code => "name"
  *         prefix .. code => "prefix - name"
  *         vat ..    vat-prefix => code
  * @return array
  */
 public static function get_country_codes($type = 'prefix')
 {
     if (null === self::$Countries) {
         $country_names = MS_Gateway::get_country_codes();
         // Country names in current language.
         $list = get_site_transient('ms_taxamo_countries');
         $list = false;
         if (!$list || !is_array($list)) {
             $resp = self::taxamo()->getCountriesDict('true');
             $list = array();
             foreach ($resp->dictionary as $item) {
                 $list[$item->code] = array('name' => $item->name, 'vat' => $item->tax_number_country_code);
             }
             set_site_transient('ms_taxamo_countries', $list, WEEK_IN_SECONDS);
         }
         self::$Countries = array();
         self::$Countries_Prefix = array();
         self::$Countries_Vat = array();
         foreach ($list as $code => $item) {
             if (isset($country_names[$code])) {
                 $item['name'] = $country_names[$code];
             }
             self::$Countries[$code] = $item['name'];
             self::$Countries_Prefix[$code] = $code . ' - ' . $item['name'];
             self::$Countries_Vat[$item['vat']] = $code;
         }
         self::$Countries['XX'] = '- ' . __('Outside the EU', 'membership2') . ' -';
         self::$Countries_Prefix['XX'] = '- ' . __('Outside the EU', 'membership2') . ' -';
     }
     switch ($type) {
         case 'prefix':
             return self::$Countries_Prefix;
         case 'vat':
             return self::$Countries_Vat;
         case 'name':
         default:
             return self::$Countries;
     }
 }
 /**
  * Validate specific property before set.
  *
  * @since  1.0.0
  *
  * @access public
  * @param string $property The name of a property to associate.
  * @param mixed $value The value of a property.
  */
 public function __set($property, $value)
 {
     if (property_exists($this, $property)) {
         switch ($property) {
             case 'payment_info':
                 $this->{$property} = wp_kses_post($value);
                 break;
             default:
                 parent::__set($property, $value);
                 break;
         }
     }
     do_action('ms_gateway_manual__set_after', $property, $value, $this);
 }
 /**
  * When a member cancels a subscription we need to notify Stripe to also
  * cancel the Stripe subscription.
  *
  * @since  1.0.0
  * @param MS_Model_Relationship $subscription The membership relationship.
  */
 public function cancel_membership($subscription)
 {
     parent::cancel_membership($subscription);
     $this->_api->set_gateway($this);
     $customer = $this->_api->find_customer($subscription->get_member());
     $membership = $subscription->get_membership();
     $stripe_sub = false;
     if ($customer) {
         $stripe_sub = $this->_api->get_subscription($customer, $membership);
     }
     if ($stripe_sub) {
         $stripe_sub->cancel(array('at_period_end' => true));
     }
 }
 /**
  * Translate a single payment gateway before it is saved to DB.
  *
  * @since  1.0.1.0
  *
  * @param  array $obj The serialized data collection.
  * @param  string $class The class name of the object.
  * @param  MS_Gateway $model The source object.
  * @return array The serialized data collection.
  */
 public function serialize_gateway($data, $class, $model)
 {
     if ($this->current_lang == $this->default_lang) {
         return $data;
     }
     if (0 !== strpos($class, 'MS_Gateway')) {
         return $data;
     }
     // Save the translated values before resetting the model.
     $tr_button = $data['pay_button_url'];
     $tr_info = isset($data['payment_info']) ? $data['payment_info'] : '';
     // Reset the values to Default language.
     $data['pay_button_url'] = $model->reset_field('pay_button_url');
     $data['payment_info'] = $model->reset_field('payment_info');
     // Store translations via WPML.
     if (function_exists('icl_add_string_translation')) {
         // 1. Subject.
         $string_name = 'ms-pay-button-' . $model->id;
         do_action('wpml_register_single_string', self::CONTEXT, $string_name, $data['pay_button_url']);
         $string_id = icl_get_string_id($data['pay_button_url'], self::CONTEXT, $string_name);
         if ($string_id) {
             icl_add_string_translation($string_id, $this->current_lang, $tr_button, ICL_TM_COMPLETE);
         }
         // 1. Message Body.
         $string_name = 'ms-pay-info-' . $model->id;
         do_action('wpml_register_single_string', self::CONTEXT, $string_name, $data['payment_info']);
         $string_id = icl_get_string_id($data['payment_info'], self::CONTEXT, $string_name);
         if ($string_id) {
             icl_add_string_translation($string_id, $this->current_lang, $tr_info, ICL_TM_COMPLETE);
         }
     }
     return $data;
 }