/** * Checks all Memberships and creates/updates the payment plan on stripe if * the membership changed since the plan was last changed. * * This function is called when the gateway is activated and after a * membership was saved to database. * * @since 1.0.0 */ public function update_stripe_data() { if (!$this->active) { return false; } $this->_api->set_gateway($this); // 1. Update all playment plans. $memberships = MS_Model_Membership::get_memberships(); foreach ($memberships as $membership) { $this->update_stripe_data_membership($membership); } // 2. Update all coupons (if Add-on is enabled) if (MS_Addon_Coupon::is_active()) { $coupons = MS_Addon_Coupon_Model::get_coupons(); foreach ($coupons as $coupon) { $this->update_stripe_data_coupon($coupon); } } }
/** * Sets or gets the coupon model that is processed in the current * registration form. * * @since 1.0.0 * @param MS_Addon_Coupon_Model $new_value * @return MS_Addon_Coupon_Model */ private static function the_coupon($new_value = null) { if ($new_value !== null) { self::$the_coupon = $new_value; } else { if (null === self::$the_coupon) { self::$the_coupon = MS_Factory::load('MS_Addon_Coupon_Model'); } } return self::$the_coupon; }